Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ai-sdk/openai

Package Overview
Dependencies
Maintainers
2
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ai-sdk/openai - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

105

dist/index.d.ts

@@ -6,32 +6,32 @@ import { LanguageModelV1 } from '@ai-sdk/provider';

/**
* Modify the likelihood of specified tokens appearing in the completion.
*
* Accepts a JSON object that maps tokens (specified by their token ID in
* the GPT tokenizer) to an associated bias value from -100 to 100. You
* can use this tokenizer tool to convert text to token IDs. Mathematically,
* the bias is added to the logits generated by the model prior to sampling.
* The exact effect will vary per model, but values between -1 and 1 should
* decrease or increase likelihood of selection; values like -100 or 100
* should result in a ban or exclusive selection of the relevant token.
*
* As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
* token from being generated.
*/
Modify the likelihood of specified tokens appearing in the completion.
Accepts a JSON object that maps tokens (specified by their token ID in
the GPT tokenizer) to an associated bias value from -100 to 100. You
can use this tokenizer tool to convert text to token IDs. Mathematically,
the bias is added to the logits generated by the model prior to sampling.
The exact effect will vary per model, but values between -1 and 1 should
decrease or increase likelihood of selection; values like -100 or 100
should result in a ban or exclusive selection of the relevant token.
As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
token from being generated.
*/
logitBias?: Record<number, number>;
/**
* The log probabilities of the tokens. Including logprobs will increase
* the response size and can slow down response times. However, it can
* be useful for developers to better understand how the model is behaving.
*
* Setting to true will return the log probabilities of the tokens that
* were generated.
*
* Setting to a number will return the log probabilities of the top n
* tokens that were generated.
*/
Return the log probabilities of the tokens. Including logprobs will increase
the response size and can slow down response times. However, it can
be useful to better understand how the model is behaving.
Setting to true will return the log probabilities of the tokens that
were generated.
Setting to a number will return the log probabilities of the top n
tokens that were generated.
*/
logprobs?: boolean | number;
/**
* A unique identifier representing your end-user, which can help OpenAI to
* monitor and detect abuse. Learn more.
*/
A unique identifier representing your end-user, which can help OpenAI to
monitor and detect abuse. Learn more.
*/
user?: string;

@@ -61,35 +61,39 @@ }

/**
* Echo back the prompt in addition to the completion
Echo back the prompt in addition to the completion.
*/
echo?: boolean;
/**
* Modify the likelihood of specified tokens appearing in the completion.
*
* Accepts a JSON object that maps tokens (specified by their token ID in
* the GPT tokenizer) to an associated bias value from -100 to 100. You
* can use this tokenizer tool to convert text to token IDs. Mathematically,
* the bias is added to the logits generated by the model prior to sampling.
* The exact effect will vary per model, but values between -1 and 1 should
* decrease or increase likelihood of selection; values like -100 or 100
* should result in a ban or exclusive selection of the relevant token.
*
* As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
* token from being generated.
Modify the likelihood of specified tokens appearing in the completion.
Accepts a JSON object that maps tokens (specified by their token ID in
the GPT tokenizer) to an associated bias value from -100 to 100. You
can use this tokenizer tool to convert text to token IDs. Mathematically,
the bias is added to the logits generated by the model prior to sampling.
The exact effect will vary per model, but values between -1 and 1 should
decrease or increase likelihood of selection; values like -100 or 100
should result in a ban or exclusive selection of the relevant token.
As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
token from being generated.
*/
logitBias?: Record<number, number>;
/**
* The number of logprobs to return.
*
* Including logprobs will increase the response size and can slow down
* response times. However, it can be useful for developers to better
* understand how the model is behaving.
Return the log probabilities of the tokens. Including logprobs will increase
the response size and can slow down response times. However, it can
be useful to better understand how the model is behaving.
Setting to true will return the log probabilities of the tokens that
were generated.
Setting to a number will return the log probabilities of the top n
tokens that were generated.
*/
logprobs?: boolean | number;
/**
* The suffix that comes after a completion of inserted text.
The suffix that comes after a completion of inserted text.
*/
suffix?: string;
/**
* A unique identifier representing your end-user, which can help OpenAI to
* monitor and detect abuse. Learn more.
A unique identifier representing your end-user, which can help OpenAI to
monitor and detect abuse. Learn more.
*/

@@ -163,5 +167,10 @@ user?: string;

/**
Base URL for the OpenAI API calls.
Use a different URL prefix for API calls, e.g. to use proxy servers.
The default prefix is `https://api.openai.com/v1`.
*/
readonly baseURL: string;
/**
API key that is being send using the `Authorization` header.
It defaults to the `OPENAI_API_KEY` environment variable.
*/
readonly apiKey?: string;

@@ -168,0 +177,0 @@ /**

{
"name": "@ai-sdk/openai",
"version": "0.0.7",
"version": "0.0.8",
"license": "Apache-2.0",

@@ -22,3 +22,3 @@ "sideEffects": false,

"@ai-sdk/provider": "0.0.2",
"@ai-sdk/provider-utils": "0.0.3"
"@ai-sdk/provider-utils": "0.0.4"
},

@@ -25,0 +25,0 @@ "devDependencies": {

# Vercel AI SDK - OpenAI Provider
The OpenAI provider contains language model support for the OpenAI chat and completion APIs.
The [OpenAI](https://platform.openai.com/) provider for the [Vercel AI SDK](https://sdk.vercel.ai/docs) contains language model support for the OpenAI chat and completion APIs.
It creates language model objects that can be used with the `generateText`, `streamText`, `generateObject`, and `streamObject` AI functions.

@@ -16,33 +16,42 @@

You can import `createOpenAI` from `@ai-sdk/openai` and create a provider instance with various settings:
You can import the default provider instance `openai` from `@ai-sdk/openai`:
```ts
import { openai } from '@ai-sdk/openai';
```
If you need a customized setup, you can import `createOpenAI` from `@ai-sdk/openai` and create a provider instance with your settings:
```ts
import { createOpenAI } from '@ai-sdk/openai';
const openai = createOpenAI({
// optional base URL for proxies etc.
baseURL: '',
// custom settings
});
```
// optional API key, default to env property OPENAI_API_KEY
apiKey: '',
You can use the following optional settings to customize the OpenAI provider instance:
// optional OpenAI organization:
organization: '',
- **baseURL** _string_
// optional OpenAI project:
project: '',
Use a different URL prefix for API calls, e.g. to use proxy servers.
The default prefix is `https://api.openai.com/v1`.
// optional custom headers:
headers: {
'custom-header': 'value',
},
});
```
- **apiKey** _string_
The AI SDK also provides a shorthand `openai` import with an OpenAI provider instance that uses defaults:
API key that is being send using the `Authorization` header.
It defaults to the `OPENAI_API_KEY` environment variable.
```ts
import { openai } from '@ai-sdk/openai';
```
- **organization** _string_
OpenAI Organization.
- **project** _string_
OpenAI project.
- **headers** _Record<string,string>_
Custom headers to include in the requests.
## Models

@@ -57,5 +66,13 @@

It automatically selects the correct API based on the model id.
You can also pass additional settings in the second argument:
You can also provide model-specific parameters or select a model API by using `.chat` or `.completion`.
```ts
const model = openai('gpt-3.5-turbo', {
// additional settings
});
```
The available options depend on the API that's automatically chosen for the model (see below).
If you want to explicitly select a specific model API, you can use `.chat` or `.completion`.
### Chat Models

@@ -84,2 +101,36 @@

The following optional settings are available for OpenAI chat models:
- **logitBias** _Record<number, number>_
Modifies the likelihood of specified tokens appearing in the completion.
Accepts a JSON object that maps tokens (specified by their token ID in
the GPT tokenizer) to an associated bias value from -100 to 100. You
can use this tokenizer tool to convert text to token IDs. Mathematically,
the bias is added to the logits generated by the model prior to sampling.
The exact effect will vary per model, but values between -1 and 1 should
decrease or increase likelihood of selection; values like -100 or 100
should result in a ban or exclusive selection of the relevant token.
As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
token from being generated.
- **logProbs** _boolean | number_
Return the log probabilities of the tokens. Including logprobs will increase
the response size and can slow down response times. However, it can
be useful to better understand how the model is behaving.
Setting to true will return the log probabilities of the tokens that
were generated.
Setting to a number will return the log probabilities of the top n
tokens that were generated.
- **user** _string_
A unique identifier representing your end-user, which can help OpenAI to
monitor and detect abuse. Learn more.
### Completion Models

@@ -109,1 +160,43 @@

```
The following optional settings are available for OpenAI completion models:
- **echo**: _boolean_
Echo back the prompt in addition to the completion.
- **logitBias** _Record<number, number>_
Modifies the likelihood of specified tokens appearing in the completion.
Accepts a JSON object that maps tokens (specified by their token ID in
the GPT tokenizer) to an associated bias value from -100 to 100. You
can use this tokenizer tool to convert text to token IDs. Mathematically,
the bias is added to the logits generated by the model prior to sampling.
The exact effect will vary per model, but values between -1 and 1 should
decrease or increase likelihood of selection; values like -100 or 100
should result in a ban or exclusive selection of the relevant token.
As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
token from being generated.
- **logProbs** _boolean | number_
Return the log probabilities of the tokens. Including logprobs will increase
the response size and can slow down response times. However, it can
be useful to better understand how the model is behaving.
Setting to true will return the log probabilities of the tokens that
were generated.
Setting to a number will return the log probabilities of the top n
tokens that were generated.
- **suffix** _string_
The suffix that comes after a completion of inserted text.
- **user** _string_
A unique identifier representing your end-user, which can help OpenAI to
monitor and detect abuse. Learn more.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc