@ai-sdk/openai 3.0.20 → 3.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +8 -0
- package/dist/index.d.mts +27 -27
- package/dist/index.d.ts +27 -27
- package/dist/index.js +32 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -32
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +31 -31
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +31 -31
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +65 -6
- package/package.json +1 -1
- package/src/completion/openai-completion-options.ts +28 -28
- package/src/embedding/openai-embedding-options.ts +6 -6
- package/src/openai-provider.ts +27 -27
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -11,6 +11,14 @@ The OpenAI provider is available in the `@ai-sdk/openai` module. You can install
|
|
|
11
11
|
npm i @ai-sdk/openai
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
+
## Skill for Coding Agents
|
|
15
|
+
|
|
16
|
+
If you use coding agents such as Claude Code or Cursor, we highly recommend adding the AI SDK skill to your repository:
|
|
17
|
+
|
|
18
|
+
```shell
|
|
19
|
+
npx skills add vercel/ai
|
|
20
|
+
```
|
|
21
|
+
|
|
14
22
|
## Provider Instance
|
|
15
23
|
|
|
16
24
|
You can import the default provider instance `openai` from `@ai-sdk/openai`:
|
package/dist/index.d.mts
CHANGED
|
@@ -817,27 +817,27 @@ type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-
|
|
|
817
817
|
interface OpenAIProvider extends ProviderV3 {
|
|
818
818
|
(modelId: OpenAIResponsesModelId): LanguageModelV3;
|
|
819
819
|
/**
|
|
820
|
-
|
|
820
|
+
* Creates an OpenAI model for text generation.
|
|
821
821
|
*/
|
|
822
822
|
languageModel(modelId: OpenAIResponsesModelId): LanguageModelV3;
|
|
823
823
|
/**
|
|
824
|
-
|
|
824
|
+
* Creates an OpenAI chat model for text generation.
|
|
825
825
|
*/
|
|
826
826
|
chat(modelId: OpenAIChatModelId): LanguageModelV3;
|
|
827
827
|
/**
|
|
828
|
-
|
|
828
|
+
* Creates an OpenAI responses API model for text generation.
|
|
829
829
|
*/
|
|
830
830
|
responses(modelId: OpenAIResponsesModelId): LanguageModelV3;
|
|
831
831
|
/**
|
|
832
|
-
|
|
832
|
+
* Creates an OpenAI completion model for text generation.
|
|
833
833
|
*/
|
|
834
834
|
completion(modelId: OpenAICompletionModelId): LanguageModelV3;
|
|
835
835
|
/**
|
|
836
|
-
|
|
836
|
+
* Creates a model for text embeddings.
|
|
837
837
|
*/
|
|
838
838
|
embedding(modelId: OpenAIEmbeddingModelId): EmbeddingModelV3;
|
|
839
839
|
/**
|
|
840
|
-
|
|
840
|
+
* Creates a model for text embeddings.
|
|
841
841
|
*/
|
|
842
842
|
embeddingModel(modelId: OpenAIEmbeddingModelId): EmbeddingModelV3;
|
|
843
843
|
/**
|
|
@@ -849,63 +849,63 @@ interface OpenAIProvider extends ProviderV3 {
|
|
|
849
849
|
*/
|
|
850
850
|
textEmbeddingModel(modelId: OpenAIEmbeddingModelId): EmbeddingModelV3;
|
|
851
851
|
/**
|
|
852
|
-
|
|
852
|
+
* Creates a model for image generation.
|
|
853
853
|
*/
|
|
854
854
|
image(modelId: OpenAIImageModelId): ImageModelV3;
|
|
855
855
|
/**
|
|
856
|
-
|
|
856
|
+
* Creates a model for image generation.
|
|
857
857
|
*/
|
|
858
858
|
imageModel(modelId: OpenAIImageModelId): ImageModelV3;
|
|
859
859
|
/**
|
|
860
|
-
|
|
860
|
+
* Creates a model for transcription.
|
|
861
861
|
*/
|
|
862
862
|
transcription(modelId: OpenAITranscriptionModelId): TranscriptionModelV3;
|
|
863
863
|
/**
|
|
864
|
-
|
|
864
|
+
* Creates a model for speech generation.
|
|
865
865
|
*/
|
|
866
866
|
speech(modelId: OpenAISpeechModelId): SpeechModelV3;
|
|
867
867
|
/**
|
|
868
|
-
|
|
868
|
+
* OpenAI-specific tools.
|
|
869
869
|
*/
|
|
870
870
|
tools: typeof openaiTools;
|
|
871
871
|
}
|
|
872
872
|
interface OpenAIProviderSettings {
|
|
873
873
|
/**
|
|
874
|
-
|
|
875
|
-
|
|
874
|
+
* Base URL for the OpenAI API calls.
|
|
875
|
+
*/
|
|
876
876
|
baseURL?: string;
|
|
877
877
|
/**
|
|
878
|
-
|
|
879
|
-
|
|
878
|
+
* API key for authenticating requests.
|
|
879
|
+
*/
|
|
880
880
|
apiKey?: string;
|
|
881
881
|
/**
|
|
882
|
-
|
|
883
|
-
|
|
882
|
+
* OpenAI Organization.
|
|
883
|
+
*/
|
|
884
884
|
organization?: string;
|
|
885
885
|
/**
|
|
886
|
-
|
|
887
|
-
|
|
886
|
+
* OpenAI project.
|
|
887
|
+
*/
|
|
888
888
|
project?: string;
|
|
889
889
|
/**
|
|
890
|
-
|
|
891
|
-
|
|
890
|
+
* Custom headers to include in the requests.
|
|
891
|
+
*/
|
|
892
892
|
headers?: Record<string, string>;
|
|
893
893
|
/**
|
|
894
|
-
|
|
894
|
+
* Provider name. Overrides the `openai` default name for 3rd party providers.
|
|
895
895
|
*/
|
|
896
896
|
name?: string;
|
|
897
897
|
/**
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
898
|
+
* Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
899
|
+
* or to provide a custom fetch implementation for e.g. testing.
|
|
900
|
+
*/
|
|
901
901
|
fetch?: FetchFunction;
|
|
902
902
|
}
|
|
903
903
|
/**
|
|
904
|
-
Create an OpenAI provider instance.
|
|
904
|
+
* Create an OpenAI provider instance.
|
|
905
905
|
*/
|
|
906
906
|
declare function createOpenAI(options?: OpenAIProviderSettings): OpenAIProvider;
|
|
907
907
|
/**
|
|
908
|
-
Default OpenAI provider instance.
|
|
908
|
+
* Default OpenAI provider instance.
|
|
909
909
|
*/
|
|
910
910
|
declare const openai: OpenAIProvider;
|
|
911
911
|
|
package/dist/index.d.ts
CHANGED
|
@@ -817,27 +817,27 @@ type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-
|
|
|
817
817
|
interface OpenAIProvider extends ProviderV3 {
|
|
818
818
|
(modelId: OpenAIResponsesModelId): LanguageModelV3;
|
|
819
819
|
/**
|
|
820
|
-
|
|
820
|
+
* Creates an OpenAI model for text generation.
|
|
821
821
|
*/
|
|
822
822
|
languageModel(modelId: OpenAIResponsesModelId): LanguageModelV3;
|
|
823
823
|
/**
|
|
824
|
-
|
|
824
|
+
* Creates an OpenAI chat model for text generation.
|
|
825
825
|
*/
|
|
826
826
|
chat(modelId: OpenAIChatModelId): LanguageModelV3;
|
|
827
827
|
/**
|
|
828
|
-
|
|
828
|
+
* Creates an OpenAI responses API model for text generation.
|
|
829
829
|
*/
|
|
830
830
|
responses(modelId: OpenAIResponsesModelId): LanguageModelV3;
|
|
831
831
|
/**
|
|
832
|
-
|
|
832
|
+
* Creates an OpenAI completion model for text generation.
|
|
833
833
|
*/
|
|
834
834
|
completion(modelId: OpenAICompletionModelId): LanguageModelV3;
|
|
835
835
|
/**
|
|
836
|
-
|
|
836
|
+
* Creates a model for text embeddings.
|
|
837
837
|
*/
|
|
838
838
|
embedding(modelId: OpenAIEmbeddingModelId): EmbeddingModelV3;
|
|
839
839
|
/**
|
|
840
|
-
|
|
840
|
+
* Creates a model for text embeddings.
|
|
841
841
|
*/
|
|
842
842
|
embeddingModel(modelId: OpenAIEmbeddingModelId): EmbeddingModelV3;
|
|
843
843
|
/**
|
|
@@ -849,63 +849,63 @@ interface OpenAIProvider extends ProviderV3 {
|
|
|
849
849
|
*/
|
|
850
850
|
textEmbeddingModel(modelId: OpenAIEmbeddingModelId): EmbeddingModelV3;
|
|
851
851
|
/**
|
|
852
|
-
|
|
852
|
+
* Creates a model for image generation.
|
|
853
853
|
*/
|
|
854
854
|
image(modelId: OpenAIImageModelId): ImageModelV3;
|
|
855
855
|
/**
|
|
856
|
-
|
|
856
|
+
* Creates a model for image generation.
|
|
857
857
|
*/
|
|
858
858
|
imageModel(modelId: OpenAIImageModelId): ImageModelV3;
|
|
859
859
|
/**
|
|
860
|
-
|
|
860
|
+
* Creates a model for transcription.
|
|
861
861
|
*/
|
|
862
862
|
transcription(modelId: OpenAITranscriptionModelId): TranscriptionModelV3;
|
|
863
863
|
/**
|
|
864
|
-
|
|
864
|
+
* Creates a model for speech generation.
|
|
865
865
|
*/
|
|
866
866
|
speech(modelId: OpenAISpeechModelId): SpeechModelV3;
|
|
867
867
|
/**
|
|
868
|
-
|
|
868
|
+
* OpenAI-specific tools.
|
|
869
869
|
*/
|
|
870
870
|
tools: typeof openaiTools;
|
|
871
871
|
}
|
|
872
872
|
interface OpenAIProviderSettings {
|
|
873
873
|
/**
|
|
874
|
-
|
|
875
|
-
|
|
874
|
+
* Base URL for the OpenAI API calls.
|
|
875
|
+
*/
|
|
876
876
|
baseURL?: string;
|
|
877
877
|
/**
|
|
878
|
-
|
|
879
|
-
|
|
878
|
+
* API key for authenticating requests.
|
|
879
|
+
*/
|
|
880
880
|
apiKey?: string;
|
|
881
881
|
/**
|
|
882
|
-
|
|
883
|
-
|
|
882
|
+
* OpenAI Organization.
|
|
883
|
+
*/
|
|
884
884
|
organization?: string;
|
|
885
885
|
/**
|
|
886
|
-
|
|
887
|
-
|
|
886
|
+
* OpenAI project.
|
|
887
|
+
*/
|
|
888
888
|
project?: string;
|
|
889
889
|
/**
|
|
890
|
-
|
|
891
|
-
|
|
890
|
+
* Custom headers to include in the requests.
|
|
891
|
+
*/
|
|
892
892
|
headers?: Record<string, string>;
|
|
893
893
|
/**
|
|
894
|
-
|
|
894
|
+
* Provider name. Overrides the `openai` default name for 3rd party providers.
|
|
895
895
|
*/
|
|
896
896
|
name?: string;
|
|
897
897
|
/**
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
898
|
+
* Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
899
|
+
* or to provide a custom fetch implementation for e.g. testing.
|
|
900
|
+
*/
|
|
901
901
|
fetch?: FetchFunction;
|
|
902
902
|
}
|
|
903
903
|
/**
|
|
904
|
-
Create an OpenAI provider instance.
|
|
904
|
+
* Create an OpenAI provider instance.
|
|
905
905
|
*/
|
|
906
906
|
declare function createOpenAI(options?: OpenAIProviderSettings): OpenAIProvider;
|
|
907
907
|
/**
|
|
908
|
-
Default OpenAI provider instance.
|
|
908
|
+
* Default OpenAI provider instance.
|
|
909
909
|
*/
|
|
910
910
|
declare const openai: OpenAIProvider;
|
|
911
911
|
|
package/dist/index.js
CHANGED
|
@@ -1339,42 +1339,42 @@ var openaiCompletionProviderOptions = (0, import_provider_utils7.lazySchema)(
|
|
|
1339
1339
|
() => (0, import_provider_utils7.zodSchema)(
|
|
1340
1340
|
import_v45.z.object({
|
|
1341
1341
|
/**
|
|
1342
|
-
|
|
1343
|
-
|
|
1342
|
+
* Echo back the prompt in addition to the completion.
|
|
1343
|
+
*/
|
|
1344
1344
|
echo: import_v45.z.boolean().optional(),
|
|
1345
1345
|
/**
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1346
|
+
* Modify the likelihood of specified tokens appearing in the completion.
|
|
1347
|
+
*
|
|
1348
|
+
* Accepts a JSON object that maps tokens (specified by their token ID in
|
|
1349
|
+
* the GPT tokenizer) to an associated bias value from -100 to 100. You
|
|
1350
|
+
* can use this tokenizer tool to convert text to token IDs. Mathematically,
|
|
1351
|
+
* the bias is added to the logits generated by the model prior to sampling.
|
|
1352
|
+
* The exact effect will vary per model, but values between -1 and 1 should
|
|
1353
|
+
* decrease or increase likelihood of selection; values like -100 or 100
|
|
1354
|
+
* should result in a ban or exclusive selection of the relevant token.
|
|
1355
|
+
*
|
|
1356
|
+
* As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
|
|
1357
|
+
* token from being generated.
|
|
1358
1358
|
*/
|
|
1359
1359
|
logitBias: import_v45.z.record(import_v45.z.string(), import_v45.z.number()).optional(),
|
|
1360
1360
|
/**
|
|
1361
|
-
|
|
1361
|
+
* The suffix that comes after a completion of inserted text.
|
|
1362
1362
|
*/
|
|
1363
1363
|
suffix: import_v45.z.string().optional(),
|
|
1364
1364
|
/**
|
|
1365
|
-
|
|
1366
|
-
|
|
1365
|
+
* A unique identifier representing your end-user, which can help OpenAI to
|
|
1366
|
+
* monitor and detect abuse. Learn more.
|
|
1367
1367
|
*/
|
|
1368
1368
|
user: import_v45.z.string().optional(),
|
|
1369
1369
|
/**
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1370
|
+
* Return the log probabilities of the tokens. Including logprobs will increase
|
|
1371
|
+
* the response size and can slow down response times. However, it can
|
|
1372
|
+
* be useful to better understand how the model is behaving.
|
|
1373
|
+
* Setting to true will return the log probabilities of the tokens that
|
|
1374
|
+
* were generated.
|
|
1375
|
+
* Setting to a number will return the log probabilities of the top n
|
|
1376
|
+
* tokens that were generated.
|
|
1377
|
+
*/
|
|
1378
1378
|
logprobs: import_v45.z.union([import_v45.z.boolean(), import_v45.z.number()]).optional()
|
|
1379
1379
|
})
|
|
1380
1380
|
)
|
|
@@ -1620,14 +1620,14 @@ var openaiEmbeddingProviderOptions = (0, import_provider_utils9.lazySchema)(
|
|
|
1620
1620
|
() => (0, import_provider_utils9.zodSchema)(
|
|
1621
1621
|
import_v46.z.object({
|
|
1622
1622
|
/**
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1623
|
+
* The number of dimensions the resulting output embeddings should have.
|
|
1624
|
+
* Only supported in text-embedding-3 and later models.
|
|
1625
|
+
*/
|
|
1626
1626
|
dimensions: import_v46.z.number().optional(),
|
|
1627
1627
|
/**
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1628
|
+
* A unique identifier representing your end-user, which can help OpenAI to
|
|
1629
|
+
* monitor and detect abuse. Learn more.
|
|
1630
|
+
*/
|
|
1631
1631
|
user: import_v46.z.string().optional()
|
|
1632
1632
|
})
|
|
1633
1633
|
)
|
|
@@ -5786,7 +5786,7 @@ var OpenAITranscriptionModel = class {
|
|
|
5786
5786
|
};
|
|
5787
5787
|
|
|
5788
5788
|
// src/version.ts
|
|
5789
|
-
var VERSION = true ? "3.0.
|
|
5789
|
+
var VERSION = true ? "3.0.22" : "0.0.0-test";
|
|
5790
5790
|
|
|
5791
5791
|
// src/openai-provider.ts
|
|
5792
5792
|
function createOpenAI(options = {}) {
|