diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 52c31fe71..6b843f931 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "4.76.3"
+ ".": "4.77.0"
}
diff --git a/.stats.yml b/.stats.yml
index 3cc042fe0..7b5235e3c 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,2 +1,2 @@
configured_endpoints: 68
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-2e0e0678be19d1118fd796af291822075e40538dba326611e177e9f3dc245a53.yml
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-0d64ca9e45f51b4279f87b205eeb3a3576df98407698ce053f2e2302c1c08df1.yml
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4b6f57fe4..d33ce4c1a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,19 @@
# Changelog
+## 4.77.0 (2024-12-17)
+
+Full Changelog: [v4.76.3...v4.77.0](https://github.com/openai/openai-node/compare/v4.76.3...v4.77.0)
+
+### Features
+
+* **api:** new o1 and GPT-4o models + preference fine-tuning ([#1229](https://github.com/openai/openai-node/issues/1229)) ([2e872d4](https://github.com/openai/openai-node/commit/2e872d4ac3717ab8f61741efffb7a31acd798338))
+
+
+### Chores
+
+* **internal:** fix some typos ([#1227](https://github.com/openai/openai-node/issues/1227)) ([d51fcfe](https://github.com/openai/openai-node/commit/d51fcfe3a66550a684eeeb0e6f17e1d9825cdf78))
+* **internal:** spec update ([#1230](https://github.com/openai/openai-node/issues/1230)) ([ed2b61d](https://github.com/openai/openai-node/commit/ed2b61d32703b64d9f91223bc02627a607f60483))
+
## 4.76.3 (2024-12-13)
Full Changelog: [v4.76.2...v4.76.3](https://github.com/openai/openai-node/compare/v4.76.2...v4.76.3)
diff --git a/api.md b/api.md
index 465730de8..54bcf08d7 100644
--- a/api.md
+++ b/api.md
@@ -41,6 +41,7 @@ Types:
- ChatCompletionContentPartInputAudio
- ChatCompletionContentPartRefusal
- ChatCompletionContentPartText
+- ChatCompletionDeveloperMessageParam
- ChatCompletionFunctionCallOption
- ChatCompletionFunctionMessageParam
- ChatCompletionMessage
@@ -49,6 +50,7 @@ Types:
- ChatCompletionModality
- ChatCompletionNamedToolChoice
- ChatCompletionPredictionContent
+- ChatCompletionReasoningEffort
- ChatCompletionRole
- ChatCompletionStreamOptions
- ChatCompletionSystemMessageParam
diff --git a/jsr.json b/jsr.json
index ef9ce6848..d76a2040e 100644
--- a/jsr.json
+++ b/jsr.json
@@ -1,6 +1,6 @@
{
"name": "@openai/openai",
- "version": "4.76.3",
+ "version": "4.77.0",
"exports": "./index.ts",
"publish": {
"exclude": [
diff --git a/package.json b/package.json
index 47f363ba1..54633aa5d 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "openai",
- "version": "4.76.3",
+ "version": "4.77.0",
"description": "The official TypeScript library for the OpenAI API",
"author": "OpenAI ",
"types": "dist/index.d.ts",
diff --git a/src/core.ts b/src/core.ts
index e1a93f272..68f1e676a 100644
--- a/src/core.ts
+++ b/src/core.ts
@@ -198,7 +198,7 @@ export abstract class APIClient {
maxRetries = 2,
timeout = 600000, // 10 minutes
httpAgent,
- fetch: overridenFetch,
+ fetch: overriddenFetch,
}: {
baseURL: string;
maxRetries?: number | undefined;
@@ -211,7 +211,7 @@ export abstract class APIClient {
this.timeout = validatePositiveInteger('timeout', timeout);
this.httpAgent = httpAgent;
- this.fetch = overridenFetch ?? fetch;
+ this.fetch = overriddenFetch ?? fetch;
}
protected authHeaders(opts: FinalRequestOptions): Headers {
diff --git a/src/index.ts b/src/index.ts
index 58d7410e4..2320850fb 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -80,6 +80,7 @@ import {
ChatCompletionCreateParams,
ChatCompletionCreateParamsNonStreaming,
ChatCompletionCreateParamsStreaming,
+ ChatCompletionDeveloperMessageParam,
ChatCompletionFunctionCallOption,
ChatCompletionFunctionMessageParam,
ChatCompletionMessage,
@@ -88,6 +89,7 @@ import {
ChatCompletionModality,
ChatCompletionNamedToolChoice,
ChatCompletionPredictionContent,
+ ChatCompletionReasoningEffort,
ChatCompletionRole,
ChatCompletionStreamOptions,
ChatCompletionSystemMessageParam,
@@ -353,6 +355,7 @@ export declare namespace OpenAI {
type ChatCompletionContentPartInputAudio as ChatCompletionContentPartInputAudio,
type ChatCompletionContentPartRefusal as ChatCompletionContentPartRefusal,
type ChatCompletionContentPartText as ChatCompletionContentPartText,
+ type ChatCompletionDeveloperMessageParam as ChatCompletionDeveloperMessageParam,
type ChatCompletionFunctionCallOption as ChatCompletionFunctionCallOption,
type ChatCompletionFunctionMessageParam as ChatCompletionFunctionMessageParam,
type ChatCompletionMessage as ChatCompletionMessage,
@@ -361,6 +364,7 @@ export declare namespace OpenAI {
type ChatCompletionModality as ChatCompletionModality,
type ChatCompletionNamedToolChoice as ChatCompletionNamedToolChoice,
type ChatCompletionPredictionContent as ChatCompletionPredictionContent,
+ type ChatCompletionReasoningEffort as ChatCompletionReasoningEffort,
type ChatCompletionRole as ChatCompletionRole,
type ChatCompletionStreamOptions as ChatCompletionStreamOptions,
type ChatCompletionSystemMessageParam as ChatCompletionSystemMessageParam,
diff --git a/src/resources/chat/chat.ts b/src/resources/chat/chat.ts
index 09cd3d123..2230b19bd 100644
--- a/src/resources/chat/chat.ts
+++ b/src/resources/chat/chat.ts
@@ -16,6 +16,7 @@ import {
ChatCompletionCreateParams,
ChatCompletionCreateParamsNonStreaming,
ChatCompletionCreateParamsStreaming,
+ ChatCompletionDeveloperMessageParam,
ChatCompletionFunctionCallOption,
ChatCompletionFunctionMessageParam,
ChatCompletionMessage,
@@ -24,6 +25,7 @@ import {
ChatCompletionModality,
ChatCompletionNamedToolChoice,
ChatCompletionPredictionContent,
+ ChatCompletionReasoningEffort,
ChatCompletionRole,
ChatCompletionStreamOptions,
ChatCompletionSystemMessageParam,
@@ -44,6 +46,8 @@ export class Chat extends APIResource {
}
export type ChatModel =
+ | 'o1'
+ | 'o1-2024-12-17'
| 'o1-preview'
| 'o1-preview-2024-09-12'
| 'o1-mini'
@@ -52,10 +56,11 @@ export type ChatModel =
| 'gpt-4o-2024-11-20'
| 'gpt-4o-2024-08-06'
| 'gpt-4o-2024-05-13'
- | 'gpt-4o-realtime-preview'
- | 'gpt-4o-realtime-preview-2024-10-01'
| 'gpt-4o-audio-preview'
| 'gpt-4o-audio-preview-2024-10-01'
+ | 'gpt-4o-audio-preview-2024-12-17'
+ | 'gpt-4o-mini-audio-preview'
+ | 'gpt-4o-mini-audio-preview-2024-12-17'
| 'chatgpt-4o-latest'
| 'gpt-4o-mini'
| 'gpt-4o-mini-2024-07-18'
@@ -96,6 +101,7 @@ export declare namespace Chat {
type ChatCompletionContentPartInputAudio as ChatCompletionContentPartInputAudio,
type ChatCompletionContentPartRefusal as ChatCompletionContentPartRefusal,
type ChatCompletionContentPartText as ChatCompletionContentPartText,
+ type ChatCompletionDeveloperMessageParam as ChatCompletionDeveloperMessageParam,
type ChatCompletionFunctionCallOption as ChatCompletionFunctionCallOption,
type ChatCompletionFunctionMessageParam as ChatCompletionFunctionMessageParam,
type ChatCompletionMessage as ChatCompletionMessage,
@@ -104,6 +110,7 @@ export declare namespace Chat {
type ChatCompletionModality as ChatCompletionModality,
type ChatCompletionNamedToolChoice as ChatCompletionNamedToolChoice,
type ChatCompletionPredictionContent as ChatCompletionPredictionContent,
+ type ChatCompletionReasoningEffort as ChatCompletionReasoningEffort,
type ChatCompletionRole as ChatCompletionRole,
type ChatCompletionStreamOptions as ChatCompletionStreamOptions,
type ChatCompletionSystemMessageParam as ChatCompletionSystemMessageParam,
diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts
index 8e9a4385e..31f5814cb 100644
--- a/src/resources/chat/completions.ts
+++ b/src/resources/chat/completions.ts
@@ -15,6 +15,12 @@ export class Completions extends APIResource {
* [text generation](https://platform.openai.com/docs/guides/text-generation),
* [vision](https://platform.openai.com/docs/guides/vision), and
* [audio](https://platform.openai.com/docs/guides/audio) guides.
+ *
+ * Parameter support can differ depending on the model used to generate the
+ * response, particularly for newer reasoning models. Parameters that are only
+ * supported for reasoning models are noted below. For the current state of
+ * unsupported parameters in reasoning models,
+ * [refer to the reasoning guide](https://platform.openai.com/docs/guides/reasoning).
*/
create(
body: ChatCompletionCreateParamsNonStreaming,
@@ -135,6 +141,9 @@ export namespace ChatCompletion {
}
}
+/**
+ * Messages sent by the model in response to user messages.
+ */
export interface ChatCompletionAssistantMessageParam {
/**
* The role of the messages author, in this case `assistant`.
@@ -530,6 +539,29 @@ export interface ChatCompletionContentPartText {
type: 'text';
}
+/**
+ * Developer-provided instructions that the model should follow, regardless of
+ * messages sent by the user. With o1 models and newer, `developer` messages
+ * replace the previous `system` messages.
+ */
+export interface ChatCompletionDeveloperMessageParam {
+ /**
+ * The contents of the developer message.
+ */
+ content: string | Array;
+
+ /**
+ * The role of the messages author, in this case `developer`.
+ */
+ role: 'developer';
+
+ /**
+ * An optional name for the participant. Provides the model information to
+ * differentiate between participants of the same role.
+ */
+ name?: string;
+}
+
/**
* Specifying a particular function via `{"name": "my_function"}` forces the model
* to call that function.
@@ -620,7 +652,13 @@ export namespace ChatCompletionMessage {
}
}
+/**
+ * Developer-provided instructions that the model should follow, regardless of
+ * messages sent by the user. With o1 models and newer, `developer` messages
+ * replace the previous `system` messages.
+ */
export type ChatCompletionMessageParam =
+ | ChatCompletionDeveloperMessageParam
| ChatCompletionSystemMessageParam
| ChatCompletionUserMessageParam
| ChatCompletionAssistantMessageParam
@@ -707,6 +745,16 @@ export interface ChatCompletionPredictionContent {
type: 'content';
}
+/**
+ * **o1 models only**
+ *
+ * Constrains effort on reasoning for
+ * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
+ * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
+ * result in faster responses and fewer tokens used on reasoning in a response.
+ */
+export type ChatCompletionReasoningEffort = 'low' | 'medium' | 'high';
+
/**
* The role of the author of a message
*/
@@ -725,6 +773,11 @@ export interface ChatCompletionStreamOptions {
include_usage?: boolean;
}
+/**
+ * Developer-provided instructions that the model should follow, regardless of
+ * messages sent by the user. With o1 models and newer, use `developer` messages
+ * for this purpose instead.
+ */
export interface ChatCompletionSystemMessageParam {
/**
* The contents of the system message.
@@ -835,6 +888,10 @@ export interface ChatCompletionToolMessageParam {
tool_call_id: string;
}
+/**
+ * Messages sent by an end user, containing prompts or additional context
+ * information.
+ */
export interface ChatCompletionUserMessageParam {
/**
* The contents of the user message.
@@ -891,20 +948,22 @@ export interface ChatCompletionCreateParamsBase {
* Number between -2.0 and 2.0. Positive values penalize new tokens based on their
* existing frequency in the text so far, decreasing the model's likelihood to
* repeat the same line verbatim.
- *
- * [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation)
*/
frequency_penalty?: number | null;
/**
* Deprecated in favor of `tool_choice`.
*
- * Controls which (if any) function is called by the model. `none` means the model
- * will not call a function and instead generates a message. `auto` means the model
- * can pick between generating a message or calling a function. Specifying a
- * particular function via `{"name": "my_function"}` forces the model to call that
+ * Controls which (if any) function is called by the model.
+ *
+ * `none` means the model will not call a function and instead generates a message.
+ *
+ * `auto` means the model can pick between generating a message or calling a
* function.
*
+ * Specifying a particular function via `{"name": "my_function"}` forces the model
+ * to call that function.
+ *
* `none` is the default when no functions are present. `auto` is the default if
* functions are present.
*/
@@ -998,17 +1057,21 @@ export interface ChatCompletionCreateParamsBase {
* Number between -2.0 and 2.0. Positive values penalize new tokens based on
* whether they appear in the text so far, increasing the model's likelihood to
* talk about new topics.
- *
- * [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation)
*/
presence_penalty?: number | null;
/**
- * An object specifying the format that the model must output. Compatible with
- * [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
- * [GPT-4o mini](https://platform.openai.com/docs/models#gpt-4o-mini),
- * [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4) and
- * all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
+ * **o1 models only**
+ *
+ * Constrains effort on reasoning for
+ * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
+ * supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
+ * result in faster responses and fewer tokens used on reasoning in a response.
+ */
+ reasoning_effort?: ChatCompletionReasoningEffort;
+
+ /**
+ * An object specifying the format that the model must output.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which ensures the model will match your supplied JSON schema. Learn more
@@ -1088,9 +1151,8 @@ export interface ChatCompletionCreateParamsBase {
/**
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
* make the output more random, while lower values like 0.2 will make it more
- * focused and deterministic.
- *
- * We generally recommend altering this or `top_p` but not both.
+ * focused and deterministic. We generally recommend altering this or `top_p` but
+ * not both.
*/
temperature?: number | null;
@@ -1223,6 +1285,7 @@ export declare namespace Completions {
type ChatCompletionContentPartInputAudio as ChatCompletionContentPartInputAudio,
type ChatCompletionContentPartRefusal as ChatCompletionContentPartRefusal,
type ChatCompletionContentPartText as ChatCompletionContentPartText,
+ type ChatCompletionDeveloperMessageParam as ChatCompletionDeveloperMessageParam,
type ChatCompletionFunctionCallOption as ChatCompletionFunctionCallOption,
type ChatCompletionFunctionMessageParam as ChatCompletionFunctionMessageParam,
type ChatCompletionMessage as ChatCompletionMessage,
@@ -1231,6 +1294,7 @@ export declare namespace Completions {
type ChatCompletionModality as ChatCompletionModality,
type ChatCompletionNamedToolChoice as ChatCompletionNamedToolChoice,
type ChatCompletionPredictionContent as ChatCompletionPredictionContent,
+ type ChatCompletionReasoningEffort as ChatCompletionReasoningEffort,
type ChatCompletionRole as ChatCompletionRole,
type ChatCompletionStreamOptions as ChatCompletionStreamOptions,
type ChatCompletionSystemMessageParam as ChatCompletionSystemMessageParam,
diff --git a/src/resources/chat/index.ts b/src/resources/chat/index.ts
index 262bf75a2..c3be19402 100644
--- a/src/resources/chat/index.ts
+++ b/src/resources/chat/index.ts
@@ -13,6 +13,7 @@ export {
type ChatCompletionContentPartInputAudio,
type ChatCompletionContentPartRefusal,
type ChatCompletionContentPartText,
+ type ChatCompletionDeveloperMessageParam,
type ChatCompletionFunctionCallOption,
type ChatCompletionFunctionMessageParam,
type ChatCompletionMessage,
@@ -21,6 +22,7 @@ export {
type ChatCompletionModality,
type ChatCompletionNamedToolChoice,
type ChatCompletionPredictionContent,
+ type ChatCompletionReasoningEffort,
type ChatCompletionRole,
type ChatCompletionStreamOptions,
type ChatCompletionSystemMessageParam,
diff --git a/src/resources/fine-tuning/jobs/jobs.ts b/src/resources/fine-tuning/jobs/jobs.ts
index 0c320e028..44dd011aa 100644
--- a/src/resources/fine-tuning/jobs/jobs.ts
+++ b/src/resources/fine-tuning/jobs/jobs.ts
@@ -127,9 +127,8 @@ export interface FineTuningJob {
finished_at: number | null;
/**
- * The hyperparameters used for the fine-tuning job. See the
- * [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning) for
- * more details.
+ * The hyperparameters used for the fine-tuning job. This value will only be
+ * returned when running `supervised` jobs.
*/
hyperparameters: FineTuningJob.Hyperparameters;
@@ -195,6 +194,11 @@ export interface FineTuningJob {
* A list of integrations to enable for this fine-tuning job.
*/
integrations?: Array | null;
+
+ /**
+ * The method used for fine-tuning.
+ */
+ method?: FineTuningJob.Method;
}
export namespace FineTuningJob {
@@ -221,18 +225,125 @@ export namespace FineTuningJob {
}
/**
- * The hyperparameters used for the fine-tuning job. See the
- * [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning) for
- * more details.
+ * The hyperparameters used for the fine-tuning job. This value will only be
+ * returned when running `supervised` jobs.
*/
export interface Hyperparameters {
+ /**
+ * Number of examples in each batch. A larger batch size means that model
+ * parameters are updated less frequently, but with lower variance.
+ */
+ batch_size?: 'auto' | number;
+
+ /**
+ * Scaling factor for the learning rate. A smaller learning rate may be useful to
+ * avoid overfitting.
+ */
+ learning_rate_multiplier?: 'auto' | number;
+
/**
* The number of epochs to train the model for. An epoch refers to one full cycle
- * through the training dataset. "auto" decides the optimal number of epochs based
- * on the size of the dataset. If setting the number manually, we support any
- * number between 1 and 50 epochs.
+ * through the training dataset.
+ */
+ n_epochs?: 'auto' | number;
+ }
+
+ /**
+ * The method used for fine-tuning.
+ */
+ export interface Method {
+ /**
+ * Configuration for the DPO fine-tuning method.
+ */
+ dpo?: Method.Dpo;
+
+ /**
+ * Configuration for the supervised fine-tuning method.
*/
- n_epochs: 'auto' | number;
+ supervised?: Method.Supervised;
+
+ /**
+ * The type of method. Is either `supervised` or `dpo`.
+ */
+ type?: 'supervised' | 'dpo';
+ }
+
+ export namespace Method {
+ /**
+ * Configuration for the DPO fine-tuning method.
+ */
+ export interface Dpo {
+ /**
+ * The hyperparameters used for the fine-tuning job.
+ */
+ hyperparameters?: Dpo.Hyperparameters;
+ }
+
+ export namespace Dpo {
+ /**
+ * The hyperparameters used for the fine-tuning job.
+ */
+ export interface Hyperparameters {
+ /**
+ * Number of examples in each batch. A larger batch size means that model
+ * parameters are updated less frequently, but with lower variance.
+ */
+ batch_size?: 'auto' | number;
+
+ /**
+ * The beta value for the DPO method. A higher beta value will increase the weight
+ * of the penalty between the policy and reference model.
+ */
+ beta?: 'auto' | number;
+
+ /**
+ * Scaling factor for the learning rate. A smaller learning rate may be useful to
+ * avoid overfitting.
+ */
+ learning_rate_multiplier?: 'auto' | number;
+
+ /**
+ * The number of epochs to train the model for. An epoch refers to one full cycle
+ * through the training dataset.
+ */
+ n_epochs?: 'auto' | number;
+ }
+ }
+
+ /**
+ * Configuration for the supervised fine-tuning method.
+ */
+ export interface Supervised {
+ /**
+ * The hyperparameters used for the fine-tuning job.
+ */
+ hyperparameters?: Supervised.Hyperparameters;
+ }
+
+ export namespace Supervised {
+ /**
+ * The hyperparameters used for the fine-tuning job.
+ */
+ export interface Hyperparameters {
+ /**
+ * Number of examples in each batch. A larger batch size means that model
+ * parameters are updated less frequently, but with lower variance.
+ */
+ batch_size?: 'auto' | number;
+
+ /**
+ * Scaling factor for the learning rate. A smaller learning rate may be useful to
+ * avoid overfitting.
+ */
+ learning_rate_multiplier?: 'auto' | number;
+
+ /**
+ * The number of epochs to train the model for. An epoch refers to one full cycle
+ * through the training dataset.
+ */
+ n_epochs?: 'auto' | number;
+ }
+ }
}
}
@@ -240,15 +351,40 @@ export namespace FineTuningJob {
* Fine-tuning job event object
*/
export interface FineTuningJobEvent {
+ /**
+ * The object identifier.
+ */
id: string;
+ /**
+ * The Unix timestamp (in seconds) for when the fine-tuning job was created.
+ */
created_at: number;
+ /**
+ * The log level of the event.
+ */
level: 'info' | 'warn' | 'error';
+ /**
+ * The message of the event.
+ */
message: string;
+ /**
+ * The object type, which is always "fine_tuning.job.event".
+ */
object: 'fine_tuning.job.event';
+
+ /**
+ * The data associated with the event.
+ */
+ data?: unknown;
+
+ /**
+ * The type of event.
+ */
+ type?: 'message' | 'metrics';
}
export type FineTuningJobIntegration = FineTuningJobWandbIntegrationObject;
@@ -318,8 +454,10 @@ export interface JobCreateParams {
* your file with the purpose `fine-tune`.
*
* The contents of the file should differ depending on if the model uses the
- * [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or
+ * [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input),
* [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
+ * format, or if the fine-tuning method uses the
+ * [preference](https://platform.openai.com/docs/api-reference/fine-tuning/preference-input)
* format.
*
* See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning)
@@ -328,7 +466,8 @@ export interface JobCreateParams {
training_file: string;
/**
- * The hyperparameters used for the fine-tuning job.
+ * The hyperparameters used for the fine-tuning job. This value is now deprecated
+ * in favor of `method`, and should be passed in under the `method` parameter.
*/
hyperparameters?: JobCreateParams.Hyperparameters;
@@ -337,6 +476,11 @@ export interface JobCreateParams {
*/
integrations?: Array | null;
+ /**
+ * The method used for fine-tuning.
+ */
+ method?: JobCreateParams.Method;
+
/**
* The seed controls the reproducibility of the job. Passing in the same seed and
* job parameters should produce the same results, but may differ in rare cases. If
@@ -372,7 +516,9 @@ export interface JobCreateParams {
export namespace JobCreateParams {
/**
- * The hyperparameters used for the fine-tuning job.
+ * @deprecated: The hyperparameters used for the fine-tuning job. This value is now
+ * deprecated in favor of `method`, and should be passed in under the `method`
+ * parameter.
*/
export interface Hyperparameters {
/**
@@ -444,6 +590,104 @@ export namespace JobCreateParams {
tags?: Array;
}
}
+
+ /**
+ * The method used for fine-tuning.
+ */
+ export interface Method {
+ /**
+ * Configuration for the DPO fine-tuning method.
+ */
+ dpo?: Method.Dpo;
+
+ /**
+ * Configuration for the supervised fine-tuning method.
+ */
+ supervised?: Method.Supervised;
+
+ /**
+ * The type of method. Is either `supervised` or `dpo`.
+ */
+ type?: 'supervised' | 'dpo';
+ }
+
+ export namespace Method {
+ /**
+ * Configuration for the DPO fine-tuning method.
+ */
+ export interface Dpo {
+ /**
+ * The hyperparameters used for the fine-tuning job.
+ */
+ hyperparameters?: Dpo.Hyperparameters;
+ }
+
+ export namespace Dpo {
+ /**
+ * The hyperparameters used for the fine-tuning job.
+ */
+ export interface Hyperparameters {
+ /**
+ * Number of examples in each batch. A larger batch size means that model
+ * parameters are updated less frequently, but with lower variance.
+ */
+ batch_size?: 'auto' | number;
+
+ /**
+ * The beta value for the DPO method. A higher beta value will increase the weight
+ * of the penalty between the policy and reference model.
+ */
+ beta?: 'auto' | number;
+
+ /**
+ * Scaling factor for the learning rate. A smaller learning rate may be useful to
+ * avoid overfitting.
+ */
+ learning_rate_multiplier?: 'auto' | number;
+
+ /**
+ * The number of epochs to train the model for. An epoch refers to one full cycle
+ * through the training dataset.
+ */
+ n_epochs?: 'auto' | number;
+ }
+ }
+
+ /**
+ * Configuration for the supervised fine-tuning method.
+ */
+ export interface Supervised {
+ /**
+ * The hyperparameters used for the fine-tuning job.
+ */
+ hyperparameters?: Supervised.Hyperparameters;
+ }
+
+ export namespace Supervised {
+ /**
+ * The hyperparameters used for the fine-tuning job.
+ */
+ export interface Hyperparameters {
+ /**
+ * Number of examples in each batch. A larger batch size means that model
+ * parameters are updated less frequently, but with lower variance.
+ */
+ batch_size?: 'auto' | number;
+
+ /**
+ * Scaling factor for the learning rate. A smaller learning rate may be useful to
+ * avoid overfitting.
+ */
+ learning_rate_multiplier?: 'auto' | number;
+
+ /**
+ * The number of epochs to train the model for. An epoch refers to one full cycle
+ * through the training dataset.
+ */
+ n_epochs?: 'auto' | number;
+ }
+ }
+ }
}
export interface JobListParams extends CursorPageParams {}
diff --git a/src/version.ts b/src/version.ts
index 01cd56405..fdf4e5224 100644
--- a/src/version.ts
+++ b/src/version.ts
@@ -1 +1 @@
-export const VERSION = '4.76.3'; // x-release-please-version
+export const VERSION = '4.77.0'; // x-release-please-version
diff --git a/tests/api-resources/chat/completions.test.ts b/tests/api-resources/chat/completions.test.ts
index 5dcbf9ad6..dfc09f69b 100644
--- a/tests/api-resources/chat/completions.test.ts
+++ b/tests/api-resources/chat/completions.test.ts
@@ -11,7 +11,7 @@ const client = new OpenAI({
describe('resource completions', () => {
test('create: only required params', async () => {
const responsePromise = client.chat.completions.create({
- messages: [{ content: 'string', role: 'system' }],
+ messages: [{ content: 'string', role: 'developer' }],
model: 'gpt-4o',
});
const rawResponse = await responsePromise.asResponse();
@@ -25,7 +25,7 @@ describe('resource completions', () => {
test('create: required and optional params', async () => {
const response = await client.chat.completions.create({
- messages: [{ content: 'string', role: 'system', name: 'name' }],
+ messages: [{ content: 'string', role: 'developer', name: 'name' }],
model: 'gpt-4o',
audio: { format: 'wav', voice: 'alloy' },
frequency_penalty: -2,
@@ -41,6 +41,7 @@ describe('resource completions', () => {
parallel_tool_calls: true,
prediction: { content: 'string', type: 'content' },
presence_penalty: -2,
+ reasoning_effort: 'low',
response_format: { type: 'text' },
seed: -9007199254740991,
service_tier: 'auto',
diff --git a/tests/api-resources/fine-tuning/jobs/jobs.test.ts b/tests/api-resources/fine-tuning/jobs/jobs.test.ts
index 0ab09768a..4de83a8b7 100644
--- a/tests/api-resources/fine-tuning/jobs/jobs.test.ts
+++ b/tests/api-resources/fine-tuning/jobs/jobs.test.ts
@@ -34,6 +34,20 @@ describe('resource jobs', () => {
wandb: { project: 'my-wandb-project', entity: 'entity', name: 'name', tags: ['custom-tag'] },
},
],
+ method: {
+ dpo: {
+ hyperparameters: {
+ batch_size: 'auto',
+ beta: 'auto',
+ learning_rate_multiplier: 'auto',
+ n_epochs: 'auto',
+ },
+ },
+ supervised: {
+ hyperparameters: { batch_size: 'auto', learning_rate_multiplier: 'auto', n_epochs: 'auto' },
+ },
+ type: 'supervised',
+ },
seed: 42,
suffix: 'x',
validation_file: 'file-abc123',
diff --git a/tests/index.test.ts b/tests/index.test.ts
index f39571121..bf113e7bb 100644
--- a/tests/index.test.ts
+++ b/tests/index.test.ts
@@ -177,7 +177,7 @@ describe('instantiate client', () => {
expect(client.apiKey).toBe('My API Key');
});
- test('with overriden environment variable arguments', () => {
+ test('with overridden environment variable arguments', () => {
// set options via env var
process.env['OPENAI_API_KEY'] = 'another My API Key';
const client = new OpenAI({ apiKey: 'My API Key' });