diff --git a/specification/ai-foundry/cspell.yaml b/specification/ai-foundry/cspell.yaml index 9fddc6206754..399997bf61c7 100644 --- a/specification/ai-foundry/cspell.yaml +++ b/specification/ai-foundry/cspell.yaml @@ -19,6 +19,44 @@ words: - logprobs - dedup overrides: + # OpenAI related terms + - filename: + - '**/specification/ai-foundry/data-plane/Foundry/src/openai/**' + - '**/specification/ai-foundry/data-plane/Foundry/openapi3' + - '**/specification/ai-foundry/data-plane/Foundry/stable' + - '**/specification/ai-foundry/data-plane/Foundry/preview' + words: + - acemeco + - ahrenheit + - Buffett + - dall + - egroup + - erun + - FDOC + - ftjob + - GEICO's + - granularities + - Hsqc + - Jwfo + - Liegl + - mpga + - msid + - notificiation + - okhttp + - ouputs + - rtpmap + - SAVPF + - tcptype + - tfmt + - ufrag + - uhhm + - Vbqg + - vsfb + - webrtc + - wuzzy + - Xxulc + - Zdws + # Red-team related terms - filename: - '**/specification/ai-foundry/data-plane/Foundry/src/red-teams' @@ -49,6 +87,15 @@ overrides: - filename: '**/*client*tsp' ignoreRegExpList: - '/@@clientName\([^\"]*\"([^\"]*)/g' + # Route documentation checker terminology + - filename: '**/data-plane/Foundry/.github/skills/foundry-route-doc-check/references/route-documentation-rules.md' + words: + - reemits + # Windows command script built-ins + - filename: '**/data-plane/Foundry/compile_all.cmd' + words: + - popd + - pushd # Example and output patterns: ignore common false positives in examples and emission outputs - filename: - '**/specification/ai-foundry/data-plane/Foundry/examples' @@ -82,4 +129,4 @@ overrides: - '**/specification/ai-foundry/data-plane/Foundry/.github/skills' words: - fdoc - - reemits \ No newline at end of file + - reemits diff --git a/specification/ai-foundry/data-plane/Foundry/.github/skills/foundry-route-doc-check/SKILL.md b/specification/ai-foundry/data-plane/Foundry/.github/skills/foundry-route-doc-check/SKILL.md index ff5675308675..e9e78923ad6d 100644 --- a/specification/ai-foundry/data-plane/Foundry/.github/skills/foundry-route-doc-check/SKILL.md +++ b/specification/ai-foundry/data-plane/Foundry/.github/skills/foundry-route-doc-check/SKILL.md @@ -2,8 +2,8 @@ name: foundry-route-doc-check license: MIT metadata: - version: "1.4.0" -description: "Validates that all TypeSpec route operations in the AI Foundry data-plane (Foundry) domain have documentation comments and @summary decorators with correct voice. USE FOR: reviewing or authoring routes.tsp files under specification/ai-foundry/data-plane/Foundry/src/. DO NOT USE FOR: files outside the Foundry data-plane area, model-only .tsp files, or SDK client customization files (client.tsp)." + version: "1.6.1" +description: "Validates that all TypeSpec route operations in the AI Foundry data-plane (Foundry) domain have documentation comments and @summary decorators with correct voice, replaces documentation-required suppressions with generated documentation, and uses description override extensions when TypeSpec would concatenate noisy descriptions. USE FOR: reviewing or authoring routes.tsp and routes.generated.tsp files under specification/ai-foundry/data-plane/Foundry/src/, including nested OpenAI routes under src/openai/. DO NOT USE FOR: files outside the Foundry data-plane area, model-only .tsp files, or SDK client customization files (client.tsp)." --- # Foundry Route Documentation Check @@ -18,8 +18,11 @@ This skill applies **only** to files matching: ``` specification/ai-foundry/data-plane/Foundry/src/**/routes.tsp +specification/ai-foundry/data-plane/Foundry/src/**/routes.generated.tsp ``` +OpenAI route files are nested under `specification/ai-foundry/data-plane/Foundry/src/openai//`. + It does **not** apply to: - `models.tsp`, `client.tsp`, `client.*.tsp`, or `main.tsp` files @@ -41,15 +44,24 @@ operations that have an explicit, significant rule violation: - Wrong grammatical voice (`@summary` using third-person, or doc comment using imperative) → fix - Empty or placeholder documentation → fix - Summary contains unnecessary filler ("all", "by id") that can be removed → fix +- Summary uses a multiline triple-quoted string, full sentence, or paragraph instead of a concise single-line phrase → fix - Description is near-identical to the summary with no added detail → fix - Description uses `@doc()` instead of a TSDoc `/** ... */` comment → fix +- `#suppress "@azure-tools/typespec-azure-core/documentation-required" ...` hides missing route or parameter documentation → remove the suppression and add documentation +- Multiple adjacent TSDoc comment blocks apply to the same operation or parameter → merge or remove the redundant block +- Multiple route variants or content types would cause TypeSpec to concatenate request body or parameter descriptions into noisy OpenAPI text → add the appropriate override extension with the intended final description instead of stacking TSDoc comments - Minor wording preferences or stylistic differences that do not violate a rule → **leave unchanged** When in doubt, leave the existing text alone. +For `routes.generated.tsp` files, it is acceptable to apply this skill's automated +rewrite directly to the generated file. The intended workflow is to run route +generation first and then run this rewrite immediately afterward, so the generated +route documentation changes are consistently reapplied and not lost overall. + ## Rules -Every operation defined inside an `interface` block in a `routes.tsp` file must satisfy +Every operation defined inside an `interface` block in a `routes.tsp` or `routes.generated.tsp` file must satisfy **all** of the following requirements. See [route-documentation-rules.md](references/route-documentation-rules.md) for the full rule definitions, examples, and remediation guidance. @@ -58,19 +70,86 @@ for the full rule definitions, examples, and remediation guidance. | `FDOC-001` | **Every** operation must have a TSDoc `/** ... */` comment. Prefer TSDoc over `@doc()`. | | `FDOC-002` | **Every** operation must have a `@summary()` decorator — no exceptions | | `FDOC-003` | The TSDoc description must use **third-person indicative** voice ("Creates an agent"), must add meaningful detail beyond the summary, and must not be near-identical to the summary. | -| `FDOC-004` | `@summary()` must be a maximally concise **imperative** phrase ("Create an agent"). No trailing period. No filler ("all", "by ID", "info about"). Must not be truncated. Always include articles. | +| `FDOC-004` | `@summary()` must be a maximally concise, single-line **imperative** phrase ("Create an agent"). No multiline strings. No trailing period. No filler ("all", "by ID", "info about"). Must not be truncated. Always include articles. | | `FDOC-005` | Each `@path`, `@query`, `@header`, and `@body` parameter must have a doc comment or `@doc()` | +| `FDOC-006` | Do not leave multiple adjacent TSDoc comment blocks on the same operation or parameter. TypeSpec concatenates adjacent docs into one OpenAPI `description`, which can produce malformed text. | +| `FDOC-007` | Remove `documentation-required` suppressions on routes and parameters, including auto-generated import suppressions, and replace them with generated TSDoc documentation. | +| `FDOC-008` | When TypeSpec would concatenate operation summaries/descriptions, request body descriptions, or parameter descriptions for shared routes, multiple content types, or adjacent imported docs, add the appropriate override extension with the desired final text. | + +### `documentation-required` suppressions + +When a route file contains a suppression for missing documentation, treat it as a fixable +documentation violation, not as an accepted exception. This includes suppressions such as: + +```typespec +#suppress "@azure-tools/typespec-azure-core/documentation-required" "Auto-suppressed warnings non-applicable rules during import." +``` + +For each matching suppression in a scoped `routes.tsp` or `routes.generated.tsp` file: + +1. Remove the `#suppress` directive. +2. Identify the operation, operation parameter, request body, query/header/path parameter, or + route-related declaration the suppression was shielding. +3. Add or repair the appropriate TSDoc documentation using rules `FDOC-001` through `FDOC-005`. +4. If the target already has a TSDoc comment or participates in a shared route / multiple-content-type request body where TypeSpec would concatenate descriptions, keep a single TSDoc comment for linter compliance and add the correct override extension. + + For `@path`, `@query`, and real `@header` parameters, apply the parameter-level extension: + + ```typespec + @extension("x-ms-description-override", "The intended final OpenAPI description.") + ``` + + For `@body` and `@multipartBody`, apply an operation-level request-body override because + TypeSpec does not emit parameter-level extensions onto the OpenAPI `requestBody` object: + + ```typespec + @extension("x-ms-request-body-description-override", "The intended final request body description.") + ``` + + Put this operation-level extension with the operation decorators (near `@summary`, `@route`, + and `@post`). Import and use `TypeSpec.OpenAPI` if the file does not already do so. +5. Preserve unrelated suppressions and any non-documentation suppressions. +6. Do not leave the file in a state where `documentation-required` still needs to be suppressed. + +### Description override extensions + +Use description override extensions when the source must retain documentation for TypeSpec +linting but the emitted OpenAPI description would otherwise be noisy because TypeSpec +concatenates multiple source descriptions. + +Use: + +- `x-ms-summary-override` and `x-ms-description-override` on each shared-route + operation variant when TypeSpec would merge multiple operations into one OpenAPI + operation and concatenate their summaries/descriptions +- `x-ms-description-override` on `@path`, `@query`, and real `@header` parameters +- `x-ms-request-body-description-override` on the operation for `@body` and + `@multipartBody` request bodies + +Common examples: + +- Shared-route operation variants that combine multipart and JSON request bodies into + one OpenAPI operation, causing summaries such as + `"Create a video edit multipart Create a video edit json"` +- Shared-route request bodies that combine JSON and multipart content types into one OpenAPI `requestBody` +- Imported generated parameters where the import already contributed a generic description +- Any route parameter or request body that would emit repeated text such as `"The request body.The request body."` or `"The file id path parameter.The ID of the file."` + +Prefer one concise TSDoc comment for the source declaration and one override extension with +the exact final OpenAPI text. Do not add adjacent TSDoc comments as a workaround. Do not add +`x-ms-description-override` directly to `@body` or `@multipartBody` declarations because the +OpenAPI emitter does not preserve those extensions on `requestBody`. ## Post-Edit Steps -After applying fixes to any `routes.tsp` file, **always** run the following steps in order: +After applying fixes to any `routes.tsp` or `routes.generated.tsp` file, **always** run the following steps in order: ### 1. Format Run `tsp format` on the changed files to ensure consistent formatting: ```shell -npx tsp format specification/ai-foundry/data-plane/Foundry/src/**/routes.tsp +npx tsp format specification/ai-foundry/data-plane/Foundry/src/**/routes.tsp specification/ai-foundry/data-plane/Foundry/src/**/routes.generated.tsp ``` ### 2. Regenerate OpenAPI artifacts @@ -87,9 +166,9 @@ Verify that the files under `openapi3/{version}/` are updated for every versione ## Workflow -1. **Identify** all `routes.tsp` files under `specification/ai-foundry/data-plane/Foundry/src/` +1. **Identify** all `routes.tsp` and `routes.generated.tsp` files under `specification/ai-foundry/data-plane/Foundry/src/` 2. **Parse** each `interface` block and enumerate its operations -3. **Check** each operation against rules `FDOC-001` through `FDOC-005` +3. **Check** each operation against rules `FDOC-001` through `FDOC-008` 4. **Report** findings grouped by file, with rule ID, operation name, and line number 5. **Fix** only operations with explicit, significant rule violations (see Conservative Change Policy) 6. **Run `tsp format`** on all modified files @@ -103,6 +182,7 @@ Report results as a markdown table: | File | Operation | Rule | Finding | | ---- | --------- | ---- | ------- | | src/connections/routes.tsp | get | FDOC-002 | Missing `@summary()` decorator | +| src/openai/chat/routes.generated.tsp | createChatCompletion | FDOC-004 | `@summary()` uses third-person voice | ``` If all operations pass, report: ✅ All Foundry route operations are fully documented. diff --git a/specification/ai-foundry/data-plane/Foundry/.github/skills/foundry-route-doc-check/references/route-documentation-rules.md b/specification/ai-foundry/data-plane/Foundry/.github/skills/foundry-route-doc-check/references/route-documentation-rules.md index 20ca3c86082c..95ce722846ed 100644 --- a/specification/ai-foundry/data-plane/Foundry/.github/skills/foundry-route-doc-check/references/route-documentation-rules.md +++ b/specification/ai-foundry/data-plane/Foundry/.github/skills/foundry-route-doc-check/references/route-documentation-rules.md @@ -185,6 +185,9 @@ Summaries must follow all of these constraints: - **Always include articles** for grammatical completeness — "Create a response", not "Create response"; "Get an agent", not "Get agent". - **Never truncate** — the text must be a complete, self-contained phrase. +- **Use a single-line string literal** — do not use multiline triple-quoted + summaries. If the source summary is a paragraph, move the detail into the + TSDoc operation description and replace the summary with a short phrase. - **Prefer the shortest correct phrasing.** The summary should name the verb and the resource, plus just enough context to distinguish it from sibling operations. Move any additional detail into the TSDoc description. @@ -247,6 +250,19 @@ The verb "Get" already implies retrieving the resource. Do not pad with @summary("This operation lists all connections that are currently available in the project, including those that are pending and those that are active, and returns them as a paginated list") ``` +### ❌ Bad — multiline paragraph + +```typespec +@summary(""" + Create a Realtime client secret with an associated session configuration. + + Client secrets are short-lived tokens that can be passed to a client app. + """) +``` + +Use `@summary("Create a Realtime client secret")` and move the paragraph +details into the operation TSDoc description. + ### ❌ Bad — truncated ```typespec @@ -271,6 +287,7 @@ Do not repeat the verb or splice in the doc-comment text. Use a clean imperative - Use imperative voice: "Create", "Get", "List", "Delete", "Update" (not "Creates", "Gets", etc.) - **No trailing period** — summaries are phrases, not sentences +- Use a single-line string literal, not a multiline triple-quoted string - Keep under ~60 characters - Remove filler words ("all", "by ID", "info about") unless needed for disambiguation - Always include articles ("a", "an", "the") for grammatical completeness @@ -319,6 +336,247 @@ Add a `/** ... */` comment immediately before the parameter declaration, or add --- +## FDOC-006 — No Adjacent TSDoc Blocks + +**Requirement:** Do not place multiple TSDoc block comments next to each other when +they apply to the same operation or parameter. + +**Why:** TypeSpec concatenates adjacent documentation blocks into a single OpenAPI +`description`. This can produce malformed output such as: + +```json +"description": "Must not exceed 63 characters.The agent name path parameter." +``` + +### ✅ Good + +```typespec +/** + * The unique name that identifies the agent. + * - Must start and end with alphanumeric characters. + * - Can contain hyphens in the middle. + */ +@path +agent_name: string; +``` + +### ❌ Bad + +```typespec +/** + * The unique name that identifies the agent. + * - Must start and end with alphanumeric characters. + */ +/** The agent name path parameter. */ +@path +agent_name: string; +``` + +### Remediation + +Merge the comments into a single TSDoc block, or remove the redundant generic +comment when a more specific description already exists. Prefer preserving the +more specific, customer-facing documentation. + +--- + +## FDOC-007 — Remove Documentation Suppressions + +**Requirement:** Do not keep suppressions for +`@azure-tools/typespec-azure-core/documentation-required` in scoped route files. +When the skill encounters a suppression for missing documentation, it must +remove the suppression and add the missing TSDoc documentation instead. + +This includes auto-generated import suppressions such as: + +```typespec +#suppress "@azure-tools/typespec-azure-core/documentation-required" "Auto-suppressed warnings non-applicable rules during import." +``` + +**Why:** Documentation suppressions hide gaps that flow into generated OpenAPI, +SDK documentation, and developer portals. Missing route and parameter +descriptions should be fixed at the TypeSpec source level so downstream +artifacts remain complete without relying on linter exceptions. + +### ✅ Good + +```typespec +/** Retrieves the requested response by its unique identifier. */ +@summary("Get a response") +@get +@route("/responses/{response_id}") +getResponse is FoundryDataPlaneOperation< + { + /** The unique identifier of the response to retrieve. */ + @path response_id: string; + }, + ResponseObject +>; +``` + +### ❌ Bad + +```typespec +#suppress "@azure-tools/typespec-azure-core/documentation-required" "Auto-suppressed warnings non-applicable rules during import." +@get +@route("/responses/{response_id}") +getResponse is FoundryDataPlaneOperation< + { + #suppress "@azure-tools/typespec-azure-core/documentation-required" "Auto-suppressed warnings non-applicable rules during import." + @path response_id: string; + }, + ResponseObject +>; +``` + +### Remediation + +Remove each `documentation-required` suppression and add the relevant TSDoc +comment: + +- For operations, add an operation TSDoc comment and `@summary()` per + `FDOC-001` through `FDOC-004`. +- For `@path`, `@query`, `@header`, and `@body` parameters, add a parameter + TSDoc comment or `@doc()` per `FDOC-005`. +- Preserve unrelated suppressions and suppressions for rules other than + `documentation-required`. + +Do not leave a scoped route file in a state where the +`documentation-required` warning still needs to be suppressed. + +--- + +## FDOC-008 — Description Override for Concatenated Descriptions + +**Requirement:** When TypeSpec would concatenate multiple operation summaries, +operation descriptions, request body descriptions, or parameter descriptions +into noisy OpenAPI output, keep concise source documentation and add the +appropriate override extension with the intended final OpenAPI text. + +This commonly happens for shared routes that support multiple content types +or for imported generated route parameters that already carry a generic +description. Without an override, OpenAPI can contain descriptions such as: + +```yaml +summary: Create a video edit multipart Create a video edit json +description: Creates a video edit multipart from the supplied request. Creates a video edit json from the supplied request. +description: The request body.The request body. +description: The file id path parameter.The ID of the file. +``` + +**Why:** TypeSpec source still needs documentation to satisfy +`documentation-required`, but adjacent or merged documentation can produce +repetitive downstream descriptions. The Foundry OpenAPI post-processing +understands description override extensions, so use them to declare the clean +final description instead of stacking TSDoc comments. + +### ✅ Good — shared route operation summary and description + +```typespec +/** Creates a video edit from the supplied request. */ +@summary("Create a video edit") +@extension("x-ms-summary-override", "Create a video edit") +@extension("x-ms-description-override", "Creates a video edit from the supplied request.") +@sharedRoute +@route("edits") +@post +createVideoEditMultipart is OpenAIOperation<...>; + +/** Creates a video edit from the supplied request. */ +@summary("Create a video edit") +@extension("x-ms-summary-override", "Create a video edit") +@extension("x-ms-description-override", "Creates a video edit from the supplied request.") +@sharedRoute +@route("edits") +@post +createVideoEditJson is OpenAIOperation<...>; +``` + +Add the same operation-level summary and description overrides to every variant +that TypeSpec merges into a single OpenAPI operation. + +### ✅ Good — shared route request body + +```typespec +@extension("x-ms-request-body-description-override", "The request body.") +@sharedRoute +@post +createContainerFileJson is OpenAIOperation< + { + /** The request body. */ + @body + body: OpenAI.CreateContainerFileBody; + }, + OpenAI.ContainerFileResource +>; +``` + +Use the operation-level `x-ms-request-body-description-override` extension for +`@body` and `@multipartBody` because TypeSpec does not emit parameter-level +extensions onto OpenAPI `requestBody`. + +### ✅ Good — route parameter + +```typespec +/** The file ID path parameter. */ +@extension("x-ms-description-override", "The ID of the file.") +@path +file_id: string; +``` + +### ✅ Good — imported/generated parameter with existing generic text + +```typespec +/** The file ID path parameter. */ +@extension("x-ms-description-override", "The ID of the file.") +@path +file_id: string; +``` + +### ❌ Bad — adjacent TSDoc blocks + +```typespec +/** The file id path parameter. */ +/** The ID of the file. */ +@path +file_id: string; +``` + +### ❌ Bad — repeated request body docs + +```typespec +/** The request body. */ +/** The request body. */ +@body +body: OpenAI.ModifyAssistantRequest; +``` + +### Remediation + +1. Remove adjacent duplicate or competing TSDoc blocks. +2. Keep a single TSDoc comment so the declaration remains documented. +3. For shared-route operation variants that emit concatenated operation + summaries or descriptions, add the same `x-ms-summary-override` and + `x-ms-description-override` to each variant. +4. For `@path`, `@query`, and real `@header` parameters, add + `@extension("x-ms-description-override", "...")` immediately before the + parameter decorator. +5. For `@body` and `@multipartBody`, add + `@extension("x-ms-request-body-description-override", "...")` to the + operation decorators, not to the body declaration. +6. Use the clean, customer-facing final description as the override value. +7. If the file does not already import and use OpenAPI decorators, add: + + ```typespec + import "@typespec/openapi"; + using TypeSpec.OpenAPI; + ``` + +Do not use adjacent TSDoc comments to combine generic and specific +documentation. + +--- + ## Post-Edit: Format and Regenerate After making any documentation fixes, **always** run these two steps: diff --git a/specification/ai-foundry/data-plane/Foundry/compile_all.cmd b/specification/ai-foundry/data-plane/Foundry/compile_all.cmd new file mode 100644 index 000000000000..2908ca8d3d54 --- /dev/null +++ b/specification/ai-foundry/data-plane/Foundry/compile_all.cmd @@ -0,0 +1,34 @@ +:: Script to compile main.tsp at the project root and all client.tsp files in the \src\sdk-* folders +@echo off +setlocal + +set "ROOT_DIR=%~dp0" +cd /d "%ROOT_DIR%" || exit /b 1 + +echo Compiling all sdk-* client TypeSpec files... +for /d %%D in ("src\sdk-*") do ( + if exist "%%~fD\client.tsp" ( + echo. + echo [%%~fD] npx tsp compile client.tsp + pushd "%%~fD" || exit /b 1 + call npx tsp compile client.tsp + @echo off + if errorlevel 1 ( + popd + echo. + echo Compile failed in %%~fD + exit /b 1 + ) + popd + ) +) + +echo. +echo [ROOT] npx tsp compile . +call npx tsp compile . +@echo off +if errorlevel 1 exit /b 1 + +echo. +echo All compilations completed successfully. +exit /b 0 diff --git a/specification/ai-foundry/data-plane/Foundry/compile_all.ps1 b/specification/ai-foundry/data-plane/Foundry/compile_all.ps1 new file mode 100644 index 000000000000..556496b98881 --- /dev/null +++ b/specification/ai-foundry/data-plane/Foundry/compile_all.ps1 @@ -0,0 +1,45 @@ +# Script to compile main.tsp at the project root and all client.tsp files in the \src\sdk-* folders +$ErrorActionPreference = 'Stop' + +$rootDir = $PSScriptRoot +if (-not $rootDir) { + $rootDir = Split-Path -Parent $MyInvocation.MyCommand.Path +} + +Set-Location -Path $rootDir + +Write-Host 'Compiling all sdk-* client TypeSpec files...' + +Get-ChildItem -Path 'src' -Directory -Filter 'sdk-*' | ForEach-Object { + $dirPath = $_.FullName + $clientTspPath = Join-Path $dirPath 'client.tsp' + + if (Test-Path -Path $clientTspPath) { + Write-Host '' + Write-Host "[$dirPath] npx tsp compile client.tsp" + + Push-Location -Path $dirPath + try { + & npx tsp compile client.tsp + if ($LASTEXITCODE -ne 0) { + Write-Host '' + Write-Host "Compile failed in $dirPath" + exit 1 + } + } + finally { + Pop-Location + } + } +} + +Write-Host '' +Write-Host '[ROOT] npx tsp compile .' +& npx tsp compile . +if ($LASTEXITCODE -ne 0) { + exit 1 +} + +Write-Host '' +Write-Host 'All compilations completed successfully.' +exit 0 diff --git a/specification/ai-foundry/data-plane/Foundry/main.tsp b/specification/ai-foundry/data-plane/Foundry/main.tsp index f80e510cb311..22a1ce77fcc1 100644 --- a/specification/ai-foundry/data-plane/Foundry/main.tsp +++ b/specification/ai-foundry/data-plane/Foundry/main.tsp @@ -18,10 +18,27 @@ import "./src/insights/routes.tsp"; import "./src/managed-blueprints/routes.tsp"; import "./src/models/routes.tsp"; import "./src/memory-stores/routes.tsp"; -import "./src/openai-conversations/routes.tsp"; -import "./src/openai-evaluations/routes.tsp"; -import "./src/openai-finetuning/routes.tsp"; -import "./src/openai-responses/routes.tsp"; +import "./src/openai/assistants/main.tsp"; +import "./src/openai/audio/main.tsp"; +import "./src/openai/batch/main.tsp"; +import "./src/openai/chat/main.tsp"; +import "./src/openai/completions/main.tsp"; +import "./src/openai/containers/main.tsp"; +import "./src/openai/conversations/main.tsp"; +import "./src/openai/embeddings/main.tsp"; +import "./src/openai/evaluations/main.tsp"; +import "./src/openai/files/main.tsp"; +import "./src/openai/finetuning/main.tsp"; +import "./src/openai/graders/main.tsp"; +import "./src/openai/images/main.tsp"; +import "./src/openai/models/main.tsp"; +import "./src/openai/moderations/main.tsp"; +import "./src/openai/realtime/main.tsp"; +import "./src/openai/responses/main.tsp"; +import "./src/openai/threads/main.tsp"; +import "./src/openai/uploads/main.tsp"; +import "./src/openai/vectorstores/main.tsp"; +import "./src/openai/video/main.tsp"; import "./src/red-teams/routes.tsp"; import "./src/routines/routes.tsp"; import "./src/schedules/routes.tsp"; diff --git a/specification/ai-foundry/data-plane/Foundry/openapi3/v1/microsoft-foundry-openapi3.json b/specification/ai-foundry/data-plane/Foundry/openapi3/v1/microsoft-foundry-openapi3.json index 64d76a0ac370..ebca32cde5b1 100644 --- a/specification/ai-foundry/data-plane/Foundry/openapi3/v1/microsoft-foundry-openapi3.json +++ b/specification/ai-foundry/data-plane/Foundry/openapi3/v1/microsoft-foundry-openapi3.json @@ -5,9 +5,6 @@ "version": "v1" }, "tags": [ - { - "name": "Fine-Tuning" - }, { "name": "Responses Root", "description": "Responses" @@ -181,7 +178,7 @@ }, { "name": "EvaluatorGenerationJobs", - "parent": "Platform APIs", + "parent": "Evaluations", "summary": "Evaluator generation jobs" }, { @@ -221,8 +218,8 @@ "/agent_optimization_jobs": { "post": { "operationId": "AgentOptimizationJobs_create", - "summary": "Creates an agent optimization job.", - "description": "Create an optimization job. Returns 201 with the queued job. Honours `Operation-Id` for idempotent retry.", + "summary": "Create an agent optimization job", + "description": "Creates an optimization job and returns the queued job. Honors `Operation-Id` for idempotent retry.", "parameters": [ { "name": "Foundry-Features", @@ -326,8 +323,8 @@ }, "get": { "operationId": "AgentOptimizationJobs_list", - "summary": "Returns a list of agent optimization jobs.", - "description": "List optimization jobs. Supports cursor pagination and optional status / agent_name filters.", + "summary": "List agent optimization jobs", + "description": "Lists optimization jobs with cursor pagination and optional status or agent name filters.", "parameters": [ { "name": "Foundry-Features", @@ -485,8 +482,8 @@ "/agent_optimization_jobs/{jobId}": { "get": { "operationId": "AgentOptimizationJobs_get", - "summary": "Get info about an agent optimization job.", - "description": "Get an optimization job by id.", + "summary": "Get an agent optimization job", + "description": "Retrieves an optimization job by its identifier.", "parameters": [ { "name": "Foundry-Features", @@ -573,8 +570,8 @@ }, "delete": { "operationId": "AgentOptimizationJobs_delete", - "summary": "Deletes an agent optimization job.", - "description": "Delete the job and its candidate artifacts. Cancels first if non-terminal.", + "summary": "Delete an agent optimization job", + "description": "Deletes the job and its candidate artifacts, canceling the job first if it is non-terminal.", "parameters": [ { "name": "Foundry-Features", @@ -646,8 +643,8 @@ "/agent_optimization_jobs/{jobId}:cancel": { "post": { "operationId": "AgentOptimizationJobs_cancel", - "summary": "Cancels an agent optimization job.", - "description": "Request cancellation of a running or queued job. Returns an error if the job is already in a terminal state.", + "summary": "Cancel an agent optimization job", + "description": "Requests cancellation of a running or queued job and returns an error if the job is already in a terminal state.", "parameters": [ { "name": "Foundry-Features", @@ -830,7 +827,8 @@ } } } - } + }, + "description": "The content multipart request content." } }, "get": { @@ -1124,7 +1122,8 @@ } } } - } + }, + "description": "The content multipart request content." } }, "delete": { @@ -2750,7 +2749,8 @@ } } } - } + }, + "description": "The content multipart request content." } }, "get": { @@ -3069,6 +3069,149 @@ ] } }, + "/agents/{agent_name}/versions/{agent_version}/invocations/docs/asyncapi.json": { + "get": { + "operationId": "AgentInvocations_getAgentInvocationAsyncApiSpecJson", + "description": "Retrieves the AsyncAPI (JSON) specification for an agent version's event-driven\ninvocation contract (e.g. the `invocations_ws` WebSocket protocol). AsyncAPI is the\ncompanion to OpenAPI for streaming/bidirectional surfaces that OpenAPI cannot express.\nReturns 404 if the agent does not publish an AsyncAPI specification. Publishing is\noptional; when published, both JSON and YAML representations are available.", + "parameters": [ + { + "name": "agent_name", + "in": "path", + "required": true, + "description": "The name of the agent.", + "schema": { + "type": "string" + } + }, + { + "name": "agent_version", + "in": "path", + "required": true, + "description": "The version of the agent.", + "schema": { + "type": "string" + } + }, + { + "name": "api-version", + "in": "query", + "required": true, + "description": "The API version to use for this operation.", + "schema": { + "type": "string" + }, + "explode": false + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "content": { + "application/json": { + "schema": { + "type": "object", + "unevaluatedProperties": {} + } + } + } + }, + "4XX": { + "description": "Client error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } + }, + "5XX": { + "description": "Server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } + } + }, + "tags": [ + "Agent Invocations" + ] + } + }, + "/agents/{agent_name}/versions/{agent_version}/invocations/docs/asyncapi.yaml": { + "get": { + "operationId": "AgentInvocations_getAgentInvocationAsyncApiSpecYaml", + "description": "Retrieves the AsyncAPI (YAML) specification for an agent version's event-driven\ninvocation contract. Companion to `getAgentInvocationAsyncApiSpecJson`; the path\nextension is authoritative for the returned content type (no `Accept` negotiation).\nReturns 404 if the agent does not publish an AsyncAPI specification.", + "parameters": [ + { + "name": "agent_name", + "in": "path", + "required": true, + "description": "The name of the agent.", + "schema": { + "type": "string" + } + }, + { + "name": "agent_version", + "in": "path", + "required": true, + "description": "The version of the agent.", + "schema": { + "type": "string" + } + }, + { + "name": "api-version", + "in": "query", + "required": true, + "description": "The API version to use for this operation.", + "schema": { + "type": "string" + }, + "explode": false + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "content": { + "application/yaml": { + "schema": { + "type": "string" + } + } + } + }, + "4XX": { + "description": "Client error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } + }, + "5XX": { + "description": "Server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } + } + }, + "tags": [ + "Agent Invocations" + ] + } + }, "/agents/{agent_name}/versions/{agent_version}/sessions/{session_id}:logstream": { "get": { "operationId": "Agents_getSessionLogStream", @@ -3274,7 +3417,10 @@ } } } - } + }, + "tags": [ + "Agents" + ] } }, "/agents/{agent_name}:enable": { @@ -3327,7 +3473,10 @@ } } } - } + }, + "tags": [ + "Agents" + ] } }, "/agents:import": { @@ -4550,7 +4699,7 @@ "post": { "operationId": "Datasets_getCredentials", "summary": "Get dataset credentials", - "description": "Gets the SAS credential to access the storage account associated with a Dataset version.", + "description": "Retrieves the SAS credential to access the storage account associated with a dataset version.", "parameters": [ { "$ref": "#/components/parameters/Azure.Core.Foundations.ApiVersionParameter" @@ -4834,7 +4983,7 @@ "get": { "operationId": "Deployments_get", "summary": "Get a deployment", - "description": "Gets a deployed model.", + "description": "Retrieves a deployed model.", "parameters": [ { "$ref": "#/components/parameters/Azure.Core.Foundations.ApiVersionParameter" @@ -5622,7 +5771,7 @@ "patch": { "operationId": "EvaluationTaxonomies_update", "summary": "Update an evaluation taxonomy", - "description": "Update an evaluation taxonomy.", + "description": "Modifies the specified evaluation taxonomy with the provided changes.", "parameters": [ { "$ref": "#/components/parameters/Azure.Core.Foundations.ApiVersionParameter" @@ -6204,7 +6353,7 @@ "get": { "operationId": "Evaluators_listLatestVersions", "summary": "List latest evaluator versions", - "description": "Lists the latest version of each evaluator", + "description": "Lists the latest version of each evaluator.", "parameters": [ { "$ref": "#/components/parameters/Azure.Core.Foundations.ApiVersionParameter" @@ -6828,6 +6977,7 @@ "name": "name", "in": "path", "required": true, + "description": "The name path parameter.", "schema": { "type": "string" } @@ -6927,6 +7077,7 @@ "name": "name", "in": "path", "required": true, + "description": "The name path parameter.", "schema": { "type": "string" } @@ -9463,7 +9614,7 @@ "delete": { "operationId": "Models_deleteVersion", "summary": "Delete a model version", - "description": "Delete the specific version of the ModelVersion. The service returns 200 OK if the ModelVersion was deleted successfully or if the ModelVersion does not exist.", + "description": "Removes the specified model version. Returns 200 whether the version existed or not.", "parameters": [ { "$ref": "#/components/parameters/Azure.Core.Foundations.ApiVersionParameter" @@ -9554,7 +9705,7 @@ "patch": { "operationId": "Models_updateVersion", "summary": "Update a model version", - "description": "Update an existing ModelVersion with the given version id", + "description": "Updates an existing model version identified by its version ID.", "parameters": [ { "$ref": "#/components/parameters/Azure.Core.Foundations.ApiVersionParameter" @@ -9912,7 +10063,8 @@ "$ref": "#/components/schemas/ModelCredentialRequest" } } - } + }, + "description": "The credential request request body." }, "x-ms-foundry-meta": { "required_previews": [ @@ -10022,7 +10174,8 @@ "$ref": "#/components/schemas/ModelPendingUploadRequest" } } - } + }, + "description": "The pending upload request request body." }, "x-ms-foundry-meta": { "required_previews": [ @@ -10031,140 +10184,47 @@ } } }, - "/openai/v1/conversations": { - "post": { - "operationId": "createConversation", - "summary": "Create a conversation", - "description": "Creates a new conversation resource.", - "parameters": [ - { - "name": "x-ms-user-identity", - "in": "header", - "required": false, - "description": "Opaque per-user identity string used to scope endpoint-scoped data to a specific end user. The caller must have the `agents/endpoints/UserIdentityImpersonation/action` RBAC permission.", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "The request has succeeded.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OpenAI.ConversationResource" - } - } - } - }, - "4XX": { - "description": "Client error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiErrorResponse" - } - } - } - }, - "5XX": { - "description": "Server error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiErrorResponse" - } - } - } - } - }, - "tags": [ - "Conversations" - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OpenAI.CreateConversationBody" - } - } - } - } - }, + "/openai/v1/assistants": { "get": { - "operationId": "listConversations", - "summary": "List conversations", - "description": "Returns the conversations available in the current project.", + "operationId": "Assistants_listAssistants", + "summary": "List assistants", + "description": "Lists assistants matching the request filters.", "parameters": [ { "name": "limit", "in": "query", "required": false, - "description": "A limit on the number of objects to be returned. Limit can range between 1 and 100, and the\ndefault is 20.", + "description": "A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.", "schema": { - "type": "integer", - "format": "int32", + "$ref": "#/components/schemas/integer", "default": 20 - }, - "explode": false + } }, { "name": "order", "in": "query", "required": false, - "description": "Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`\nfor descending order.", + "description": "Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.", "schema": { - "$ref": "#/components/schemas/PageOrder" - }, - "explode": false + "$ref": "#/components/schemas/OpenAI.OrderEnum", + "default": "desc" + } }, { "name": "after", "in": "query", "required": false, - "description": "A cursor for use in pagination. `after` is an object ID that defines your place in the list.\nFor instance, if you make a list request and receive 100 objects, ending with obj_foo, your\nsubsequent call can include after=obj_foo in order to fetch the next page of the list.", + "description": "A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.", "schema": { "type": "string" }, - "explode": false + "x-ms-list-continuation-token": true }, { "name": "before", "in": "query", "required": false, - "description": "A cursor for use in pagination. `before` is an object ID that defines your place in the list.\nFor instance, if you make a list request and receive 100 objects, ending with obj_foo, your\nsubsequent call can include before=obj_foo in order to fetch the previous page of the list.", - "schema": { - "type": "string" - }, - "explode": false - }, - { - "name": "agent_name", - "in": "query", - "required": false, - "description": "Filter by agent name. If provided, only items associated with the specified agent will be returned.", - "schema": { - "type": "string" - }, - "explode": false - }, - { - "name": "agent_id", - "in": "query", - "required": false, - "description": "Filter by agent ID in the format `name:version`. If provided, only items associated with the specified agent ID will be returned.", - "schema": { - "type": "string" - }, - "explode": false - }, - { - "name": "x-ms-user-identity", - "in": "header", - "required": false, - "description": "Opaque per-user identity string used to scope endpoint-scoped data to a specific end user. The caller must have the `agents/endpoints/UserIdentityImpersonation/action` RBAC permission.", + "description": "A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.", "schema": { "type": "string" } @@ -10176,33 +10236,7 @@ "content": { "application/json": { "schema": { - "type": "object", - "required": [ - "data", - "has_more" - ], - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/OpenAI.ConversationResource" - }, - "description": "The requested list of items." - }, - "first_id": { - "type": "string", - "description": "The first ID represented in this list." - }, - "last_id": { - "type": "string", - "description": "The last ID represented in this list." - }, - "has_more": { - "type": "boolean", - "description": "A value indicating whether there are additional values available not captured in this list." - } - }, - "description": "The response data for a requested list of items." + "$ref": "#/components/schemas/OpenAI.ListAssistantsResponse" } } } @@ -10229,42 +10263,39 @@ } }, "tags": [ - "Conversations" - ] - } - }, - "/openai/v1/conversations/{conversation_id}": { - "post": { - "operationId": "updateConversation", - "summary": "Update a conversation", - "description": "Modifies the specified conversation's properties.", - "parameters": [ - { - "name": "conversation_id", - "in": "path", - "required": true, - "description": "The id of the conversation to update.", - "schema": { - "type": "string" - } - }, - { - "name": "x-ms-user-identity", - "in": "header", - "required": false, - "description": "Opaque per-user identity string used to scope endpoint-scoped data to a specific end user. The caller must have the `agents/endpoints/UserIdentityImpersonation/action` RBAC permission.", - "schema": { - "type": "string" - } - } + "Assistants" ], + "deprecated": true, + "x-oaiMeta": { + "name": "List assistants", + "group": "assistants", + "examples": { + "request": { + "curl": "curl \"https://api.openai.com/v1/assistants?order=desc&limit=20\" \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v2\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\npage = client.beta.assistants.list()\npage = page.data[0]\nprint(page.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const myAssistants = await openai.beta.assistants.list({\n order: \"desc\",\n limit: \"20\",\n });\n\n console.log(myAssistants.data);\n}\n\nmain();", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const assistant of client.beta.assistants.list()) {\n console.log(assistant.id);\n}", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.Beta.Assistants.List(context.TODO(), openai.BetaAssistantListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", page)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.assistants.AssistantListPage;\nimport com.openai.models.beta.assistants.AssistantListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n AssistantListPage page = client.beta().assistants().list();\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\npage = openai.beta.assistants.list\n\nputs(page)" + }, + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"asst_abc123\",\n \"object\": \"assistant\",\n \"created_at\": 1698982736,\n \"name\": \"Coding Tutor\",\n \"description\": null,\n \"model\": \"gpt-4o\",\n \"instructions\": \"You are a helpful assistant designed to make me better at coding!\",\n \"tools\": [],\n \"tool_resources\": {},\n \"metadata\": {},\n \"top_p\": 1.0,\n \"temperature\": 1.0,\n \"response_format\": \"auto\"\n },\n {\n \"id\": \"asst_abc456\",\n \"object\": \"assistant\",\n \"created_at\": 1698982718,\n \"name\": \"My Assistant\",\n \"description\": null,\n \"model\": \"gpt-4o\",\n \"instructions\": \"You are a helpful assistant designed to make me better at coding!\",\n \"tools\": [],\n \"tool_resources\": {},\n \"metadata\": {},\n \"top_p\": 1.0,\n \"temperature\": 1.0,\n \"response_format\": \"auto\"\n },\n {\n \"id\": \"asst_abc789\",\n \"object\": \"assistant\",\n \"created_at\": 1698982643,\n \"name\": null,\n \"description\": null,\n \"model\": \"gpt-4o\",\n \"instructions\": null,\n \"tools\": [],\n \"tool_resources\": {},\n \"metadata\": {},\n \"top_p\": 1.0,\n \"temperature\": 1.0,\n \"response_format\": \"auto\"\n }\n ],\n \"first_id\": \"asst_abc123\",\n \"last_id\": \"asst_abc789\",\n \"has_more\": false\n}\n" + } + }, + "x-ms-list": true + }, + "post": { + "operationId": "Assistants_createAssistant", + "summary": "Create an assistant", + "description": "Creates an assistant from the supplied request.", + "parameters": [], "responses": { "200": { "description": "The request has succeeded.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OpenAI.ConversationResource" + "$ref": "#/components/schemas/OpenAI.AssistantObject" } } } @@ -10291,38 +10322,65 @@ } }, "tags": [ - "Conversations" + "Assistants" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OpenAI.UpdateConversationBody" + "$ref": "#/components/schemas/OpenAI.CreateAssistantRequest" } } - } + }, + "description": "The request body." + }, + "deprecated": true, + "x-oaiMeta": { + "name": "Create assistant", + "group": "assistants", + "examples": [ + { + "title": "Code Interpreter", + "request": { + "curl": "curl \"https://api.openai.com/v1/assistants\" \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v2\" \\\n -d '{\n \"instructions\": \"You are a personal math tutor. When asked a question, write and run Python code to answer the question.\",\n \"name\": \"Math Tutor\",\n \"tools\": [{\"type\": \"code_interpreter\"}],\n \"model\": \"gpt-4o\"\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nassistant = client.beta.assistants.create(\n model=\"gpt-4o\",\n)\nprint(assistant.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const myAssistant = await openai.beta.assistants.create({\n instructions:\n \"You are a personal math tutor. When asked a question, write and run Python code to answer the question.\",\n name: \"Math Tutor\",\n tools: [{ type: \"code_interpreter\" }],\n model: \"gpt-4o\",\n });\n\n console.log(myAssistant);\n}\n\nmain();", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst assistant = await client.beta.assistants.create({ model: 'gpt-4o' });\n\nconsole.log(assistant.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n\t\"github.com/openai/openai-go/shared\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tassistant, err := client.Beta.Assistants.New(context.TODO(), openai.BetaAssistantNewParams{\n\t\tModel: shared.ChatModelGPT4o,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", assistant.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.ChatModel;\nimport com.openai.models.beta.assistants.Assistant;\nimport com.openai.models.beta.assistants.AssistantCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n AssistantCreateParams params = AssistantCreateParams.builder()\n .model(ChatModel.GPT_4O)\n .build();\n Assistant assistant = client.beta().assistants().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nassistant = openai.beta.assistants.create(model: :\"gpt-4o\")\n\nputs(assistant)" + }, + "response": "{\n \"id\": \"asst_abc123\",\n \"object\": \"assistant\",\n \"created_at\": 1698984975,\n \"name\": \"Math Tutor\",\n \"description\": null,\n \"model\": \"gpt-4o\",\n \"instructions\": \"You are a personal math tutor. When asked a question, write and run Python code to answer the question.\",\n \"tools\": [\n {\n \"type\": \"code_interpreter\"\n }\n ],\n \"metadata\": {},\n \"top_p\": 1.0,\n \"temperature\": 1.0,\n \"response_format\": \"auto\"\n}\n" + }, + { + "title": "Files", + "request": { + "curl": "curl https://api.openai.com/v1/assistants \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v2\" \\\n -d '{\n \"instructions\": \"You are an HR bot, and you have access to files to answer employee questions about company policies.\",\n \"tools\": [{\"type\": \"file_search\"}],\n \"tool_resources\": {\"file_search\": {\"vector_store_ids\": [\"vs_123\"]}},\n \"model\": \"gpt-4o\"\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nassistant = client.beta.assistants.create(\n model=\"gpt-4o\",\n)\nprint(assistant.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const myAssistant = await openai.beta.assistants.create({\n instructions:\n \"You are an HR bot, and you have access to files to answer employee questions about company policies.\",\n name: \"HR Helper\",\n tools: [{ type: \"file_search\" }],\n tool_resources: {\n file_search: {\n vector_store_ids: [\"vs_123\"]\n }\n },\n model: \"gpt-4o\"\n });\n\n console.log(myAssistant);\n}\n\nmain();", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst assistant = await client.beta.assistants.create({ model: 'gpt-4o' });\n\nconsole.log(assistant.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n\t\"github.com/openai/openai-go/shared\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tassistant, err := client.Beta.Assistants.New(context.TODO(), openai.BetaAssistantNewParams{\n\t\tModel: shared.ChatModelGPT4o,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", assistant.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.ChatModel;\nimport com.openai.models.beta.assistants.Assistant;\nimport com.openai.models.beta.assistants.AssistantCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n AssistantCreateParams params = AssistantCreateParams.builder()\n .model(ChatModel.GPT_4O)\n .build();\n Assistant assistant = client.beta().assistants().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nassistant = openai.beta.assistants.create(model: :\"gpt-4o\")\n\nputs(assistant)" + }, + "response": "{\n \"id\": \"asst_abc123\",\n \"object\": \"assistant\",\n \"created_at\": 1699009403,\n \"name\": \"HR Helper\",\n \"description\": null,\n \"model\": \"gpt-4o\",\n \"instructions\": \"You are an HR bot, and you have access to files to answer employee questions about company policies.\",\n \"tools\": [\n {\n \"type\": \"file_search\"\n }\n ],\n \"tool_resources\": {\n \"file_search\": {\n \"vector_store_ids\": [\"vs_123\"]\n }\n },\n \"metadata\": {},\n \"top_p\": 1.0,\n \"temperature\": 1.0,\n \"response_format\": \"auto\"\n}\n" + } + ] } - }, - "get": { - "operationId": "getConversation", - "summary": "Retrieve a conversation", - "description": "Retrieves the specified conversation and its metadata.", + } + }, + "/openai/v1/assistants/{assistant_id}": { + "delete": { + "operationId": "Assistants_deleteAssistant", + "summary": "Delete an assistant", + "description": "Deletes an assistant by its identifier.", "parameters": [ { - "name": "conversation_id", + "name": "assistant_id", "in": "path", "required": true, - "description": "The id of the conversation to retrieve.", - "schema": { - "type": "string" - } - }, - { - "name": "x-ms-user-identity", - "in": "header", - "required": false, - "description": "Opaque per-user identity string used to scope endpoint-scoped data to a specific end user. The caller must have the `agents/endpoints/UserIdentityImpersonation/action` RBAC permission.", + "description": "The ID of the assistant to delete.", "schema": { "type": "string" } @@ -10334,7 +10392,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OpenAI.ConversationResource" + "$ref": "#/components/schemas/OpenAI.DeleteAssistantResponse" } } } @@ -10361,28 +10419,36 @@ } }, "tags": [ - "Conversations" - ] + "Assistants" + ], + "deprecated": true, + "x-oaiMeta": { + "name": "Delete assistant", + "group": "assistants", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/assistants/asst_abc123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v2\" \\\n -X DELETE\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nassistant_deleted = client.beta.assistants.delete(\n \"assistant_id\",\n)\nprint(assistant_deleted.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const response = await openai.beta.assistants.delete(\"asst_abc123\");\n\n console.log(response);\n}\nmain();", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst assistantDeleted = await client.beta.assistants.delete('assistant_id');\n\nconsole.log(assistantDeleted.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tassistantDeleted, err := client.Beta.Assistants.Delete(context.TODO(), \"assistant_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", assistantDeleted.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.assistants.AssistantDeleteParams;\nimport com.openai.models.beta.assistants.AssistantDeleted;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n AssistantDeleted assistantDeleted = client.beta().assistants().delete(\"assistant_id\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nassistant_deleted = openai.beta.assistants.delete(\"assistant_id\")\n\nputs(assistant_deleted)" + }, + "response": "{\n \"id\": \"asst_abc123\",\n \"object\": \"assistant.deleted\",\n \"deleted\": true\n}\n" + } + } }, - "delete": { - "operationId": "deleteConversation", - "summary": "Delete a conversation", - "description": "Removes the specified conversation resource from the current project.", + "get": { + "operationId": "Assistants_getAssistant", + "summary": "Get an assistant", + "description": "Retrieves an assistant by its identifier.", "parameters": [ { - "name": "conversation_id", + "name": "assistant_id", "in": "path", "required": true, - "description": "The id of the conversation to delete.", - "schema": { - "type": "string" - } - }, - { - "name": "x-ms-user-identity", - "in": "header", - "required": false, - "description": "Opaque per-user identity string used to scope endpoint-scoped data to a specific end user. The caller must have the `agents/endpoints/UserIdentityImpersonation/action` RBAC permission.", + "description": "The ID of the assistant to retrieve.", "schema": { "type": "string" } @@ -10394,7 +10460,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OpenAI.DeletedConversationResource" + "$ref": "#/components/schemas/OpenAI.AssistantObject" } } } @@ -10421,43 +10487,36 @@ } }, "tags": [ - "Conversations" - ] - } - }, - "/openai/v1/conversations/{conversation_id}/items": { + "Assistants" + ], + "deprecated": true, + "x-oaiMeta": { + "name": "Retrieve assistant", + "group": "assistants", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/assistants/asst_abc123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v2\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nassistant = client.beta.assistants.retrieve(\n \"assistant_id\",\n)\nprint(assistant.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const myAssistant = await openai.beta.assistants.retrieve(\n \"asst_abc123\"\n );\n\n console.log(myAssistant);\n}\n\nmain();", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst assistant = await client.beta.assistants.retrieve('assistant_id');\n\nconsole.log(assistant.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tassistant, err := client.Beta.Assistants.Get(context.TODO(), \"assistant_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", assistant.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.assistants.Assistant;\nimport com.openai.models.beta.assistants.AssistantRetrieveParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n Assistant assistant = client.beta().assistants().retrieve(\"assistant_id\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nassistant = openai.beta.assistants.retrieve(\"assistant_id\")\n\nputs(assistant)" + }, + "response": "{\n \"id\": \"asst_abc123\",\n \"object\": \"assistant\",\n \"created_at\": 1699009709,\n \"name\": \"HR Helper\",\n \"description\": null,\n \"model\": \"gpt-4o\",\n \"instructions\": \"You are an HR bot, and you have access to files to answer employee questions about company policies.\",\n \"tools\": [\n {\n \"type\": \"file_search\"\n }\n ],\n \"metadata\": {},\n \"top_p\": 1.0,\n \"temperature\": 1.0,\n \"response_format\": \"auto\"\n}\n" + } + } + }, "post": { - "operationId": "createConversationItems", - "summary": "Create conversation items", - "description": "Adds one or more items to the specified conversation.", + "operationId": "Assistants_modifyAssistant", + "summary": "Update an assistant", + "description": "Updates an assistant with the supplied changes.", "parameters": [ { - "name": "conversation_id", + "name": "assistant_id", "in": "path", "required": true, - "description": "The id of the conversation on which the item needs to be created.", - "schema": { - "type": "string" - } - }, - { - "name": "include", - "in": "query", - "required": false, - "description": "Additional fields to include in the response.\nSee the `include` parameter for listing Conversation items for more information.", - "schema": { - "type": "array", - "items": { - "type": "string" - } - }, - "explode": false - }, - { - "name": "x-ms-user-identity", - "in": "header", - "required": false, - "description": "Opaque per-user identity string used to scope endpoint-scoped data to a specific end user. The caller must have the `agents/endpoints/UserIdentityImpersonation/action` RBAC permission.", + "description": "The ID of the assistant to modify.", "schema": { "type": "string" } @@ -10469,7 +10528,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OpenAI.ConversationItemList" + "$ref": "#/components/schemas/OpenAI.AssistantObject" } } } @@ -10496,141 +10555,60 @@ } }, "tags": [ - "Conversations" + "Assistants" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "items": { - "type": "array", - "items": { - "$ref": "#/components/schemas/OpenAI.Item" - }, - "maxItems": 20, - "description": "The items to add to the conversation. You may add up to 20 items at a time." - } - }, - "required": [ - "items" - ] + "$ref": "#/components/schemas/OpenAI.ModifyAssistantRequest" } } - } - } - }, - "get": { - "operationId": "listConversationItems", - "summary": "List conversation items", - "description": "Returns the items belonging to the specified conversation.", - "parameters": [ - { - "name": "conversation_id", - "in": "path", - "required": true, - "description": "The id of the conversation on which the items needs to be listed.", - "schema": { - "type": "string" - } - }, - { - "name": "limit", - "in": "query", - "required": false, - "description": "A limit on the number of objects to be returned. Limit can range between 1 and 100, and the\ndefault is 20.", - "schema": { - "type": "integer", - "format": "int32", - "default": 20 - }, - "explode": false - }, - { - "name": "order", - "in": "query", - "required": false, - "description": "Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`\nfor descending order.", - "schema": { - "$ref": "#/components/schemas/PageOrder" - }, - "explode": false - }, - { - "name": "after", - "in": "query", - "required": false, - "description": "A cursor for use in pagination. `after` is an object ID that defines your place in the list.\nFor instance, if you make a list request and receive 100 objects, ending with obj_foo, your\nsubsequent call can include after=obj_foo in order to fetch the next page of the list.", - "schema": { - "type": "string" - }, - "explode": false - }, - { - "name": "before", - "in": "query", - "required": false, - "description": "A cursor for use in pagination. `before` is an object ID that defines your place in the list.\nFor instance, if you make a list request and receive 100 objects, ending with obj_foo, your\nsubsequent call can include before=obj_foo in order to fetch the previous page of the list.", - "schema": { - "type": "string" - }, - "explode": false }, - { - "name": "item_type", - "in": "query", - "required": false, - "description": "Filter by item type. If provided, only items of the specified type will be returned.", - "schema": { - "$ref": "#/components/schemas/OpenAI.ItemType" + "description": "The request body." + }, + "deprecated": true, + "x-oaiMeta": { + "name": "Modify assistant", + "group": "assistants", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/assistants/asst_abc123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v2\" \\\n -d '{\n \"instructions\": \"You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.\",\n \"tools\": [{\"type\": \"file_search\"}],\n \"model\": \"gpt-4o\"\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nassistant = client.beta.assistants.update(\n assistant_id=\"assistant_id\",\n)\nprint(assistant.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const myUpdatedAssistant = await openai.beta.assistants.update(\n \"asst_abc123\",\n {\n instructions:\n \"You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.\",\n name: \"HR Helper\",\n tools: [{ type: \"file_search\" }],\n model: \"gpt-4o\"\n }\n );\n\n console.log(myUpdatedAssistant);\n}\n\nmain();", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst assistant = await client.beta.assistants.update('assistant_id');\n\nconsole.log(assistant.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tassistant, err := client.Beta.Assistants.Update(\n\t\tcontext.TODO(),\n\t\t\"assistant_id\",\n\t\topenai.BetaAssistantUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", assistant.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.assistants.Assistant;\nimport com.openai.models.beta.assistants.AssistantUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n Assistant assistant = client.beta().assistants().update(\"assistant_id\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nassistant = openai.beta.assistants.update(\"assistant_id\")\n\nputs(assistant)" }, - "explode": false - }, - { - "name": "x-ms-user-identity", - "in": "header", - "required": false, - "description": "Opaque per-user identity string used to scope endpoint-scoped data to a specific end user. The caller must have the `agents/endpoints/UserIdentityImpersonation/action` RBAC permission.", - "schema": { - "type": "string" - } + "response": "{\n \"id\": \"asst_123\",\n \"object\": \"assistant\",\n \"created_at\": 1699009709,\n \"name\": \"HR Helper\",\n \"description\": null,\n \"model\": \"gpt-4o\",\n \"instructions\": \"You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.\",\n \"tools\": [\n {\n \"type\": \"file_search\"\n }\n ],\n \"tool_resources\": {\n \"file_search\": {\n \"vector_store_ids\": []\n }\n },\n \"metadata\": {},\n \"top_p\": 1.0,\n \"temperature\": 1.0,\n \"response_format\": \"auto\"\n}\n" } - ], + } + } + }, + "/openai/v1/audio/speech": { + "post": { + "operationId": "Audio_createSpeech", + "summary": "Create a speech", + "description": "Creates a speech from the supplied request.", + "parameters": [], "responses": { "200": { "description": "The request has succeeded.", + "headers": { + "Transfer-Encoding": { + "required": false, + "description": "The TransferEncoding header.", + "schema": { + "type": "string" + } + } + }, "content": { - "application/json": { + "application/octet-stream": { "schema": { - "type": "object", - "required": [ - "data", - "has_more" - ], - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/OpenAI.OutputItem" - }, - "description": "The requested list of items." - }, - "first_id": { - "type": "string", - "description": "The first ID represented in this list." - }, - "last_id": { - "type": "string", - "description": "The last ID represented in this list." - }, - "has_more": { - "type": "boolean", - "description": "A value indicating whether there are additional values available not captured in this list." - } - }, - "description": "The response data for a requested list of items." + "contentMediaType": "application/octet-stream" } } } @@ -10657,51 +10635,74 @@ } }, "tags": [ - "Conversations" - ] - } - }, - "/openai/v1/conversations/{conversation_id}/items/{item_id}": { - "get": { - "operationId": "getConversationItem", - "summary": "Get a conversation item", - "description": "Retrieves a specific item from the specified conversation.", - "parameters": [ - { - "name": "conversation_id", - "in": "path", - "required": true, - "description": "The ID of the conversation that contains the item.", - "schema": { - "type": "string" - } - }, - { - "name": "item_id", - "in": "path", - "required": true, - "description": "The id of the conversation item to retrieve.", - "schema": { - "type": "string" + "Audio" + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAI.CreateSpeechRequest" + } } }, - { - "name": "x-ms-user-identity", - "in": "header", - "required": false, - "description": "Opaque per-user identity string used to scope endpoint-scoped data to a specific end user. The caller must have the `agents/endpoints/UserIdentityImpersonation/action` RBAC permission.", - "schema": { - "type": "string" + "description": "The request body." + }, + "x-oaiMeta": { + "name": "Create speech", + "group": "audio", + "examples": [ + { + "title": "Default", + "request": { + "curl": "curl https://api.openai.com/v1/audio/speech \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"model\": \"gpt-4o-mini-tts\",\n \"input\": \"The quick brown fox jumped over the lazy dog.\",\n \"voice\": \"alloy\"\n }' \\\n --output speech.mp3\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nspeech = client.audio.speech.create(\n input=\"input\",\n model=\"tts-1\",\n voice=\"alloy\",\n)\nprint(speech)\ncontent = speech.read()\nprint(content)", + "javascript": "import fs from \"fs\";\nimport path from \"path\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nconst speechFile = path.resolve(\"./speech.mp3\");\n\nasync function main() {\n const mp3 = await openai.audio.speech.create({\n model: \"gpt-4o-mini-tts\",\n voice: \"alloy\",\n input: \"Today is a wonderful day to build something people love!\",\n });\n console.log(speechFile);\n const buffer = Buffer.from(await mp3.arrayBuffer());\n await fs.promises.writeFile(speechFile, buffer);\n}\nmain();\n", + "csharp": "using System;\nusing System.IO;\n\nusing OpenAI.Audio;\n\nAudioClient client = new(\n model: \"gpt-4o-mini-tts\",\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nBinaryData speech = client.GenerateSpeech(\n text: \"The quick brown fox jumped over the lazy dog.\",\n voice: GeneratedSpeechVoice.Alloy\n);\n\nusing FileStream stream = File.OpenWrite(\"speech.mp3\");\nspeech.ToStream().CopyTo(stream);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst speech = await client.audio.speech.create({\n input: 'input',\n model: 'tts-1',\n voice: 'alloy',\n});\n\nconsole.log(speech);\n\nconst content = await speech.blob();\nconsole.log(content);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tspeech, err := client.Audio.Speech.New(context.TODO(), openai.AudioSpeechNewParams{\n\t\tInput: \"input\",\n\t\tModel: openai.SpeechModelTTS1,\n\t\tVoice: openai.AudioSpeechNewParamsVoiceUnion{\n\t\t\tOfAudioSpeechNewsVoiceString2: openai.String(\"alloy\"),\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", speech)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.core.http.HttpResponse;\nimport com.openai.models.audio.speech.SpeechCreateParams;\nimport com.openai.models.audio.speech.SpeechModel;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n SpeechCreateParams params = SpeechCreateParams.builder()\n .input(\"input\")\n .model(SpeechModel.TTS_1)\n .voice(SpeechCreateParams.Voice.UnionMember1.ALLOY)\n .build();\n HttpResponse speech = client.audio().speech().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nspeech = openai.audio.speech.create(input: \"input\", model: :\"tts-1\", voice: :alloy)\n\nputs(speech)" + } + }, + { + "title": "SSE Stream Format", + "request": { + "curl": "curl https://api.openai.com/v1/audio/speech \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"model\": \"gpt-4o-mini-tts\",\n \"input\": \"The quick brown fox jumped over the lazy dog.\",\n \"voice\": \"alloy\",\n \"stream_format\": \"sse\"\n }'\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst speech = await client.audio.speech.create({\n input: 'input',\n model: 'tts-1',\n voice: 'alloy',\n});\n\nconsole.log(speech);\n\nconst content = await speech.blob();\nconsole.log(content);", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nspeech = client.audio.speech.create(\n input=\"input\",\n model=\"tts-1\",\n voice=\"alloy\",\n)\nprint(speech)\ncontent = speech.read()\nprint(content)", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tspeech, err := client.Audio.Speech.New(context.TODO(), openai.AudioSpeechNewParams{\n\t\tInput: \"input\",\n\t\tModel: openai.SpeechModelTTS1,\n\t\tVoice: openai.AudioSpeechNewParamsVoiceUnion{\n\t\t\tOfAudioSpeechNewsVoiceString2: openai.String(\"alloy\"),\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", speech)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.core.http.HttpResponse;\nimport com.openai.models.audio.speech.SpeechCreateParams;\nimport com.openai.models.audio.speech.SpeechModel;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n SpeechCreateParams params = SpeechCreateParams.builder()\n .input(\"input\")\n .model(SpeechModel.TTS_1)\n .voice(SpeechCreateParams.Voice.UnionMember1.ALLOY)\n .build();\n HttpResponse speech = client.audio().speech().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nspeech = openai.audio.speech.create(input: \"input\", model: :\"tts-1\", voice: :alloy)\n\nputs(speech)" + } } - } - ], + ] + } + } + }, + "/openai/v1/audio/transcriptions": { + "post": { + "operationId": "Audio_createTranscription", + "summary": "Create a transcription", + "description": "Creates a transcription from the supplied request.", + "parameters": [], "responses": { "200": { "description": "The request has succeeded.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OpenAI.OutputItem" + "anyOf": [ + { + "$ref": "#/components/schemas/OpenAI.CreateTranscriptionResponseJson" + }, + { + "$ref": "#/components/schemas/OpenAI.CreateTranscriptionResponseDiarizedJson" + }, + { + "$ref": "#/components/schemas/OpenAI.CreateTranscriptionResponseVerboseJson" + } + ] } } } @@ -10728,49 +10729,157 @@ } }, "tags": [ - "Conversations" - ] - }, - "delete": { - "operationId": "deleteConversationItem", - "summary": "Delete a conversation item", - "description": "Removes the specified item from a conversation.", - "parameters": [ - { - "name": "conversation_id", - "in": "path", - "required": true, - "description": "The id of the conversation on which the item needs to be deleted from.", - "schema": { - "type": "string" - } - }, - { - "name": "item_id", - "in": "path", - "required": true, - "description": "The id of the conversation item to delete.", - "schema": { - "type": "string" + "Audio" + ], + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/OpenAI.CreateTranscriptionRequest" + }, + "encoding": { + "model": { + "contentType": "text/plain" + }, + "response_format": { + "contentType": "application/json" + }, + "temperature": { + "contentType": "text/plain" + }, + "include": { + "contentType": "application/json" + }, + "timestamp_granularities": { + "contentType": "application/json" + }, + "stream": { + "contentType": "application/json" + }, + "chunking_strategy": { + "contentType": "application/json" + }, + "known_speaker_names": { + "contentType": "application/json" + }, + "known_speaker_references": { + "contentType": "application/json" + } + } } }, - { - "name": "x-ms-user-identity", - "in": "header", - "required": false, - "description": "Opaque per-user identity string used to scope endpoint-scoped data to a specific end user. The caller must have the `agents/endpoints/UserIdentityImpersonation/action` RBAC permission.", - "schema": { - "type": "string" + "description": "The multipart request body." + }, + "x-oaiMeta": { + "name": "Create transcription", + "group": "audio", + "examples": [ + { + "title": "Default", + "request": { + "curl": "curl https://api.openai.com/v1/audio/transcriptions \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: multipart/form-data\" \\\n -F file=\"@/path/to/file/audio.mp3\" \\\n -F model=\"gpt-4o-transcribe\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor transcription in client.audio.transcriptions.create(\n file=b\"Example data\",\n model=\"gpt-4o-transcribe\",\n):\n print(transcription)", + "javascript": "import fs from \"fs\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const transcription = await openai.audio.transcriptions.create({\n file: fs.createReadStream(\"audio.mp3\"),\n model: \"gpt-4o-transcribe\",\n });\n\n console.log(transcription.text);\n}\nmain();\n", + "csharp": "using System;\n\nusing OpenAI.Audio;\nstring audioFilePath = \"audio.mp3\";\n\nAudioClient client = new(\n model: \"gpt-4o-transcribe\",\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nAudioTranscription transcription = client.TranscribeAudio(audioFilePath);\n\nConsole.WriteLine($\"{transcription.Text}\");\n", + "node.js": "import fs from 'fs';\nimport OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst transcription = await client.audio.transcriptions.create({\n file: fs.createReadStream('speech.mp3'),\n model: 'gpt-4o-transcribe',\n});\n\nconsole.log(transcription);", + "go": "package main\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\ttranscription, err := client.Audio.Transcriptions.New(context.TODO(), openai.AudioTranscriptionNewParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"Example data\"))),\n\t\tModel: openai.AudioModelGPT4oTranscribe,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", transcription)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.audio.AudioModel;\nimport com.openai.models.audio.transcriptions.TranscriptionCreateParams;\nimport com.openai.models.audio.transcriptions.TranscriptionCreateResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n TranscriptionCreateParams params = TranscriptionCreateParams.builder()\n .file(new ByteArrayInputStream(\"Example data\".getBytes()))\n .model(AudioModel.GPT_4O_TRANSCRIBE)\n .build();\n TranscriptionCreateResponse transcription = client.audio().transcriptions().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\ntranscription = openai.audio.transcriptions.create(file: StringIO.new(\"Example data\"), model: :\"gpt-4o-transcribe\")\n\nputs(transcription)" + }, + "response": "{\n \"text\": \"Imagine the wildest idea that you've ever had, and you're curious about how it might scale to something that's a 100, a 1,000 times bigger. This is a place where you can get to do that.\",\n \"usage\": {\n \"type\": \"tokens\",\n \"input_tokens\": 14,\n \"input_token_details\": {\n \"text_tokens\": 0,\n \"audio_tokens\": 14\n },\n \"output_tokens\": 45,\n \"total_tokens\": 59\n }\n}\n" + }, + { + "title": "Diarization", + "request": { + "curl": "curl https://api.openai.com/v1/audio/transcriptions \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: multipart/form-data\" \\\n -F file=\"@/path/to/file/meeting.wav\" \\\n -F model=\"gpt-4o-transcribe-diarize\" \\\n -F response_format=\"diarized_json\" \\\n -F chunking_strategy=auto \\\n -F 'known_speaker_names[]=agent' \\\n -F 'known_speaker_references[]=data:audio/wav;base64,AAA...'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor transcription in client.audio.transcriptions.create(\n file=b\"Example data\",\n model=\"gpt-4o-transcribe\",\n):\n print(transcription)", + "javascript": "import fs from \"fs\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nconst speakerRef = fs.readFileSync(\"agent.wav\").toString(\"base64\");\n\nconst transcript = await openai.audio.transcriptions.create({\n file: fs.createReadStream(\"meeting.wav\"),\n model: \"gpt-4o-transcribe-diarize\",\n response_format: \"diarized_json\",\n chunking_strategy: \"auto\",\n extra_body: {\n known_speaker_names: [\"agent\"],\n known_speaker_references: [`data:audio/wav;base64,${speakerRef}`],\n },\n});\n\nconsole.log(transcript.segments);\n", + "node.js": "import fs from 'fs';\nimport OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst transcription = await client.audio.transcriptions.create({\n file: fs.createReadStream('speech.mp3'),\n model: 'gpt-4o-transcribe',\n});\n\nconsole.log(transcription);", + "go": "package main\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\ttranscription, err := client.Audio.Transcriptions.New(context.TODO(), openai.AudioTranscriptionNewParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"Example data\"))),\n\t\tModel: openai.AudioModelGPT4oTranscribe,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", transcription)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.audio.AudioModel;\nimport com.openai.models.audio.transcriptions.TranscriptionCreateParams;\nimport com.openai.models.audio.transcriptions.TranscriptionCreateResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n TranscriptionCreateParams params = TranscriptionCreateParams.builder()\n .file(new ByteArrayInputStream(\"Example data\".getBytes()))\n .model(AudioModel.GPT_4O_TRANSCRIBE)\n .build();\n TranscriptionCreateResponse transcription = client.audio().transcriptions().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\ntranscription = openai.audio.transcriptions.create(file: StringIO.new(\"Example data\"), model: :\"gpt-4o-transcribe\")\n\nputs(transcription)" + }, + "response": "{\n \"task\": \"transcribe\",\n \"duration\": 27.4,\n \"text\": \"Agent: Thanks for calling OpenAI support.\nA: Hi, I'm trying to enable diarization.\nAgent: Happy to walk you through the steps.\",\n \"segments\": [\n {\n \"type\": \"transcript.text.segment\",\n \"id\": \"seg_001\",\n \"start\": 0.0,\n \"end\": 4.7,\n \"text\": \"Thanks for calling OpenAI support.\",\n \"speaker\": \"agent\"\n },\n {\n \"type\": \"transcript.text.segment\",\n \"id\": \"seg_002\",\n \"start\": 4.7,\n \"end\": 11.8,\n \"text\": \"Hi, I'm trying to enable diarization.\",\n \"speaker\": \"A\"\n },\n {\n \"type\": \"transcript.text.segment\",\n \"id\": \"seg_003\",\n \"start\": 12.1,\n \"end\": 18.5,\n \"text\": \"Happy to walk you through the steps.\",\n \"speaker\": \"agent\"\n }\n ],\n \"usage\": {\n \"type\": \"duration\",\n \"seconds\": 27\n }\n}\n" + }, + { + "title": "Streaming", + "request": { + "curl": "curl https://api.openai.com/v1/audio/transcriptions \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: multipart/form-data\" \\\n -F file=\"@/path/to/file/audio.mp3\" \\\n -F model=\"gpt-4o-mini-transcribe\" \\\n -F stream=true\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor transcription in client.audio.transcriptions.create(\n file=b\"Example data\",\n model=\"gpt-4o-transcribe\",\n):\n print(transcription)", + "javascript": "import fs from \"fs\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nconst stream = await openai.audio.transcriptions.create({\n file: fs.createReadStream(\"audio.mp3\"),\n model: \"gpt-4o-mini-transcribe\",\n stream: true,\n});\n\nfor await (const event of stream) {\n console.log(event);\n}\n", + "node.js": "import fs from 'fs';\nimport OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst transcription = await client.audio.transcriptions.create({\n file: fs.createReadStream('speech.mp3'),\n model: 'gpt-4o-transcribe',\n});\n\nconsole.log(transcription);", + "go": "package main\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\ttranscription, err := client.Audio.Transcriptions.New(context.TODO(), openai.AudioTranscriptionNewParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"Example data\"))),\n\t\tModel: openai.AudioModelGPT4oTranscribe,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", transcription)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.audio.AudioModel;\nimport com.openai.models.audio.transcriptions.TranscriptionCreateParams;\nimport com.openai.models.audio.transcriptions.TranscriptionCreateResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n TranscriptionCreateParams params = TranscriptionCreateParams.builder()\n .file(new ByteArrayInputStream(\"Example data\".getBytes()))\n .model(AudioModel.GPT_4O_TRANSCRIBE)\n .build();\n TranscriptionCreateResponse transcription = client.audio().transcriptions().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\ntranscription = openai.audio.transcriptions.create(file: StringIO.new(\"Example data\"), model: :\"gpt-4o-transcribe\")\n\nputs(transcription)" + }, + "response": "data: {\"type\":\"transcript.text.delta\",\"delta\":\"I\",\"logprobs\":[{\"token\":\"I\",\"logprob\":-0.00007588794,\"bytes\":[73]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" see\",\"logprobs\":[{\"token\":\" see\",\"logprob\":-3.1281633e-7,\"bytes\":[32,115,101,101]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" skies\",\"logprobs\":[{\"token\":\" skies\",\"logprob\":-2.3392786e-6,\"bytes\":[32,115,107,105,101,115]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" of\",\"logprobs\":[{\"token\":\" of\",\"logprob\":-3.1281633e-7,\"bytes\":[32,111,102]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" blue\",\"logprobs\":[{\"token\":\" blue\",\"logprob\":-1.0280384e-6,\"bytes\":[32,98,108,117,101]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" and\",\"logprobs\":[{\"token\":\" and\",\"logprob\":-0.0005108566,\"bytes\":[32,97,110,100]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" clouds\",\"logprobs\":[{\"token\":\" clouds\",\"logprob\":-1.9361265e-7,\"bytes\":[32,99,108,111,117,100,115]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" of\",\"logprobs\":[{\"token\":\" of\",\"logprob\":-1.9361265e-7,\"bytes\":[32,111,102]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" white\",\"logprobs\":[{\"token\":\" white\",\"logprob\":-7.89631e-7,\"bytes\":[32,119,104,105,116,101]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\",\",\"logprobs\":[{\"token\":\",\",\"logprob\":-0.0014890312,\"bytes\":[44]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" the\",\"logprobs\":[{\"token\":\" the\",\"logprob\":-0.0110956915,\"bytes\":[32,116,104,101]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" bright\",\"logprobs\":[{\"token\":\" bright\",\"logprob\":0.0,\"bytes\":[32,98,114,105,103,104,116]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" blessed\",\"logprobs\":[{\"token\":\" blessed\",\"logprob\":-0.000045848617,\"bytes\":[32,98,108,101,115,115,101,100]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" days\",\"logprobs\":[{\"token\":\" days\",\"logprob\":-0.000010802739,\"bytes\":[32,100,97,121,115]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\",\",\"logprobs\":[{\"token\":\",\",\"logprob\":-0.00001700133,\"bytes\":[44]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" the\",\"logprobs\":[{\"token\":\" the\",\"logprob\":-0.0000118755715,\"bytes\":[32,116,104,101]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" dark\",\"logprobs\":[{\"token\":\" dark\",\"logprob\":-5.5122365e-7,\"bytes\":[32,100,97,114,107]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" sacred\",\"logprobs\":[{\"token\":\" sacred\",\"logprob\":-5.4385737e-6,\"bytes\":[32,115,97,99,114,101,100]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" nights\",\"logprobs\":[{\"token\":\" nights\",\"logprob\":-4.00813e-6,\"bytes\":[32,110,105,103,104,116,115]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\",\",\"logprobs\":[{\"token\":\",\",\"logprob\":-0.0036910512,\"bytes\":[44]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" and\",\"logprobs\":[{\"token\":\" and\",\"logprob\":-0.0031903093,\"bytes\":[32,97,110,100]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" I\",\"logprobs\":[{\"token\":\" I\",\"logprob\":-1.504853e-6,\"bytes\":[32,73]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" think\",\"logprobs\":[{\"token\":\" think\",\"logprob\":-4.3202e-7,\"bytes\":[32,116,104,105,110,107]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" to\",\"logprobs\":[{\"token\":\" to\",\"logprob\":-1.9361265e-7,\"bytes\":[32,116,111]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" myself\",\"logprobs\":[{\"token\":\" myself\",\"logprob\":-1.7432603e-6,\"bytes\":[32,109,121,115,101,108,102]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\",\",\"logprobs\":[{\"token\":\",\",\"logprob\":-0.29254505,\"bytes\":[44]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" what\",\"logprobs\":[{\"token\":\" what\",\"logprob\":-0.016815351,\"bytes\":[32,119,104,97,116]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" a\",\"logprobs\":[{\"token\":\" a\",\"logprob\":-3.1281633e-7,\"bytes\":[32,97]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" wonderful\",\"logprobs\":[{\"token\":\" wonderful\",\"logprob\":-2.1008714e-6,\"bytes\":[32,119,111,110,100,101,114,102,117,108]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\" world\",\"logprobs\":[{\"token\":\" world\",\"logprob\":-8.180258e-6,\"bytes\":[32,119,111,114,108,100]}]}\n\ndata: {\"type\":\"transcript.text.delta\",\"delta\":\".\",\"logprobs\":[{\"token\":\".\",\"logprob\":-0.014231676,\"bytes\":[46]}]}\n\ndata: {\"type\":\"transcript.text.done\",\"text\":\"I see skies of blue and clouds of white, the bright blessed days, the dark sacred nights, and I think to myself, what a wonderful world.\",\"logprobs\":[{\"token\":\"I\",\"logprob\":-0.00007588794,\"bytes\":[73]},{\"token\":\" see\",\"logprob\":-3.1281633e-7,\"bytes\":[32,115,101,101]},{\"token\":\" skies\",\"logprob\":-2.3392786e-6,\"bytes\":[32,115,107,105,101,115]},{\"token\":\" of\",\"logprob\":-3.1281633e-7,\"bytes\":[32,111,102]},{\"token\":\" blue\",\"logprob\":-1.0280384e-6,\"bytes\":[32,98,108,117,101]},{\"token\":\" and\",\"logprob\":-0.0005108566,\"bytes\":[32,97,110,100]},{\"token\":\" clouds\",\"logprob\":-1.9361265e-7,\"bytes\":[32,99,108,111,117,100,115]},{\"token\":\" of\",\"logprob\":-1.9361265e-7,\"bytes\":[32,111,102]},{\"token\":\" white\",\"logprob\":-7.89631e-7,\"bytes\":[32,119,104,105,116,101]},{\"token\":\",\",\"logprob\":-0.0014890312,\"bytes\":[44]},{\"token\":\" the\",\"logprob\":-0.0110956915,\"bytes\":[32,116,104,101]},{\"token\":\" bright\",\"logprob\":0.0,\"bytes\":[32,98,114,105,103,104,116]},{\"token\":\" blessed\",\"logprob\":-0.000045848617,\"bytes\":[32,98,108,101,115,115,101,100]},{\"token\":\" days\",\"logprob\":-0.000010802739,\"bytes\":[32,100,97,121,115]},{\"token\":\",\",\"logprob\":-0.00001700133,\"bytes\":[44]},{\"token\":\" the\",\"logprob\":-0.0000118755715,\"bytes\":[32,116,104,101]},{\"token\":\" dark\",\"logprob\":-5.5122365e-7,\"bytes\":[32,100,97,114,107]},{\"token\":\" sacred\",\"logprob\":-5.4385737e-6,\"bytes\":[32,115,97,99,114,101,100]},{\"token\":\" nights\",\"logprob\":-4.00813e-6,\"bytes\":[32,110,105,103,104,116,115]},{\"token\":\",\",\"logprob\":-0.0036910512,\"bytes\":[44]},{\"token\":\" and\",\"logprob\":-0.0031903093,\"bytes\":[32,97,110,100]},{\"token\":\" I\",\"logprob\":-1.504853e-6,\"bytes\":[32,73]},{\"token\":\" think\",\"logprob\":-4.3202e-7,\"bytes\":[32,116,104,105,110,107]},{\"token\":\" to\",\"logprob\":-1.9361265e-7,\"bytes\":[32,116,111]},{\"token\":\" myself\",\"logprob\":-1.7432603e-6,\"bytes\":[32,109,121,115,101,108,102]},{\"token\":\",\",\"logprob\":-0.29254505,\"bytes\":[44]},{\"token\":\" what\",\"logprob\":-0.016815351,\"bytes\":[32,119,104,97,116]},{\"token\":\" a\",\"logprob\":-3.1281633e-7,\"bytes\":[32,97]},{\"token\":\" wonderful\",\"logprob\":-2.1008714e-6,\"bytes\":[32,119,111,110,100,101,114,102,117,108]},{\"token\":\" world\",\"logprob\":-8.180258e-6,\"bytes\":[32,119,111,114,108,100]},{\"token\":\".\",\"logprob\":-0.014231676,\"bytes\":[46]}],\"usage\":{\"input_tokens\":14,\"input_token_details\":{\"text_tokens\":0,\"audio_tokens\":14},\"output_tokens\":45,\"total_tokens\":59}}\n" + }, + { + "title": "Logprobs", + "request": { + "curl": "curl https://api.openai.com/v1/audio/transcriptions \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: multipart/form-data\" \\\n -F file=\"@/path/to/file/audio.mp3\" \\\n -F \"include[]=logprobs\" \\\n -F model=\"gpt-4o-transcribe\" \\\n -F response_format=\"json\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor transcription in client.audio.transcriptions.create(\n file=b\"Example data\",\n model=\"gpt-4o-transcribe\",\n):\n print(transcription)", + "javascript": "import fs from \"fs\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const transcription = await openai.audio.transcriptions.create({\n file: fs.createReadStream(\"audio.mp3\"),\n model: \"gpt-4o-transcribe\",\n response_format: \"json\",\n include: [\"logprobs\"]\n });\n\n console.log(transcription);\n}\nmain();\n", + "node.js": "import fs from 'fs';\nimport OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst transcription = await client.audio.transcriptions.create({\n file: fs.createReadStream('speech.mp3'),\n model: 'gpt-4o-transcribe',\n});\n\nconsole.log(transcription);", + "go": "package main\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\ttranscription, err := client.Audio.Transcriptions.New(context.TODO(), openai.AudioTranscriptionNewParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"Example data\"))),\n\t\tModel: openai.AudioModelGPT4oTranscribe,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", transcription)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.audio.AudioModel;\nimport com.openai.models.audio.transcriptions.TranscriptionCreateParams;\nimport com.openai.models.audio.transcriptions.TranscriptionCreateResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n TranscriptionCreateParams params = TranscriptionCreateParams.builder()\n .file(new ByteArrayInputStream(\"Example data\".getBytes()))\n .model(AudioModel.GPT_4O_TRANSCRIBE)\n .build();\n TranscriptionCreateResponse transcription = client.audio().transcriptions().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\ntranscription = openai.audio.transcriptions.create(file: StringIO.new(\"Example data\"), model: :\"gpt-4o-transcribe\")\n\nputs(transcription)" + }, + "response": "{\n \"text\": \"Hey, my knee is hurting and I want to see the doctor tomorrow ideally.\",\n \"logprobs\": [\n { \"token\": \"Hey\", \"logprob\": -1.0415299, \"bytes\": [72, 101, 121] },\n { \"token\": \",\", \"logprob\": -9.805982e-5, \"bytes\": [44] },\n { \"token\": \" my\", \"logprob\": -0.00229799, \"bytes\": [32, 109, 121] },\n {\n \"token\": \" knee\",\n \"logprob\": -4.7159858e-5,\n \"bytes\": [32, 107, 110, 101, 101]\n },\n { \"token\": \" is\", \"logprob\": -0.043909557, \"bytes\": [32, 105, 115] },\n {\n \"token\": \" hurting\",\n \"logprob\": -1.1041146e-5,\n \"bytes\": [32, 104, 117, 114, 116, 105, 110, 103]\n },\n { \"token\": \" and\", \"logprob\": -0.011076359, \"bytes\": [32, 97, 110, 100] },\n { \"token\": \" I\", \"logprob\": -5.3193703e-6, \"bytes\": [32, 73] },\n {\n \"token\": \" want\",\n \"logprob\": -0.0017156356,\n \"bytes\": [32, 119, 97, 110, 116]\n },\n { \"token\": \" to\", \"logprob\": -7.89631e-7, \"bytes\": [32, 116, 111] },\n { \"token\": \" see\", \"logprob\": -5.5122365e-7, \"bytes\": [32, 115, 101, 101] },\n { \"token\": \" the\", \"logprob\": -0.0040786397, \"bytes\": [32, 116, 104, 101] },\n {\n \"token\": \" doctor\",\n \"logprob\": -2.3392786e-6,\n \"bytes\": [32, 100, 111, 99, 116, 111, 114]\n },\n {\n \"token\": \" tomorrow\",\n \"logprob\": -7.89631e-7,\n \"bytes\": [32, 116, 111, 109, 111, 114, 114, 111, 119]\n },\n {\n \"token\": \" ideally\",\n \"logprob\": -0.5800861,\n \"bytes\": [32, 105, 100, 101, 97, 108, 108, 121]\n },\n { \"token\": \".\", \"logprob\": -0.00011093382, \"bytes\": [46] }\n ],\n \"usage\": {\n \"type\": \"tokens\",\n \"input_tokens\": 14,\n \"input_token_details\": {\n \"text_tokens\": 0,\n \"audio_tokens\": 14\n },\n \"output_tokens\": 45,\n \"total_tokens\": 59\n }\n}\n" + }, + { + "title": "Word timestamps", + "request": { + "curl": "curl https://api.openai.com/v1/audio/transcriptions \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: multipart/form-data\" \\\n -F file=\"@/path/to/file/audio.mp3\" \\\n -F \"timestamp_granularities[]=word\" \\\n -F model=\"whisper-1\" \\\n -F response_format=\"verbose_json\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor transcription in client.audio.transcriptions.create(\n file=b\"Example data\",\n model=\"gpt-4o-transcribe\",\n):\n print(transcription)", + "javascript": "import fs from \"fs\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const transcription = await openai.audio.transcriptions.create({\n file: fs.createReadStream(\"audio.mp3\"),\n model: \"whisper-1\",\n response_format: \"verbose_json\",\n timestamp_granularities: [\"word\"]\n });\n\n console.log(transcription.text);\n}\nmain();\n", + "csharp": "using System;\n\nusing OpenAI.Audio;\n\nstring audioFilePath = \"audio.mp3\";\n\nAudioClient client = new(\n model: \"whisper-1\",\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nAudioTranscriptionOptions options = new()\n{\n ResponseFormat = AudioTranscriptionFormat.Verbose,\n TimestampGranularities = AudioTimestampGranularities.Word,\n};\n\nAudioTranscription transcription = client.TranscribeAudio(audioFilePath, options);\n\nConsole.WriteLine($\"{transcription.Text}\");\n", + "node.js": "import fs from 'fs';\nimport OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst transcription = await client.audio.transcriptions.create({\n file: fs.createReadStream('speech.mp3'),\n model: 'gpt-4o-transcribe',\n});\n\nconsole.log(transcription);", + "go": "package main\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\ttranscription, err := client.Audio.Transcriptions.New(context.TODO(), openai.AudioTranscriptionNewParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"Example data\"))),\n\t\tModel: openai.AudioModelGPT4oTranscribe,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", transcription)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.audio.AudioModel;\nimport com.openai.models.audio.transcriptions.TranscriptionCreateParams;\nimport com.openai.models.audio.transcriptions.TranscriptionCreateResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n TranscriptionCreateParams params = TranscriptionCreateParams.builder()\n .file(new ByteArrayInputStream(\"Example data\".getBytes()))\n .model(AudioModel.GPT_4O_TRANSCRIBE)\n .build();\n TranscriptionCreateResponse transcription = client.audio().transcriptions().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\ntranscription = openai.audio.transcriptions.create(file: StringIO.new(\"Example data\"), model: :\"gpt-4o-transcribe\")\n\nputs(transcription)" + }, + "response": "{\n \"task\": \"transcribe\",\n \"language\": \"english\",\n \"duration\": 8.470000267028809,\n \"text\": \"The beach was a popular spot on a hot summer day. People were swimming in the ocean, building sandcastles, and playing beach volleyball.\",\n \"words\": [\n {\n \"word\": \"The\",\n \"start\": 0.0,\n \"end\": 0.23999999463558197\n },\n ...\n {\n \"word\": \"volleyball\",\n \"start\": 7.400000095367432,\n \"end\": 7.900000095367432\n }\n ],\n \"usage\": {\n \"type\": \"duration\",\n \"seconds\": 9\n }\n}\n" + }, + { + "title": "Segment timestamps", + "request": { + "curl": "curl https://api.openai.com/v1/audio/transcriptions \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: multipart/form-data\" \\\n -F file=\"@/path/to/file/audio.mp3\" \\\n -F \"timestamp_granularities[]=segment\" \\\n -F model=\"whisper-1\" \\\n -F response_format=\"verbose_json\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor transcription in client.audio.transcriptions.create(\n file=b\"Example data\",\n model=\"gpt-4o-transcribe\",\n):\n print(transcription)", + "javascript": "import fs from \"fs\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const transcription = await openai.audio.transcriptions.create({\n file: fs.createReadStream(\"audio.mp3\"),\n model: \"whisper-1\",\n response_format: \"verbose_json\",\n timestamp_granularities: [\"segment\"]\n });\n\n console.log(transcription.text);\n}\nmain();\n", + "csharp": "using System;\n\nusing OpenAI.Audio;\n\nstring audioFilePath = \"audio.mp3\";\n\nAudioClient client = new(\n model: \"whisper-1\",\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nAudioTranscriptionOptions options = new()\n{\n ResponseFormat = AudioTranscriptionFormat.Verbose,\n TimestampGranularities = AudioTimestampGranularities.Segment,\n};\n\nAudioTranscription transcription = client.TranscribeAudio(audioFilePath, options);\n\nConsole.WriteLine($\"{transcription.Text}\");\n", + "node.js": "import fs from 'fs';\nimport OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst transcription = await client.audio.transcriptions.create({\n file: fs.createReadStream('speech.mp3'),\n model: 'gpt-4o-transcribe',\n});\n\nconsole.log(transcription);", + "go": "package main\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\ttranscription, err := client.Audio.Transcriptions.New(context.TODO(), openai.AudioTranscriptionNewParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"Example data\"))),\n\t\tModel: openai.AudioModelGPT4oTranscribe,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", transcription)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.audio.AudioModel;\nimport com.openai.models.audio.transcriptions.TranscriptionCreateParams;\nimport com.openai.models.audio.transcriptions.TranscriptionCreateResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n TranscriptionCreateParams params = TranscriptionCreateParams.builder()\n .file(new ByteArrayInputStream(\"Example data\".getBytes()))\n .model(AudioModel.GPT_4O_TRANSCRIBE)\n .build();\n TranscriptionCreateResponse transcription = client.audio().transcriptions().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\ntranscription = openai.audio.transcriptions.create(file: StringIO.new(\"Example data\"), model: :\"gpt-4o-transcribe\")\n\nputs(transcription)" + }, + "response": "{\n \"task\": \"transcribe\",\n \"language\": \"english\",\n \"duration\": 8.470000267028809,\n \"text\": \"The beach was a popular spot on a hot summer day. People were swimming in the ocean, building sandcastles, and playing beach volleyball.\",\n \"segments\": [\n {\n \"id\": 0,\n \"seek\": 0,\n \"start\": 0.0,\n \"end\": 3.319999933242798,\n \"text\": \" The beach was a popular spot on a hot summer day.\",\n \"tokens\": [\n 50364, 440, 7534, 390, 257, 3743, 4008, 322, 257, 2368, 4266, 786, 13, 50530\n ],\n \"temperature\": 0.0,\n \"avg_logprob\": -0.2860786020755768,\n \"compression_ratio\": 1.2363636493682861,\n \"no_speech_prob\": 0.00985979475080967\n },\n ...\n ],\n \"usage\": {\n \"type\": \"duration\",\n \"seconds\": 9\n }\n}\n" } - } - ], + ] + } + } + }, + "/openai/v1/audio/translations": { + "post": { + "operationId": "Audio_createTranslation", + "summary": "Create a translation", + "description": "Creates a translation from the supplied request.", + "parameters": [], "responses": { "200": { "description": "The request has succeeded.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OpenAI.ConversationResource" + "anyOf": [ + { + "$ref": "#/components/schemas/OpenAI.CreateTranslationResponseJson" + }, + { + "$ref": "#/components/schemas/OpenAI.CreateTranslationResponseVerboseJson" + } + ] } } } @@ -10797,64 +10906,70 @@ } }, "tags": [ - "Conversations" - ] + "Audio" + ], + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/OpenAI.CreateTranslationRequest" + }, + "encoding": { + "model": { + "contentType": "text/plain" + }, + "temperature": { + "contentType": "text/plain" + } + } + } + }, + "description": "The multipart request body." + }, + "x-oaiMeta": { + "name": "Create translation", + "group": "audio", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/audio/translations \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: multipart/form-data\" \\\n -F file=\"@/path/to/file/german.m4a\" \\\n -F model=\"whisper-1\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\ntranslation = client.audio.translations.create(\n file=b\"Example data\",\n model=\"whisper-1\",\n)\nprint(translation)", + "javascript": "import fs from \"fs\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const translation = await openai.audio.translations.create({\n file: fs.createReadStream(\"speech.mp3\"),\n model: \"whisper-1\",\n });\n\n console.log(translation.text);\n}\nmain();\n", + "csharp": "using System;\n\nusing OpenAI.Audio;\n\nstring audioFilePath = \"audio.mp3\";\n\nAudioClient client = new(\n model: \"whisper-1\",\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nAudioTranscription transcription = client.TranscribeAudio(audioFilePath);\n\nConsole.WriteLine($\"{transcription.Text}\");\n", + "node.js": "import fs from 'fs';\nimport OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst translation = await client.audio.translations.create({\n file: fs.createReadStream('speech.mp3'),\n model: 'whisper-1',\n});\n\nconsole.log(translation);", + "go": "package main\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\ttranslation, err := client.Audio.Translations.New(context.TODO(), openai.AudioTranslationNewParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"Example data\"))),\n\t\tModel: openai.AudioModelWhisper1,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", translation)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.audio.AudioModel;\nimport com.openai.models.audio.translations.TranslationCreateParams;\nimport com.openai.models.audio.translations.TranslationCreateResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n TranslationCreateParams params = TranslationCreateParams.builder()\n .file(new ByteArrayInputStream(\"Example data\".getBytes()))\n .model(AudioModel.WHISPER_1)\n .build();\n TranslationCreateResponse translation = client.audio().translations().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\ntranslation = openai.audio.translations.create(file: StringIO.new(\"Example data\"), model: :\"whisper-1\")\n\nputs(translation)" + }, + "response": "{\n \"text\": \"Hello, my name is Wolfgang and I come from Germany. Where are you heading today?\"\n}\n" + } + } } }, - "/openai/v1/evals": { + "/openai/v1/batches": { "get": { - "operationId": "Evals_listEvals", - "summary": "List evaluations", - "description": "Returns the evaluations configured in the current project.", + "operationId": "Batches_listBatches", + "summary": "List batches", + "description": "Lists batches matching the request filters.", "parameters": [ { "name": "after", "in": "query", "required": false, - "description": "Identifier for the last run from the previous pagination request.", + "description": "A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.", "schema": { "type": "string" }, - "explode": false + "x-ms-list-continuation-token": true }, { "name": "limit", "in": "query", "required": false, - "description": "Number of runs to retrieve.", + "description": "A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.", "schema": { "$ref": "#/components/schemas/integer", "default": 20 - }, - "explode": false - }, - { - "name": "order", - "in": "query", - "required": false, - "description": "Sort order for runs by timestamp. Use `asc` for ascending order or `desc` for descending order. Defaults to `asc`.", - "schema": { - "type": "string", - "enum": [ - "asc", - "desc" - ], - "default": "asc" - }, - "explode": false - }, - { - "name": "order_by", - "in": "query", - "required": false, - "description": "Evals can be ordered by creation time or last updated time.\nUse `created_at` for creation time or `updated_at` for last updated time.", - "schema": { - "type": "string", - "enum": [ - "created_at", - "updated_at" - ], - "default": "created_at" } } ], @@ -10864,33 +10979,7 @@ "content": { "application/json": { "schema": { - "type": "object", - "required": [ - "data", - "has_more" - ], - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Eval" - }, - "description": "The requested list of items." - }, - "first_id": { - "type": "string", - "description": "The first ID represented in this list." - }, - "last_id": { - "type": "string", - "description": "The last ID represented in this list." - }, - "has_more": { - "type": "boolean", - "description": "A value indicating whether there are additional values available not captured in this list." - } - }, - "description": "The response data for a requested list of items." + "$ref": "#/components/schemas/OpenAI.ListBatchesResponse" } } } @@ -10917,13 +11006,30 @@ } }, "tags": [ - "Evals" - ] + "Batch" + ], + "x-oaiMeta": { + "name": "List batches", + "group": "batch", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/batches?limit=2 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\npage = client.batches.list()\npage = page.data[0]\nprint(page.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const list = await openai.batches.list();\n\n for await (const batch of list) {\n console.log(batch);\n }\n}\n\nmain();\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const batch of client.batches.list()) {\n console.log(batch.id);\n}", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.Batches.List(context.TODO(), openai.BatchListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", page)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.batches.BatchListPage;\nimport com.openai.models.batches.BatchListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n BatchListPage page = client.batches().list();\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\npage = openai.batches.list\n\nputs(page)" + }, + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"batch_abc123\",\n \"object\": \"batch\",\n \"endpoint\": \"/v1/chat/completions\",\n \"errors\": null,\n \"input_file_id\": \"file-abc123\",\n \"completion_window\": \"24h\",\n \"status\": \"completed\",\n \"output_file_id\": \"file-cvaTdG\",\n \"error_file_id\": \"file-HOWS94\",\n \"created_at\": 1711471533,\n \"in_progress_at\": 1711471538,\n \"expires_at\": 1711557933,\n \"finalizing_at\": 1711493133,\n \"completed_at\": 1711493163,\n \"failed_at\": null,\n \"expired_at\": null,\n \"cancelling_at\": null,\n \"cancelled_at\": null,\n \"request_counts\": {\n \"total\": 100,\n \"completed\": 95,\n \"failed\": 5\n },\n \"metadata\": {\n \"customer_id\": \"user_123456789\",\n \"batch_description\": \"Nightly job\",\n }\n },\n { ... },\n ],\n \"first_id\": \"batch_abc123\",\n \"last_id\": \"batch_abc456\",\n \"has_more\": true\n}\n" + } + }, + "x-ms-list": true }, "post": { - "operationId": "Evals_createEval", - "summary": "Create an evaluation", - "description": "Creates the structure of an evaluation that can be used to test a model's performance.\nAn evaluation is a set of testing criteria and the config for a data source, which dictates the schema of the data used in the evaluation. After creating an evaluation, you can run it on different models and model parameters. We support several types of graders and datasources.\nFor more information, see the [Evals guide](https://platform.openai.com/docs/guides/evals).", + "operationId": "Batches_createBatch", + "summary": "Create a batch", + "description": "Creates a batch from the supplied request.", "parameters": [], "responses": { "200": { @@ -10931,7 +11037,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Eval" + "$ref": "#/components/schemas/OpenAI.Batch" } } } @@ -10958,31 +11064,48 @@ } }, "tags": [ - "Evals" + "Batch" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/CreateEvalRequest" + "$ref": "#/components/schemas/OpenAI.CreateBatchParametersBody" } } + }, + "description": "The request body." + }, + "x-oaiMeta": { + "name": "Create batch", + "group": "batch", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/batches \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"input_file_id\": \"file-abc123\",\n \"endpoint\": \"/v1/chat/completions\",\n \"completion_window\": \"24h\"\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nbatch = client.batches.create(\n completion_window=\"24h\",\n endpoint=\"/v1/responses\",\n input_file_id=\"input_file_id\",\n)\nprint(batch.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const batch = await openai.batches.create({\n input_file_id: \"file-abc123\",\n endpoint: \"/v1/chat/completions\",\n completion_window: \"24h\"\n });\n\n console.log(batch);\n}\n\nmain();\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst batch = await client.batches.create({\n completion_window: '24h',\n endpoint: '/v1/responses',\n input_file_id: 'input_file_id',\n});\n\nconsole.log(batch.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tbatch, err := client.Batches.New(context.TODO(), openai.BatchNewParams{\n\t\tCompletionWindow: openai.BatchNewParamsCompletionWindow24h,\n\t\tEndpoint: openai.BatchNewParamsEndpointV1Responses,\n\t\tInputFileID: \"input_file_id\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", batch.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.batches.Batch;\nimport com.openai.models.batches.BatchCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n BatchCreateParams params = BatchCreateParams.builder()\n .completionWindow(BatchCreateParams.CompletionWindow._24H)\n .endpoint(BatchCreateParams.Endpoint.V1_RESPONSES)\n .inputFileId(\"input_file_id\")\n .build();\n Batch batch = client.batches().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nbatch = openai.batches.create(\n completion_window: :\"24h\",\n endpoint: :\"/v1/responses\",\n input_file_id: \"input_file_id\"\n)\n\nputs(batch)" + }, + "response": "{\n \"id\": \"batch_abc123\",\n \"object\": \"batch\",\n \"endpoint\": \"/v1/chat/completions\",\n \"errors\": null,\n \"input_file_id\": \"file-abc123\",\n \"completion_window\": \"24h\",\n \"status\": \"validating\",\n \"output_file_id\": null,\n \"error_file_id\": null,\n \"created_at\": 1711471533,\n \"in_progress_at\": null,\n \"expires_at\": null,\n \"finalizing_at\": null,\n \"completed_at\": null,\n \"failed_at\": null,\n \"expired_at\": null,\n \"cancelling_at\": null,\n \"cancelled_at\": null,\n \"request_counts\": {\n \"total\": 0,\n \"completed\": 0,\n \"failed\": 0\n },\n \"metadata\": {\n \"customer_id\": \"user_123456789\",\n \"batch_description\": \"Nightly eval job\",\n }\n}\n" } } } }, - "/openai/v1/evals/{eval_id}": { - "delete": { - "operationId": "Evals_deleteEval", - "summary": "Delete an evaluation", - "description": "Removes the specified evaluation and its associated data.", + "/openai/v1/batches/{batch_id}": { + "get": { + "operationId": "Batches_retrieveBatch", + "summary": "Get a batch", + "description": "Retrieves a batch by its identifier.", "parameters": [ { - "name": "eval_id", + "name": "batch_id", "in": "path", "required": true, - "description": "The ID of the evaluation to delete.", + "description": "The ID of the batch to retrieve.", "schema": { "type": "string" } @@ -10994,7 +11117,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/DeleteEvalResponse" + "$ref": "#/components/schemas/OpenAI.Batch" } } } @@ -11021,70 +11144,37 @@ } }, "tags": [ - "Evals" - ] - }, - "get": { - "operationId": "Evals_getEval", - "summary": "Get an evaluation", - "description": "Retrieves the specified evaluation and its configuration.", - "parameters": [ - { - "name": "eval_id", - "in": "path", - "required": true, - "description": "The ID of the evaluation to retrieve.", - "schema": { - "type": "string" - } - } + "Batch" ], - "responses": { - "200": { - "description": "The request has succeeded.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Eval" - } - } - } - }, - "4XX": { - "description": "Client error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiErrorResponse" - } - } - } - }, - "5XX": { - "description": "Server error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiErrorResponse" - } - } - } + "x-oaiMeta": { + "name": "Retrieve batch", + "group": "batch", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/batches/batch_abc123 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nbatch = client.batches.retrieve(\n \"batch_id\",\n)\nprint(batch.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const batch = await openai.batches.retrieve(\"batch_abc123\");\n\n console.log(batch);\n}\n\nmain();\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst batch = await client.batches.retrieve('batch_id');\n\nconsole.log(batch.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tbatch, err := client.Batches.Get(context.TODO(), \"batch_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", batch.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.batches.Batch;\nimport com.openai.models.batches.BatchRetrieveParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n Batch batch = client.batches().retrieve(\"batch_id\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nbatch = openai.batches.retrieve(\"batch_id\")\n\nputs(batch)" + }, + "response": "{\n \"id\": \"batch_abc123\",\n \"object\": \"batch\",\n \"endpoint\": \"/v1/completions\",\n \"errors\": null,\n \"input_file_id\": \"file-abc123\",\n \"completion_window\": \"24h\",\n \"status\": \"completed\",\n \"output_file_id\": \"file-cvaTdG\",\n \"error_file_id\": \"file-HOWS94\",\n \"created_at\": 1711471533,\n \"in_progress_at\": 1711471538,\n \"expires_at\": 1711557933,\n \"finalizing_at\": 1711493133,\n \"completed_at\": 1711493163,\n \"failed_at\": null,\n \"expired_at\": null,\n \"cancelling_at\": null,\n \"cancelled_at\": null,\n \"request_counts\": {\n \"total\": 100,\n \"completed\": 95,\n \"failed\": 5\n },\n \"metadata\": {\n \"customer_id\": \"user_123456789\",\n \"batch_description\": \"Nightly eval job\",\n }\n}\n" } - }, - "tags": [ - "Evals" - ] - }, + } + } + }, + "/openai/v1/batches/{batch_id}/cancel": { "post": { - "operationId": "Evals_updateEval", - "summary": "Update an evaluation", - "description": "Updates certain properties of an evaluation.", + "operationId": "Batches_cancelBatch", + "summary": "Cancel a batch", + "description": "Cancels a batch by its identifier.", "parameters": [ { - "name": "eval_id", + "name": "batch_id", "in": "path", "required": true, - "description": "The ID of the evaluation to update.", + "description": "The ID of the batch to cancel.", "schema": { "type": "string" } @@ -11096,7 +11186,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Eval" + "$ref": "#/components/schemas/OpenAI.Batch" } } } @@ -11123,87 +11213,86 @@ } }, "tags": [ - "Evals" + "Batch" ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UpdateEvalParametersBody" - } - } + "x-oaiMeta": { + "name": "Cancel batch", + "group": "batch", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/batches/batch_abc123/cancel \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -X POST\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nbatch = client.batches.cancel(\n \"batch_id\",\n)\nprint(batch.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const batch = await openai.batches.cancel(\"batch_abc123\");\n\n console.log(batch);\n}\n\nmain();\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst batch = await client.batches.cancel('batch_id');\n\nconsole.log(batch.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tbatch, err := client.Batches.Cancel(context.TODO(), \"batch_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", batch.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.batches.Batch;\nimport com.openai.models.batches.BatchCancelParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n Batch batch = client.batches().cancel(\"batch_id\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nbatch = openai.batches.cancel(\"batch_id\")\n\nputs(batch)" + }, + "response": "{\n \"id\": \"batch_abc123\",\n \"object\": \"batch\",\n \"endpoint\": \"/v1/chat/completions\",\n \"errors\": null,\n \"input_file_id\": \"file-abc123\",\n \"completion_window\": \"24h\",\n \"status\": \"cancelling\",\n \"output_file_id\": null,\n \"error_file_id\": null,\n \"created_at\": 1711471533,\n \"in_progress_at\": 1711471538,\n \"expires_at\": 1711557933,\n \"finalizing_at\": null,\n \"completed_at\": null,\n \"failed_at\": null,\n \"expired_at\": null,\n \"cancelling_at\": 1711475133,\n \"cancelled_at\": null,\n \"request_counts\": {\n \"total\": 100,\n \"completed\": 23,\n \"failed\": 1\n },\n \"metadata\": {\n \"customer_id\": \"user_123456789\",\n \"batch_description\": \"Nightly eval job\",\n }\n}\n" } } } }, - "/openai/v1/evals/{eval_id}/runs": { + "/openai/v1/chat/completions": { "get": { - "operationId": "Evals_listRuns", - "summary": "List evaluation runs", - "description": "Returns the runs associated with the specified evaluation.", + "operationId": "Chat_listChatCompletions", + "summary": "List chat completions", + "description": "Lists chat completions matching the request filters.", "parameters": [ { - "name": "eval_id", - "in": "path", - "required": true, - "description": "The ID of the evaluation to retrieve runs for.", + "name": "model", + "in": "query", + "required": false, + "description": "The model used to generate the Chat Completions.", "schema": { "type": "string" } }, + { + "name": "metadata", + "in": "query", + "required": false, + "description": "A list of metadata keys to filter the Chat Completions by. Example:\n `metadata[key1]=value1&metadata[key2]=value2`", + "schema": { + "anyOf": [ + { + "$ref": "#/components/schemas/OpenAI.Metadata" + }, + { + "type": "null" + } + ] + } + }, { "name": "after", "in": "query", "required": false, - "description": "Identifier for the last run from the previous pagination request.", + "description": "Identifier for the last chat completion from the previous pagination request.", "schema": { "type": "string" }, - "explode": false + "x-ms-list-continuation-token": true }, { "name": "limit", "in": "query", "required": false, - "description": "Number of runs to retrieve.", + "description": "Number of Chat Completions to retrieve.", "schema": { "$ref": "#/components/schemas/integer", "default": 20 - }, - "explode": false + } }, { "name": "order", "in": "query", "required": false, - "description": "Sort order for runs by timestamp. Use `asc` for ascending order or `desc` for descending order. Defaults to `asc`.", + "description": "Sort order for Chat Completions by timestamp. Use `asc` for ascending order or `desc` for descending order. Defaults to `asc`.", "schema": { - "type": "string", - "enum": [ - "asc", - "desc" - ], + "$ref": "#/components/schemas/OpenAI.OrderEnum", "default": "asc" - }, - "explode": false - }, - { - "name": "status", - "in": "query", - "required": false, - "description": "Filter runs by status. One of `queued` | `in_progress` | `failed` | `completed` | `canceled`.", - "schema": { - "type": "string", - "enum": [ - "queued", - "in_progress", - "completed", - "canceled", - "failed" - ] - }, - "explode": false + } } ], "responses": { @@ -11212,33 +11301,7 @@ "content": { "application/json": { "schema": { - "type": "object", - "required": [ - "data", - "has_more" - ], - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/EvalRun" - }, - "description": "The requested list of items." - }, - "first_id": { - "type": "string", - "description": "The first ID represented in this list." - }, - "last_id": { - "type": "string", - "description": "The last ID represented in this list." - }, - "has_more": { - "type": "boolean", - "description": "A value indicating whether there are additional values available not captured in this list." - } - }, - "description": "The response data for a requested list of items." + "$ref": "#/components/schemas/OpenAI.ChatCompletionList" } } } @@ -11265,31 +11328,38 @@ } }, "tags": [ - "Evals" - ] + "Chat" + ], + "x-oaiMeta": { + "name": "List Chat Completions", + "group": "chat", + "path": "list", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/chat/completions \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\npage = client.chat.completions.list()\npage = page.data[0]\nprint(page.id)", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const chatCompletion of client.chat.completions.list()) {\n console.log(chatCompletion.id);\n}", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.Chat.Completions.List(context.TODO(), openai.ChatCompletionListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", page)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.chat.completions.ChatCompletionListPage;\nimport com.openai.models.chat.completions.ChatCompletionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ChatCompletionListPage page = client.chat().completions().list();\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\npage = openai.chat.completions.list\n\nputs(page)" + }, + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"object\": \"chat.completion\",\n \"id\": \"chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2\",\n \"model\": \"gpt-5.4\",\n \"created\": 1738960610,\n \"request_id\": \"req_ded8ab984ec4bf840f37566c1011c417\",\n \"tool_choice\": null,\n \"usage\": {\n \"total_tokens\": 31,\n \"completion_tokens\": 18,\n \"prompt_tokens\": 13\n },\n \"seed\": 4944116822809979520,\n \"top_p\": 1.0,\n \"temperature\": 1.0,\n \"presence_penalty\": 0.0,\n \"frequency_penalty\": 0.0,\n \"system_fingerprint\": \"fp_50cad350e4\",\n \"input_user\": null,\n \"service_tier\": \"default\",\n \"tools\": null,\n \"metadata\": {},\n \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"content\": \"Mind of circuits hum,\nLearning patterns in silence—\nFuture's quiet spark.\",\n \"role\": \"assistant\",\n \"tool_calls\": null,\n \"function_call\": null\n },\n \"finish_reason\": \"stop\",\n \"logprobs\": null\n }\n ],\n \"response_format\": null\n }\n ],\n \"first_id\": \"chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2\",\n \"last_id\": \"chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2\",\n \"has_more\": false\n}\n" + } + }, + "x-ms-list": true }, "post": { - "operationId": "Evals_createEvalRun", - "summary": "Create an evaluation run", - "description": "Creates an evaluation run for the specified evaluation.", - "parameters": [ - { - "name": "eval_id", - "in": "path", - "required": true, - "description": "The ID of the evaluation to create a run for.", - "schema": { - "type": "string" - } - } - ], + "operationId": "Chat_createChatCompletion", + "summary": "Create a chat completion", + "description": "Creates a chat completion from the supplied request.", + "parameters": [], "responses": { "200": { "description": "The request has succeeded.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/EvalRun" + "$ref": "#/components/schemas/OpenAI.CreateChatCompletionResponse" } } } @@ -11316,40 +11386,109 @@ } }, "tags": [ - "Evals" + "Chat" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/CreateEvalRunRequest" + "$ref": "#/components/schemas/OpenAI.CreateChatCompletionRequest" } } - } + }, + "description": "The request body." + }, + "x-oaiMeta": { + "name": "Create chat completion", + "group": "chat", + "path": "create", + "examples": [ + { + "title": "Default", + "request": { + "curl": "curl https://api.openai.com/v1/chat/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"VAR_chat_model_id\",\n \"messages\": [\n {\n \"role\": \"developer\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello!\"\n }\n ]\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor completion in client.chat.completions.create(\n messages=[{\n \"content\": \"string\",\n \"role\": \"developer\",\n }],\n model=\"gpt-5.4\",\n):\n print(completion)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const completion = await openai.chat.completions.create({\n messages: [{ role: \"developer\", content: \"You are a helpful assistant.\" }],\n model: \"VAR_chat_model_id\",\n store: true,\n });\n\n console.log(completion.choices[0]);\n}\n\nmain();\n", + "csharp": "using System;\nusing System.Collections.Generic;\n\nusing OpenAI.Chat;\n\nChatClient client = new(\n model: \"gpt-5.4\",\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nList messages =\n[\n new SystemChatMessage(\"You are a helpful assistant.\"),\n new UserChatMessage(\"Hello!\")\n];\n\nChatCompletion completion = client.CompleteChat(messages);\n\nConsole.WriteLine(completion.Content[0].Text);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst chatCompletion = await client.chat.completions.create({\n messages: [{ content: 'string', role: 'developer' }],\n model: 'gpt-5.4',\n});\n\nconsole.log(chatCompletion);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n\t\"github.com/openai/openai-go/shared\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tchatCompletion, err := client.Chat.Completions.New(context.TODO(), openai.ChatCompletionNewParams{\n\t\tMessages: []openai.ChatCompletionMessageParamUnion{{\n\t\t\tOfDeveloper: &openai.ChatCompletionDeveloperMessageParam{\n\t\t\t\tContent: openai.ChatCompletionDeveloperMessageParamContentUnion{\n\t\t\t\t\tOfString: openai.String(\"string\"),\n\t\t\t\t},\n\t\t\t},\n\t\t}},\n\t\tModel: shared.ChatModelGPT5_4,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", chatCompletion)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.ChatModel;\nimport com.openai.models.chat.completions.ChatCompletion;\nimport com.openai.models.chat.completions.ChatCompletionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()\n .addDeveloperMessage(\"string\")\n .model(ChatModel.GPT_5_4)\n .build();\n ChatCompletion chatCompletion = client.chat().completions().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nchat_completion = openai.chat.completions.create(messages: [{content: \"string\", role: :developer}], model: :\"gpt-5.4\")\n\nputs(chat_completion)" + }, + "response": "{\n \"id\": \"chatcmpl-B9MBs8CjcvOU2jLn4n570S5qMJKcT\",\n \"object\": \"chat.completion\",\n \"created\": 1741569952,\n \"model\": \"gpt-5.4\",\n \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"Hello! How can I assist you today?\",\n \"refusal\": null,\n \"annotations\": []\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 19,\n \"completion_tokens\": 10,\n \"total_tokens\": 29,\n \"prompt_tokens_details\": {\n \"cached_tokens\": 0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\": {\n \"reasoning_tokens\": 0,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\": 0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\": \"default\"\n}\n" + }, + { + "title": "Image input", + "request": { + "curl": "curl https://api.openai.com/v1/chat/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"gpt-5.4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"What is in this image?\"\n },\n {\n \"type\": \"image_url\",\n \"image_url\": {\n \"url\": \"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg\"\n }\n }\n ]\n }\n ],\n \"max_tokens\": 300\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor completion in client.chat.completions.create(\n messages=[{\n \"content\": \"string\",\n \"role\": \"developer\",\n }],\n model=\"gpt-5.4\",\n):\n print(completion)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const response = await openai.chat.completions.create({\n model: \"gpt-5.4\",\n messages: [\n {\n role: \"user\",\n content: [\n { type: \"text\", text: \"What's in this image?\" },\n {\n type: \"image_url\",\n image_url: {\n \"url\": \"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg\",\n },\n }\n ],\n },\n ],\n });\n console.log(response.choices[0]);\n}\nmain();\n", + "csharp": "using System;\nusing System.Collections.Generic;\n\nusing OpenAI.Chat;\n\nChatClient client = new(\n model: \"gpt-5.4\",\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nList messages =\n[\n new UserChatMessage(\n [\n ChatMessageContentPart.CreateTextPart(\"What's in this image?\"),\n ChatMessageContentPart.CreateImagePart(new Uri(\"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg\"))\n ])\n];\n\nChatCompletion completion = client.CompleteChat(messages);\n\nConsole.WriteLine(completion.Content[0].Text);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst chatCompletion = await client.chat.completions.create({\n messages: [{ content: 'string', role: 'developer' }],\n model: 'gpt-5.4',\n});\n\nconsole.log(chatCompletion);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n\t\"github.com/openai/openai-go/shared\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tchatCompletion, err := client.Chat.Completions.New(context.TODO(), openai.ChatCompletionNewParams{\n\t\tMessages: []openai.ChatCompletionMessageParamUnion{{\n\t\t\tOfDeveloper: &openai.ChatCompletionDeveloperMessageParam{\n\t\t\t\tContent: openai.ChatCompletionDeveloperMessageParamContentUnion{\n\t\t\t\t\tOfString: openai.String(\"string\"),\n\t\t\t\t},\n\t\t\t},\n\t\t}},\n\t\tModel: shared.ChatModelGPT5_4,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", chatCompletion)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.ChatModel;\nimport com.openai.models.chat.completions.ChatCompletion;\nimport com.openai.models.chat.completions.ChatCompletionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()\n .addDeveloperMessage(\"string\")\n .model(ChatModel.GPT_5_4)\n .build();\n ChatCompletion chatCompletion = client.chat().completions().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nchat_completion = openai.chat.completions.create(messages: [{content: \"string\", role: :developer}], model: :\"gpt-5.4\")\n\nputs(chat_completion)" + }, + "response": "{\n \"id\": \"chatcmpl-B9MHDbslfkBeAs8l4bebGdFOJ6PeG\",\n \"object\": \"chat.completion\",\n \"created\": 1741570283,\n \"model\": \"gpt-5.4\",\n \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"The image shows a wooden boardwalk path running through a lush green field or meadow. The sky is bright blue with some scattered clouds, giving the scene a serene and peaceful atmosphere. Trees and shrubs are visible in the background.\",\n \"refusal\": null,\n \"annotations\": []\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 1117,\n \"completion_tokens\": 46,\n \"total_tokens\": 1163,\n \"prompt_tokens_details\": {\n \"cached_tokens\": 0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\": {\n \"reasoning_tokens\": 0,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\": 0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\": \"default\"\n}\n" + }, + { + "title": "Streaming", + "request": { + "curl": "curl https://api.openai.com/v1/chat/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"VAR_chat_model_id\",\n \"messages\": [\n {\n \"role\": \"developer\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello!\"\n }\n ],\n \"stream\": true\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor completion in client.chat.completions.create(\n messages=[{\n \"content\": \"string\",\n \"role\": \"developer\",\n }],\n model=\"gpt-5.4\",\n):\n print(completion)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const completion = await openai.chat.completions.create({\n model: \"VAR_chat_model_id\",\n messages: [\n {\"role\": \"developer\", \"content\": \"You are a helpful assistant.\"},\n {\"role\": \"user\", \"content\": \"Hello!\"}\n ],\n stream: true,\n });\n\n for await (const chunk of completion) {\n console.log(chunk.choices[0].delta.content);\n }\n}\n\nmain();\n", + "csharp": "using System;\nusing System.ClientModel;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\n\nusing OpenAI.Chat;\n\nChatClient client = new(\n model: \"gpt-5.4\",\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nList messages =\n[\n new SystemChatMessage(\"You are a helpful assistant.\"),\n new UserChatMessage(\"Hello!\")\n];\n\nAsyncCollectionResult completionUpdates = client.CompleteChatStreamingAsync(messages);\n\nawait foreach (StreamingChatCompletionUpdate completionUpdate in completionUpdates)\n{\n if (completionUpdate.ContentUpdate.Count > 0)\n {\n Console.Write(completionUpdate.ContentUpdate[0].Text);\n }\n}\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst chatCompletion = await client.chat.completions.create({\n messages: [{ content: 'string', role: 'developer' }],\n model: 'gpt-5.4',\n});\n\nconsole.log(chatCompletion);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n\t\"github.com/openai/openai-go/shared\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tchatCompletion, err := client.Chat.Completions.New(context.TODO(), openai.ChatCompletionNewParams{\n\t\tMessages: []openai.ChatCompletionMessageParamUnion{{\n\t\t\tOfDeveloper: &openai.ChatCompletionDeveloperMessageParam{\n\t\t\t\tContent: openai.ChatCompletionDeveloperMessageParamContentUnion{\n\t\t\t\t\tOfString: openai.String(\"string\"),\n\t\t\t\t},\n\t\t\t},\n\t\t}},\n\t\tModel: shared.ChatModelGPT5_4,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", chatCompletion)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.ChatModel;\nimport com.openai.models.chat.completions.ChatCompletion;\nimport com.openai.models.chat.completions.ChatCompletionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()\n .addDeveloperMessage(\"string\")\n .model(ChatModel.GPT_5_4)\n .build();\n ChatCompletion chatCompletion = client.chat().completions().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nchat_completion = openai.chat.completions.create(messages: [{content: \"string\", role: :developer}], model: :\"gpt-5.4\")\n\nputs(chat_completion)" + }, + "response": "{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-4o-mini\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"logprobs\":null,\"finish_reason\":null}]}\n\n{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-4o-mini\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{\"content\":\"Hello\"},\"logprobs\":null,\"finish_reason\":null}]}\n\n....\n\n{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-4o-mini\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}]}\n" + }, + { + "title": "Functions", + "request": { + "curl": "curl https://api.openai.com/v1/chat/completions \\\n-H \"Content-Type: application/json\" \\\n-H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n-d '{\n \"model\": \"gpt-5.4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What is the weather like in Boston today?\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_weather\",\n \"description\": \"Get the current weather in a given location\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city and state, e.g. San Francisco, CA\"\n },\n \"unit\": {\n \"type\": \"string\",\n \"enum\": [\"celsius\", \"fahrenheit\"]\n }\n },\n \"required\": [\"location\"]\n }\n }\n }\n ],\n \"tool_choice\": \"auto\"\n}'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor completion in client.chat.completions.create(\n messages=[{\n \"content\": \"string\",\n \"role\": \"developer\",\n }],\n model=\"gpt-5.4\",\n):\n print(completion)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const messages = [{\"role\": \"user\", \"content\": \"What's the weather like in Boston today?\"}];\n const tools = [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_weather\",\n \"description\": \"Get the current weather in a given location\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city and state, e.g. San Francisco, CA\",\n },\n \"unit\": {\"type\": \"string\", \"enum\": [\"celsius\", \"fahrenheit\"]},\n },\n \"required\": [\"location\"],\n },\n }\n }\n ];\n\n const response = await openai.chat.completions.create({\n model: \"gpt-5.4\",\n messages: messages,\n tools: tools,\n tool_choice: \"auto\",\n });\n\n console.log(response);\n}\n\nmain();\n", + "csharp": "using System;\nusing System.Collections.Generic;\n\nusing OpenAI.Chat;\n\nChatClient client = new(\n model: \"gpt-5.4\",\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nChatTool getCurrentWeatherTool = ChatTool.CreateFunctionTool(\n functionName: \"get_current_weather\",\n functionDescription: \"Get the current weather in a given location\",\n functionParameters: BinaryData.FromString(\"\"\"\n {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city and state, e.g. San Francisco, CA\"\n },\n \"unit\": {\n \"type\": \"string\",\n \"enum\": [ \"celsius\", \"fahrenheit\" ]\n }\n },\n \"required\": [ \"location\" ]\n }\n \"\"\")\n);\n\nList messages =\n[\n new UserChatMessage(\"What's the weather like in Boston today?\"),\n];\n\nChatCompletionOptions options = new()\n{\n Tools =\n {\n getCurrentWeatherTool\n },\n ToolChoice = ChatToolChoice.CreateAutoChoice(),\n};\n\nChatCompletion completion = client.CompleteChat(messages, options);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst chatCompletion = await client.chat.completions.create({\n messages: [{ content: 'string', role: 'developer' }],\n model: 'gpt-5.4',\n});\n\nconsole.log(chatCompletion);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n\t\"github.com/openai/openai-go/shared\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tchatCompletion, err := client.Chat.Completions.New(context.TODO(), openai.ChatCompletionNewParams{\n\t\tMessages: []openai.ChatCompletionMessageParamUnion{{\n\t\t\tOfDeveloper: &openai.ChatCompletionDeveloperMessageParam{\n\t\t\t\tContent: openai.ChatCompletionDeveloperMessageParamContentUnion{\n\t\t\t\t\tOfString: openai.String(\"string\"),\n\t\t\t\t},\n\t\t\t},\n\t\t}},\n\t\tModel: shared.ChatModelGPT5_4,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", chatCompletion)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.ChatModel;\nimport com.openai.models.chat.completions.ChatCompletion;\nimport com.openai.models.chat.completions.ChatCompletionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()\n .addDeveloperMessage(\"string\")\n .model(ChatModel.GPT_5_4)\n .build();\n ChatCompletion chatCompletion = client.chat().completions().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nchat_completion = openai.chat.completions.create(messages: [{content: \"string\", role: :developer}], model: :\"gpt-5.4\")\n\nputs(chat_completion)" + }, + "response": "{\n \"id\": \"chatcmpl-abc123\",\n \"object\": \"chat.completion\",\n \"created\": 1699896916,\n \"model\": \"gpt-4o-mini\",\n \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": null,\n \"tool_calls\": [\n {\n \"id\": \"call_abc123\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_weather\",\n \"arguments\": \"{\n\"location\": \"Boston, MA\"\n}\"\n }\n }\n ]\n },\n \"logprobs\": null,\n \"finish_reason\": \"tool_calls\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 82,\n \"completion_tokens\": 17,\n \"total_tokens\": 99,\n \"completion_tokens_details\": {\n \"reasoning_tokens\": 0,\n \"accepted_prediction_tokens\": 0,\n \"rejected_prediction_tokens\": 0\n }\n }\n}\n" + }, + { + "title": "Logprobs", + "request": { + "curl": "curl https://api.openai.com/v1/chat/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"VAR_chat_model_id\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello!\"\n }\n ],\n \"logprobs\": true,\n \"top_logprobs\": 2\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor completion in client.chat.completions.create(\n messages=[{\n \"content\": \"string\",\n \"role\": \"developer\",\n }],\n model=\"gpt-5.4\",\n):\n print(completion)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const completion = await openai.chat.completions.create({\n messages: [{ role: \"user\", content: \"Hello!\" }],\n model: \"VAR_chat_model_id\",\n logprobs: true,\n top_logprobs: 2,\n });\n\n console.log(completion.choices[0]);\n}\n\nmain();\n", + "csharp": "using System;\nusing System.Collections.Generic;\n\nusing OpenAI.Chat;\n\nChatClient client = new(\n model: \"gpt-5.4\",\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nList messages =\n[\n new UserChatMessage(\"Hello!\")\n];\n\nChatCompletionOptions options = new()\n{\n IncludeLogProbabilities = true,\n TopLogProbabilityCount = 2\n};\n\nChatCompletion completion = client.CompleteChat(messages, options);\n\nConsole.WriteLine(completion.Content[0].Text);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst chatCompletion = await client.chat.completions.create({\n messages: [{ content: 'string', role: 'developer' }],\n model: 'gpt-5.4',\n});\n\nconsole.log(chatCompletion);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n\t\"github.com/openai/openai-go/shared\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tchatCompletion, err := client.Chat.Completions.New(context.TODO(), openai.ChatCompletionNewParams{\n\t\tMessages: []openai.ChatCompletionMessageParamUnion{{\n\t\t\tOfDeveloper: &openai.ChatCompletionDeveloperMessageParam{\n\t\t\t\tContent: openai.ChatCompletionDeveloperMessageParamContentUnion{\n\t\t\t\t\tOfString: openai.String(\"string\"),\n\t\t\t\t},\n\t\t\t},\n\t\t}},\n\t\tModel: shared.ChatModelGPT5_4,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", chatCompletion)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.ChatModel;\nimport com.openai.models.chat.completions.ChatCompletion;\nimport com.openai.models.chat.completions.ChatCompletionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()\n .addDeveloperMessage(\"string\")\n .model(ChatModel.GPT_5_4)\n .build();\n ChatCompletion chatCompletion = client.chat().completions().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nchat_completion = openai.chat.completions.create(messages: [{content: \"string\", role: :developer}], model: :\"gpt-5.4\")\n\nputs(chat_completion)" + }, + "response": "{\n \"id\": \"chatcmpl-123\",\n \"object\": \"chat.completion\",\n \"created\": 1702685778,\n \"model\": \"gpt-4o-mini\",\n \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"Hello! How can I assist you today?\"\n },\n \"logprobs\": {\n \"content\": [\n {\n \"token\": \"Hello\",\n \"logprob\": -0.31725305,\n \"bytes\": [72, 101, 108, 108, 111],\n \"top_logprobs\": [\n {\n \"token\": \"Hello\",\n \"logprob\": -0.31725305,\n \"bytes\": [72, 101, 108, 108, 111]\n },\n {\n \"token\": \"Hi\",\n \"logprob\": -1.3190403,\n \"bytes\": [72, 105]\n }\n ]\n },\n {\n \"token\": \"!\",\n \"logprob\": -0.02380986,\n \"bytes\": [\n 33\n ],\n \"top_logprobs\": [\n {\n \"token\": \"!\",\n \"logprob\": -0.02380986,\n \"bytes\": [33]\n },\n {\n \"token\": \" there\",\n \"logprob\": -3.787621,\n \"bytes\": [32, 116, 104, 101, 114, 101]\n }\n ]\n },\n {\n \"token\": \" How\",\n \"logprob\": -0.000054669687,\n \"bytes\": [32, 72, 111, 119],\n \"top_logprobs\": [\n {\n \"token\": \" How\",\n \"logprob\": -0.000054669687,\n \"bytes\": [32, 72, 111, 119]\n },\n {\n \"token\": \"<|end|>\",\n \"logprob\": -10.953937,\n \"bytes\": null\n }\n ]\n },\n {\n \"token\": \" can\",\n \"logprob\": -0.015801601,\n \"bytes\": [32, 99, 97, 110],\n \"top_logprobs\": [\n {\n \"token\": \" can\",\n \"logprob\": -0.015801601,\n \"bytes\": [32, 99, 97, 110]\n },\n {\n \"token\": \" may\",\n \"logprob\": -4.161023,\n \"bytes\": [32, 109, 97, 121]\n }\n ]\n },\n {\n \"token\": \" I\",\n \"logprob\": -3.7697225e-6,\n \"bytes\": [\n 32,\n 73\n ],\n \"top_logprobs\": [\n {\n \"token\": \" I\",\n \"logprob\": -3.7697225e-6,\n \"bytes\": [32, 73]\n },\n {\n \"token\": \" assist\",\n \"logprob\": -13.596657,\n \"bytes\": [32, 97, 115, 115, 105, 115, 116]\n }\n ]\n },\n {\n \"token\": \" assist\",\n \"logprob\": -0.04571125,\n \"bytes\": [32, 97, 115, 115, 105, 115, 116],\n \"top_logprobs\": [\n {\n \"token\": \" assist\",\n \"logprob\": -0.04571125,\n \"bytes\": [32, 97, 115, 115, 105, 115, 116]\n },\n {\n \"token\": \" help\",\n \"logprob\": -3.1089056,\n \"bytes\": [32, 104, 101, 108, 112]\n }\n ]\n },\n {\n \"token\": \" you\",\n \"logprob\": -5.4385737e-6,\n \"bytes\": [32, 121, 111, 117],\n \"top_logprobs\": [\n {\n \"token\": \" you\",\n \"logprob\": -5.4385737e-6,\n \"bytes\": [32, 121, 111, 117]\n },\n {\n \"token\": \" today\",\n \"logprob\": -12.807695,\n \"bytes\": [32, 116, 111, 100, 97, 121]\n }\n ]\n },\n {\n \"token\": \" today\",\n \"logprob\": -0.0040071653,\n \"bytes\": [32, 116, 111, 100, 97, 121],\n \"top_logprobs\": [\n {\n \"token\": \" today\",\n \"logprob\": -0.0040071653,\n \"bytes\": [32, 116, 111, 100, 97, 121]\n },\n {\n \"token\": \"?\",\n \"logprob\": -5.5247097,\n \"bytes\": [63]\n }\n ]\n },\n {\n \"token\": \"?\",\n \"logprob\": -0.0008108172,\n \"bytes\": [63],\n \"top_logprobs\": [\n {\n \"token\": \"?\",\n \"logprob\": -0.0008108172,\n \"bytes\": [63]\n },\n {\n \"token\": \"?\n\",\n \"logprob\": -7.184561,\n \"bytes\": [63, 10]\n }\n ]\n }\n ]\n },\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 9,\n \"completion_tokens\": 9,\n \"total_tokens\": 18,\n \"completion_tokens_details\": {\n \"reasoning_tokens\": 0,\n \"accepted_prediction_tokens\": 0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"system_fingerprint\": null\n}\n" + } + ] } } }, - "/openai/v1/evals/{eval_id}/runs/{run_id}": { + "/openai/v1/chat/completions/{completion_id}": { "delete": { - "operationId": "Evals_deleteEvalRun", - "summary": "Delete an evaluation run", - "description": "Removes the specified evaluation run.", + "operationId": "Chat_deleteChatCompletion", + "summary": "Delete a chat completion", + "description": "Deletes a chat completion by its identifier.", "parameters": [ { - "name": "eval_id", - "in": "path", - "required": true, - "description": "The ID of the evaluation to delete the run from.", - "schema": { - "type": "string" - } - }, - { - "name": "run_id", + "name": "completion_id", "in": "path", "required": true, - "description": "The ID of the run to delete.", + "description": "The ID of the chat completion to delete.", "schema": { "type": "string" } @@ -11361,7 +11500,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/DeleteEvalRunResponse" + "$ref": "#/components/schemas/OpenAI.ChatCompletionDeleted" } } } @@ -11388,28 +11527,34 @@ } }, "tags": [ - "Evals" - ] + "Chat" + ], + "x-oaiMeta": { + "name": "Delete chat completion", + "group": "chat", + "examples": { + "request": { + "curl": "curl -X DELETE https://api.openai.com/v1/chat/completions/chat_abc123 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nchat_completion_deleted = client.chat.completions.delete(\n \"completion_id\",\n)\nprint(chat_completion_deleted.id)", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst chatCompletionDeleted = await client.chat.completions.delete('completion_id');\n\nconsole.log(chatCompletionDeleted.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tchatCompletionDeleted, err := client.Chat.Completions.Delete(context.TODO(), \"completion_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", chatCompletionDeleted.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.chat.completions.ChatCompletionDeleteParams;\nimport com.openai.models.chat.completions.ChatCompletionDeleted;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ChatCompletionDeleted chatCompletionDeleted = client.chat().completions().delete(\"completion_id\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nchat_completion_deleted = openai.chat.completions.delete(\"completion_id\")\n\nputs(chat_completion_deleted)" + }, + "response": "{\n \"object\": \"chat.completion.deleted\",\n \"id\": \"chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2\",\n \"deleted\": true\n}\n" + } + } }, "get": { - "operationId": "Evals_getEvalRun", - "summary": "Get an evaluation run", - "description": "Retrieves the specified evaluation run and its current status.", + "operationId": "Chat_getChatCompletion", + "summary": "Get a chat completion", + "description": "Retrieves a chat completion by its identifier.", "parameters": [ { - "name": "eval_id", - "in": "path", - "required": true, - "description": "The ID of the evaluation to retrieve runs for.", - "schema": { - "type": "string" - } - }, - { - "name": "run_id", + "name": "completion_id", "in": "path", "required": true, - "description": "The ID of the run to retrieve.", + "description": "The ID of the chat completion to retrieve.", "schema": { "type": "string" } @@ -11421,7 +11566,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/EvalRun" + "$ref": "#/components/schemas/OpenAI.CreateChatCompletionResponse" } } } @@ -11448,28 +11593,34 @@ } }, "tags": [ - "Evals" - ] + "Chat" + ], + "x-oaiMeta": { + "name": "Get chat completion", + "group": "chat", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/chat/completions/chatcmpl-abc123 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nchat_completion = client.chat.completions.retrieve(\n \"completion_id\",\n)\nprint(chat_completion.id)", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst chatCompletion = await client.chat.completions.retrieve('completion_id');\n\nconsole.log(chatCompletion.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tchatCompletion, err := client.Chat.Completions.Get(context.TODO(), \"completion_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", chatCompletion.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.chat.completions.ChatCompletion;\nimport com.openai.models.chat.completions.ChatCompletionRetrieveParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ChatCompletion chatCompletion = client.chat().completions().retrieve(\"completion_id\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nchat_completion = openai.chat.completions.retrieve(\"completion_id\")\n\nputs(chat_completion)" + }, + "response": "{\n \"object\": \"chat.completion\",\n \"id\": \"chatcmpl-abc123\",\n \"model\": \"gpt-4o-2024-08-06\",\n \"created\": 1738960610,\n \"request_id\": \"req_ded8ab984ec4bf840f37566c1011c417\",\n \"tool_choice\": null,\n \"usage\": {\n \"total_tokens\": 31,\n \"completion_tokens\": 18,\n \"prompt_tokens\": 13\n },\n \"seed\": 4944116822809979520,\n \"top_p\": 1.0,\n \"temperature\": 1.0,\n \"presence_penalty\": 0.0,\n \"frequency_penalty\": 0.0,\n \"system_fingerprint\": \"fp_50cad350e4\",\n \"input_user\": null,\n \"service_tier\": \"default\",\n \"tools\": null,\n \"metadata\": {},\n \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"content\": \"Mind of circuits hum,\nLearning patterns in silence—\nFuture's quiet spark.\",\n \"role\": \"assistant\",\n \"tool_calls\": null,\n \"function_call\": null\n },\n \"finish_reason\": \"stop\",\n \"logprobs\": null\n }\n ],\n \"response_format\": null\n}\n" + } + } }, "post": { - "operationId": "Evals_cancelEvalRun", - "summary": "Cancel an evaluation run", - "description": "Cancels an ongoing evaluation run.", + "operationId": "Chat_updateChatCompletion", + "summary": "Update a chat completion", + "description": "Updates a chat completion with the supplied changes.", "parameters": [ { - "name": "eval_id", - "in": "path", - "required": true, - "description": "The ID of the evaluation whose run you want to cancel.", - "schema": { - "type": "string" - } - }, - { - "name": "run_id", + "name": "completion_id", "in": "path", "required": true, - "description": "The ID of the run to cancel.", + "description": "The ID of the chat completion to update.", "schema": { "type": "string" } @@ -11481,7 +11632,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/EvalRun" + "$ref": "#/components/schemas/OpenAI.CreateChatCompletionResponse" } } } @@ -11508,29 +11659,47 @@ } }, "tags": [ - "Evals" - ] + "Chat" + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAI.UpdateChatCompletionParametersBody" + } + } + }, + "description": "The request body." + }, + "x-oaiMeta": { + "name": "Update chat completion", + "group": "chat", + "examples": { + "request": { + "curl": "curl -X POST https://api.openai.com/v1/chat/completions/chat_abc123 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"metadata\": {\"foo\": \"bar\"}}'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nchat_completion = client.chat.completions.update(\n completion_id=\"completion_id\",\n metadata={\n \"foo\": \"string\"\n },\n)\nprint(chat_completion.id)", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst chatCompletion = await client.chat.completions.update('completion_id', {\n metadata: { foo: 'string' },\n});\n\nconsole.log(chatCompletion.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n\t\"github.com/openai/openai-go/shared\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tchatCompletion, err := client.Chat.Completions.Update(\n\t\tcontext.TODO(),\n\t\t\"completion_id\",\n\t\topenai.ChatCompletionUpdateParams{\n\t\t\tMetadata: shared.Metadata{\n\t\t\t\t\"foo\": \"string\",\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", chatCompletion.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.core.JsonValue;\nimport com.openai.models.chat.completions.ChatCompletion;\nimport com.openai.models.chat.completions.ChatCompletionUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ChatCompletionUpdateParams params = ChatCompletionUpdateParams.builder()\n .completionId(\"completion_id\")\n .metadata(ChatCompletionUpdateParams.Metadata.builder()\n .putAdditionalProperty(\"foo\", JsonValue.from(\"string\"))\n .build())\n .build();\n ChatCompletion chatCompletion = client.chat().completions().update(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nchat_completion = openai.chat.completions.update(\"completion_id\", metadata: {foo: \"string\"})\n\nputs(chat_completion)" + }, + "response": "{\n \"object\": \"chat.completion\",\n \"id\": \"chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2\",\n \"model\": \"gpt-4o-2024-08-06\",\n \"created\": 1738960610,\n \"request_id\": \"req_ded8ab984ec4bf840f37566c1011c417\",\n \"tool_choice\": null,\n \"usage\": {\n \"total_tokens\": 31,\n \"completion_tokens\": 18,\n \"prompt_tokens\": 13\n },\n \"seed\": 4944116822809979520,\n \"top_p\": 1.0,\n \"temperature\": 1.0,\n \"presence_penalty\": 0.0,\n \"frequency_penalty\": 0.0,\n \"system_fingerprint\": \"fp_50cad350e4\",\n \"input_user\": null,\n \"service_tier\": \"default\",\n \"tools\": null,\n \"metadata\": {\n \"foo\": \"bar\"\n },\n \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"content\": \"Mind of circuits hum,\nLearning patterns in silence—\nFuture's quiet spark.\",\n \"role\": \"assistant\",\n \"tool_calls\": null,\n \"function_call\": null\n },\n \"finish_reason\": \"stop\",\n \"logprobs\": null\n }\n ],\n \"response_format\": null\n}\n" + } + } } }, - "/openai/v1/evals/{eval_id}/runs/{run_id}/output_items": { + "/openai/v1/chat/completions/{completion_id}/messages": { "get": { - "operationId": "Evals_getEvalRunOutputItems", - "summary": "List evaluation run output items", - "description": "Returns the output items produced by the specified evaluation run.", + "operationId": "Chat_getChatCompletionMessages", + "summary": "Get chat completion messages", + "description": "Retrieves chat completion messages by its identifier.", "parameters": [ { - "name": "eval_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "run_id", + "name": "completion_id", "in": "path", "required": true, - "description": "The ID of the run to retrieve output items for.", + "description": "The ID of the chat completion to retrieve messages from.", "schema": { "type": "string" } @@ -11539,49 +11708,30 @@ "name": "after", "in": "query", "required": false, - "description": "Identifier for the last run from the previous pagination request.", + "description": "Identifier for the last message from the previous pagination request.", "schema": { "type": "string" }, - "explode": false + "x-ms-list-continuation-token": true }, { "name": "limit", "in": "query", "required": false, - "description": "Number of runs to retrieve.", + "description": "Number of messages to retrieve.", "schema": { "$ref": "#/components/schemas/integer", "default": 20 - }, - "explode": false + } }, { "name": "order", "in": "query", "required": false, - "description": "Sort order for runs by timestamp. Use `asc` for ascending order or `desc` for descending order. Defaults to `asc`.", + "description": "Sort order for messages by timestamp. Use `asc` for ascending order or `desc` for descending order. Defaults to `asc`.", "schema": { - "type": "string", - "enum": [ - "asc", - "desc" - ], + "$ref": "#/components/schemas/OpenAI.OrderEnum", "default": "asc" - }, - "explode": false - }, - { - "name": "status", - "in": "query", - "required": false, - "description": "Filter output items by status. Use `failed` to filter by failed output\nitems or `pass` to filter by passed output items.", - "schema": { - "type": "string", - "enum": [ - "fail", - "pass" - ] } } ], @@ -11591,33 +11741,7 @@ "content": { "application/json": { "schema": { - "type": "object", - "required": [ - "data", - "has_more" - ], - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/EvalRunOutputItem" - }, - "description": "The requested list of items." - }, - "first_id": { - "type": "string", - "description": "The first ID represented in this list." - }, - "last_id": { - "type": "string", - "description": "The last ID represented in this list." - }, - "has_more": { - "type": "boolean", - "description": "A value indicating whether there are additional values available not captured in this list." - } - }, - "description": "The response data for a requested list of items." + "$ref": "#/components/schemas/OpenAI.ChatCompletionMessageList" } } } @@ -11644,51 +11768,39 @@ } }, "tags": [ - "Evals" - ] + "Chat" + ], + "x-oaiMeta": { + "name": "Get chat messages", + "group": "chat", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/chat/completions/chat_abc123/messages \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\npage = client.chat.completions.messages.list(\n completion_id=\"completion_id\",\n)\npage = page.data[0]\nprint(page)", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const chatCompletionStoreMessage of client.chat.completions.messages.list(\n 'completion_id',\n)) {\n console.log(chatCompletionStoreMessage);\n}", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.Chat.Completions.Messages.List(\n\t\tcontext.TODO(),\n\t\t\"completion_id\",\n\t\topenai.ChatCompletionMessageListParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", page)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.chat.completions.messages.MessageListPage;\nimport com.openai.models.chat.completions.messages.MessageListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n MessageListPage page = client.chat().completions().messages().list(\"completion_id\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\npage = openai.chat.completions.messages.list(\"completion_id\")\n\nputs(page)" + }, + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2-0\",\n \"role\": \"user\",\n \"content\": \"write a haiku about ai\",\n \"name\": null,\n \"content_parts\": null\n }\n ],\n \"first_id\": \"chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2-0\",\n \"last_id\": \"chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2-0\",\n \"has_more\": false\n}\n" + } + }, + "x-ms-list": true } }, - "/openai/v1/evals/{eval_id}/runs/{run_id}/output_items/{output_item_id}": { - "get": { - "operationId": "Evals_getEvalRunOutputItem", - "summary": "Get an output item of an evaluation run", - "description": "Retrieves a single output item from the specified evaluation run.", - "parameters": [ - { - "name": "eval_id", - "in": "path", - "required": true, - "description": "The ID of the evaluation to retrieve runs for.", - "schema": { - "type": "string" - } - }, - { - "name": "run_id", - "in": "path", - "required": true, - "description": "The ID of the run to retrieve.", - "schema": { - "type": "string" - } - }, - { - "name": "output_item_id", - "in": "path", - "required": true, - "description": "The ID of the output item to retrieve.", - "schema": { - "type": "string" - } - } - ], + "/openai/v1/completions": { + "post": { + "operationId": "Completions_createCompletion", + "summary": "Create a completion", + "description": "Creates a completion from the supplied request.", + "parameters": [], "responses": { "200": { "description": "The request has succeeded.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/EvalRunOutputItem" + "$ref": "#/components/schemas/OpenAI.CreateCompletionResponse" } } } @@ -11715,25 +11827,98 @@ } }, "tags": [ - "Evals" - ] + "Completions" + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAI.CreateCompletionRequest" + } + } + }, + "description": "The request body." + }, + "x-oaiMeta": { + "name": "Create completion", + "group": "completions", + "legacy": true, + "examples": [ + { + "title": "No streaming", + "request": { + "curl": "curl https://api.openai.com/v1/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"VAR_completion_model_id\",\n \"prompt\": \"Say this is a test\",\n \"max_tokens\": 7,\n \"temperature\": 0\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor completion in client.completions.create(\n model=\"gpt-3.5-turbo-instruct\",\n prompt=\"This is a test.\",\n):\n print(completion)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const completion = await openai.completions.create({\n model: \"VAR_completion_model_id\",\n prompt: \"Say this is a test.\",\n max_tokens: 7,\n temperature: 0,\n });\n\n console.log(completion);\n}\nmain();", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst completion = await client.completions.create({\n model: 'gpt-3.5-turbo-instruct',\n prompt: 'This is a test.',\n});\n\nconsole.log(completion);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tcompletion, err := client.Completions.New(context.TODO(), openai.CompletionNewParams{\n\t\tModel: openai.CompletionNewParamsModelGPT3_5TurboInstruct,\n\t\tPrompt: openai.CompletionNewParamsPromptUnion{\n\t\t\tOfString: openai.String(\"This is a test.\"),\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", completion)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.completions.Completion;\nimport com.openai.models.completions.CompletionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n CompletionCreateParams params = CompletionCreateParams.builder()\n .model(CompletionCreateParams.Model.GPT_3_5_TURBO_INSTRUCT)\n .prompt(\"This is a test.\")\n .build();\n Completion completion = client.completions().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\ncompletion = openai.completions.create(model: :\"gpt-3.5-turbo-instruct\", prompt: \"This is a test.\")\n\nputs(completion)" + }, + "response": "{\n \"id\": \"cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7\",\n \"object\": \"text_completion\",\n \"created\": 1589478378,\n \"model\": \"VAR_completion_model_id\",\n \"system_fingerprint\": \"fp_44709d6fcb\",\n \"choices\": [\n {\n \"text\": \"\n\nThis is indeed a test\",\n \"index\": 0,\n \"logprobs\": null,\n \"finish_reason\": \"length\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 5,\n \"completion_tokens\": 7,\n \"total_tokens\": 12\n }\n}\n" + }, + { + "title": "Streaming", + "request": { + "curl": "curl https://api.openai.com/v1/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"VAR_completion_model_id\",\n \"prompt\": \"Say this is a test\",\n \"max_tokens\": 7,\n \"temperature\": 0,\n \"stream\": true\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor completion in client.completions.create(\n model=\"gpt-3.5-turbo-instruct\",\n prompt=\"This is a test.\",\n):\n print(completion)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const stream = await openai.completions.create({\n model: \"VAR_completion_model_id\",\n prompt: \"Say this is a test.\",\n stream: true,\n });\n\n for await (const chunk of stream) {\n console.log(chunk.choices[0].text)\n }\n}\nmain();", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst completion = await client.completions.create({\n model: 'gpt-3.5-turbo-instruct',\n prompt: 'This is a test.',\n});\n\nconsole.log(completion);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tcompletion, err := client.Completions.New(context.TODO(), openai.CompletionNewParams{\n\t\tModel: openai.CompletionNewParamsModelGPT3_5TurboInstruct,\n\t\tPrompt: openai.CompletionNewParamsPromptUnion{\n\t\t\tOfString: openai.String(\"This is a test.\"),\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", completion)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.completions.Completion;\nimport com.openai.models.completions.CompletionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n CompletionCreateParams params = CompletionCreateParams.builder()\n .model(CompletionCreateParams.Model.GPT_3_5_TURBO_INSTRUCT)\n .prompt(\"This is a test.\")\n .build();\n Completion completion = client.completions().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\ncompletion = openai.completions.create(model: :\"gpt-3.5-turbo-instruct\", prompt: \"This is a test.\")\n\nputs(completion)" + }, + "response": "{\n \"id\": \"cmpl-7iA7iJjj8V2zOkCGvWF2hAkDWBQZe\",\n \"object\": \"text_completion\",\n \"created\": 1690759702,\n \"choices\": [\n {\n \"text\": \"This\",\n \"index\": 0,\n \"logprobs\": null,\n \"finish_reason\": null\n }\n ],\n \"model\": \"gpt-3.5-turbo-instruct\"\n \"system_fingerprint\": \"fp_44709d6fcb\",\n}\n" + } + ] + } } }, - "/openai/v1/fine_tuning/jobs": { - "post": { - "operationId": "createFineTuningJob", - "summary": "Create a fine-tuning job", - "description": "Creates a fine-tuning job which begins the process of creating a new model from a given dataset.\n\nResponse includes details of the enqueued job including job status and the name of the fine-tuned models once complete.\n\n[Learn more about fine-tuning](https://platform.openai.com/docs/guides/fine-tuning)", + "/openai/v1/containers": { + "get": { + "operationId": "Containers_listContainers", + "summary": "List containers", + "description": "Lists containers matching the request filters.", "parameters": [ { - "name": "api-version", + "name": "limit", "in": "query", - "required": true, - "description": "The API version to use for this operation.", + "required": false, + "description": "A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.", + "schema": { + "$ref": "#/components/schemas/integer", + "default": 20 + } + }, + { + "name": "order", + "in": "query", + "required": false, + "description": "Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.", + "schema": { + "$ref": "#/components/schemas/OpenAI.OrderEnum", + "default": "desc" + } + }, + { + "name": "after", + "in": "query", + "required": false, + "description": "A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.", "schema": { "type": "string" }, - "explode": false + "x-ms-list-continuation-token": true + }, + { + "name": "name", + "in": "query", + "required": false, + "description": "Filter results by container name.", + "schema": { + "type": "string" + } } ], "responses": { @@ -11742,7 +11927,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OpenAI.FineTuningJob" + "$ref": "#/components/schemas/OpenAI.ContainerListResource" } } } @@ -11769,64 +11954,38 @@ } }, "tags": [ - "Fine-Tuning" + "Containers" ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OpenAI.CreateFineTuningJobRequest" - } - } + "x-oaiMeta": { + "name": "List containers", + "group": "containers", + "path": "get", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/containers \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const containerListResponse of client.containers.list()) {\n console.log(containerListResponse.id);\n}", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\npage = client.containers.list()\npage = page.data[0]\nprint(page.id)", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.Containers.List(context.TODO(), openai.ContainerListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", page)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.containers.ContainerListPage;\nimport com.openai.models.containers.ContainerListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ContainerListPage page = client.containers().list();\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\npage = openai.containers.list\n\nputs(page)" + }, + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863\",\n \"object\": \"container\",\n \"created_at\": 1747844794,\n \"status\": \"running\",\n \"expires_after\": {\n \"anchor\": \"last_active_at\",\n \"minutes\": 20\n },\n \"last_active_at\": 1747844794,\n \"memory_limit\": \"4g\",\n \"name\": \"My Container\"\n }\n ],\n \"first_id\": \"container_123\",\n \"last_id\": \"container_123\",\n \"has_more\": false\n}\n" } - } + }, + "x-ms-list": true }, - "get": { - "operationId": "listPaginatedFineTuningJobs", - "summary": "List fine-tuning jobs", - "description": "Returns the fine-tuning jobs for the current organization.", - "parameters": [ - { - "name": "after", - "in": "query", - "required": false, - "description": "Identifier for the last job from the previous pagination request.", - "schema": { - "type": "string" - }, - "explode": false - }, - { - "name": "limit", - "in": "query", - "required": false, - "description": "Number of fine-tuning jobs to retrieve.", - "schema": { - "type": "integer", - "format": "int32", - "default": 20 - }, - "explode": false - }, - { - "name": "api-version", - "in": "query", - "required": true, - "description": "The API version to use for this operation.", - "schema": { - "type": "string" - }, - "explode": false - } - ], + "post": { + "operationId": "Containers_createContainer", + "summary": "Create a container", + "description": "Creates a container from the supplied request.", + "parameters": [], "responses": { "200": { "description": "The request has succeeded.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OpenAI.ListPaginatedFineTuningJobsResponse" + "$ref": "#/components/schemas/OpenAI.ContainerResource" } } } @@ -11853,34 +12012,111 @@ } }, "tags": [ - "Fine-Tuning" - ] + "Containers" + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAI.CreateContainerBody" + } + } + }, + "description": "The request body." + }, + "x-oaiMeta": { + "name": "Create container", + "group": "containers", + "path": "post", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/containers \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"My Container\",\n \"memory_limit\": \"4g\",\n \"skills\": [\n {\n \"type\": \"skill_reference\",\n \"skill_id\": \"skill_4db6f1a2c9e73508b41f9da06e2c7b5f\"\n },\n {\n \"type\": \"skill_reference\",\n \"skill_id\": \"openai-spreadsheets\",\n \"version\": \"latest\"\n }\n ],\n \"network_policy\": {\n \"type\": \"allowlist\",\n \"allowed_domains\": [\"api.buildkite.com\"]\n }\n }'\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst container = await client.containers.create({ name: 'name' });\n\nconsole.log(container.id);", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\ncontainer = client.containers.create(\n name=\"name\",\n)\nprint(container.id)", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tcontainer, err := client.Containers.New(context.TODO(), openai.ContainerNewParams{\n\t\tName: \"name\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", container.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.containers.ContainerCreateParams;\nimport com.openai.models.containers.ContainerCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ContainerCreateParams params = ContainerCreateParams.builder()\n .name(\"name\")\n .build();\n ContainerCreateResponse container = client.containers().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\ncontainer = openai.containers.create(name: \"name\")\n\nputs(container)" + }, + "response": "{\n \"id\": \"cntr_682e30645a488191b6363a0cbefc0f0a025ec61b66250591\",\n \"object\": \"container\",\n \"created_at\": 1747857508,\n \"status\": \"running\",\n \"expires_after\": {\n \"anchor\": \"last_active_at\",\n \"minutes\": 20\n },\n \"last_active_at\": 1747857508,\n \"network_policy\": {\n \"type\": \"allowlist\",\n \"allowed_domains\": [\"api.buildkite.com\"]\n },\n \"memory_limit\": \"4g\",\n \"name\": \"My Container\"\n}\n" + } + } } }, - "/openai/v1/fine_tuning/jobs/{fine_tuning_job_id}": { - "get": { - "operationId": "retrieveFineTuningJob", - "summary": "Get a fine-tuning job", - "description": "Gets info about a fine-tuning job.\n\n[Learn more about fine-tuning](https://platform.openai.com/docs/guides/fine-tuning)", + "/openai/v1/containers/{container_id}": { + "delete": { + "operationId": "Containers_deleteContainer", + "summary": "Delete a container", + "description": "Deletes a container by its identifier.", "parameters": [ { - "name": "fine_tuning_job_id", + "name": "container_id", "in": "path", "required": true, - "description": "The ID of the fine-tuning job.", + "description": "The ID of the container to delete.", "schema": { "type": "string" } + } + ], + "responses": { + "200": { + "description": "The request has succeeded." + }, + "4XX": { + "description": "Client error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } }, + "5XX": { + "description": "Server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } + } + }, + "tags": [ + "Containers" + ], + "x-oaiMeta": { + "name": "Delete a container", + "group": "containers", + "path": "delete", + "examples": { + "request": { + "curl": "curl -X DELETE https://api.openai.com/v1/containers/cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nawait client.containers.delete('container_id');", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nclient.containers.delete(\n \"container_id\",\n)", + "go": "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\terr := client.Containers.Delete(context.TODO(), \"container_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.containers.ContainerDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n client.containers().delete(\"container_id\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nresult = openai.containers.delete(\"container_id\")\n\nputs(result)" + }, + "response": "{\n \"id\": \"cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863\",\n \"object\": \"container.deleted\",\n \"deleted\": true\n}\n" + } + } + }, + "get": { + "operationId": "Containers_retrieveContainer", + "summary": "Get a container", + "description": "Retrieves a container by its identifier.", + "parameters": [ { - "name": "api-version", - "in": "query", + "name": "container_id", + "in": "path", "required": true, - "description": "The API version to use for this operation.", + "description": "The ID of the container.", "schema": { "type": "string" - }, - "explode": false + } } ], "responses": { @@ -11889,7 +12125,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OpenAI.FineTuningJob" + "$ref": "#/components/schemas/OpenAI.ContainerResource" } } } @@ -11916,34 +12152,70 @@ } }, "tags": [ - "Fine-Tuning" - ] + "Containers" + ], + "x-oaiMeta": { + "name": "Retrieve container", + "group": "containers", + "path": "get", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/containers/cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst container = await client.containers.retrieve('container_id');\n\nconsole.log(container.id);", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\ncontainer = client.containers.retrieve(\n \"container_id\",\n)\nprint(container.id)", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tcontainer, err := client.Containers.Get(context.TODO(), \"container_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", container.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.containers.ContainerRetrieveParams;\nimport com.openai.models.containers.ContainerRetrieveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ContainerRetrieveResponse container = client.containers().retrieve(\"container_id\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\ncontainer = openai.containers.retrieve(\"container_id\")\n\nputs(container)" + }, + "response": "{\n \"id\": \"cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863\",\n \"object\": \"container\",\n \"created_at\": 1747844794,\n \"status\": \"running\",\n \"expires_after\": {\n \"anchor\": \"last_active_at\",\n \"minutes\": 20\n },\n \"last_active_at\": 1747844794,\n \"memory_limit\": \"4g\",\n \"name\": \"My Container\"\n}\n" + } + } } }, - "/openai/v1/fine_tuning/jobs/{fine_tuning_job_id}/cancel": { - "post": { - "operationId": "cancelFineTuningJob", - "summary": "Cancel a fine-tuning job", - "description": "Immediately cancels the specified fine-tuning job.", + "/openai/v1/containers/{container_id}/files": { + "get": { + "operationId": "Containers_listContainerFiles", + "summary": "List container files", + "description": "Lists container files matching the request filters.", "parameters": [ { - "name": "fine_tuning_job_id", + "name": "container_id", "in": "path", "required": true, - "description": "The ID of the fine-tuning job to cancel.", + "description": "The ID of the container.", "schema": { "type": "string" } }, { - "name": "api-version", + "name": "limit", "in": "query", - "required": true, - "description": "The API version to use for this operation.", + "required": false, + "description": "A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.", + "schema": { + "$ref": "#/components/schemas/integer", + "default": 20 + } + }, + { + "name": "order", + "in": "query", + "required": false, + "description": "Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.", + "schema": { + "$ref": "#/components/schemas/OpenAI.OrderEnum", + "default": "desc" + } + }, + { + "name": "after", + "in": "query", + "required": false, + "description": "A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.", "schema": { "type": "string" }, - "explode": false + "x-ms-list-continuation-token": true } ], "responses": { @@ -11952,7 +12224,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OpenAI.FineTuningJob" + "$ref": "#/components/schemas/OpenAI.ContainerFileListResource" } } } @@ -11979,65 +12251,48 @@ } }, "tags": [ - "Fine-Tuning" - ] - } - }, - "/openai/v1/fine_tuning/jobs/{fine_tuning_job_id}/checkpoints": { - "get": { - "operationId": "listFineTuningJobCheckpoints", - "summary": "List fine-tuning job checkpoints", - "description": "Returns the checkpoints saved during the specified fine-tuning job.", + "Containers" + ], + "x-oaiMeta": { + "name": "List container files", + "group": "containers", + "path": "get", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/containers/cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04/files \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const fileListResponse of client.containers.files.list('container_id')) {\n console.log(fileListResponse.id);\n}", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\npage = client.containers.files.list(\n container_id=\"container_id\",\n)\npage = page.data[0]\nprint(page.id)", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.Containers.Files.List(\n\t\tcontext.TODO(),\n\t\t\"container_id\",\n\t\topenai.ContainerFileListParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", page)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.containers.files.FileListPage;\nimport com.openai.models.containers.files.FileListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n FileListPage page = client.containers().files().list(\"container_id\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\npage = openai.containers.files.list(\"container_id\")\n\nputs(page)" + }, + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"cfile_682e0e8a43c88191a7978f477a09bdf5\",\n \"object\": \"container.file\",\n \"created_at\": 1747848842,\n \"bytes\": 880,\n \"container_id\": \"cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04\",\n \"path\": \"/mnt/data/88e12fa445d32636f190a0b33daed6cb-tsconfig.json\",\n \"source\": \"user\"\n }\n ],\n \"first_id\": \"cfile_682e0e8a43c88191a7978f477a09bdf5\",\n \"has_more\": false,\n \"last_id\": \"cfile_682e0e8a43c88191a7978f477a09bdf5\"\n}\n" + } + }, + "x-ms-list": true + }, + "post": { + "operationId": "Containers_createContainerFileMultipart_Containers_createContainerFileJson", "parameters": [ { - "name": "fine_tuning_job_id", + "name": "container_id", "in": "path", "required": true, - "description": "The ID of the fine-tuning job to get checkpoints for.", + "description": "The ID of the container.", "schema": { "type": "string" } - }, - { - "name": "after", - "in": "query", - "required": false, - "description": "Identifier for the last checkpoint ID from the previous pagination request.", - "schema": { - "type": "string" - }, - "explode": false - }, - { - "name": "limit", - "in": "query", - "required": false, - "description": "Number of checkpoints to retrieve.", - "schema": { - "type": "integer", - "format": "int32", - "default": 10 - }, - "explode": false - }, - { - "name": "api-version", - "in": "query", - "required": true, - "description": "The API version to use for this operation.", - "schema": { - "type": "string" - }, - "explode": false } ], + "description": "Creates a container file multipart from the supplied request. Creates a container file json from the supplied request.", + "summary": "Create a container file multipart Create a container file json", "responses": { "200": { "description": "The request has succeeded.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OpenAI.ListFineTuningJobCheckpointsResponse" + "$ref": "#/components/schemas/OpenAI.ContainerFileResource" } } } @@ -12063,57 +12318,138 @@ } } }, + "x-ms-request-body-description-override": "The request body.", + "x-oaiMeta": { + "name": "Create container file", + "group": "containers", + "path": "post", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/containers/cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04/files \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -F file=\"@example.txt\"\n", + "node.js": "import fs from 'fs';\nimport OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst file = await client.containers.files.create('container_id');\n\nconsole.log(file.id);", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfile = client.containers.files.create(\n container_id=\"container_id\",\n)\nprint(file.id)", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tfile, err := client.Containers.Files.New(\n\t\tcontext.TODO(),\n\t\t\"container_id\",\n\t\topenai.ContainerFileNewParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", file.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.containers.files.FileCreateParams;\nimport com.openai.models.containers.files.FileCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n FileCreateResponse file = client.containers().files().create(\"container_id\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nfile = openai.containers.files.create(\"container_id\")\n\nputs(file)" + }, + "response": "{\n \"id\": \"cfile_682e0e8a43c88191a7978f477a09bdf5\",\n \"object\": \"container.file\",\n \"created_at\": 1747848842,\n \"bytes\": 880,\n \"container_id\": \"cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04\",\n \"path\": \"/mnt/data/88e12fa445d32636f190a0b33daed6cb-tsconfig.json\",\n \"source\": \"user\"\n}\n" + } + }, "tags": [ - "Fine-Tuning" - ] + "Containers" + ], + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/OpenAI.CreateContainerFileBody" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAI.CreateContainerFileBody" + } + } + }, + "description": "The multipart request body. The request body." + } } }, - "/openai/v1/fine_tuning/jobs/{fine_tuning_job_id}/events": { - "get": { - "operationId": "listFineTuningJobEvents", - "summary": "List fine-tuning job events", - "description": "Returns the status events emitted during the specified fine-tuning job.", + "/openai/v1/containers/{container_id}/files/{file_id}": { + "delete": { + "operationId": "Containers_deleteContainerFile", + "summary": "Delete a container file", + "description": "Deletes a container file by its identifier.", "parameters": [ { - "name": "fine_tuning_job_id", + "name": "container_id", "in": "path", "required": true, - "description": "The ID of the fine-tuning job to get events for.", + "description": "The ID of the container.", "schema": { "type": "string" } }, { - "name": "after", - "in": "query", - "required": false, - "description": "Identifier for the last event from the previous pagination request.", + "name": "file_id", + "in": "path", + "required": true, + "description": "The ID of the file.", "schema": { "type": "string" }, - "explode": false + "x-ms-description-override": "The ID of the file." + } + ], + "responses": { + "200": { + "description": "The request has succeeded." + }, + "4XX": { + "description": "Client error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } }, + "5XX": { + "description": "Server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } + } + }, + "tags": [ + "Containers" + ], + "x-oaiMeta": { + "name": "Delete a container file", + "group": "containers", + "path": "delete", + "examples": { + "request": { + "curl": "curl -X DELETE https://api.openai.com/v1/containers/cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863/files/cfile_682e0e8a43c88191a7978f477a09bdf5 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nawait client.containers.files.delete('file_id', { container_id: 'container_id' });", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nclient.containers.files.delete(\n file_id=\"file_id\",\n container_id=\"container_id\",\n)", + "go": "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\terr := client.Containers.Files.Delete(\n\t\tcontext.TODO(),\n\t\t\"container_id\",\n\t\t\"file_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.containers.files.FileDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n FileDeleteParams params = FileDeleteParams.builder()\n .containerId(\"container_id\")\n .fileId(\"file_id\")\n .build();\n client.containers().files().delete(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nresult = openai.containers.files.delete(\"file_id\", container_id: \"container_id\")\n\nputs(result)" + }, + "response": "{\n \"id\": \"cfile_682e0e8a43c88191a7978f477a09bdf5\",\n \"object\": \"container.file.deleted\",\n \"deleted\": true\n}\n" + } + } + }, + "get": { + "operationId": "Containers_retrieveContainerFile", + "summary": "Get a container file", + "description": "Retrieves a container file by its identifier.", + "parameters": [ { - "name": "limit", - "in": "query", - "required": false, - "description": "Number of events to retrieve.", + "name": "container_id", + "in": "path", + "required": true, + "description": "The ID of the container.", "schema": { - "type": "integer", - "format": "int32", - "default": 20 - }, - "explode": false + "type": "string" + } }, { - "name": "api-version", - "in": "query", + "name": "file_id", + "in": "path", "required": true, - "description": "The API version to use for this operation.", + "description": "The ID of the file.", "schema": { "type": "string" }, - "explode": false + "x-ms-description-override": "The ID of the file." } ], "responses": { @@ -12122,7 +12458,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OpenAI.ListFineTuningJobEventsResponse" + "$ref": "#/components/schemas/OpenAI.ContainerFileResource" } } } @@ -12149,34 +12485,112 @@ } }, "tags": [ - "Fine-Tuning" - ] + "Containers" + ], + "x-oaiMeta": { + "name": "Retrieve container file", + "group": "containers", + "path": "get", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/containers/container_123/files/file_456 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst file = await client.containers.files.retrieve('file_id', { container_id: 'container_id' });\n\nconsole.log(file.id);", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfile = client.containers.files.retrieve(\n file_id=\"file_id\",\n container_id=\"container_id\",\n)\nprint(file.id)", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tfile, err := client.Containers.Files.Get(\n\t\tcontext.TODO(),\n\t\t\"container_id\",\n\t\t\"file_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", file.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.containers.files.FileRetrieveParams;\nimport com.openai.models.containers.files.FileRetrieveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n FileRetrieveParams params = FileRetrieveParams.builder()\n .containerId(\"container_id\")\n .fileId(\"file_id\")\n .build();\n FileRetrieveResponse file = client.containers().files().retrieve(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nfile = openai.containers.files.retrieve(\"file_id\", container_id: \"container_id\")\n\nputs(file)" + }, + "response": "{\n \"id\": \"cfile_682e0e8a43c88191a7978f477a09bdf5\",\n \"object\": \"container.file\",\n \"created_at\": 1747848842,\n \"bytes\": 880,\n \"container_id\": \"cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04\",\n \"path\": \"/mnt/data/88e12fa445d32636f190a0b33daed6cb-tsconfig.json\",\n \"source\": \"user\"\n}\n" + } + } } }, - "/openai/v1/fine_tuning/jobs/{fine_tuning_job_id}/pause": { - "post": { - "operationId": "pauseFineTuningJob", - "summary": "Pause a fine-tuning job", - "description": "Pauses the specified fine-tuning job while it is running.", + "/openai/v1/containers/{container_id}/files/{file_id}/content": { + "get": { + "operationId": "Containers_retrieveContainerFileContent", + "summary": "Get a container file content", + "description": "Retrieves a container file content by its identifier.", "parameters": [ { - "name": "fine_tuning_job_id", + "name": "container_id", "in": "path", "required": true, - "description": "The ID of the fine-tuning job to pause.", + "description": "The ID of the container.", "schema": { "type": "string" } }, { - "name": "api-version", - "in": "query", + "name": "file_id", + "in": "path", "required": true, - "description": "The API version to use for this operation.", + "description": "The ID of the file.", "schema": { "type": "string" }, - "explode": false + "x-ms-description-override": "The ID of the file." + } + ], + "responses": { + "200": { + "description": "The request has succeeded." + }, + "4XX": { + "description": "Client error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } + }, + "5XX": { + "description": "Server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } + } + }, + "tags": [ + "Containers" + ], + "x-oaiMeta": { + "name": "Retrieve container file content", + "group": "containers", + "path": "get", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/containers/container_123/files/cfile_456/content \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst content = await client.containers.files.content.retrieve('file_id', {\n container_id: 'container_id',\n});\n\nconsole.log(content);\n\nconst data = await content.blob();\nconsole.log(data);", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\ncontent = client.containers.files.content.retrieve(\n file_id=\"file_id\",\n container_id=\"container_id\",\n)\nprint(content)\ndata = content.read()\nprint(data)", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tcontent, err := client.Containers.Files.Content.Get(\n\t\tcontext.TODO(),\n\t\t\"container_id\",\n\t\t\"file_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", content)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.core.http.HttpResponse;\nimport com.openai.models.containers.files.content.ContentRetrieveParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ContentRetrieveParams params = ContentRetrieveParams.builder()\n .containerId(\"container_id\")\n .fileId(\"file_id\")\n .build();\n HttpResponse content = client.containers().files().content().retrieve(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\ncontent = openai.containers.files.content.retrieve(\"file_id\", container_id: \"container_id\")\n\nputs(content)" + }, + "response": "\n" + } + } + } + }, + "/openai/v1/conversations": { + "post": { + "operationId": "createConversation", + "summary": "Create a conversation", + "description": "Creates a new conversation resource.", + "parameters": [ + { + "name": "x-ms-user-identity", + "in": "header", + "required": false, + "description": "Opaque per-user identity string used to scope endpoint-scoped data to a specific end user. The caller must have the `agents/endpoints/UserIdentityImpersonation/action` RBAC permission.", + "schema": { + "type": "string" + } } ], "responses": { @@ -12185,7 +12599,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OpenAI.FineTuningJob" + "$ref": "#/components/schemas/OpenAI.ConversationResource" } } } @@ -12212,34 +12626,112 @@ } }, "tags": [ - "Fine-Tuning" - ] - } - }, - "/openai/v1/fine_tuning/jobs/{fine_tuning_job_id}/resume": { - "post": { - "operationId": "resumeFineTuningJob", - "summary": "Resume a fine-tuning job", - "description": "Resumes the specified fine-tuning job after it has been paused.", + "Conversations" + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAI.CreateConversationBody" + } + } + } + }, + "x-oaiMeta": { + "name": "Create a conversation", + "group": "conversations", + "path": "create", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/conversations \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"metadata\": {\"topic\": \"demo\"},\n \"items\": [\n {\n \"type\": \"message\",\n \"role\": \"user\",\n \"content\": \"Hello!\"\n }\n ]\n }'\n", + "javascript": "import OpenAI from \"openai\";\nconst client = new OpenAI();\n\nconst conversation = await client.conversations.create({\n metadata: { topic: \"demo\" },\n items: [\n { type: \"message\", role: \"user\", content: \"Hello!\" }\n ],\n});\nconsole.log(conversation);\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nconversation = client.conversations.create()\nprint(conversation.id)", + "csharp": "using System;\nusing System.Collections.Generic;\nusing OpenAI.Conversations;\n\nOpenAIConversationClient client = new(\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nConversation conversation = client.CreateConversation(\n new CreateConversationOptions\n {\n Metadata = new Dictionary\n {\n { \"topic\", \"demo\" }\n },\n Items =\n {\n new ConversationMessageInput\n {\n Role = \"user\",\n Content = \"Hello!\",\n }\n }\n }\n);\nConsole.WriteLine(conversation.Id);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst conversation = await client.conversations.create();\n\nconsole.log(conversation.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/conversations\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tconversation, err := client.Conversations.New(context.TODO(), conversations.ConversationNewParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", conversation.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.conversations.Conversation;\nimport com.openai.models.conversations.ConversationCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n Conversation conversation = client.conversations().create();\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nconversation = openai.conversations.create\n\nputs(conversation)" + }, + "response": "{\n \"id\": \"conv_123\",\n \"object\": \"conversation\",\n \"created_at\": 1741900000,\n \"metadata\": {\"topic\": \"demo\"}\n}\n" + } + } + }, + "get": { + "operationId": "listConversations", + "summary": "List conversations", + "description": "Returns the conversations available in the current project.", "parameters": [ { - "name": "fine_tuning_job_id", - "in": "path", - "required": true, - "description": "The ID of the fine-tuning job to resume.", + "name": "limit", + "in": "query", + "required": false, + "description": "A limit on the number of objects to be returned. Limit can range between 1 and 100, and the\ndefault is 20.", + "schema": { + "type": "integer", + "format": "int32", + "default": 20 + }, + "explode": false + }, + { + "name": "order", + "in": "query", + "required": false, + "description": "Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`\nfor descending order.", + "schema": { + "$ref": "#/components/schemas/PageOrder" + }, + "explode": false + }, + { + "name": "after", + "in": "query", + "required": false, + "description": "A cursor for use in pagination. `after` is an object ID that defines your place in the list.\nFor instance, if you make a list request and receive 100 objects, ending with obj_foo, your\nsubsequent call can include after=obj_foo in order to fetch the next page of the list.", "schema": { "type": "string" - } + }, + "explode": false }, { - "name": "api-version", + "name": "before", "in": "query", - "required": true, - "description": "The API version to use for this operation.", + "required": false, + "description": "A cursor for use in pagination. `before` is an object ID that defines your place in the list.\nFor instance, if you make a list request and receive 100 objects, ending with obj_foo, your\nsubsequent call can include before=obj_foo in order to fetch the previous page of the list.", + "schema": { + "type": "string" + }, + "explode": false + }, + { + "name": "agent_name", + "in": "query", + "required": false, + "description": "Filter by agent name. If provided, only items associated with the specified agent will be returned.", + "schema": { + "type": "string" + }, + "explode": false + }, + { + "name": "agent_id", + "in": "query", + "required": false, + "description": "Filter by agent ID in the format `name:version`. If provided, only items associated with the specified agent ID will be returned.", "schema": { "type": "string" }, "explode": false + }, + { + "name": "x-ms-user-identity", + "in": "header", + "required": false, + "description": "Opaque per-user identity string used to scope endpoint-scoped data to a specific end user. The caller must have the `agents/endpoints/UserIdentityImpersonation/action` RBAC permission.", + "schema": { + "type": "string" + } } ], "responses": { @@ -12248,7 +12740,33 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OpenAI.FineTuningJob" + "type": "object", + "required": [ + "data", + "has_more" + ], + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OpenAI.ConversationResource" + }, + "description": "The requested list of items." + }, + "first_id": { + "type": "string", + "description": "The first ID represented in this list." + }, + "last_id": { + "type": "string", + "description": "The last ID represented in this list." + }, + "has_more": { + "type": "boolean", + "description": "A value indicating whether there are additional values available not captured in this list." + } + }, + "description": "The response data for a requested list of items." } } } @@ -12275,16 +12793,25 @@ } }, "tags": [ - "Fine-Tuning" + "Conversations" ] } }, - "/openai/v1/responses": { + "/openai/v1/conversations/{conversation_id}": { "post": { - "operationId": "createResponse", - "summary": "Create a model response", - "description": "Creates a model response. Provide text or image inputs to generate text or JSON outputs. Have the model call your own custom code or use built-in tools like web search or file search to use your own data as input for the model’s response.", + "operationId": "updateConversation", + "summary": "Update a conversation", + "description": "Modifies the specified conversation's properties.", "parameters": [ + { + "name": "conversation_id", + "in": "path", + "required": true, + "description": "The id of the conversation to update.", + "schema": { + "type": "string" + } + }, { "name": "x-ms-user-identity", "in": "header", @@ -12298,339 +12825,98 @@ "responses": { "200": { "description": "The request has succeeded.", - "headers": { - "x-agent-session-id": { - "required": false, - "description": "Session ID for this request. Only present for hosted agent responses. Returns the provided session ID or an auto-generated one if not provided in the request.", + "content": { + "application/json": { "schema": { - "type": "string" + "$ref": "#/components/schemas/OpenAI.ConversationResource" } } - }, + } + }, + "4XX": { + "description": "Client error", "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "metadata": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.Metadata" - }, - { - "type": "null" - } - ] - }, - "top_logprobs": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.integer" - }, - { - "type": "null" - } - ] - }, - "temperature": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.numeric" - }, - { - "type": "null" - } - ], - "default": 1 - }, - "top_p": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.numeric" - }, - { - "type": "null" - } - ], - "default": 1 - }, - "user": { - "type": "string", - "description": "This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use `prompt_cache_key` instead to maintain caching optimizations.\n A stable identifier for your end-users.\n Used to boost cache hit rates by better bucketing similar requests and to help OpenAI detect and prevent abuse. [Learn more](/docs/guides/safety-best-practices#safety-identifiers).", - "deprecated": true - }, - "safety_identifier": { - "type": "string", - "maxLength": 64, - "description": "A stable identifier used to help detect users of your application that may be violating OpenAI's usage policies.\n The IDs should be a string that uniquely identifies each user, with a maximum length of 64 characters. We recommend hashing their username or email address, in order to avoid sending us any identifying information. [Learn more](/docs/guides/safety-best-practices#safety-identifiers)." - }, - "prompt_cache_key": { - "type": "string", - "description": "Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces the `user` field. [Learn more](/docs/guides/prompt-caching)." - }, - "service_tier": { - "$ref": "#/components/schemas/OpenAI.ServiceTier" - }, - "prompt_cache_retention": { - "anyOf": [ - { - "type": "string", - "enum": [ - "in_memory", - "24h" - ] - }, - { - "type": "null" - } - ] - }, - "previous_response_id": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ] - }, - "model": { - "type": "string", - "description": "The model deployment to use for the creation of this response." - }, - "background": { - "anyOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ] - }, - "max_tool_calls": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.integer" - }, - { - "type": "null" - } - ] - }, - "text": { - "$ref": "#/components/schemas/OpenAI.ResponseTextParam" - }, - "tools": { - "$ref": "#/components/schemas/OpenAI.ToolsArray" - }, - "tool_choice": { - "oneOf": [ - { - "$ref": "#/components/schemas/OpenAI.ToolChoiceOptions" - }, - { - "$ref": "#/components/schemas/OpenAI.ToolChoiceParam" - } - ] - }, - "prompt": { - "$ref": "#/components/schemas/OpenAI.Prompt" - }, - "truncation": { - "anyOf": [ - { - "type": "string", - "enum": [ - "auto", - "disabled" - ] - }, - { - "type": "null" - } - ], - "default": "disabled" - }, - "id": { - "type": "string", - "description": "Unique identifier for this Response." - }, - "object": { - "type": "string", - "enum": [ - "response" - ], - "description": "The object type of this resource - always set to `response`.", - "x-stainless-const": true - }, - "status": { - "type": "string", - "enum": [ - "completed", - "failed", - "in_progress", - "cancelled", - "queued", - "incomplete" - ], - "description": "The status of the response generation. One of `completed`, `failed`,\n `in_progress`, `cancelled`, `queued`, or `incomplete`." - }, - "created_at": { - "type": "integer", - "format": "unixtime", - "description": "Unix timestamp (in seconds) of when this Response was created." - }, - "completed_at": { - "anyOf": [ - { - "type": "string", - "format": "date-time" - }, - { - "type": "null" - } - ], - "type": "integer", - "format": "unixTimestamp" - }, - "error": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.ResponseError" - }, - { - "type": "null" - } - ] - }, - "incomplete_details": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.ResponseIncompleteDetails" - }, - { - "type": "null" - } - ] - }, - "output": { - "type": "array", - "items": { - "$ref": "#/components/schemas/OpenAI.OutputItem" - }, - "description": "An array of content items generated by the model.\n - The length and order of items in the `output` array is dependent\n on the model's response.\n - Rather than accessing the first item in the `output` array and\n assuming it's an `assistant` message with the content generated by\n the model, you might consider using the `output_text` property where\n supported in SDKs." - }, - "reasoning": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.Reasoning" - }, - { - "type": "null" - } - ] - }, - "instructions": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "array", - "items": { - "$ref": "#/components/schemas/OpenAI.InputItem" - } - }, - { - "type": "null" - } - ] - }, - "output_text": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ] - }, - "usage": { - "$ref": "#/components/schemas/OpenAI.ResponseUsage" - }, - "moderation": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.Moderation" - }, - { - "type": "null" - } - ] - }, - "parallel_tool_calls": { - "type": "boolean", - "description": "Whether to allow the model to run tool calls in parallel.", - "default": true - }, - "conversation": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.ConversationReference" - }, - { - "type": "null" - } - ] - }, - "max_output_tokens": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.integer" - }, - { - "type": "null" - } - ] - }, - "agent_reference": { - "anyOf": [ - { - "$ref": "#/components/schemas/AgentReference" - }, - { - "type": "null" - } - ], - "description": "The agent used for this response" - }, - "content_filters": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ContentFilterResult" - }, - "description": "The content filter evaluation results." - } - }, - "required": [ - "id", - "object", - "created_at", - "error", - "incomplete_details", - "output", - "instructions", - "parallel_tool_calls", - "agent_reference" - ] + "$ref": "#/components/schemas/ApiErrorResponse" } - }, - "text/event-stream": { + } + } + }, + "5XX": { + "description": "Server error", + "content": { + "application/json": { "schema": { - "$ref": "#/components/schemas/OpenAI.CreateResponseStreamingResponse" + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } + } + }, + "tags": [ + "Conversations" + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAI.UpdateConversationBody" + } + } + } + }, + "x-oaiMeta": { + "name": "Update a conversation", + "group": "conversations", + "path": "update", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/conversations/conv_123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"metadata\": {\"topic\": \"project-x\"}\n }'\n", + "javascript": "import OpenAI from \"openai\";\nconst client = new OpenAI();\n\nconst updated = await client.conversations.update(\n \"conv_123\",\n { metadata: { topic: \"project-x\" } }\n);\nconsole.log(updated);\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nconversation = client.conversations.update(\n conversation_id=\"conv_123\",\n metadata={\n \"foo\": \"string\"\n },\n)\nprint(conversation.id)", + "csharp": "using System;\nusing System.Collections.Generic;\nusing OpenAI.Conversations;\n\nOpenAIConversationClient client = new(\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nConversation updated = client.UpdateConversation(\n conversationId: \"conv_123\",\n new UpdateConversationOptions\n {\n Metadata = new Dictionary\n {\n { \"topic\", \"project-x\" }\n }\n }\n);\nConsole.WriteLine(updated.Id);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst conversation = await client.conversations.update('conv_123', { metadata: { foo: 'string' } });\n\nconsole.log(conversation.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/conversations\"\n\t\"github.com/openai/openai-go/option\"\n\t\"github.com/openai/openai-go/shared\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tconversation, err := client.Conversations.Update(\n\t\tcontext.TODO(),\n\t\t\"conv_123\",\n\t\tconversations.ConversationUpdateParams{\n\t\t\tMetadata: shared.Metadata{\n\t\t\t\t\"foo\": \"string\",\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", conversation.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.core.JsonValue;\nimport com.openai.models.conversations.Conversation;\nimport com.openai.models.conversations.ConversationUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ConversationUpdateParams params = ConversationUpdateParams.builder()\n .conversationId(\"conv_123\")\n .metadata(ConversationUpdateParams.Metadata.builder()\n .putAdditionalProperty(\"foo\", JsonValue.from(\"string\"))\n .build())\n .build();\n Conversation conversation = client.conversations().update(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nconversation = openai.conversations.update(\"conv_123\", metadata: {foo: \"string\"})\n\nputs(conversation)" + }, + "response": "{\n \"id\": \"conv_123\",\n \"object\": \"conversation\",\n \"created_at\": 1741900000,\n \"metadata\": {\"topic\": \"project-x\"}\n}\n" + } + } + }, + "get": { + "operationId": "getConversation", + "summary": "Retrieve a conversation", + "description": "Retrieves the specified conversation and its metadata.", + "parameters": [ + { + "name": "conversation_id", + "in": "path", + "required": true, + "description": "The id of the conversation to retrieve.", + "schema": { + "type": "string" + } + }, + { + "name": "x-ms-user-identity", + "in": "header", + "required": false, + "description": "Opaque per-user identity string used to scope endpoint-scoped data to a specific end user. The caller must have the `agents/endpoints/UserIdentityImpersonation/action` RBAC permission.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAI.ConversationResource" } } } @@ -12657,7 +12943,178 @@ } }, "tags": [ - "Responses" + "Conversations" + ], + "x-oaiMeta": { + "name": "Retrieve a conversation", + "group": "conversations", + "path": "retrieve", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/conversations/conv_123 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "javascript": "import OpenAI from \"openai\";\nconst client = new OpenAI();\n\nconst conversation = await client.conversations.retrieve(\"conv_123\");\nconsole.log(conversation);\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nconversation = client.conversations.retrieve(\n \"conv_123\",\n)\nprint(conversation.id)", + "csharp": "using System;\nusing OpenAI.Conversations;\n\nOpenAIConversationClient client = new(\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nConversation conversation = client.GetConversation(\"conv_123\");\nConsole.WriteLine(conversation.Id);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst conversation = await client.conversations.retrieve('conv_123');\n\nconsole.log(conversation.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tconversation, err := client.Conversations.Get(context.TODO(), \"conv_123\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", conversation.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.conversations.Conversation;\nimport com.openai.models.conversations.ConversationRetrieveParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n Conversation conversation = client.conversations().retrieve(\"conv_123\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nconversation = openai.conversations.retrieve(\"conv_123\")\n\nputs(conversation)" + }, + "response": "{\n \"id\": \"conv_123\",\n \"object\": \"conversation\",\n \"created_at\": 1741900000,\n \"metadata\": {\"topic\": \"demo\"}\n}\n" + } + } + }, + "delete": { + "operationId": "deleteConversation", + "summary": "Delete a conversation", + "description": "Removes the specified conversation resource from the current project.", + "parameters": [ + { + "name": "conversation_id", + "in": "path", + "required": true, + "description": "The id of the conversation to delete.", + "schema": { + "type": "string" + } + }, + { + "name": "x-ms-user-identity", + "in": "header", + "required": false, + "description": "Opaque per-user identity string used to scope endpoint-scoped data to a specific end user. The caller must have the `agents/endpoints/UserIdentityImpersonation/action` RBAC permission.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAI.DeletedConversationResource" + } + } + } + }, + "4XX": { + "description": "Client error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } + }, + "5XX": { + "description": "Server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } + } + }, + "tags": [ + "Conversations" + ], + "x-oaiMeta": { + "name": "Delete a conversation", + "group": "conversations", + "path": "delete", + "examples": { + "request": { + "curl": "curl -X DELETE https://api.openai.com/v1/conversations/conv_123 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "javascript": "import OpenAI from \"openai\";\nconst client = new OpenAI();\n\nconst deleted = await client.conversations.delete(\"conv_123\");\nconsole.log(deleted);\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nconversation_deleted_resource = client.conversations.delete(\n \"conv_123\",\n)\nprint(conversation_deleted_resource.id)", + "csharp": "using System;\nusing OpenAI.Conversations;\n\nOpenAIConversationClient client = new(\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nDeletedConversation deleted = client.DeleteConversation(\"conv_123\");\nConsole.WriteLine(deleted.Id);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst conversationDeletedResource = await client.conversations.delete('conv_123');\n\nconsole.log(conversationDeletedResource.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tconversationDeletedResource, err := client.Conversations.Delete(context.TODO(), \"conv_123\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", conversationDeletedResource.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.conversations.ConversationDeleteParams;\nimport com.openai.models.conversations.ConversationDeletedResource;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ConversationDeletedResource conversationDeletedResource = client.conversations().delete(\"conv_123\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nconversation_deleted_resource = openai.conversations.delete(\"conv_123\")\n\nputs(conversation_deleted_resource)" + }, + "response": "{\n \"id\": \"conv_123\",\n \"object\": \"conversation.deleted\",\n \"deleted\": true\n}\n" + } + } + } + }, + "/openai/v1/conversations/{conversation_id}/items": { + "post": { + "operationId": "createConversationItems", + "summary": "Create conversation items", + "description": "Adds one or more items to the specified conversation.", + "parameters": [ + { + "name": "conversation_id", + "in": "path", + "required": true, + "description": "The id of the conversation on which the item needs to be created.", + "schema": { + "type": "string" + } + }, + { + "name": "include", + "in": "query", + "required": false, + "description": "Additional fields to include in the response.\nSee the `include` parameter for listing Conversation items for more information.", + "schema": { + "type": "array", + "items": { + "type": "string" + } + }, + "explode": false + }, + { + "name": "x-ms-user-identity", + "in": "header", + "required": false, + "description": "Opaque per-user identity string used to scope endpoint-scoped data to a specific end user. The caller must have the `agents/endpoints/UserIdentityImpersonation/action` RBAC permission.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAI.ConversationItemList" + } + } + } + }, + "4XX": { + "description": "Client error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } + }, + "5XX": { + "description": "Server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } + } + }, + "tags": [ + "Conversations" ], "requestBody": { "required": true, @@ -12666,290 +13123,55 @@ "schema": { "type": "object", "properties": { - "metadata": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.Metadata" - }, - { - "type": "null" - } - ] - }, - "top_logprobs": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.integer" - }, - { - "type": "null" - } - ] - }, - "temperature": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.numeric" - }, - { - "type": "null" - } - ], - "default": 1 - }, - "top_p": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.numeric" - }, - { - "type": "null" - } - ], - "default": 1 - }, - "user": { - "type": "string", - "description": "This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use `prompt_cache_key` instead to maintain caching optimizations.\n A stable identifier for your end-users.\n Used to boost cache hit rates by better bucketing similar requests and to help OpenAI detect and prevent abuse. [Learn more](/docs/guides/safety-best-practices#safety-identifiers).", - "deprecated": true - }, - "safety_identifier": { - "type": "string", - "maxLength": 64, - "description": "A stable identifier used to help detect users of your application that may be violating OpenAI's usage policies.\n The IDs should be a string that uniquely identifies each user, with a maximum length of 64 characters. We recommend hashing their username or email address, in order to avoid sending us any identifying information. [Learn more](/docs/guides/safety-best-practices#safety-identifiers)." - }, - "prompt_cache_key": { - "type": "string", - "description": "Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces the `user` field. [Learn more](/docs/guides/prompt-caching)." - }, - "service_tier": { - "$ref": "#/components/schemas/OpenAI.ServiceTier" - }, - "prompt_cache_retention": { - "anyOf": [ - { - "type": "string", - "enum": [ - "in_memory", - "24h" - ] - }, - { - "type": "null" - } - ] - }, - "previous_response_id": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ] - }, - "model": { - "type": "string", - "description": "The model deployment to use for the creation of this response." - }, - "background": { - "anyOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ] - }, - "max_tool_calls": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.integer" - }, - { - "type": "null" - } - ] - }, - "text": { - "$ref": "#/components/schemas/OpenAI.ResponseTextParam" - }, - "tools": { - "$ref": "#/components/schemas/OpenAI.ToolsArray" - }, - "tool_choice": { - "oneOf": [ - { - "$ref": "#/components/schemas/OpenAI.ToolChoiceOptions" - }, - { - "$ref": "#/components/schemas/OpenAI.ToolChoiceParam" - } - ] - }, - "prompt": { - "$ref": "#/components/schemas/OpenAI.Prompt" - }, - "truncation": { - "anyOf": [ - { - "type": "string", - "enum": [ - "auto", - "disabled" - ] - }, - { - "type": "null" - } - ], - "deprecated": true, - "default": "disabled" - }, - "reasoning": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.Reasoning" - }, - { - "type": "null" - } - ] - }, - "input": { - "$ref": "#/components/schemas/OpenAI.InputParam" - }, - "include": { - "anyOf": [ - { - "type": "array", - "items": { - "$ref": "#/components/schemas/OpenAI.IncludeEnum" - } - }, - { - "type": "null" - } - ] - }, - "parallel_tool_calls": { - "anyOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ], - "default": true - }, - "store": { - "anyOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ], - "default": true - }, - "instructions": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ] - }, - "moderation": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.ModerationParam" - }, - { - "type": "null" - } - ] - }, - "stream": { - "anyOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ] - }, - "stream_options": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.ResponseStreamOptions" - }, - { - "type": "null" - } - ] - }, - "conversation": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.ConversationParam" - }, - { - "type": "null" - } - ] - }, - "context_management": { - "anyOf": [ - { - "type": "array", - "items": { - "$ref": "#/components/schemas/OpenAI.ContextManagementParam" - } - }, - { - "type": "null" - } - ], - "description": "Context management configuration for this request." - }, - "max_output_tokens": { - "anyOf": [ - { - "$ref": "#/components/schemas/OpenAI.integer" - }, - { - "type": "null" - } - ] - }, - "agent_reference": { - "$ref": "#/components/schemas/AgentReference", - "description": "The agent to use for generating the response." - }, - "structured_inputs": { - "type": "object", - "unevaluatedProperties": {}, - "description": "The structured inputs to the response that can participate in prompt template substitution or tool argument bindings." + "items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OpenAI.Item" + }, + "maxItems": 20, + "description": "The items to add to the conversation. You may add up to 20 items at a time." } - } + }, + "required": [ + "items" + ] } } } + }, + "x-oaiMeta": { + "name": "Create items", + "group": "conversations", + "path": "create-item", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/conversations/conv_123/items \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"items\": [\n {\n \"type\": \"message\",\n \"role\": \"user\",\n \"content\": [\n {\"type\": \"input_text\", \"text\": \"Hello!\"}\n ]\n },\n {\n \"type\": \"message\",\n \"role\": \"user\",\n \"content\": [\n {\"type\": \"input_text\", \"text\": \"How are you?\"}\n ]\n }\n ]\n }'\n", + "javascript": "import OpenAI from \"openai\";\nconst client = new OpenAI();\n\nconst items = await client.conversations.items.create(\n \"conv_123\",\n {\n items: [\n {\n type: \"message\",\n role: \"user\",\n content: [{ type: \"input_text\", text: \"Hello!\" }],\n },\n {\n type: \"message\",\n role: \"user\",\n content: [{ type: \"input_text\", text: \"How are you?\" }],\n },\n ],\n }\n);\nconsole.log(items.data);\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nconversation_item_list = client.conversations.items.create(\n conversation_id=\"conv_123\",\n items=[{\n \"content\": \"string\",\n \"role\": \"user\",\n \"type\": \"message\",\n }],\n)\nprint(conversation_item_list.first_id)", + "csharp": "using System;\nusing System.Collections.Generic;\nusing OpenAI.Conversations;\n\nOpenAIConversationClient client = new(\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nConversationItemList created = client.ConversationItems.Create(\n conversationId: \"conv_123\",\n new CreateConversationItemsOptions\n {\n Items = new List\n {\n new ConversationMessage\n {\n Role = \"user\",\n Content =\n {\n new ConversationInputText { Text = \"Hello!\" }\n }\n },\n new ConversationMessage\n {\n Role = \"user\",\n Content =\n {\n new ConversationInputText { Text = \"How are you?\" }\n }\n }\n }\n }\n);\nConsole.WriteLine(created.Data.Count);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst conversationItemList = await client.conversations.items.create('conv_123', {\n items: [\n {\n content: 'string',\n role: 'user',\n type: 'message',\n },\n ],\n});\n\nconsole.log(conversationItemList.first_id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/conversations\"\n\t\"github.com/openai/openai-go/option\"\n\t\"github.com/openai/openai-go/responses\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tconversationItemList, err := client.Conversations.Items.New(\n\t\tcontext.TODO(),\n\t\t\"conv_123\",\n\t\tconversations.ItemNewParams{\n\t\t\tItems: []responses.ResponseInputItemUnionParam{{\n\t\t\t\tOfMessage: &responses.EasyInputMessageParam{\n\t\t\t\t\tContent: responses.EasyInputMessageContentUnionParam{\n\t\t\t\t\t\tOfString: openai.String(\"string\"),\n\t\t\t\t\t},\n\t\t\t\t\tRole: responses.EasyInputMessageRoleUser,\n\t\t\t\t\tType: responses.EasyInputMessageTypeMessage,\n\t\t\t\t},\n\t\t\t}},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", conversationItemList.FirstID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.conversations.items.ConversationItemList;\nimport com.openai.models.conversations.items.ItemCreateParams;\nimport com.openai.models.responses.EasyInputMessage;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ItemCreateParams params = ItemCreateParams.builder()\n .conversationId(\"conv_123\")\n .addItem(EasyInputMessage.builder()\n .content(\"string\")\n .role(EasyInputMessage.Role.USER)\n .type(EasyInputMessage.Type.MESSAGE)\n .build())\n .build();\n ConversationItemList conversationItemList = client.conversations().items().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nconversation_item_list = openai.conversations.items.create(\"conv_123\", items: [{content: \"string\", role: :user, type: :message}])\n\nputs(conversation_item_list)" + }, + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"type\": \"message\",\n \"id\": \"msg_abc\",\n \"status\": \"completed\",\n \"role\": \"user\",\n \"content\": [\n {\"type\": \"input_text\", \"text\": \"Hello!\"}\n ]\n },\n {\n \"type\": \"message\",\n \"id\": \"msg_def\",\n \"status\": \"completed\",\n \"role\": \"user\",\n \"content\": [\n {\"type\": \"input_text\", \"text\": \"How are you?\"}\n ]\n }\n ],\n \"first_id\": \"msg_abc\",\n \"last_id\": \"msg_def\",\n \"has_more\": false\n}\n" + } } }, "get": { - "operationId": "listResponses", - "summary": "List responses", - "description": "Returns a collection of all stored responses matching specified filter criteria.", + "operationId": "listConversationItems", + "summary": "List conversation items", + "description": "Returns the items belonging to the specified conversation.", "parameters": [ + { + "name": "conversation_id", + "in": "path", + "required": true, + "description": "The id of the conversation on which the items needs to be listed.", + "schema": { + "type": "string" + } + }, { "name": "limit", "in": "query", @@ -12993,32 +13215,12 @@ "explode": false }, { - "name": "agent_name", - "in": "query", - "required": false, - "description": "Filter by agent name. If provided, only items associated with the specified agent will be returned.", - "schema": { - "type": "string" - }, - "explode": false - }, - { - "name": "agent_id", - "in": "query", - "required": false, - "description": "Filter by agent ID in the format `name:version`. If provided, only items associated with the specified agent ID will be returned.", - "schema": { - "type": "string" - }, - "explode": false - }, - { - "name": "conversation_id", + "name": "item_type", "in": "query", "required": false, - "description": "Filter by conversation ID. If provided, only responses associated with the specified conversation will be returned.", + "description": "Filter by item type. If provided, only items of the specified type will be returned.", "schema": { - "type": "string" + "$ref": "#/components/schemas/OpenAI.ItemType" }, "explode": false }, @@ -13047,7 +13249,7 @@ "data": { "type": "array", "items": { - "$ref": "#/components/schemas/OpenAI.Response" + "$ref": "#/components/schemas/OpenAI.OutputItem" }, "description": "The requested list of items." }, @@ -13091,23 +13293,70 @@ } }, "tags": [ - "Responses" - ] + "Conversations" + ], + "x-oaiMeta": { + "name": "List items", + "group": "conversations", + "path": "list-items", + "examples": { + "request": { + "curl": "curl \"https://api.openai.com/v1/conversations/conv_123/items?limit=10\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "javascript": "import OpenAI from \"openai\";\nconst client = new OpenAI();\n\nconst items = await client.conversations.items.list(\"conv_123\", { limit: 10 });\nconsole.log(items.data);\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\npage = client.conversations.items.list(\n conversation_id=\"conv_123\",\n)\npage = page.data[0]\nprint(page)", + "csharp": "using System;\nusing OpenAI.Conversations;\n\nOpenAIConversationClient client = new(\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nConversationItemList items = client.ConversationItems.List(\n conversationId: \"conv_123\",\n new ListConversationItemsOptions { Limit = 10 }\n);\nConsole.WriteLine(items.Data.Count);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const conversationItem of client.conversations.items.list('conv_123')) {\n console.log(conversationItem);\n}", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/conversations\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.Conversations.Items.List(\n\t\tcontext.TODO(),\n\t\t\"conv_123\",\n\t\tconversations.ItemListParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", page)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.conversations.items.ItemListPage;\nimport com.openai.models.conversations.items.ItemListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ItemListPage page = client.conversations().items().list(\"conv_123\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\npage = openai.conversations.items.list(\"conv_123\")\n\nputs(page)" + }, + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"type\": \"message\",\n \"id\": \"msg_abc\",\n \"status\": \"completed\",\n \"role\": \"user\",\n \"content\": [\n {\"type\": \"input_text\", \"text\": \"Hello!\"}\n ]\n }\n ],\n \"first_id\": \"msg_abc\",\n \"last_id\": \"msg_abc\",\n \"has_more\": false\n}\n" + } + }, + "x-ms-list": true } }, - "/openai/v1/responses/compact": { - "post": { - "operationId": "compactResponseConversation", - "summary": "Compact a conversation", - "description": "Compacts a conversation into a response object suitable for long-running and zero-data-retention scenarios.", - "parameters": [], + "/openai/v1/conversations/{conversation_id}/items/{item_id}": { + "get": { + "operationId": "getConversationItem", + "summary": "Get a conversation item", + "description": "Retrieves a specific item from the specified conversation.", + "parameters": [ + { + "name": "conversation_id", + "in": "path", + "required": true, + "description": "The ID of the conversation that contains the item.", + "schema": { + "type": "string" + } + }, + { + "name": "item_id", + "in": "path", + "required": true, + "description": "The id of the conversation item to retrieve.", + "schema": { + "type": "string" + } + }, + { + "name": "x-ms-user-identity", + "in": "header", + "required": false, + "description": "Opaque per-user identity string used to scope endpoint-scoped data to a specific end user. The caller must have the `agents/endpoints/UserIdentityImpersonation/action` RBAC permission.", + "schema": { + "type": "string" + } + } + ], "responses": { "200": { "description": "The request has succeeded.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OpenAI.CompactResource" + "$ref": "#/components/schemas/OpenAI.OutputItem" } } } @@ -13134,66 +13383,50 @@ } }, "tags": [ - "Responses" + "Conversations" ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OpenAI.CompactResponseMethodPublicBody" - } - } + "x-oaiMeta": { + "name": "Retrieve an item", + "group": "conversations", + "path": "get-item", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/conversations/conv_123/items/msg_abc \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "javascript": "import OpenAI from \"openai\";\nconst client = new OpenAI();\n\nconst item = await client.conversations.items.retrieve(\n \"conv_123\",\n \"msg_abc\"\n);\nconsole.log(item);\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nconversation_item = client.conversations.items.retrieve(\n item_id=\"msg_abc\",\n conversation_id=\"conv_123\",\n)\nprint(conversation_item)", + "csharp": "using System;\nusing OpenAI.Conversations;\n\nOpenAIConversationClient client = new(\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nConversationItem item = client.ConversationItems.Get(\n conversationId: \"conv_123\",\n itemId: \"msg_abc\"\n);\nConsole.WriteLine(item.Id);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst conversationItem = await client.conversations.items.retrieve('msg_abc', {\n conversation_id: 'conv_123',\n});\n\nconsole.log(conversationItem);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/conversations\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tconversationItem, err := client.Conversations.Items.Get(\n\t\tcontext.TODO(),\n\t\t\"conv_123\",\n\t\t\"msg_abc\",\n\t\tconversations.ItemGetParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", conversationItem)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.conversations.items.ConversationItem;\nimport com.openai.models.conversations.items.ItemRetrieveParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ItemRetrieveParams params = ItemRetrieveParams.builder()\n .conversationId(\"conv_123\")\n .itemId(\"msg_abc\")\n .build();\n ConversationItem conversationItem = client.conversations().items().retrieve(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nconversation_item = openai.conversations.items.retrieve(\"msg_abc\", conversation_id: \"conv_123\")\n\nputs(conversation_item)" + }, + "response": "{\n \"type\": \"message\",\n \"id\": \"msg_abc\",\n \"status\": \"completed\",\n \"role\": \"user\",\n \"content\": [\n {\"type\": \"input_text\", \"text\": \"Hello!\"}\n ]\n}\n" } } - } - }, - "/openai/v1/responses/{response_id}": { - "get": { - "operationId": "getResponse", - "summary": "Retrieve a model response", - "description": "Retrieves a model response with the given ID.", + }, + "delete": { + "operationId": "deleteConversationItem", + "summary": "Delete a conversation item", + "description": "Removes the specified item from a conversation.", "parameters": [ { - "name": "response_id", + "name": "conversation_id", "in": "path", "required": true, + "description": "The id of the conversation on which the item needs to be deleted from.", "schema": { "type": "string" } }, { - "name": "include[]", - "in": "query", - "required": false, + "name": "item_id", + "in": "path", + "required": true, + "description": "The id of the conversation item to delete.", "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/OpenAI.IncludeEnum" - }, - "default": [] + "type": "string" } }, - { - "name": "stream", - "in": "query", - "required": false, - "schema": { - "type": "boolean", - "default": false - }, - "explode": false - }, - { - "name": "starting_after", - "in": "query", - "required": false, - "schema": { - "type": "integer", - "format": "int32" - }, - "explode": false - }, { "name": "x-ms-user-identity", "in": "header", @@ -13207,24 +13440,10 @@ "responses": { "200": { "description": "The request has succeeded.", - "headers": { - "x-agent-session-id": { - "required": false, - "description": "Session ID for this request. Only present for hosted agent responses. Returns the provided session ID or an auto-generated one if not provided in the request.", - "schema": { - "type": "string" - } - } - }, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/OpenAI.Response" - } - }, - "text/event-stream": { - "schema": { - "$ref": "#/components/schemas/OpenAI.CreateResponseStreamingResponse" + "$ref": "#/components/schemas/OpenAI.ConversationResource" } } } @@ -13251,49 +13470,41 @@ } }, "tags": [ - "Responses" - ] - }, - "delete": { - "operationId": "deleteResponse", - "summary": "Delete a model response", - "description": "Deletes a model response.", - "parameters": [ - { - "name": "response_id", - "in": "path", - "required": true, - "description": "The ID of the response to delete.", - "schema": { - "type": "string" - } - }, - { - "name": "x-ms-user-identity", - "in": "header", - "required": false, - "description": "Opaque per-user identity string used to scope endpoint-scoped data to a specific end user. The caller must have the `agents/endpoints/UserIdentityImpersonation/action` RBAC permission.", - "schema": { - "type": "string" - } - } + "Conversations" ], + "x-oaiMeta": { + "name": "Delete an item", + "group": "conversations", + "path": "delete-item", + "examples": { + "request": { + "curl": "curl -X DELETE https://api.openai.com/v1/conversations/conv_123/items/msg_abc \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "javascript": "import OpenAI from \"openai\";\nconst client = new OpenAI();\n\nconst conversation = await client.conversations.items.delete(\n \"conv_123\",\n \"msg_abc\"\n);\nconsole.log(conversation);\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nconversation = client.conversations.items.delete(\n item_id=\"msg_abc\",\n conversation_id=\"conv_123\",\n)\nprint(conversation.id)", + "csharp": "using System;\nusing OpenAI.Conversations;\n\nOpenAIConversationClient client = new(\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nConversation conversation = client.ConversationItems.Delete(\n conversationId: \"conv_123\",\n itemId: \"msg_abc\"\n);\nConsole.WriteLine(conversation.Id);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst conversation = await client.conversations.items.delete('msg_abc', {\n conversation_id: 'conv_123',\n});\n\nconsole.log(conversation.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tconversation, err := client.Conversations.Items.Delete(\n\t\tcontext.TODO(),\n\t\t\"conv_123\",\n\t\t\"msg_abc\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", conversation.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.conversations.Conversation;\nimport com.openai.models.conversations.items.ItemDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ItemDeleteParams params = ItemDeleteParams.builder()\n .conversationId(\"conv_123\")\n .itemId(\"msg_abc\")\n .build();\n Conversation conversation = client.conversations().items().delete(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nconversation = openai.conversations.items.delete(\"msg_abc\", conversation_id: \"conv_123\")\n\nputs(conversation)" + }, + "response": "{\n \"id\": \"conv_123\",\n \"object\": \"conversation\",\n \"created_at\": 1741900000,\n \"metadata\": {\"topic\": \"demo\"}\n}\n" + } + } + } + }, + "/openai/v1/embeddings": { + "post": { + "operationId": "Embeddings_createEmbedding", + "summary": "Create an embedding", + "description": "Creates an embedding from the supplied request.", + "parameters": [], "responses": { "200": { "description": "The request has succeeded.", - "headers": { - "x-agent-session-id": { - "required": false, - "description": "Session ID for this request. Only present for hosted agent responses. Returns the provided session ID or an auto-generated one if not provided in the request.", - "schema": { - "type": "string" - } - } - }, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/DeleteResponseResult" + "$ref": "#/components/schemas/OpenAI.CreateEmbeddingResponse" } } } @@ -13320,159 +13531,98 @@ } }, "tags": [ - "Responses" - ] - } - }, - "/openai/v1/responses/{response_id}/cancel": { - "post": { - "operationId": "cancelResponse", - "summary": "Cancel a model response", - "description": "Cancels a model response with the given ID. Only responses created with the background parameter set to true can be cancelled.", - "parameters": [ - { - "name": "response_id", - "in": "path", - "required": true, - "description": "The ID of the response to cancel.", - "schema": { - "type": "string" - } - }, - { - "name": "x-ms-user-identity", - "in": "header", - "required": false, - "description": "Opaque per-user identity string used to scope endpoint-scoped data to a specific end user. The caller must have the `agents/endpoints/UserIdentityImpersonation/action` RBAC permission.", - "schema": { - "type": "string" - } - } + "Embeddings" ], - "responses": { - "200": { - "description": "The request has succeeded.", - "headers": { - "x-agent-session-id": { - "required": false, - "description": "Session ID for this request. Only present for hosted agent responses. Returns the provided session ID or an auto-generated one if not provided in the request.", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OpenAI.Response" - } - } - } - }, - "4XX": { - "description": "Client error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiErrorResponse" - } + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAI.CreateEmbeddingRequest" } } }, - "5XX": { - "description": "Server error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiErrorResponse" - } - } - } - } + "description": "The request body." }, - "tags": [ - "Responses" - ] + "x-oaiMeta": { + "name": "Create embeddings", + "group": "embeddings", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/embeddings \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"input\": \"The food was delicious and the waiter...\",\n \"model\": \"text-embedding-ada-002\",\n \"encoding_format\": \"float\"\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\ncreate_embedding_response = client.embeddings.create(\n input=\"The quick brown fox jumped over the lazy dog\",\n model=\"text-embedding-3-small\",\n)\nprint(create_embedding_response.data)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const embedding = await openai.embeddings.create({\n model: \"text-embedding-ada-002\",\n input: \"The quick brown fox jumped over the lazy dog\",\n encoding_format: \"float\",\n });\n\n console.log(embedding);\n}\n\nmain();\n", + "csharp": "using System;\n\nusing OpenAI.Embeddings;\n\nEmbeddingClient client = new(\n model: \"text-embedding-3-small\",\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nOpenAIEmbedding embedding = client.GenerateEmbedding(input: \"The quick brown fox jumped over the lazy dog\");\nReadOnlyMemory vector = embedding.ToFloats();\n\nfor (int i = 0; i < vector.Length; i++)\n{\n Console.WriteLine($\" [{i,4}] = {vector.Span[i]}\");\n}\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst createEmbeddingResponse = await client.embeddings.create({\n input: 'The quick brown fox jumped over the lazy dog',\n model: 'text-embedding-3-small',\n});\n\nconsole.log(createEmbeddingResponse.data);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tcreateEmbeddingResponse, err := client.Embeddings.New(context.TODO(), openai.EmbeddingNewParams{\n\t\tInput: openai.EmbeddingNewParamsInputUnion{\n\t\t\tOfString: openai.String(\"The quick brown fox jumped over the lazy dog\"),\n\t\t},\n\t\tModel: openai.EmbeddingModelTextEmbedding3Small,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", createEmbeddingResponse.Data)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.embeddings.CreateEmbeddingResponse;\nimport com.openai.models.embeddings.EmbeddingCreateParams;\nimport com.openai.models.embeddings.EmbeddingModel;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n EmbeddingCreateParams params = EmbeddingCreateParams.builder()\n .input(\"The quick brown fox jumped over the lazy dog\")\n .model(EmbeddingModel.TEXT_EMBEDDING_3_SMALL)\n .build();\n CreateEmbeddingResponse createEmbeddingResponse = client.embeddings().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\ncreate_embedding_response = openai.embeddings.create(\n input: \"The quick brown fox jumped over the lazy dog\",\n model: :\"text-embedding-3-small\"\n)\n\nputs(create_embedding_response)" + }, + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"object\": \"embedding\",\n \"embedding\": [\n 0.0023064255,\n -0.009327292,\n .... (1536 floats total for ada-002)\n -0.0028842222,\n ],\n \"index\": 0\n }\n ],\n \"model\": \"text-embedding-ada-002\",\n \"usage\": {\n \"prompt_tokens\": 8,\n \"total_tokens\": 8\n }\n}\n" + } + } } }, - "/openai/v1/responses/{response_id}/input_items": { + "/openai/v1/evals": { "get": { - "operationId": "listInputItems", - "summary": "List input items for a response", - "description": "Retrieves the input items associated with the specified response.", + "operationId": "Evals_listEvals", + "summary": "List evaluations", + "description": "Returns the evaluations configured in the current project.", "parameters": [ { - "name": "response_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "limit", + "name": "after", "in": "query", "required": false, - "description": "A limit on the number of objects to be returned. Limit can range between 1 and 100, and the\ndefault is 20.", + "description": "Identifier for the last run from the previous pagination request.", "schema": { - "type": "integer", - "format": "int32", - "default": 20 + "type": "string" }, "explode": false }, { - "name": "order", + "name": "limit", "in": "query", "required": false, - "description": "Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`\nfor descending order.", + "description": "Number of runs to retrieve.", "schema": { - "$ref": "#/components/schemas/PageOrder" + "$ref": "#/components/schemas/integer", + "default": 20 }, "explode": false }, { - "name": "after", + "name": "order", "in": "query", "required": false, - "description": "A cursor for use in pagination. `after` is an object ID that defines your place in the list.\nFor instance, if you make a list request and receive 100 objects, ending with obj_foo, your\nsubsequent call can include after=obj_foo in order to fetch the next page of the list.", + "description": "Sort order for runs by timestamp. Use `asc` for ascending order or `desc` for descending order. Defaults to `asc`.", "schema": { - "type": "string" + "type": "string", + "enum": [ + "asc", + "desc" + ], + "default": "asc" }, "explode": false }, { - "name": "before", + "name": "order_by", "in": "query", "required": false, - "description": "A cursor for use in pagination. `before` is an object ID that defines your place in the list.\nFor instance, if you make a list request and receive 100 objects, ending with obj_foo, your\nsubsequent call can include before=obj_foo in order to fetch the previous page of the list.", - "schema": { - "type": "string" - }, - "explode": false - }, - { - "name": "x-ms-user-identity", - "in": "header", - "required": false, - "description": "Opaque per-user identity string used to scope endpoint-scoped data to a specific end user. The caller must have the `agents/endpoints/UserIdentityImpersonation/action` RBAC permission.", + "description": "Evals can be ordered by creation time or last updated time.\nUse `created_at` for creation time or `updated_at` for last updated time.", "schema": { - "type": "string" + "type": "string", + "enum": [ + "created_at", + "updated_at" + ], + "default": "created_at" } } ], "responses": { "200": { "description": "The request has succeeded.", - "headers": { - "x-agent-session-id": { - "required": false, - "description": "Session ID for this request. Only present for hosted agent responses. Returns the provided session ID or an auto-generated one if not provided in the request.", - "schema": { - "type": "string" - } - } - }, "content": { "application/json": { "schema": { @@ -13485,7 +13635,7 @@ "data": { "type": "array", "items": { - "$ref": "#/components/schemas/OpenAI.ItemResource" + "$ref": "#/components/schemas/Eval" }, "description": "The requested list of items." }, @@ -13529,29 +13679,107 @@ } }, "tags": [ - "Responses" - ] + "Evals" + ], + "x-oaiMeta": { + "name": "List evals", + "group": "evals", + "path": "list", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/evals?limit=1 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\npage = client.evals.list()\npage = page.data[0]\nprint(page.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nconst evals = await openai.evals.list({ limit: 1 });\nconsole.log(evals);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const evalListResponse of client.evals.list()) {\n console.log(evalListResponse.id);\n}", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.evals.EvalListPage;\nimport com.openai.models.evals.EvalListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n EvalListPage page = client.evals().list();\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\npage = openai.evals.list\n\nputs(page)" + }, + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"eval_67abd54d9b0081909a86353f6fb9317a\",\n \"object\": \"eval\",\n \"data_source_config\": {\n \"type\": \"stored_completions\",\n \"metadata\": {\n \"usecase\": \"push_notifications_summarizer\"\n },\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"item\": {\n \"type\": \"object\"\n },\n \"sample\": {\n \"type\": \"object\"\n }\n },\n \"required\": [\n \"item\",\n \"sample\"\n ]\n }\n },\n \"testing_criteria\": [\n {\n \"name\": \"Push Notification Summary Grader\",\n \"id\": \"Push Notification Summary Grader-9b876f24-4762-4be9-aff4-db7a9b31c673\",\n \"type\": \"label_model\",\n \"model\": \"o3-mini\",\n \"input\": [\n {\n \"type\": \"message\",\n \"role\": \"developer\",\n \"content\": {\n \"type\": \"input_text\",\n \"text\": \"\nLabel the following push notification summary as either correct or incorrect.\nThe push notification and the summary will be provided below.\nA good push notificiation summary is concise and snappy.\nIf it is good, then label it as correct, if not, then incorrect.\n\"\n }\n },\n {\n \"type\": \"message\",\n \"role\": \"user\",\n \"content\": {\n \"type\": \"input_text\",\n \"text\": \"\nPush notifications: {{item.input}}\nSummary: {{sample.output_text}}\n\"\n }\n }\n ],\n \"passing_labels\": [\n \"correct\"\n ],\n \"labels\": [\n \"correct\",\n \"incorrect\"\n ],\n \"sampling_params\": null\n }\n ],\n \"name\": \"Push Notification Summary Grader\",\n \"created_at\": 1739314509,\n \"metadata\": {\n \"description\": \"A stored completions eval for push notification summaries\"\n }\n }\n ],\n \"first_id\": \"eval_67abd54d9b0081909a86353f6fb9317a\",\n \"last_id\": \"eval_67aa884cf6688190b58f657d4441c8b7\",\n \"has_more\": true\n}\n" + } + }, + "x-ms-list": true + }, + "post": { + "operationId": "Evals_createEval", + "summary": "Create an evaluation", + "description": "Creates the structure of an evaluation that can be used to test a model's performance.\nAn evaluation is a set of testing criteria and the config for a data source, which dictates the schema of the data used in the evaluation. After creating an evaluation, you can run it on different models and model parameters. We support several types of graders and datasources.\nFor more information, see the [Evals guide](https://platform.openai.com/docs/guides/evals).", + "parameters": [], + "responses": { + "200": { + "description": "The request has succeeded.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Eval" + } + } + } + }, + "4XX": { + "description": "Client error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } + }, + "5XX": { + "description": "Server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } + } + }, + "tags": [ + "Evals" + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateEvalRequest" + } + } + } + }, + "x-oaiMeta": { + "name": "Create eval", + "group": "evals", + "path": "post", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/evals \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Sentiment\",\n \"data_source_config\": {\n \"type\": \"stored_completions\",\n \"metadata\": {\n \"usecase\": \"chatbot\"\n }\n },\n \"testing_criteria\": [\n {\n \"type\": \"label_model\",\n \"model\": \"o3-mini\",\n \"input\": [\n {\n \"role\": \"developer\",\n \"content\": \"Classify the sentiment of the following statement as one of 'positive', 'neutral', or 'negative'\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Statement: {{item.input}}\"\n }\n ],\n \"passing_labels\": [\n \"positive\"\n ],\n \"labels\": [\n \"positive\",\n \"neutral\",\n \"negative\"\n ],\n \"name\": \"Example label grader\"\n }\n ]\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\neval = client.evals.create(\n data_source_config={\n \"item_schema\": {\n \"foo\": \"bar\"\n },\n \"type\": \"custom\",\n },\n testing_criteria=[{\n \"input\": [{\n \"content\": \"content\",\n \"role\": \"role\",\n }],\n \"labels\": [\"string\"],\n \"model\": \"model\",\n \"name\": \"name\",\n \"passing_labels\": [\"string\"],\n \"type\": \"label_model\",\n }],\n)\nprint(eval.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nconst evalObj = await openai.evals.create({\n name: \"Sentiment\",\n data_source_config: {\n type: \"stored_completions\",\n metadata: { usecase: \"chatbot\" }\n },\n testing_criteria: [\n {\n type: \"label_model\",\n model: \"o3-mini\",\n input: [\n { role: \"developer\", content: \"Classify the sentiment of the following statement as one of 'positive', 'neutral', or 'negative'\" },\n { role: \"user\", content: \"Statement: {{item.input}}\" }\n ],\n passing_labels: [\"positive\"],\n labels: [\"positive\", \"neutral\", \"negative\"],\n name: \"Example label grader\"\n }\n ]\n});\nconsole.log(evalObj);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst _eval = await client.evals.create({\n data_source_config: {\n item_schema: { foo: 'bar' },\n type: 'custom',\n },\n testing_criteria: [\n {\n input: [{ content: 'content', role: 'role' }],\n labels: ['string'],\n model: 'model',\n name: 'name',\n passing_labels: ['string'],\n type: 'label_model',\n },\n ],\n});\n\nconsole.log(_eval.id);", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.core.JsonValue;\nimport com.openai.models.evals.EvalCreateParams;\nimport com.openai.models.evals.EvalCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n EvalCreateParams params = EvalCreateParams.builder()\n .customDataSourceConfig(EvalCreateParams.DataSourceConfig.Custom.ItemSchema.builder()\n .putAdditionalProperty(\"foo\", JsonValue.from(\"bar\"))\n .build())\n .addTestingCriterion(EvalCreateParams.TestingCriterion.LabelModel.builder()\n .addInput(EvalCreateParams.TestingCriterion.LabelModel.Input.SimpleInputMessage.builder()\n .content(\"content\")\n .role(\"role\")\n .build())\n .addLabel(\"string\")\n .model(\"model\")\n .name(\"name\")\n .addPassingLabel(\"string\")\n .build())\n .build();\n EvalCreateResponse eval = client.evals().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\neval_ = openai.evals.create(\n data_source_config: {item_schema: {foo: \"bar\"}, type: :custom},\n testing_criteria: [\n {\n input: [{content: \"content\", role: \"role\"}],\n labels: [\"string\"],\n model: \"model\",\n name: \"name\",\n passing_labels: [\"string\"],\n type: :label_model\n }\n ]\n)\n\nputs(eval_)" + }, + "response": "{\n \"object\": \"eval\",\n \"id\": \"eval_67b7fa9a81a88190ab4aa417e397ea21\",\n \"data_source_config\": {\n \"type\": \"stored_completions\",\n \"metadata\": {\n \"usecase\": \"chatbot\"\n },\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"item\": {\n \"type\": \"object\"\n },\n \"sample\": {\n \"type\": \"object\"\n }\n },\n \"required\": [\n \"item\",\n \"sample\"\n ]\n },\n \"testing_criteria\": [\n {\n \"name\": \"Example label grader\",\n \"type\": \"label_model\",\n \"model\": \"o3-mini\",\n \"input\": [\n {\n \"type\": \"message\",\n \"role\": \"developer\",\n \"content\": {\n \"type\": \"input_text\",\n \"text\": \"Classify the sentiment of the following statement as one of positive, neutral, or negative\"\n }\n },\n {\n \"type\": \"message\",\n \"role\": \"user\",\n \"content\": {\n \"type\": \"input_text\",\n \"text\": \"Statement: {{item.input}}\"\n }\n }\n ],\n \"passing_labels\": [\n \"positive\"\n ],\n \"labels\": [\n \"positive\",\n \"neutral\",\n \"negative\"\n ]\n }\n ],\n \"name\": \"Sentiment\",\n \"created_at\": 1740110490,\n \"metadata\": {\n \"description\": \"An eval for sentiment analysis\"\n }\n}\n" + } + } } }, - "/redTeams/runs": { - "get": { - "operationId": "RedTeams_list", - "summary": "List redteams", - "description": "Returns the redteams available in the current project.", + "/openai/v1/evals/{eval_id}": { + "delete": { + "operationId": "Evals_deleteEval", + "summary": "Delete an evaluation", + "description": "Removes the specified evaluation and its associated data.", "parameters": [ { - "$ref": "#/components/parameters/Azure.Core.Foundations.ApiVersionParameter" - }, - { - "name": "Foundry-Features", - "in": "header", + "name": "eval_id", + "in": "path", "required": true, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", + "description": "The ID of the evaluation to delete.", "schema": { - "type": "string", - "enum": [ - "RedTeams=V1Preview" - ] + "type": "string" } } ], @@ -13561,84 +13789,64 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PagedRedTeam" + "$ref": "#/components/schemas/DeleteEvalResponse" } } } }, "4XX": { "description": "Client error", - "headers": { - "x-ms-error-code": { - "required": false, - "description": "String error code indicating what went wrong.", - "schema": { - "type": "string" - } - } - }, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Azure.Core.Foundations.ErrorResponse" + "$ref": "#/components/schemas/ApiErrorResponse" } } } }, "5XX": { "description": "Server error", - "headers": { - "x-ms-error-code": { - "required": false, - "description": "String error code indicating what went wrong.", - "schema": { - "type": "string" - } - } - }, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Azure.Core.Foundations.ErrorResponse" + "$ref": "#/components/schemas/ApiErrorResponse" } } } } }, "tags": [ - "Redteams" - ] - } - }, - "/redTeams/runs/{name}": { + "Evals" + ], + "x-oaiMeta": { + "name": "Delete an eval", + "group": "evals", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/evals/eval_abc123 \\\n -X DELETE \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\neval = client.evals.delete(\n \"eval_id\",\n)\nprint(eval.eval_id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nconst deleted = await openai.evals.delete(\"eval_abc123\");\nconsole.log(deleted);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst _eval = await client.evals.delete('eval_id');\n\nconsole.log(_eval.eval_id);", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.evals.EvalDeleteParams;\nimport com.openai.models.evals.EvalDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n EvalDeleteResponse eval = client.evals().delete(\"eval_id\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\neval_ = openai.evals.delete(\"eval_id\")\n\nputs(eval_)" + }, + "response": "{\n \"object\": \"eval.deleted\",\n \"deleted\": true,\n \"eval_id\": \"eval_abc123\"\n}\n" + } + } + }, "get": { - "operationId": "RedTeams_get", - "summary": "Get a redteam", - "description": "Retrieves the specified redteam and its configuration.", + "operationId": "Evals_getEval", + "summary": "Get an evaluation", + "description": "Retrieves the specified evaluation and its configuration.", "parameters": [ { - "$ref": "#/components/parameters/Azure.Core.Foundations.ApiVersionParameter" - }, - { - "name": "name", + "name": "eval_id", "in": "path", "required": true, - "description": "Identifier of the red team run.", + "description": "The ID of the evaluation to retrieve.", "schema": { "type": "string" } - }, - { - "name": "Foundry-Features", - "in": "header", - "required": true, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", - "schema": { - "type": "string", - "enum": [ - "RedTeams=V1Preview" - ] - } } ], "responses": { @@ -13647,91 +13855,74 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RedTeam" + "$ref": "#/components/schemas/Eval" } } } }, "4XX": { "description": "Client error", - "headers": { - "x-ms-error-code": { - "required": false, - "description": "String error code indicating what went wrong.", - "schema": { - "type": "string" - } - } - }, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Azure.Core.Foundations.ErrorResponse" + "$ref": "#/components/schemas/ApiErrorResponse" } } } }, "5XX": { "description": "Server error", - "headers": { - "x-ms-error-code": { - "required": false, - "description": "String error code indicating what went wrong.", - "schema": { - "type": "string" - } - } - }, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Azure.Core.Foundations.ErrorResponse" + "$ref": "#/components/schemas/ApiErrorResponse" } } } } }, "tags": [ - "Redteams" - ] - } - }, - "/redTeams/runs:run": { + "Evals" + ], + "x-oaiMeta": { + "name": "Get an eval", + "group": "evals", + "path": "get", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/evals/eval_67abd54d9b0081909a86353f6fb9317a \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\neval = client.evals.retrieve(\n \"eval_id\",\n)\nprint(eval.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nconst evalObj = await openai.evals.retrieve(\"eval_67abd54d9b0081909a86353f6fb9317a\");\nconsole.log(evalObj);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst _eval = await client.evals.retrieve('eval_id');\n\nconsole.log(_eval.id);", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.evals.EvalRetrieveParams;\nimport com.openai.models.evals.EvalRetrieveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n EvalRetrieveResponse eval = client.evals().retrieve(\"eval_id\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\neval_ = openai.evals.retrieve(\"eval_id\")\n\nputs(eval_)" + }, + "response": "{\n \"object\": \"eval\",\n \"id\": \"eval_67abd54d9b0081909a86353f6fb9317a\",\n \"data_source_config\": {\n \"type\": \"custom\",\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"item\": {\n \"type\": \"object\",\n \"properties\": {\n \"input\": {\n \"type\": \"string\"\n },\n \"ground_truth\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"input\",\n \"ground_truth\"\n ]\n }\n },\n \"required\": [\n \"item\"\n ]\n }\n },\n \"testing_criteria\": [\n {\n \"name\": \"String check\",\n \"id\": \"String check-2eaf2d8d-d649-4335-8148-9535a7ca73c2\",\n \"type\": \"string_check\",\n \"input\": \"{{item.input}}\",\n \"reference\": \"{{item.ground_truth}}\",\n \"operation\": \"eq\"\n }\n ],\n \"name\": \"External Data Eval\",\n \"created_at\": 1739314509,\n \"metadata\": {},\n}\n" + } + } + }, "post": { - "operationId": "RedTeams_create", - "summary": "Create a redteam run", - "description": "Submits a new redteam run for execution with the provided configuration.", + "operationId": "Evals_updateEval", + "summary": "Update an evaluation", + "description": "Updates certain properties of an evaluation.", "parameters": [ { - "name": "Foundry-Features", - "in": "header", - "required": true, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", - "schema": { - "type": "string", - "enum": [ - "RedTeams=V1Preview" - ] - } - }, - { - "name": "api-version", - "in": "query", + "name": "eval_id", + "in": "path", "required": true, - "description": "The API version to use for this operation.", + "description": "The ID of the evaluation to update.", "schema": { "type": "string" - }, - "explode": false + } } ], "responses": { - "201": { - "description": "The request has succeeded and a new resource has been created as a result.", + "200": { + "description": "The request has succeeded.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RedTeam" + "$ref": "#/components/schemas/Eval" } } } @@ -13758,58 +13949,101 @@ } }, "tags": [ - "Redteams" + "Evals" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RedTeam" + "$ref": "#/components/schemas/UpdateEvalParametersBody" } } - }, - "description": "Redteam to be run" + } + }, + "x-oaiMeta": { + "name": "Update an eval", + "group": "evals", + "path": "update", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/evals/eval_67abd54d9b0081909a86353f6fb9317a \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"name\": \"Updated Eval\", \"metadata\": {\"description\": \"Updated description\"}}'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\neval = client.evals.update(\n eval_id=\"eval_id\",\n)\nprint(eval.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nconst updatedEval = await openai.evals.update(\n \"eval_67abd54d9b0081909a86353f6fb9317a\",\n {\n name: \"Updated Eval\",\n metadata: { description: \"Updated description\" }\n }\n);\nconsole.log(updatedEval);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst _eval = await client.evals.update('eval_id');\n\nconsole.log(_eval.id);", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.evals.EvalUpdateParams;\nimport com.openai.models.evals.EvalUpdateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n EvalUpdateResponse eval = client.evals().update(\"eval_id\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\neval_ = openai.evals.update(\"eval_id\")\n\nputs(eval_)" + }, + "response": "{\n \"object\": \"eval\",\n \"id\": \"eval_67abd54d9b0081909a86353f6fb9317a\",\n \"data_source_config\": {\n \"type\": \"custom\",\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"item\": {\n \"type\": \"object\",\n \"properties\": {\n \"input\": {\n \"type\": \"string\"\n },\n \"ground_truth\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"input\",\n \"ground_truth\"\n ]\n }\n },\n \"required\": [\n \"item\"\n ]\n }\n },\n \"testing_criteria\": [\n {\n \"name\": \"String check\",\n \"id\": \"String check-2eaf2d8d-d649-4335-8148-9535a7ca73c2\",\n \"type\": \"string_check\",\n \"input\": \"{{item.input}}\",\n \"reference\": \"{{item.ground_truth}}\",\n \"operation\": \"eq\"\n }\n ],\n \"name\": \"Updated Eval\",\n \"created_at\": 1739314509,\n \"metadata\": {\"description\": \"Updated description\"},\n}\n" + } } } }, - "/routines": { + "/openai/v1/evals/{eval_id}/runs": { "get": { - "operationId": "listRoutines", - "summary": "List routines", - "description": "Returns the routines available in the current project.", + "operationId": "Evals_listRuns", + "summary": "List evaluation runs", + "description": "Returns the runs associated with the specified evaluation.", "parameters": [ { - "name": "Foundry-Features", - "in": "header", - "required": false, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", + "name": "eval_id", + "in": "path", + "required": true, + "description": "The ID of the evaluation to retrieve runs for.", "schema": { - "type": "string", - "enum": [ - "Routines=V1Preview" - ] + "type": "string" } }, { - "$ref": "#/components/parameters/ListRoutinesParameters.limit" - }, - { - "$ref": "#/components/parameters/ListRoutinesParameters.after" + "name": "after", + "in": "query", + "required": false, + "description": "Identifier for the last run from the previous pagination request.", + "schema": { + "type": "string" + }, + "explode": false }, { - "$ref": "#/components/parameters/ListRoutinesParameters.before" + "name": "limit", + "in": "query", + "required": false, + "description": "Number of runs to retrieve.", + "schema": { + "$ref": "#/components/schemas/integer", + "default": 20 + }, + "explode": false }, { - "$ref": "#/components/parameters/ListRoutinesParameters.order" + "name": "order", + "in": "query", + "required": false, + "description": "Sort order for runs by timestamp. Use `asc` for ascending order or `desc` for descending order. Defaults to `asc`.", + "schema": { + "type": "string", + "enum": [ + "asc", + "desc" + ], + "default": "asc" + }, + "explode": false }, { - "name": "api-version", + "name": "status", "in": "query", - "required": true, - "description": "The API version to use for this operation.", + "required": false, + "description": "Filter runs by status. One of `queued` | `in_progress` | `failed` | `completed` | `canceled`.", "schema": { - "type": "string" + "type": "string", + "enum": [ + "queued", + "in_progress", + "completed", + "canceled", + "failed" + ] }, "explode": false } @@ -13829,7 +14063,7 @@ "data": { "type": "array", "items": { - "$ref": "#/components/schemas/Routine" + "$ref": "#/components/schemas/EvalRun" }, "description": "The requested list of items." }, @@ -13873,45 +14107,22 @@ } }, "tags": [ - "Routines" - ], - "x-ms-foundry-meta": { - "conditional_previews": [ - "Routines=V1Preview" - ] - } - } - }, - "/routines/{routine_name}": { - "put": { - "operationId": "createOrUpdateRoutine", - "summary": "Create or update a routine", - "description": "Creates a new routine or replaces an existing routine with the supplied definition.", + "Evals" + ] + }, + "post": { + "operationId": "Evals_createEvalRun", + "summary": "Create an evaluation run", + "description": "Creates an evaluation run for the specified evaluation.", "parameters": [ { - "name": "Foundry-Features", - "in": "header", - "required": false, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", - "schema": { - "type": "string", - "enum": [ - "Routines=V1Preview" - ] - } - }, - { - "$ref": "#/components/parameters/CreateOrUpdateRoutineParameters.routine_name" - }, - { - "name": "api-version", - "in": "query", + "name": "eval_id", + "in": "path", "required": true, - "description": "The API version to use for this operation.", + "description": "The ID of the evaluation to create a run for.", "schema": { "type": "string" - }, - "explode": false + } } ], "responses": { @@ -13920,7 +14131,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Routine" + "$ref": "#/components/schemas/EvalRun" } } } @@ -13947,53 +14158,58 @@ } }, "tags": [ - "Routines" + "Evals" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RoutineCreateOrUpdateRequest" + "$ref": "#/components/schemas/CreateEvalRunRequest" } } } }, - "x-ms-foundry-meta": { - "conditional_previews": [ - "Routines=V1Preview" - ] + "x-oaiMeta": { + "name": "Create eval run", + "group": "evals", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/evals/eval_67e579652b548190aaa83ada4b125f47/runs \\\n -X POST \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"name\":\"gpt-4o-mini\",\"data_source\":{\"type\":\"completions\",\"input_messages\":{\"type\":\"template\",\"template\":[{\"role\":\"developer\",\"content\":\"Categorize a given news headline into one of the following topics: Technology, Markets, World, Business, or Sports.\n\n# Steps\n\n1. Analyze the content of the news headline to understand its primary focus.\n2. Extract the subject matter, identifying any key indicators or keywords.\n3. Use the identified indicators to determine the most suitable category out of the five options: Technology, Markets, World, Business, or Sports.\n4. Ensure only one category is selected per headline.\n\n# Output Format\n\nRespond with the chosen category as a single word. For instance: \"Technology\", \"Markets\", \"World\", \"Business\", or \"Sports\".\n\n# Examples\n\n**Input**: \"Apple Unveils New iPhone Model, Featuring Advanced AI Features\"\n**Output**: \"Technology\"\n\n**Input**: \"Global Stocks Mixed as Investors Await Central Bank Decisions\"\n**Output**: \"Markets\"\n\n**Input**: \"War in Ukraine: Latest Updates on Negotiation Status\"\n**Output**: \"World\"\n\n**Input**: \"Microsoft in Talks to Acquire Gaming Company for $2 Billion\"\n**Output**: \"Business\"\n\n**Input**: \"Manchester United Secures Win in Premier League Football Match\"\n**Output**: \"Sports\"\n\n# Notes\n\n- If the headline appears to fit into more than one category, choose the most dominant theme.\n- Keywords or phrases such as \"stocks\", \"company acquisition\", \"match\", or technological brands can be good indicators for classification.\n\"} , {\"role\":\"user\",\"content\":\"{{item.input}}\"}]} ,\"sampling_params\":{\"temperature\":1,\"max_completions_tokens\":2048,\"top_p\":1,\"seed\":42},\"model\":\"gpt-4o-mini\",\"source\":{\"type\":\"file_content\",\"content\":[{\"item\":{\"input\":\"Tech Company Launches Advanced Artificial Intelligence Platform\",\"ground_truth\":\"Technology\"}}]}}'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nrun = client.evals.runs.create(\n eval_id=\"eval_id\",\n data_source={\n \"source\": {\n \"content\": [{\n \"item\": {\n \"foo\": \"bar\"\n }\n }],\n \"type\": \"file_content\",\n },\n \"type\": \"jsonl\",\n },\n)\nprint(run.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nconst run = await openai.evals.runs.create(\n \"eval_67e579652b548190aaa83ada4b125f47\",\n {\n name: \"gpt-4o-mini\",\n data_source: {\n type: \"completions\",\n input_messages: {\n type: \"template\",\n template: [\n {\n role: \"developer\",\n content: \"Categorize a given news headline into one of the following topics: Technology, Markets, World, Business, or Sports.\n\n# Steps\n\n1. Analyze the content of the news headline to understand its primary focus.\n2. Extract the subject matter, identifying any key indicators or keywords.\n3. Use the identified indicators to determine the most suitable category out of the five options: Technology, Markets, World, Business, or Sports.\n4. Ensure only one category is selected per headline.\n\n# Output Format\n\nRespond with the chosen category as a single word. For instance: \"Technology\", \"Markets\", \"World\", \"Business\", or \"Sports\".\n\n# Examples\n\n**Input**: \"Apple Unveils New iPhone Model, Featuring Advanced AI Features\"\n**Output**: \"Technology\"\n\n**Input**: \"Global Stocks Mixed as Investors Await Central Bank Decisions\"\n**Output**: \"Markets\"\n\n**Input**: \"War in Ukraine: Latest Updates on Negotiation Status\"\n**Output**: \"World\"\n\n**Input**: \"Microsoft in Talks to Acquire Gaming Company for $2 Billion\"\n**Output**: \"Business\"\n\n**Input**: \"Manchester United Secures Win in Premier League Football Match\"\n**Output**: \"Sports\"\n\n# Notes\n\n- If the headline appears to fit into more than one category, choose the most dominant theme.\n- Keywords or phrases such as \"stocks\", \"company acquisition\", \"match\", or technological brands can be good indicators for classification.\n\"\n },\n {\n role: \"user\",\n content: \"{{item.input}}\"\n }\n ]\n },\n sampling_params: {\n temperature: 1,\n max_completions_tokens: 2048,\n top_p: 1,\n seed: 42\n },\n model: \"gpt-4o-mini\",\n source: {\n type: \"file_content\",\n content: [\n {\n item: {\n input: \"Tech Company Launches Advanced Artificial Intelligence Platform\",\n ground_truth: \"Technology\"\n }\n }\n ]\n }\n }\n }\n);\nconsole.log(run);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst run = await client.evals.runs.create('eval_id', {\n data_source: {\n source: { content: [{ item: { foo: 'bar' } }], type: 'file_content' },\n type: 'jsonl',\n },\n});\n\nconsole.log(run.id);", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.core.JsonValue;\nimport com.openai.models.evals.runs.CreateEvalJsonlRunDataSource;\nimport com.openai.models.evals.runs.RunCreateParams;\nimport com.openai.models.evals.runs.RunCreateResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n RunCreateParams params = RunCreateParams.builder()\n .evalId(\"eval_id\")\n .dataSource(CreateEvalJsonlRunDataSource.builder()\n .fileContentSource(List.of(CreateEvalJsonlRunDataSource.Source.FileContent.Content.builder()\n .item(CreateEvalJsonlRunDataSource.Source.FileContent.Content.Item.builder()\n .putAdditionalProperty(\"foo\", JsonValue.from(\"bar\"))\n .build())\n .build()))\n .build())\n .build();\n RunCreateResponse run = client.evals().runs().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nrun = openai.evals.runs.create(\n \"eval_id\",\n data_source: {source: {content: [{item: {foo: \"bar\"}}], type: :file_content}, type: :jsonl}\n)\n\nputs(run)" + }, + "response": "{\n \"object\": \"eval.run\",\n \"id\": \"evalrun_67e57965b480819094274e3a32235e4c\",\n \"eval_id\": \"eval_67e579652b548190aaa83ada4b125f47\",\n \"report_url\": \"https://platform.openai.com/evaluations/eval_67e579652b548190aaa83ada4b125f47&run_id=evalrun_67e57965b480819094274e3a32235e4c\",\n \"status\": \"queued\",\n \"model\": \"gpt-4o-mini\",\n \"name\": \"gpt-4o-mini\",\n \"created_at\": 1743092069,\n \"result_counts\": {\n \"total\": 0,\n \"errored\": 0,\n \"failed\": 0,\n \"passed\": 0\n },\n \"per_model_usage\": null,\n \"per_testing_criteria_results\": null,\n \"data_source\": {\n \"type\": \"completions\",\n \"source\": {\n \"type\": \"file_content\",\n \"content\": [\n {\n \"item\": {\n \"input\": \"Tech Company Launches Advanced Artificial Intelligence Platform\",\n \"ground_truth\": \"Technology\"\n }\n }\n ]\n },\n \"input_messages\": {\n \"type\": \"template\",\n \"template\": [\n {\n \"type\": \"message\",\n \"role\": \"developer\",\n \"content\": {\n \"type\": \"input_text\",\n \"text\": \"Categorize a given news headline into one of the following topics: Technology, Markets, World, Business, or Sports.\n\n# Steps\n\n1. Analyze the content of the news headline to understand its primary focus.\n2. Extract the subject matter, identifying any key indicators or keywords.\n3. Use the identified indicators to determine the most suitable category out of the five options: Technology, Markets, World, Business, or Sports.\n4. Ensure only one category is selected per headline.\n\n# Output Format\n\nRespond with the chosen category as a single word. For instance: \"Technology\", \"Markets\", \"World\", \"Business\", or \"Sports\".\n\n# Examples\n\n**Input**: \"Apple Unveils New iPhone Model, Featuring Advanced AI Features\"\n**Output**: \"Technology\"\n\n**Input**: \"Global Stocks Mixed as Investors Await Central Bank Decisions\"\n**Output**: \"Markets\"\n\n**Input**: \"War in Ukraine: Latest Updates on Negotiation Status\"\n**Output**: \"World\"\n\n**Input**: \"Microsoft in Talks to Acquire Gaming Company for $2 Billion\"\n**Output**: \"Business\"\n\n**Input**: \"Manchester United Secures Win in Premier League Football Match\"\n**Output**: \"Sports\"\n\n# Notes\n\n- If the headline appears to fit into more than one category, choose the most dominant theme.\n- Keywords or phrases such as \"stocks\", \"company acquisition\", \"match\", or technological brands can be good indicators for classification.\n\"\n }\n },\n {\n \"type\": \"message\",\n \"role\": \"user\",\n \"content\": {\n \"type\": \"input_text\",\n \"text\": \"{{item.input}}\"\n }\n }\n ]\n },\n \"model\": \"gpt-4o-mini\",\n \"sampling_params\": {\n \"seed\": 42,\n \"temperature\": 1.0,\n \"top_p\": 1.0,\n \"max_completions_tokens\": 2048\n }\n },\n \"error\": null,\n \"metadata\": {}\n}\n" + } } - }, - "get": { - "operationId": "getRoutine", - "summary": "Get a routine", - "description": "Retrieves the specified routine and its current configuration.", + } + }, + "/openai/v1/evals/{eval_id}/runs/{run_id}": { + "delete": { + "operationId": "Evals_deleteEvalRun", + "summary": "Delete an evaluation run", + "description": "Removes the specified evaluation run.", "parameters": [ { - "name": "Foundry-Features", - "in": "header", - "required": false, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", + "name": "eval_id", + "in": "path", + "required": true, + "description": "The ID of the evaluation to delete the run from.", "schema": { - "type": "string", - "enum": [ - "Routines=V1Preview" - ] + "type": "string" } }, { - "$ref": "#/components/parameters/GetRoutineParameters" - }, - { - "name": "api-version", - "in": "query", + "name": "run_id", + "in": "path", "required": true, - "description": "The API version to use for this operation.", + "description": "The ID of the run to delete.", "schema": { "type": "string" - }, - "explode": false + } } ], "responses": { @@ -14002,7 +14218,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Routine" + "$ref": "#/components/schemas/DeleteEvalRunResponse" } } } @@ -14029,48 +14245,59 @@ } }, "tags": [ - "Routines" + "Evals" ], - "x-ms-foundry-meta": { - "conditional_previews": [ - "Routines=V1Preview" - ] + "x-oaiMeta": { + "name": "Delete eval run", + "group": "evals", + "path": "delete", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/evals/eval_123abc/runs/evalrun_abc456 \\\n -X DELETE \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nrun = client.evals.runs.delete(\n run_id=\"run_id\",\n eval_id=\"eval_id\",\n)\nprint(run.run_id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nconst deleted = await openai.evals.runs.delete(\n \"eval_123abc\",\n \"evalrun_abc456\"\n);\nconsole.log(deleted);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst run = await client.evals.runs.delete('run_id', { eval_id: 'eval_id' });\n\nconsole.log(run.run_id);", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.evals.runs.RunDeleteParams;\nimport com.openai.models.evals.runs.RunDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n RunDeleteParams params = RunDeleteParams.builder()\n .evalId(\"eval_id\")\n .runId(\"run_id\")\n .build();\n RunDeleteResponse run = client.evals().runs().delete(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nrun = openai.evals.runs.delete(\"run_id\", eval_id: \"eval_id\")\n\nputs(run)" + }, + "response": "{\n \"object\": \"eval.run.deleted\",\n \"deleted\": true,\n \"run_id\": \"evalrun_abc456\"\n}\n" + } } }, - "delete": { - "operationId": "deleteRoutine", - "summary": "Delete a routine", - "description": "Deletes the specified routine.", + "get": { + "operationId": "Evals_getEvalRun", + "summary": "Get an evaluation run", + "description": "Retrieves the specified evaluation run and its current status.", "parameters": [ { - "name": "Foundry-Features", - "in": "header", - "required": false, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", + "name": "eval_id", + "in": "path", + "required": true, + "description": "The ID of the evaluation to retrieve runs for.", "schema": { - "type": "string", - "enum": [ - "Routines=V1Preview" - ] + "type": "string" } }, { - "$ref": "#/components/parameters/DeleteRoutineParameters" - }, - { - "name": "api-version", - "in": "query", + "name": "run_id", + "in": "path", "required": true, - "description": "The API version to use for this operation.", + "description": "The ID of the run to retrieve.", "schema": { "type": "string" - }, - "explode": false + } } ], "responses": { - "204": { - "description": "There is no content to send for this request, but the headers may be useful." + "200": { + "description": "The request has succeeded.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EvalRun" + } + } + } }, "4XX": { "description": "Client error", @@ -14094,60 +14321,174 @@ } }, "tags": [ - "Routines" + "Evals" ], - "x-ms-foundry-meta": { - "conditional_previews": [ - "Routines=V1Preview" - ] + "x-oaiMeta": { + "name": "Get an eval run", + "group": "evals", + "path": "get", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/evals/eval_67abd54d9b0081909a86353f6fb9317a/runs/evalrun_67abd54d60ec8190832b46859da808f7 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nrun = client.evals.runs.retrieve(\n run_id=\"run_id\",\n eval_id=\"eval_id\",\n)\nprint(run.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nconst run = await openai.evals.runs.retrieve(\n \"evalrun_67abd54d60ec8190832b46859da808f7\",\n { eval_id: \"eval_67abd54d9b0081909a86353f6fb9317a\" }\n);\nconsole.log(run);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst run = await client.evals.runs.retrieve('run_id', { eval_id: 'eval_id' });\n\nconsole.log(run.id);", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.evals.runs.RunRetrieveParams;\nimport com.openai.models.evals.runs.RunRetrieveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n RunRetrieveParams params = RunRetrieveParams.builder()\n .evalId(\"eval_id\")\n .runId(\"run_id\")\n .build();\n RunRetrieveResponse run = client.evals().runs().retrieve(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nrun = openai.evals.runs.retrieve(\"run_id\", eval_id: \"eval_id\")\n\nputs(run)" + }, + "response": "{\n \"object\": \"eval.run\",\n \"id\": \"evalrun_67abd54d60ec8190832b46859da808f7\",\n \"eval_id\": \"eval_67abd54d9b0081909a86353f6fb9317a\",\n \"report_url\": \"https://platform.openai.com/evaluations/eval_67abd54d9b0081909a86353f6fb9317a?run_id=evalrun_67abd54d60ec8190832b46859da808f7\",\n \"status\": \"queued\",\n \"model\": \"gpt-4o-mini\",\n \"name\": \"gpt-4o-mini\",\n \"created_at\": 1743092069,\n \"result_counts\": {\n \"total\": 0,\n \"errored\": 0,\n \"failed\": 0,\n \"passed\": 0\n },\n \"per_model_usage\": null,\n \"per_testing_criteria_results\": null,\n \"data_source\": {\n \"type\": \"completions\",\n \"source\": {\n \"type\": \"file_content\",\n \"content\": [\n {\n \"item\": {\n \"input\": \"Tech Company Launches Advanced Artificial Intelligence Platform\",\n \"ground_truth\": \"Technology\"\n }\n },\n {\n \"item\": {\n \"input\": \"Central Bank Increases Interest Rates Amid Inflation Concerns\",\n \"ground_truth\": \"Markets\"\n }\n },\n {\n \"item\": {\n \"input\": \"International Summit Addresses Climate Change Strategies\",\n \"ground_truth\": \"World\"\n }\n },\n {\n \"item\": {\n \"input\": \"Major Retailer Reports Record-Breaking Holiday Sales\",\n \"ground_truth\": \"Business\"\n }\n },\n {\n \"item\": {\n \"input\": \"National Team Qualifies for World Championship Finals\",\n \"ground_truth\": \"Sports\"\n }\n },\n {\n \"item\": {\n \"input\": \"Stock Markets Rally After Positive Economic Data Released\",\n \"ground_truth\": \"Markets\"\n }\n },\n {\n \"item\": {\n \"input\": \"Global Manufacturer Announces Merger with Competitor\",\n \"ground_truth\": \"Business\"\n }\n },\n {\n \"item\": {\n \"input\": \"Breakthrough in Renewable Energy Technology Unveiled\",\n \"ground_truth\": \"Technology\"\n }\n },\n {\n \"item\": {\n \"input\": \"World Leaders Sign Historic Climate Agreement\",\n \"ground_truth\": \"World\"\n }\n },\n {\n \"item\": {\n \"input\": \"Professional Athlete Sets New Record in Championship Event\",\n \"ground_truth\": \"Sports\"\n }\n },\n {\n \"item\": {\n \"input\": \"Financial Institutions Adapt to New Regulatory Requirements\",\n \"ground_truth\": \"Business\"\n }\n },\n {\n \"item\": {\n \"input\": \"Tech Conference Showcases Advances in Artificial Intelligence\",\n \"ground_truth\": \"Technology\"\n }\n },\n {\n \"item\": {\n \"input\": \"Global Markets Respond to Oil Price Fluctuations\",\n \"ground_truth\": \"Markets\"\n }\n },\n {\n \"item\": {\n \"input\": \"International Cooperation Strengthened Through New Treaty\",\n \"ground_truth\": \"World\"\n }\n },\n {\n \"item\": {\n \"input\": \"Sports League Announces Revised Schedule for Upcoming Season\",\n \"ground_truth\": \"Sports\"\n }\n }\n ]\n },\n \"input_messages\": {\n \"type\": \"template\",\n \"template\": [\n {\n \"type\": \"message\",\n \"role\": \"developer\",\n \"content\": {\n \"type\": \"input_text\",\n \"text\": \"Categorize a given news headline into one of the following topics: Technology, Markets, World, Business, or Sports.\n\n# Steps\n\n1. Analyze the content of the news headline to understand its primary focus.\n2. Extract the subject matter, identifying any key indicators or keywords.\n3. Use the identified indicators to determine the most suitable category out of the five options: Technology, Markets, World, Business, or Sports.\n4. Ensure only one category is selected per headline.\n\n# Output Format\n\nRespond with the chosen category as a single word. For instance: \"Technology\", \"Markets\", \"World\", \"Business\", or \"Sports\".\n\n# Examples\n\n**Input**: \"Apple Unveils New iPhone Model, Featuring Advanced AI Features\"\n**Output**: \"Technology\"\n\n**Input**: \"Global Stocks Mixed as Investors Await Central Bank Decisions\"\n**Output**: \"Markets\"\n\n**Input**: \"War in Ukraine: Latest Updates on Negotiation Status\"\n**Output**: \"World\"\n\n**Input**: \"Microsoft in Talks to Acquire Gaming Company for $2 Billion\"\n**Output**: \"Business\"\n\n**Input**: \"Manchester United Secures Win in Premier League Football Match\"\n**Output**: \"Sports\"\n\n# Notes\n\n- If the headline appears to fit into more than one category, choose the most dominant theme.\n- Keywords or phrases such as \"stocks\", \"company acquisition\", \"match\", or technological brands can be good indicators for classification.\n\"\n }\n },\n {\n \"type\": \"message\",\n \"role\": \"user\",\n \"content\": {\n \"type\": \"input_text\",\n \"text\": \"{{item.input}}\"\n }\n }\n ]\n },\n \"model\": \"gpt-4o-mini\",\n \"sampling_params\": {\n \"seed\": 42,\n \"temperature\": 1.0,\n \"top_p\": 1.0,\n \"max_completions_tokens\": 2048\n }\n },\n \"error\": null,\n \"metadata\": {}\n}\n" + } } - } - }, - "/routines/{routine_name}/runs": { - "get": { - "operationId": "listRoutineRuns", - "summary": "List prior runs for a routine", - "description": "Returns prior runs recorded for the specified routine.", + }, + "post": { + "operationId": "Evals_cancelEvalRun", + "summary": "Cancel an evaluation run", + "description": "Cancels an ongoing evaluation run.", "parameters": [ { - "name": "Foundry-Features", - "in": "header", - "required": false, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", + "name": "eval_id", + "in": "path", + "required": true, + "description": "The ID of the evaluation whose run you want to cancel.", "schema": { - "type": "string", - "enum": [ - "Routines=V1Preview" - ] + "type": "string" } }, { - "$ref": "#/components/parameters/ListRoutineRunsParameters.routine_name" + "name": "run_id", + "in": "path", + "required": true, + "description": "The ID of the run to cancel.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EvalRun" + } + } + } }, - { - "$ref": "#/components/parameters/ListRoutineRunsParameters.filter" + "4XX": { + "description": "Client error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } }, + "5XX": { + "description": "Server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } + } + }, + "tags": [ + "Evals" + ], + "x-oaiMeta": { + "name": "Cancel eval run", + "group": "evals", + "path": "post", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/evals/eval_67abd54d9b0081909a86353f6fb9317a/runs/evalrun_67abd54d60ec8190832b46859da808f7/cancel \\\n -X POST \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nresponse = client.evals.runs.cancel(\n run_id=\"run_id\",\n eval_id=\"eval_id\",\n)\nprint(response.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nconst canceledRun = await openai.evals.runs.cancel(\n \"evalrun_67abd54d60ec8190832b46859da808f7\",\n { eval_id: \"eval_67abd54d9b0081909a86353f6fb9317a\" }\n);\nconsole.log(canceledRun);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.evals.runs.cancel('run_id', { eval_id: 'eval_id' });\n\nconsole.log(response.id);", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.evals.runs.RunCancelParams;\nimport com.openai.models.evals.runs.RunCancelResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n RunCancelParams params = RunCancelParams.builder()\n .evalId(\"eval_id\")\n .runId(\"run_id\")\n .build();\n RunCancelResponse response = client.evals().runs().cancel(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nresponse = openai.evals.runs.cancel(\"run_id\", eval_id: \"eval_id\")\n\nputs(response)" + }, + "response": "{\n \"object\": \"eval.run\",\n \"id\": \"evalrun_67abd54d60ec8190832b46859da808f7\",\n \"eval_id\": \"eval_67abd54d9b0081909a86353f6fb9317a\",\n \"report_url\": \"https://platform.openai.com/evaluations/eval_67abd54d9b0081909a86353f6fb9317a?run_id=evalrun_67abd54d60ec8190832b46859da808f7\",\n \"status\": \"canceled\",\n \"model\": \"gpt-4o-mini\",\n \"name\": \"gpt-4o-mini\",\n \"created_at\": 1743092069,\n \"result_counts\": {\n \"total\": 0,\n \"errored\": 0,\n \"failed\": 0,\n \"passed\": 0\n },\n \"per_model_usage\": null,\n \"per_testing_criteria_results\": null,\n \"data_source\": {\n \"type\": \"completions\",\n \"source\": {\n \"type\": \"file_content\",\n \"content\": [\n {\n \"item\": {\n \"input\": \"Tech Company Launches Advanced Artificial Intelligence Platform\",\n \"ground_truth\": \"Technology\"\n }\n },\n {\n \"item\": {\n \"input\": \"Central Bank Increases Interest Rates Amid Inflation Concerns\",\n \"ground_truth\": \"Markets\"\n }\n },\n {\n \"item\": {\n \"input\": \"International Summit Addresses Climate Change Strategies\",\n \"ground_truth\": \"World\"\n }\n },\n {\n \"item\": {\n \"input\": \"Major Retailer Reports Record-Breaking Holiday Sales\",\n \"ground_truth\": \"Business\"\n }\n },\n {\n \"item\": {\n \"input\": \"National Team Qualifies for World Championship Finals\",\n \"ground_truth\": \"Sports\"\n }\n },\n {\n \"item\": {\n \"input\": \"Stock Markets Rally After Positive Economic Data Released\",\n \"ground_truth\": \"Markets\"\n }\n },\n {\n \"item\": {\n \"input\": \"Global Manufacturer Announces Merger with Competitor\",\n \"ground_truth\": \"Business\"\n }\n },\n {\n \"item\": {\n \"input\": \"Breakthrough in Renewable Energy Technology Unveiled\",\n \"ground_truth\": \"Technology\"\n }\n },\n {\n \"item\": {\n \"input\": \"World Leaders Sign Historic Climate Agreement\",\n \"ground_truth\": \"World\"\n }\n },\n {\n \"item\": {\n \"input\": \"Professional Athlete Sets New Record in Championship Event\",\n \"ground_truth\": \"Sports\"\n }\n },\n {\n \"item\": {\n \"input\": \"Financial Institutions Adapt to New Regulatory Requirements\",\n \"ground_truth\": \"Business\"\n }\n },\n {\n \"item\": {\n \"input\": \"Tech Conference Showcases Advances in Artificial Intelligence\",\n \"ground_truth\": \"Technology\"\n }\n },\n {\n \"item\": {\n \"input\": \"Global Markets Respond to Oil Price Fluctuations\",\n \"ground_truth\": \"Markets\"\n }\n },\n {\n \"item\": {\n \"input\": \"International Cooperation Strengthened Through New Treaty\",\n \"ground_truth\": \"World\"\n }\n },\n {\n \"item\": {\n \"input\": \"Sports League Announces Revised Schedule for Upcoming Season\",\n \"ground_truth\": \"Sports\"\n }\n }\n ]\n },\n \"input_messages\": {\n \"type\": \"template\",\n \"template\": [\n {\n \"type\": \"message\",\n \"role\": \"developer\",\n \"content\": {\n \"type\": \"input_text\",\n \"text\": \"Categorize a given news headline into one of the following topics: Technology, Markets, World, Business, or Sports.\n\n# Steps\n\n1. Analyze the content of the news headline to understand its primary focus.\n2. Extract the subject matter, identifying any key indicators or keywords.\n3. Use the identified indicators to determine the most suitable category out of the five options: Technology, Markets, World, Business, or Sports.\n4. Ensure only one category is selected per headline.\n\n# Output Format\n\nRespond with the chosen category as a single word. For instance: \"Technology\", \"Markets\", \"World\", \"Business\", or \"Sports\".\n\n# Examples\n\n**Input**: \"Apple Unveils New iPhone Model, Featuring Advanced AI Features\"\n**Output**: \"Technology\"\n\n**Input**: \"Global Stocks Mixed as Investors Await Central Bank Decisions\"\n**Output**: \"Markets\"\n\n**Input**: \"War in Ukraine: Latest Updates on Negotiation Status\"\n**Output**: \"World\"\n\n**Input**: \"Microsoft in Talks to Acquire Gaming Company for $2 Billion\"\n**Output**: \"Business\"\n\n**Input**: \"Manchester United Secures Win in Premier League Football Match\"\n**Output**: \"Sports\"\n\n# Notes\n\n- If the headline appears to fit into more than one category, choose the most dominant theme.\n- Keywords or phrases such as \"stocks\", \"company acquisition\", \"match\", or technological brands can be good indicators for classification.\n\"\n }\n },\n {\n \"type\": \"message\",\n \"role\": \"user\",\n \"content\": {\n \"type\": \"input_text\",\n \"text\": \"{{item.input}}\"\n }\n }\n ]\n },\n \"model\": \"gpt-4o-mini\",\n \"sampling_params\": {\n \"seed\": 42,\n \"temperature\": 1.0,\n \"top_p\": 1.0,\n \"max_completions_tokens\": 2048\n }\n },\n \"error\": null,\n \"metadata\": {}\n}\n" + } + } + } + }, + "/openai/v1/evals/{eval_id}/runs/{run_id}/output_items": { + "get": { + "operationId": "Evals_getEvalRunOutputItems", + "summary": "List evaluation run output items", + "description": "Returns the output items produced by the specified evaluation run.", + "parameters": [ { - "$ref": "#/components/parameters/ListRoutineRunsParameters.limit" + "name": "eval_id", + "in": "path", + "required": true, + "description": "The eval id path parameter.", + "schema": { + "type": "string" + } }, { - "$ref": "#/components/parameters/ListRoutineRunsParameters.after" + "name": "run_id", + "in": "path", + "required": true, + "description": "The ID of the run to retrieve output items for.", + "schema": { + "type": "string" + } }, { - "$ref": "#/components/parameters/ListRoutineRunsParameters.before" + "name": "after", + "in": "query", + "required": false, + "description": "Identifier for the last run from the previous pagination request.", + "schema": { + "type": "string" + }, + "explode": false }, { - "$ref": "#/components/parameters/ListRoutineRunsParameters.order" + "name": "limit", + "in": "query", + "required": false, + "description": "Number of runs to retrieve.", + "schema": { + "$ref": "#/components/schemas/integer", + "default": 20 + }, + "explode": false }, { - "name": "api-version", + "name": "order", "in": "query", - "required": true, - "description": "The API version to use for this operation.", + "required": false, + "description": "Sort order for runs by timestamp. Use `asc` for ascending order or `desc` for descending order. Defaults to `asc`.", "schema": { - "type": "string" + "type": "string", + "enum": [ + "asc", + "desc" + ], + "default": "asc" }, "explode": false + }, + { + "name": "status", + "in": "query", + "required": false, + "description": "Filter output items by status. Use `failed` to filter by failed output\nitems or `pass` to filter by passed output items.", + "schema": { + "type": "string", + "enum": [ + "fail", + "pass" + ] + } } ], "responses": { @@ -14165,7 +14506,7 @@ "data": { "type": "array", "items": { - "$ref": "#/components/schemas/RoutineRun" + "$ref": "#/components/schemas/EvalRunOutputItem" }, "description": "The requested list of items." }, @@ -14209,45 +14550,59 @@ } }, "tags": [ - "Routines" + "Evals" ], - "x-ms-foundry-meta": { - "conditional_previews": [ - "Routines=V1Preview" - ] - } + "x-oaiMeta": { + "name": "Get eval run output items", + "group": "evals", + "path": "get", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/evals/egroup_67abd54d9b0081909a86353f6fb9317a/runs/erun_67abd54d60ec8190832b46859da808f7/output_items \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\npage = client.evals.runs.output_items.list(\n run_id=\"run_id\",\n eval_id=\"eval_id\",\n)\npage = page.data[0]\nprint(page.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nconst outputItems = await openai.evals.runs.outputItems.list(\n \"egroup_67abd54d9b0081909a86353f6fb9317a\",\n \"erun_67abd54d60ec8190832b46859da808f7\"\n);\nconsole.log(outputItems);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const outputItemListResponse of client.evals.runs.outputItems.list('run_id', {\n eval_id: 'eval_id',\n})) {\n console.log(outputItemListResponse.id);\n}", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.evals.runs.outputitems.OutputItemListPage;\nimport com.openai.models.evals.runs.outputitems.OutputItemListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n OutputItemListParams params = OutputItemListParams.builder()\n .evalId(\"eval_id\")\n .runId(\"run_id\")\n .build();\n OutputItemListPage page = client.evals().runs().outputItems().list(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\npage = openai.evals.runs.output_items.list(\"run_id\", eval_id: \"eval_id\")\n\nputs(page)" + }, + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"object\": \"eval.run.output_item\",\n \"id\": \"outputitem_67e5796c28e081909917bf79f6e6214d\",\n \"created_at\": 1743092076,\n \"run_id\": \"evalrun_67abd54d60ec8190832b46859da808f7\",\n \"eval_id\": \"eval_67abd54d9b0081909a86353f6fb9317a\",\n \"status\": \"pass\",\n \"datasource_item_id\": 5,\n \"datasource_item\": {\n \"input\": \"Stock Markets Rally After Positive Economic Data Released\",\n \"ground_truth\": \"Markets\"\n },\n \"results\": [\n {\n \"name\": \"String check-a2486074-d803-4445-b431-ad2262e85d47\",\n \"sample\": null,\n \"passed\": true,\n \"score\": 1.0\n }\n ],\n \"sample\": {\n \"input\": [\n {\n \"role\": \"developer\",\n \"content\": \"Categorize a given news headline into one of the following topics: Technology, Markets, World, Business, or Sports.\n\n# Steps\n\n1. Analyze the content of the news headline to understand its primary focus.\n2. Extract the subject matter, identifying any key indicators or keywords.\n3. Use the identified indicators to determine the most suitable category out of the five options: Technology, Markets, World, Business, or Sports.\n4. Ensure only one category is selected per headline.\n\n# Output Format\n\nRespond with the chosen category as a single word. For instance: \"Technology\", \"Markets\", \"World\", \"Business\", or \"Sports\".\n\n# Examples\n\n**Input**: \"Apple Unveils New iPhone Model, Featuring Advanced AI Features\"\n**Output**: \"Technology\"\n\n**Input**: \"Global Stocks Mixed as Investors Await Central Bank Decisions\"\n**Output**: \"Markets\"\n\n**Input**: \"War in Ukraine: Latest Updates on Negotiation Status\"\n**Output**: \"World\"\n\n**Input**: \"Microsoft in Talks to Acquire Gaming Company for $2 Billion\"\n**Output**: \"Business\"\n\n**Input**: \"Manchester United Secures Win in Premier League Football Match\"\n**Output**: \"Sports\"\n\n# Notes\n\n- If the headline appears to fit into more than one category, choose the most dominant theme.\n- Keywords or phrases such as \"stocks\", \"company acquisition\", \"match\", or technological brands can be good indicators for classification.\n\",\n \"tool_call_id\": null,\n \"tool_calls\": null,\n \"function_call\": null\n },\n {\n \"role\": \"user\",\n \"content\": \"Stock Markets Rally After Positive Economic Data Released\",\n \"tool_call_id\": null,\n \"tool_calls\": null,\n \"function_call\": null\n }\n ],\n \"output\": [\n {\n \"role\": \"assistant\",\n \"content\": \"Markets\",\n \"tool_call_id\": null,\n \"tool_calls\": null,\n \"function_call\": null\n }\n ],\n \"finish_reason\": \"stop\",\n \"model\": \"gpt-4o-mini-2024-07-18\",\n \"usage\": {\n \"total_tokens\": 325,\n \"completion_tokens\": 2,\n \"prompt_tokens\": 323,\n \"cached_tokens\": 0\n },\n \"error\": null,\n \"temperature\": 1.0,\n \"max_completion_tokens\": 2048,\n \"top_p\": 1.0,\n \"seed\": 42\n }\n }\n ],\n \"first_id\": \"outputitem_67e5796c28e081909917bf79f6e6214d\",\n \"last_id\": \"outputitem_67e5796c28e081909917bf79f6e6214d\",\n \"has_more\": true\n}\n" + } + }, + "x-ms-list": true } }, - "/routines/{routine_name}:disable": { - "post": { - "operationId": "disableRoutine", - "summary": "Disable a routine", - "description": "Disables the specified routine so it no longer runs.", + "/openai/v1/evals/{eval_id}/runs/{run_id}/output_items/{output_item_id}": { + "get": { + "operationId": "Evals_getEvalRunOutputItem", + "summary": "Get an output item of an evaluation run", + "description": "Retrieves a single output item from the specified evaluation run.", "parameters": [ { - "name": "Foundry-Features", - "in": "header", - "required": false, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", + "name": "eval_id", + "in": "path", + "required": true, + "description": "The ID of the evaluation to retrieve runs for.", "schema": { - "type": "string", - "enum": [ - "Routines=V1Preview" - ] + "type": "string" } }, { - "$ref": "#/components/parameters/DisableRoutineParameters" + "name": "run_id", + "in": "path", + "required": true, + "description": "The ID of the run to retrieve.", + "schema": { + "type": "string" + } }, { - "name": "api-version", - "in": "query", + "name": "output_item_id", + "in": "path", "required": true, - "description": "The API version to use for this operation.", + "description": "The ID of the output item to retrieve.", "schema": { "type": "string" - }, - "explode": false + } } ], "responses": { @@ -14256,7 +14611,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Routine" + "$ref": "#/components/schemas/EvalRunOutputItem" } } } @@ -14283,45 +14638,70 @@ } }, "tags": [ - "Routines" + "Evals" ], - "x-ms-foundry-meta": { - "conditional_previews": [ - "Routines=V1Preview" - ] + "x-oaiMeta": { + "name": "Get an output item of an eval run", + "group": "evals", + "path": "get", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/evals/eval_67abd54d9b0081909a86353f6fb9317a/runs/evalrun_67abd54d60ec8190832b46859da808f7/output_items/outputitem_67abd55eb6548190bb580745d5644a33 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\noutput_item = client.evals.runs.output_items.retrieve(\n output_item_id=\"output_item_id\",\n eval_id=\"eval_id\",\n run_id=\"run_id\",\n)\nprint(output_item.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nconst outputItem = await openai.evals.runs.outputItems.retrieve(\n \"outputitem_67abd55eb6548190bb580745d5644a33\",\n {\n eval_id: \"eval_67abd54d9b0081909a86353f6fb9317a\",\n run_id: \"evalrun_67abd54d60ec8190832b46859da808f7\",\n }\n);\nconsole.log(outputItem);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst outputItem = await client.evals.runs.outputItems.retrieve('output_item_id', {\n eval_id: 'eval_id',\n run_id: 'run_id',\n});\n\nconsole.log(outputItem.id);", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.evals.runs.outputitems.OutputItemRetrieveParams;\nimport com.openai.models.evals.runs.outputitems.OutputItemRetrieveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n OutputItemRetrieveParams params = OutputItemRetrieveParams.builder()\n .evalId(\"eval_id\")\n .runId(\"run_id\")\n .outputItemId(\"output_item_id\")\n .build();\n OutputItemRetrieveResponse outputItem = client.evals().runs().outputItems().retrieve(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\noutput_item = openai.evals.runs.output_items.retrieve(\"output_item_id\", eval_id: \"eval_id\", run_id: \"run_id\")\n\nputs(output_item)" + }, + "response": "{\n \"object\": \"eval.run.output_item\",\n \"id\": \"outputitem_67e5796c28e081909917bf79f6e6214d\",\n \"created_at\": 1743092076,\n \"run_id\": \"evalrun_67abd54d60ec8190832b46859da808f7\",\n \"eval_id\": \"eval_67abd54d9b0081909a86353f6fb9317a\",\n \"status\": \"pass\",\n \"datasource_item_id\": 5,\n \"datasource_item\": {\n \"input\": \"Stock Markets Rally After Positive Economic Data Released\",\n \"ground_truth\": \"Markets\"\n },\n \"results\": [\n {\n \"name\": \"String check-a2486074-d803-4445-b431-ad2262e85d47\",\n \"sample\": null,\n \"passed\": true,\n \"score\": 1.0\n }\n ],\n \"sample\": {\n \"input\": [\n {\n \"role\": \"developer\",\n \"content\": \"Categorize a given news headline into one of the following topics: Technology, Markets, World, Business, or Sports.\n\n# Steps\n\n1. Analyze the content of the news headline to understand its primary focus.\n2. Extract the subject matter, identifying any key indicators or keywords.\n3. Use the identified indicators to determine the most suitable category out of the five options: Technology, Markets, World, Business, or Sports.\n4. Ensure only one category is selected per headline.\n\n# Output Format\n\nRespond with the chosen category as a single word. For instance: \"Technology\", \"Markets\", \"World\", \"Business\", or \"Sports\".\n\n# Examples\n\n**Input**: \"Apple Unveils New iPhone Model, Featuring Advanced AI Features\"\n**Output**: \"Technology\"\n\n**Input**: \"Global Stocks Mixed as Investors Await Central Bank Decisions\"\n**Output**: \"Markets\"\n\n**Input**: \"War in Ukraine: Latest Updates on Negotiation Status\"\n**Output**: \"World\"\n\n**Input**: \"Microsoft in Talks to Acquire Gaming Company for $2 Billion\"\n**Output**: \"Business\"\n\n**Input**: \"Manchester United Secures Win in Premier League Football Match\"\n**Output**: \"Sports\"\n\n# Notes\n\n- If the headline appears to fit into more than one category, choose the most dominant theme.\n- Keywords or phrases such as \"stocks\", \"company acquisition\", \"match\", or technological brands can be good indicators for classification.\n\",\n \"tool_call_id\": null,\n \"tool_calls\": null,\n \"function_call\": null\n },\n {\n \"role\": \"user\",\n \"content\": \"Stock Markets Rally After Positive Economic Data Released\",\n \"tool_call_id\": null,\n \"tool_calls\": null,\n \"function_call\": null\n }\n ],\n \"output\": [\n {\n \"role\": \"assistant\",\n \"content\": \"Markets\",\n \"tool_call_id\": null,\n \"tool_calls\": null,\n \"function_call\": null\n }\n ],\n \"finish_reason\": \"stop\",\n \"model\": \"gpt-4o-mini-2024-07-18\",\n \"usage\": {\n \"total_tokens\": 325,\n \"completion_tokens\": 2,\n \"prompt_tokens\": 323,\n \"cached_tokens\": 0\n },\n \"error\": null,\n \"temperature\": 1.0,\n \"max_completion_tokens\": 2048,\n \"top_p\": 1.0,\n \"seed\": 42\n }\n}\n" + } } } }, - "/routines/{routine_name}:dispatch_async": { - "post": { - "operationId": "dispatchRoutineAsync", - "summary": "Queue an asynchronous routine dispatch", - "description": "Queues an asynchronous dispatch for the specified routine.", + "/openai/v1/files": { + "get": { + "operationId": "Files_listFiles", + "summary": "List files", + "description": "Lists files matching the request filters.", "parameters": [ { - "name": "Foundry-Features", - "in": "header", + "name": "purpose", + "in": "query", "required": false, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", + "description": "Only return files with the given purpose.", "schema": { - "type": "string", - "enum": [ - "Routines=V1Preview" - ] + "type": "string" } }, { - "$ref": "#/components/parameters/DispatchRoutineAsyncParameters.routine_name" + "name": "limit", + "in": "query", + "required": false, + "description": "A limit on the number of objects to be returned. Limit can range between 1 and 10,000, and the default is 10,000.", + "schema": { + "$ref": "#/components/schemas/integer", + "default": 10000 + } }, { - "name": "api-version", + "name": "order", "in": "query", - "required": true, - "description": "The API version to use for this operation.", + "required": false, + "description": "Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.", + "schema": { + "$ref": "#/components/schemas/OpenAI.OrderEnum", + "default": "desc" + } + }, + { + "name": "after", + "in": "query", + "required": false, + "description": "A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.", "schema": { "type": "string" }, - "explode": false + "x-ms-list-continuation-token": true } ], "responses": { @@ -14330,7 +14710,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/DispatchRoutineResponse" + "$ref": "#/components/schemas/OpenAI.ListFilesResponse" } } } @@ -14357,55 +14737,118 @@ } }, "tags": [ - "Routines" + "Files" + ], + "x-oaiMeta": { + "name": "List files", + "group": "files", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/files \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\npage = client.files.list()\npage = page.data[0]\nprint(page)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const list = await openai.files.list();\n\n for await (const file of list) {\n console.log(file);\n }\n}\n\nmain();", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const fileObject of client.files.list()) {\n console.log(fileObject);\n}", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.Files.List(context.TODO(), openai.FileListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", page)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.files.FileListPage;\nimport com.openai.models.files.FileListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n FileListPage page = client.files().list();\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\npage = openai.files.list\n\nputs(page)" + }, + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"file-abc123\",\n \"object\": \"file\",\n \"bytes\": 175,\n \"created_at\": 1613677385,\n \"expires_at\": 1677614202,\n \"filename\": \"salesOverview.pdf\",\n \"purpose\": \"assistants\",\n },\n {\n \"id\": \"file-abc456\",\n \"object\": \"file\",\n \"bytes\": 140,\n \"created_at\": 1613779121,\n \"expires_at\": 1677614202,\n \"filename\": \"puppy.jsonl\",\n \"purpose\": \"fine-tune\",\n }\n ],\n \"first_id\": \"file-abc123\",\n \"last_id\": \"file-abc456\",\n \"has_more\": false\n}\n" + } + }, + "x-ms-list": true + }, + "post": { + "operationId": "Files_createFile", + "summary": "Create a file", + "description": "Creates a file from the supplied request.", + "parameters": [], + "responses": { + "200": { + "description": "The request has succeeded.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAI.OpenAIFile" + } + } + } + }, + "4XX": { + "description": "Client error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } + }, + "5XX": { + "description": "Server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } + } + }, + "tags": [ + "Files" ], "requestBody": { "required": true, "content": { - "application/json": { + "multipart/form-data": { "schema": { - "$ref": "#/components/schemas/DispatchRoutineRequest" + "$ref": "#/components/schemas/OpenAI.CreateFileRequest" + }, + "encoding": { + "purpose": { + "contentType": "application/json" + }, + "expires_after": { + "contentType": "application/json" + } } } - } + }, + "description": "The multipart request body." }, - "x-ms-foundry-meta": { - "conditional_previews": [ - "Routines=V1Preview" - ] + "x-oaiMeta": { + "name": "Upload file", + "group": "files", + "description": "Uploads a file for later use across OpenAI APIs. Uploads to this endpoint are rate-limited to 1,000 requests per minute per authenticated user. For Retrieval or `file_search` ingestion, upload files here first. If you need to attach multiple uploaded files to the same vector store, use vector store file batches instead of attaching them one by one.\n", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/files \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -F purpose=\"fine-tune\" \\\n -F file=\"@mydata.jsonl\"\n -F expires_after[anchor]=\"created_at\"\n -F expires_after[seconds]=2592000\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfile_object = client.files.create(\n file=b\"Example data\",\n purpose=\"assistants\",\n)\nprint(file_object.id)", + "javascript": "import fs from \"fs\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const file = await openai.files.create({\n file: fs.createReadStream(\"mydata.jsonl\"),\n purpose: \"fine-tune\",\n expires_after: {\n anchor: \"created_at\",\n seconds: 2592000\n }\n });\n\n console.log(file);\n}\n\nmain();", + "node.js": "import fs from 'fs';\nimport OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst fileObject = await client.files.create({\n file: fs.createReadStream('fine-tune.jsonl'),\n purpose: 'assistants',\n});\n\nconsole.log(fileObject.id);", + "go": "package main\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tfileObject, err := client.Files.New(context.TODO(), openai.FileNewParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"Example data\"))),\n\t\tPurpose: openai.FilePurposeAssistants,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", fileObject.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.files.FileCreateParams;\nimport com.openai.models.files.FileObject;\nimport com.openai.models.files.FilePurpose;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n FileCreateParams params = FileCreateParams.builder()\n .file(new ByteArrayInputStream(\"Example data\".getBytes()))\n .purpose(FilePurpose.ASSISTANTS)\n .build();\n FileObject fileObject = client.files().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nfile_object = openai.files.create(file: StringIO.new(\"Example data\"), purpose: :assistants)\n\nputs(file_object)" + }, + "response": "{\n \"id\": \"file-abc123\",\n \"object\": \"file\",\n \"bytes\": 120000,\n \"created_at\": 1677610602,\n \"expires_at\": 1677614202,\n \"filename\": \"mydata.jsonl\",\n \"purpose\": \"fine-tune\",\n}\n" + } } } }, - "/routines/{routine_name}:enable": { - "post": { - "operationId": "enableRoutine", - "summary": "Enable a routine", - "description": "Enables the specified routine so it can be dispatched.", + "/openai/v1/files/{file_id}": { + "delete": { + "operationId": "Files_deleteFile", + "summary": "Delete a file", + "description": "Deletes a file by its identifier.", "parameters": [ { - "name": "Foundry-Features", - "in": "header", - "required": false, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", - "schema": { - "type": "string", - "enum": [ - "Routines=V1Preview" - ] - } - }, - { - "$ref": "#/components/parameters/EnableRoutineParameters" - }, - { - "name": "api-version", - "in": "query", + "name": "file_id", + "in": "path", "required": true, - "description": "The API version to use for this operation.", + "description": "The ID of the file to use for this request.", "schema": { "type": "string" - }, - "explode": false + } } ], "responses": { @@ -14414,7 +14857,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Routine" + "$ref": "#/components/schemas/OpenAI.DeleteFileResponse" } } } @@ -14441,54 +14884,37 @@ } }, "tags": [ - "Routines" + "Files" ], - "x-ms-foundry-meta": { - "conditional_previews": [ - "Routines=V1Preview" - ] + "x-oaiMeta": { + "name": "Delete file", + "group": "files", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/files/file-abc123 \\\n -X DELETE \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfile_deleted = client.files.delete(\n \"file_id\",\n)\nprint(file_deleted.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const file = await openai.files.delete(\"file-abc123\");\n\n console.log(file);\n}\n\nmain();", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst fileDeleted = await client.files.delete('file_id');\n\nconsole.log(fileDeleted.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tfileDeleted, err := client.Files.Delete(context.TODO(), \"file_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", fileDeleted.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.files.FileDeleteParams;\nimport com.openai.models.files.FileDeleted;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n FileDeleted fileDeleted = client.files().delete(\"file_id\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nfile_deleted = openai.files.delete(\"file_id\")\n\nputs(file_deleted)" + }, + "response": "{\n \"id\": \"file-abc123\",\n \"object\": \"file\",\n \"deleted\": true\n}\n" + } } - } - }, - "/schedules": { + }, "get": { - "operationId": "Schedules_list", - "summary": "List schedules", - "description": "Returns schedules that match the supplied type and enabled filters.", + "operationId": "Files_retrieveFile", + "summary": "Get a file", + "description": "Retrieves a file by its identifier.", "parameters": [ { - "$ref": "#/components/parameters/Azure.Core.Foundations.ApiVersionParameter" - }, - { - "name": "type", - "in": "query", - "required": false, - "description": "Filter by the type of schedule.", - "schema": { - "$ref": "#/components/schemas/ScheduleTaskType" - }, - "explode": false - }, - { - "name": "enabled", - "in": "query", - "required": false, - "description": "Filter by the enabled status.", - "schema": { - "type": "boolean" - }, - "explode": false - }, - { - "name": "Foundry-Features", - "in": "header", + "name": "file_id", + "in": "path", "required": true, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", + "description": "The ID of the file to use for this request.", "schema": { - "type": "string", - "enum": [ - "Schedules=V1Preview" - ] + "type": "string" } } ], @@ -14498,371 +14924,344 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PagedSchedule" + "$ref": "#/components/schemas/OpenAI.OpenAIFile" } } } }, "4XX": { "description": "Client error", - "headers": { - "x-ms-error-code": { - "required": false, - "description": "String error code indicating what went wrong.", - "schema": { - "type": "string" - } - } - }, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Azure.Core.Foundations.ErrorResponse" + "$ref": "#/components/schemas/ApiErrorResponse" } } } }, "5XX": { "description": "Server error", - "headers": { - "x-ms-error-code": { - "required": false, - "description": "String error code indicating what went wrong.", + "content": { + "application/json": { "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Azure.Core.Foundations.ErrorResponse" + "$ref": "#/components/schemas/ApiErrorResponse" } } } } }, "tags": [ - "Schedules" - ] + "Files" + ], + "x-oaiMeta": { + "name": "Retrieve file", + "group": "files", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/files/file-abc123 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfile_object = client.files.retrieve(\n \"file_id\",\n)\nprint(file_object.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const file = await openai.files.retrieve(\"file-abc123\");\n\n console.log(file);\n}\n\nmain();", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst fileObject = await client.files.retrieve('file_id');\n\nconsole.log(fileObject.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tfileObject, err := client.Files.Get(context.TODO(), \"file_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", fileObject.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.files.FileObject;\nimport com.openai.models.files.FileRetrieveParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n FileObject fileObject = client.files().retrieve(\"file_id\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nfile_object = openai.files.retrieve(\"file_id\")\n\nputs(file_object)" + }, + "response": "{\n \"id\": \"file-abc123\",\n \"object\": \"file\",\n \"bytes\": 120000,\n \"created_at\": 1677610602,\n \"expires_at\": 1677614202,\n \"filename\": \"mydata.jsonl\",\n \"purpose\": \"fine-tune\",\n}\n" + } + } } }, - "/schedules/{id}": { - "delete": { - "operationId": "Schedules_delete", - "summary": "Delete a schedule", - "description": "Deletes the specified schedule resource.", + "/openai/v1/files/{file_id}/content": { + "get": { + "operationId": "Files_downloadFile", + "summary": "Download a file", + "description": "Downloads a file.", "parameters": [ { - "$ref": "#/components/parameters/Azure.Core.Foundations.ApiVersionParameter" - }, - { - "name": "id", + "name": "file_id", "in": "path", "required": true, - "description": "Identifier of the schedule.", + "description": "The ID of the file to use for this request.", "schema": { "type": "string" } - }, - { - "name": "Foundry-Features", - "in": "header", - "required": true, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", - "schema": { - "type": "string", - "enum": [ - "Schedules=V1Preview" - ] - } } ], "responses": { - "204": { - "description": "There is no content to send for this request, but the headers may be useful." - }, - "4XX": { - "description": "Client error", - "headers": { - "x-ms-error-code": { - "required": false, - "description": "String error code indicating what went wrong.", + "200": { + "description": "The request has succeeded.", + "content": { + "text/plain": { "schema": { "type": "string" } } - }, + } + }, + "4XX": { + "description": "Client error", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Azure.Core.Foundations.ErrorResponse" + "$ref": "#/components/schemas/ApiErrorResponse" } } } }, "5XX": { "description": "Server error", - "headers": { - "x-ms-error-code": { - "required": false, - "description": "String error code indicating what went wrong.", - "schema": { - "type": "string" - } - } - }, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Azure.Core.Foundations.ErrorResponse" + "$ref": "#/components/schemas/ApiErrorResponse" } } } } }, "tags": [ - "Schedules" - ] - }, - "get": { - "operationId": "Schedules_get", - "summary": "Get a schedule", - "description": "Retrieves the specified schedule resource.", - "parameters": [ - { - "$ref": "#/components/parameters/Azure.Core.Foundations.ApiVersionParameter" - }, - { - "name": "id", - "in": "path", - "required": true, - "description": "Identifier of the schedule.", - "schema": { - "type": "string" - } - }, - { - "name": "Foundry-Features", - "in": "header", - "required": true, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", - "schema": { - "type": "string", - "enum": [ - "Schedules=V1Preview" - ] - } - } + "Files" ], + "x-oaiMeta": { + "name": "Retrieve file content", + "group": "files", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/files/file-abc123/content \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" > file.jsonl\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nresponse = client.files.content(\n \"file_id\",\n)\nprint(response)\ncontent = response.read()\nprint(content)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const file = await openai.files.content(\"file-abc123\");\n\n console.log(file);\n}\n\nmain();\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.files.content('file_id');\n\nconsole.log(response);\n\nconst content = await response.blob();\nconsole.log(content);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tresponse, err := client.Files.Content(context.TODO(), \"file_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", response)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.core.http.HttpResponse;\nimport com.openai.models.files.FileContentParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n HttpResponse response = client.files().content(\"file_id\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nresponse = openai.files.content(\"file_id\")\n\nputs(response)" + }, + "response": "" + } + } + } + }, + "/openai/v1/fine_tuning/alpha/graders/run": { + "post": { + "operationId": "Graders_runGrader", + "summary": "Run a grader", + "description": "Runs a grader.", + "parameters": [], "responses": { "200": { "description": "The request has succeeded.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Schedule" + "$ref": "#/components/schemas/OpenAI.RunGraderResponse" } } } }, "4XX": { "description": "Client error", - "headers": { - "x-ms-error-code": { - "required": false, - "description": "String error code indicating what went wrong.", - "schema": { - "type": "string" - } - } - }, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Azure.Core.Foundations.ErrorResponse" + "$ref": "#/components/schemas/ApiErrorResponse" } } } }, "5XX": { "description": "Server error", - "headers": { - "x-ms-error-code": { - "required": false, - "description": "String error code indicating what went wrong.", - "schema": { - "type": "string" - } - } - }, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Azure.Core.Foundations.ErrorResponse" + "$ref": "#/components/schemas/ApiErrorResponse" } } } } }, "tags": [ - "Schedules" - ] - }, - "put": { - "operationId": "Schedules_createOrUpdate", - "summary": "Create or update a schedule", - "description": "Creates a new schedule or updates an existing schedule with the supplied definition.", - "parameters": [ - { - "$ref": "#/components/parameters/Azure.Core.Foundations.ApiVersionParameter" - }, - { - "name": "id", - "in": "path", - "required": true, - "description": "Identifier of the schedule.", - "schema": { - "type": "string" + "Fine-tuning" + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAI.RunGraderRequest" + } } }, - { - "name": "Foundry-Features", - "in": "header", - "required": true, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", - "schema": { - "type": "string", - "enum": [ - "Schedules=V1Preview" - ] + "description": "The request body." + }, + "x-oaiMeta": { + "name": "Run grader", + "beta": true, + "group": "graders", + "examples": [ + { + "title": "Score text alignment", + "request": { + "curl": "curl -X POST https://api.openai.com/v1/fine_tuning/alpha/graders/run \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"grader\": {\n \"type\": \"score_model\",\n \"name\": \"Example score model grader\",\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"input_text\",\n \"text\": \"Score how close the reference answer is to the model answer on a 0-1 scale. Return only the score.\n\nReference answer: {{item.reference_answer}}\n\nModel answer: {{sample.output_text}}\"\n }\n ]\n }\n ],\n \"model\": \"gpt-5-mini\",\n \"sampling_params\": {\n \"temperature\": 1,\n \"top_p\": 1,\n \"seed\": 42\n }\n },\n \"item\": {\n \"reference_answer\": \"fuzzy wuzzy was a bear\"\n },\n \"model_sample\": \"fuzzy wuzzy was a bear\"\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nresponse = client.fine_tuning.alpha.graders.run(\n grader={\n \"input\": \"input\",\n \"name\": \"name\",\n \"operation\": \"eq\",\n \"reference\": \"reference\",\n \"type\": \"string_check\",\n },\n model_sample=\"model_sample\",\n)\nprint(response.metadata)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nconst result = await openai.fineTuning.alpha.graders.run({\n grader: {\n type: \"score_model\",\n name: \"Example score model grader\",\n input: [\n {\n role: \"user\",\n content: [\n {\n type: \"input_text\",\n text: \"Score how close the reference answer is to the model answer on a 0-1 scale. Return only the score.\n\nReference answer: {{item.reference_answer}}\n\nModel answer: {{sample.output_text}}\",\n },\n ],\n },\n ],\n model: \"gpt-5-mini\",\n sampling_params: { temperature: 1, top_p: 1, seed: 42 },\n },\n item: { reference_answer: \"fuzzy wuzzy was a bear\" },\n model_sample: \"fuzzy wuzzy was a bear\",\n});\nconsole.log(result);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.fineTuning.alpha.graders.run({\n grader: {\n input: 'input',\n name: 'name',\n operation: 'eq',\n reference: 'reference',\n type: 'string_check',\n },\n model_sample: 'model_sample',\n});\n\nconsole.log(response.metadata);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tresponse, err := client.FineTuning.Alpha.Graders.Run(context.TODO(), openai.FineTuningAlphaGraderRunParams{\n\t\tGrader: openai.FineTuningAlphaGraderRunParamsGraderUnion{\n\t\t\tOfStringCheck: &openai.StringCheckGraderParam{\n\t\t\t\tInput: \"input\",\n\t\t\t\tName: \"name\",\n\t\t\t\tOperation: openai.StringCheckGraderOperationEq,\n\t\t\t\tReference: \"reference\",\n\t\t\t},\n\t\t},\n\t\tModelSample: \"model_sample\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", response.Metadata)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.finetuning.alpha.graders.GraderRunParams;\nimport com.openai.models.finetuning.alpha.graders.GraderRunResponse;\nimport com.openai.models.graders.gradermodels.StringCheckGrader;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n GraderRunParams params = GraderRunParams.builder()\n .grader(StringCheckGrader.builder()\n .input(\"input\")\n .name(\"name\")\n .operation(StringCheckGrader.Operation.EQ)\n .reference(\"reference\")\n .build())\n .modelSample(\"model_sample\")\n .build();\n GraderRunResponse response = client.fineTuning().alpha().graders().run(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nresponse = openai.fine_tuning.alpha.graders.run(\n grader: {input: \"input\", name: \"name\", operation: :eq, reference: \"reference\", type: :string_check},\n model_sample: \"model_sample\"\n)\n\nputs(response)" + }, + "response": "{\n \"reward\": 1.0,\n \"metadata\": {\n \"name\": \"Example score model grader\",\n \"type\": \"score_model\",\n \"errors\": {\n \"formula_parse_error\": false,\n \"sample_parse_error\": false,\n \"truncated_observation_error\": false,\n \"unresponsive_reward_error\": false,\n \"invalid_variable_error\": false,\n \"other_error\": false,\n \"python_grader_server_error\": false,\n \"python_grader_server_error_type\": null,\n \"python_grader_runtime_error\": false,\n \"python_grader_runtime_error_details\": null,\n \"model_grader_server_error\": false,\n \"model_grader_refusal_error\": false,\n \"model_grader_parse_error\": false,\n \"model_grader_server_error_details\": null\n },\n \"execution_time\": 4.365238428115845,\n \"scores\": {},\n \"token_usage\": {\n \"prompt_tokens\": 190,\n \"total_tokens\": 324,\n \"completion_tokens\": 134,\n \"cached_tokens\": 0\n },\n \"sampled_model_name\": \"gpt-4o-2024-08-06\"\n },\n \"sub_rewards\": {},\n \"model_grader_token_usage_per_model\": {\n \"gpt-4o-2024-08-06\": {\n \"prompt_tokens\": 190,\n \"total_tokens\": 324,\n \"completion_tokens\": 134,\n \"cached_tokens\": 0\n }\n }\n}\n" + }, + { + "title": "Score an image caption", + "request": { + "curl": "curl -X POST https://api.openai.com/v1/fine_tuning/alpha/graders/run \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"grader\": {\n \"type\": \"score_model\",\n \"name\": \"Image caption grader\",\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"input_text\",\n \"text\": \"Score how well the provided caption matches the image on a 0-1 scale. Only return the score.\n\nCaption: {{sample.output_text}}\"\n },\n {\n \"type\": \"input_image\",\n \"image_url\": \"https://example.com/dog-catching-ball.png\",\n \"file_id\": null,\n \"detail\": \"high\"\n }\n ]\n }\n ],\n \"model\": \"gpt-5-mini\",\n \"sampling_params\": {\n \"temperature\": 0.2\n }\n },\n \"item\": {\n \"expected_caption\": \"A golden retriever jumps to catch a tennis ball\"\n },\n \"model_sample\": \"A dog leaps to grab a tennis ball mid-air\"\n }'\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.fineTuning.alpha.graders.run({\n grader: {\n input: 'input',\n name: 'name',\n operation: 'eq',\n reference: 'reference',\n type: 'string_check',\n },\n model_sample: 'model_sample',\n});\n\nconsole.log(response.metadata);", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nresponse = client.fine_tuning.alpha.graders.run(\n grader={\n \"input\": \"input\",\n \"name\": \"name\",\n \"operation\": \"eq\",\n \"reference\": \"reference\",\n \"type\": \"string_check\",\n },\n model_sample=\"model_sample\",\n)\nprint(response.metadata)", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tresponse, err := client.FineTuning.Alpha.Graders.Run(context.TODO(), openai.FineTuningAlphaGraderRunParams{\n\t\tGrader: openai.FineTuningAlphaGraderRunParamsGraderUnion{\n\t\t\tOfStringCheck: &openai.StringCheckGraderParam{\n\t\t\t\tInput: \"input\",\n\t\t\t\tName: \"name\",\n\t\t\t\tOperation: openai.StringCheckGraderOperationEq,\n\t\t\t\tReference: \"reference\",\n\t\t\t},\n\t\t},\n\t\tModelSample: \"model_sample\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", response.Metadata)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.finetuning.alpha.graders.GraderRunParams;\nimport com.openai.models.finetuning.alpha.graders.GraderRunResponse;\nimport com.openai.models.graders.gradermodels.StringCheckGrader;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n GraderRunParams params = GraderRunParams.builder()\n .grader(StringCheckGrader.builder()\n .input(\"input\")\n .name(\"name\")\n .operation(StringCheckGrader.Operation.EQ)\n .reference(\"reference\")\n .build())\n .modelSample(\"model_sample\")\n .build();\n GraderRunResponse response = client.fineTuning().alpha().graders().run(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nresponse = openai.fine_tuning.alpha.graders.run(\n grader: {input: \"input\", name: \"name\", operation: :eq, reference: \"reference\", type: :string_check},\n model_sample: \"model_sample\"\n)\n\nputs(response)" + } + }, + { + "title": "Score an audio response", + "request": { + "curl": "curl -X POST https://api.openai.com/v1/fine_tuning/alpha/graders/run \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"grader\": {\n \"type\": \"score_model\",\n \"name\": \"Audio clarity grader\",\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"input_text\",\n \"text\": \"Listen to the clip and return a confidence score from 0 to 1 that the speaker said: {{item.target_phrase}}\"\n },\n {\n \"type\": \"input_audio\",\n \"input_audio\": {\n \"data\": \"{{item.audio_clip_b64}}\",\n \"format\": \"mp3\"\n }\n }\n ]\n }\n ],\n \"model\": \"gpt-audio\",\n \"sampling_params\": {\n \"temperature\": 0.2,\n \"top_p\": 1,\n \"seed\": 123\n }\n },\n \"item\": {\n \"target_phrase\": \"Please deliver the package on Tuesday\",\n \"audio_clip_b64\": \"\"\n },\n \"model_sample\": \"Please deliver the package on Tuesday\"\n }'\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.fineTuning.alpha.graders.run({\n grader: {\n input: 'input',\n name: 'name',\n operation: 'eq',\n reference: 'reference',\n type: 'string_check',\n },\n model_sample: 'model_sample',\n});\n\nconsole.log(response.metadata);", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nresponse = client.fine_tuning.alpha.graders.run(\n grader={\n \"input\": \"input\",\n \"name\": \"name\",\n \"operation\": \"eq\",\n \"reference\": \"reference\",\n \"type\": \"string_check\",\n },\n model_sample=\"model_sample\",\n)\nprint(response.metadata)", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tresponse, err := client.FineTuning.Alpha.Graders.Run(context.TODO(), openai.FineTuningAlphaGraderRunParams{\n\t\tGrader: openai.FineTuningAlphaGraderRunParamsGraderUnion{\n\t\t\tOfStringCheck: &openai.StringCheckGraderParam{\n\t\t\t\tInput: \"input\",\n\t\t\t\tName: \"name\",\n\t\t\t\tOperation: openai.StringCheckGraderOperationEq,\n\t\t\t\tReference: \"reference\",\n\t\t\t},\n\t\t},\n\t\tModelSample: \"model_sample\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", response.Metadata)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.finetuning.alpha.graders.GraderRunParams;\nimport com.openai.models.finetuning.alpha.graders.GraderRunResponse;\nimport com.openai.models.graders.gradermodels.StringCheckGrader;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n GraderRunParams params = GraderRunParams.builder()\n .grader(StringCheckGrader.builder()\n .input(\"input\")\n .name(\"name\")\n .operation(StringCheckGrader.Operation.EQ)\n .reference(\"reference\")\n .build())\n .modelSample(\"model_sample\")\n .build();\n GraderRunResponse response = client.fineTuning().alpha().graders().run(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nresponse = openai.fine_tuning.alpha.graders.run(\n grader: {input: \"input\", name: \"name\", operation: :eq, reference: \"reference\", type: :string_check},\n model_sample: \"model_sample\"\n)\n\nputs(response)" + } } - } - ], + ] + } + } + }, + "/openai/v1/fine_tuning/alpha/graders/validate": { + "post": { + "operationId": "Graders_validateGrader", + "summary": "Validate a grader", + "description": "Validates a grader.", + "parameters": [], "responses": { "200": { "description": "The request has succeeded.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Schedule" - } - } - } - }, - "201": { - "description": "The request has succeeded and a new resource has been created as a result.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Schedule" + "$ref": "#/components/schemas/OpenAI.ValidateGraderResponse" } } } }, "4XX": { "description": "Client error", - "headers": { - "x-ms-error-code": { - "required": false, - "description": "String error code indicating what went wrong.", - "schema": { - "type": "string" - } - } - }, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Azure.Core.Foundations.ErrorResponse" + "$ref": "#/components/schemas/ApiErrorResponse" } } } }, "5XX": { "description": "Server error", - "headers": { - "x-ms-error-code": { - "required": false, - "description": "String error code indicating what went wrong.", - "schema": { - "type": "string" - } - } - }, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Azure.Core.Foundations.ErrorResponse" + "$ref": "#/components/schemas/ApiErrorResponse" } } } } }, "tags": [ - "Schedules" + "Fine-tuning" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Schedule" + "$ref": "#/components/schemas/OpenAI.ValidateGraderRequest" } } }, - "description": "The resource instance." + "description": "The request body." + }, + "x-oaiMeta": { + "name": "Validate grader", + "beta": true, + "group": "graders", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/fine_tuning/alpha/graders/validate \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"grader\": {\n \"type\": \"string_check\",\n \"name\": \"Example string check grader\",\n \"input\": \"{{sample.output_text}}\",\n \"reference\": \"{{item.label}}\",\n \"operation\": \"eq\"\n }\n }'\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.fineTuning.alpha.graders.validate({\n grader: {\n input: 'input',\n name: 'name',\n operation: 'eq',\n reference: 'reference',\n type: 'string_check',\n },\n});\n\nconsole.log(response.grader);", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nresponse = client.fine_tuning.alpha.graders.validate(\n grader={\n \"input\": \"input\",\n \"name\": \"name\",\n \"operation\": \"eq\",\n \"reference\": \"reference\",\n \"type\": \"string_check\",\n },\n)\nprint(response.grader)", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tresponse, err := client.FineTuning.Alpha.Graders.Validate(context.TODO(), openai.FineTuningAlphaGraderValidateParams{\n\t\tGrader: openai.FineTuningAlphaGraderValidateParamsGraderUnion{\n\t\t\tOfStringCheckGrader: &openai.StringCheckGraderParam{\n\t\t\t\tInput: \"input\",\n\t\t\t\tName: \"name\",\n\t\t\t\tOperation: openai.StringCheckGraderOperationEq,\n\t\t\t\tReference: \"reference\",\n\t\t\t},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", response.Grader)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.finetuning.alpha.graders.GraderValidateParams;\nimport com.openai.models.finetuning.alpha.graders.GraderValidateResponse;\nimport com.openai.models.graders.gradermodels.StringCheckGrader;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n GraderValidateParams params = GraderValidateParams.builder()\n .grader(StringCheckGrader.builder()\n .input(\"input\")\n .name(\"name\")\n .operation(StringCheckGrader.Operation.EQ)\n .reference(\"reference\")\n .build())\n .build();\n GraderValidateResponse response = client.fineTuning().alpha().graders().validate(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nresponse = openai.fine_tuning.alpha.graders.validate(\n grader: {input: \"input\", name: \"name\", operation: :eq, reference: \"reference\", type: :string_check}\n)\n\nputs(response)" + }, + "response": "{\n \"grader\": {\n \"type\": \"string_check\",\n \"name\": \"Example string check grader\",\n \"input\": \"{{sample.output_text}}\",\n \"reference\": \"{{item.label}}\",\n \"operation\": \"eq\"\n }\n}\n" + } } } }, - "/schedules/{id}/runs": { + "/openai/v1/fine_tuning/checkpoints/{fine_tuned_model_checkpoint}/permissions": { "get": { - "operationId": "Schedules_listRuns", - "summary": "List schedule runs", - "description": "Returns schedule runs that match the supplied filters.", + "operationId": "FineTuning_listFineTuningCheckpointPermissions", + "summary": "List fine tuning checkpoint permissions", + "description": "Lists fine tuning checkpoint permissions matching the request filters.", "parameters": [ { - "$ref": "#/components/parameters/Azure.Core.Foundations.ApiVersionParameter" - }, - { - "name": "id", + "name": "fine_tuned_model_checkpoint", "in": "path", "required": true, - "description": "Identifier of the schedule.", + "description": "The ID of the fine-tuned model checkpoint to get permissions for.", "schema": { "type": "string" } }, { - "name": "type", + "name": "project_id", "in": "query", "required": false, - "description": "Filter by the type of schedule.", + "description": "The ID of the project to get permissions for.", "schema": { - "$ref": "#/components/schemas/ScheduleTaskType" - }, - "explode": false + "type": "string" + } }, { - "name": "enabled", + "name": "after", "in": "query", "required": false, - "description": "Filter by the enabled status.", + "description": "Identifier for the last permission ID from the previous pagination request.", "schema": { - "type": "boolean" + "type": "string" }, - "explode": false + "x-ms-list-continuation-token": true }, { - "name": "Foundry-Features", - "in": "header", - "required": true, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", + "name": "limit", + "in": "query", + "required": false, + "description": "Number of permissions to retrieve.", + "schema": { + "$ref": "#/components/schemas/integer", + "default": 10 + } + }, + { + "name": "order", + "in": "query", + "required": false, + "description": "The order in which to retrieve permissions.", "schema": { "type": "string", "enum": [ - "Schedules=V1Preview" - ] + "ascending", + "descending" + ], + "default": "descending" } } ], @@ -14872,100 +15271,65 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PagedScheduleRun" + "$ref": "#/components/schemas/OpenAI.ListFineTuningCheckpointPermissionResponse" } } } }, "4XX": { "description": "Client error", - "headers": { - "x-ms-error-code": { - "required": false, - "description": "String error code indicating what went wrong.", - "schema": { - "type": "string" - } - } - }, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Azure.Core.Foundations.ErrorResponse" + "$ref": "#/components/schemas/ApiErrorResponse" } } } }, "5XX": { "description": "Server error", - "headers": { - "x-ms-error-code": { - "required": false, - "description": "String error code indicating what went wrong.", - "schema": { - "type": "string" - } - } - }, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Azure.Core.Foundations.ErrorResponse" + "$ref": "#/components/schemas/ApiErrorResponse" } } } } }, "tags": [ - "Schedules" - ] - } - }, - "/schedules/{schedule_id}/runs/{run_id}": { - "get": { - "operationId": "Schedules_getRun", - "summary": "Get a schedule run", - "description": "Retrieves the specified run for a schedule.", + "Fine-tuning" + ], + "x-oaiMeta": { + "name": "List checkpoint permissions", + "group": "fine-tuning", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/fine_tuning/checkpoints/ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd/permissions \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst permission = await client.fineTuning.checkpoints.permissions.retrieve(\n 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',\n);\n\nconsole.log(permission.first_id);", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\npermission = client.fine_tuning.checkpoints.permissions.retrieve(\n fine_tuned_model_checkpoint=\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\",\n)\nprint(permission.first_id)", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpermission, err := client.FineTuning.Checkpoints.Permissions.Get(\n\t\tcontext.TODO(),\n\t\t\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\",\n\t\topenai.FineTuningCheckpointPermissionGetParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", permission.FirstID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.finetuning.checkpoints.permissions.PermissionRetrieveParams;\nimport com.openai.models.finetuning.checkpoints.permissions.PermissionRetrieveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n PermissionRetrieveResponse permission = client.fineTuning().checkpoints().permissions().retrieve(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\npermission = openai.fine_tuning.checkpoints.permissions.retrieve(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\")\n\nputs(permission)" + }, + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"object\": \"checkpoint.permission\",\n \"id\": \"cp_zc4Q7MP6XxulcVzj4MZdwsAB\",\n \"created_at\": 1721764867,\n \"project_id\": \"proj_abGMw1llN8IrBb6SvvY5A1iH\"\n },\n {\n \"object\": \"checkpoint.permission\",\n \"id\": \"cp_enQCFmOTGj3syEpYVhBRLTSy\",\n \"created_at\": 1721764800,\n \"project_id\": \"proj_iqGMw1llN8IrBb6SvvY5A1oF\"\n },\n ],\n \"first_id\": \"cp_zc4Q7MP6XxulcVzj4MZdwsAB\",\n \"last_id\": \"cp_enQCFmOTGj3syEpYVhBRLTSy\",\n \"has_more\": false\n}\n" + } + }, + "x-ms-list": true + }, + "post": { + "operationId": "FineTuning_createFineTuningCheckpointPermission", + "summary": "Create a fine tuning checkpoint permission", + "description": "Creates a fine tuning checkpoint permission from the supplied request.", "parameters": [ { - "name": "schedule_id", - "in": "path", - "required": true, - "description": "The unique identifier of the schedule.", - "schema": { - "type": "string" - } - }, - { - "name": "run_id", + "name": "fine_tuned_model_checkpoint", "in": "path", "required": true, - "description": "The unique identifier of the schedule run.", + "description": "The ID of the fine-tuned model checkpoint to create a permission for.", "schema": { "type": "string" } - }, - { - "name": "Foundry-Features", - "in": "header", - "required": true, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", - "schema": { - "type": "string", - "enum": [ - "Schedules=V1Preview" - ] - } - }, - { - "name": "api-version", - "in": "query", - "required": true, - "description": "The API version to use for this operation.", - "schema": { - "type": "string" - }, - "explode": false } ], "responses": { @@ -14974,7 +15338,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ScheduleRun" + "$ref": "#/components/schemas/OpenAI.ListFineTuningCheckpointPermissionResponse" } } } @@ -15001,79 +15365,59 @@ } }, "tags": [ - "Schedules" - ] + "Fine-tuning" + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAI.CreateFineTuningCheckpointPermissionRequest" + } + } + }, + "description": "The request body." + }, + "x-oaiMeta": { + "name": "Create checkpoint permissions", + "group": "fine-tuning", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/fine_tuning/checkpoints/ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd/permissions \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n -d '{\"project_ids\": [\"proj_abGMw1llN8IrBb6SvvY5A1iH\"]}'\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const permissionCreateResponse of client.fineTuning.checkpoints.permissions.create(\n 'ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd',\n { project_ids: ['string'] },\n)) {\n console.log(permissionCreateResponse.id);\n}", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\npage = client.fine_tuning.checkpoints.permissions.create(\n fine_tuned_model_checkpoint=\"ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd\",\n project_ids=[\"string\"],\n)\npage = page.data[0]\nprint(page.id)", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.FineTuning.Checkpoints.Permissions.New(\n\t\tcontext.TODO(),\n\t\t\"ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd\",\n\t\topenai.FineTuningCheckpointPermissionNewParams{\n\t\t\tProjectIDs: []string{\"string\"},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", page)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.finetuning.checkpoints.permissions.PermissionCreatePage;\nimport com.openai.models.finetuning.checkpoints.permissions.PermissionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n PermissionCreateParams params = PermissionCreateParams.builder()\n .fineTunedModelCheckpoint(\"ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd\")\n .addProjectId(\"string\")\n .build();\n PermissionCreatePage page = client.fineTuning().checkpoints().permissions().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\npage = openai.fine_tuning.checkpoints.permissions.create(\n \"ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd\",\n project_ids: [\"string\"]\n)\n\nputs(page)" + }, + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"object\": \"checkpoint.permission\",\n \"id\": \"cp_zc4Q7MP6XxulcVzj4MZdwsAB\",\n \"created_at\": 1721764867,\n \"project_id\": \"proj_abGMw1llN8IrBb6SvvY5A1iH\"\n }\n ],\n \"first_id\": \"cp_zc4Q7MP6XxulcVzj4MZdwsAB\",\n \"last_id\": \"cp_zc4Q7MP6XxulcVzj4MZdwsAB\",\n \"has_more\": false\n}\n" + } + } } }, - "/skills": { - "get": { - "operationId": "Skills_listSkills", - "summary": "List skills", - "description": "Returns the skills available in the current project.", + "/openai/v1/fine_tuning/checkpoints/{fine_tuned_model_checkpoint}/permissions/{permission_id}": { + "delete": { + "operationId": "FineTuning_deleteFineTuningCheckpointPermission", + "summary": "Delete a fine tuning checkpoint permission", + "description": "Deletes a fine tuning checkpoint permission by its identifier.", "parameters": [ { - "name": "limit", - "in": "query", - "required": false, - "description": "A limit on the number of objects to be returned. Limit can range between 1 and 100, and the\ndefault is 20.", - "schema": { - "type": "integer", - "format": "int32", - "default": 20 - }, - "explode": false - }, - { - "name": "order", - "in": "query", - "required": false, - "description": "Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`\nfor descending order.", - "schema": { - "$ref": "#/components/schemas/PageOrder" - }, - "explode": false - }, - { - "name": "after", - "in": "query", - "required": false, - "description": "A cursor for use in pagination. `after` is an object ID that defines your place in the list.\nFor instance, if you make a list request and receive 100 objects, ending with obj_foo, your\nsubsequent call can include after=obj_foo in order to fetch the next page of the list.", - "schema": { - "type": "string" - }, - "explode": false - }, - { - "name": "before", - "in": "query", - "required": false, - "description": "A cursor for use in pagination. `before` is an object ID that defines your place in the list.\nFor instance, if you make a list request and receive 100 objects, ending with obj_foo, your\nsubsequent call can include before=obj_foo in order to fetch the previous page of the list.", - "schema": { - "type": "string" - }, - "explode": false - }, - { - "name": "Foundry-Features", - "in": "header", + "name": "fine_tuned_model_checkpoint", + "in": "path", "required": true, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", + "description": "The ID of the fine-tuned model checkpoint to delete a permission for.", "schema": { - "type": "string", - "enum": [ - "Skills=V1Preview" - ] + "type": "string" } }, { - "name": "api-version", - "in": "query", + "name": "permission_id", + "in": "path", "required": true, - "description": "The API version to use for this operation.", + "description": "The ID of the fine-tuned model checkpoint permission to delete.", "schema": { "type": "string" - }, - "explode": false + } } ], "responses": { @@ -15082,33 +15426,7 @@ "content": { "application/json": { "schema": { - "type": "object", - "required": [ - "data", - "has_more" - ], - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Skill" - }, - "description": "The requested list of items." - }, - "first_id": { - "type": "string", - "description": "The first ID represented in this list." - }, - "last_id": { - "type": "string", - "description": "The last ID represented in this list." - }, - "has_more": { - "type": "boolean", - "description": "A value indicating whether there are additional values available not captured in this list." - } - }, - "description": "The response data for a requested list of items." + "$ref": "#/components/schemas/OpenAI.DeleteFineTuningCheckpointPermissionResponse" } } } @@ -15135,51 +15453,69 @@ } }, "tags": [ - "Skills" + "Fine-tuning" ], - "x-ms-foundry-meta": { - "required_previews": [ - "Skills=V1Preview" - ] + "x-oaiMeta": { + "name": "Delete checkpoint permission", + "group": "fine-tuning", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/fine_tuning/checkpoints/ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd/permissions/cp_zc4Q7MP6XxulcVzj4MZdwsAB \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst permission = await client.fineTuning.checkpoints.permissions.delete(\n 'cp_zc4Q7MP6XxulcVzj4MZdwsAB',\n { fine_tuned_model_checkpoint: 'ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd' },\n);\n\nconsole.log(permission.id);", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\npermission = client.fine_tuning.checkpoints.permissions.delete(\n permission_id=\"cp_zc4Q7MP6XxulcVzj4MZdwsAB\",\n fine_tuned_model_checkpoint=\"ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd\",\n)\nprint(permission.id)", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpermission, err := client.FineTuning.Checkpoints.Permissions.Delete(\n\t\tcontext.TODO(),\n\t\t\"ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd\",\n\t\t\"cp_zc4Q7MP6XxulcVzj4MZdwsAB\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", permission.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.finetuning.checkpoints.permissions.PermissionDeleteParams;\nimport com.openai.models.finetuning.checkpoints.permissions.PermissionDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n PermissionDeleteParams params = PermissionDeleteParams.builder()\n .fineTunedModelCheckpoint(\"ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd\")\n .permissionId(\"cp_zc4Q7MP6XxulcVzj4MZdwsAB\")\n .build();\n PermissionDeleteResponse permission = client.fineTuning().checkpoints().permissions().delete(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\npermission = openai.fine_tuning.checkpoints.permissions.delete(\n \"cp_zc4Q7MP6XxulcVzj4MZdwsAB\",\n fine_tuned_model_checkpoint: \"ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd\"\n)\n\nputs(permission)" + }, + "response": "{\n \"object\": \"checkpoint.permission\",\n \"id\": \"cp_zc4Q7MP6XxulcVzj4MZdwsAB\",\n \"deleted\": true\n}\n" + } } } }, - "/skills/{name}": { + "/openai/v1/fine_tuning/jobs": { "get": { - "operationId": "Skills_getSkill", - "summary": "Retrieve a skill", - "description": "Retrieves the specified skill and its current configuration.", + "operationId": "FineTuning_listPaginatedFineTuningJobs", + "summary": "List paginated fine tuning jobs", + "description": "Lists paginated fine tuning jobs matching the request filters.", "parameters": [ { - "name": "name", - "in": "path", - "required": true, - "description": "The unique name of the skill.", + "name": "after", + "in": "query", + "required": false, + "description": "Identifier for the last job from the previous pagination request.", "schema": { - "$ref": "#/components/schemas/SkillName" - } + "type": "string" + }, + "x-ms-list-continuation-token": true }, { - "name": "Foundry-Features", - "in": "header", - "required": true, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", + "name": "limit", + "in": "query", + "required": false, + "description": "Number of fine-tuning jobs to retrieve.", "schema": { - "type": "string", - "enum": [ - "Skills=V1Preview" - ] + "$ref": "#/components/schemas/integer", + "default": 20 } }, { - "name": "api-version", + "name": "metadata", "in": "query", - "required": true, - "description": "The API version to use for this operation.", + "required": false, + "description": "Optional metadata filter. To filter, use the syntax `metadata[k]=v`. Alternatively, set `metadata=null` to indicate no metadata.", "schema": { - "type": "string" - }, - "explode": false + "anyOf": [ + { + "type": "object", + "unevaluatedProperties": { + "type": "string" + } + }, + { + "type": "null" + } + ] + } } ], "responses": { @@ -15188,7 +15524,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Skill" + "$ref": "#/components/schemas/OpenAI.ListPaginatedFineTuningJobsResponse" } } } @@ -15215,58 +15551,38 @@ } }, "tags": [ - "Skills" + "Fine-tuning" ], - "x-ms-foundry-meta": { - "required_previews": [ - "Skills=V1Preview" - ] - } - }, - "post": { - "operationId": "updateSkill", - "summary": "Update a skill", - "description": "Modifies the specified skill's configuration.", - "parameters": [ - { - "name": "name", - "in": "path", - "required": true, - "description": "The name of the skill to update.", - "schema": { - "$ref": "#/components/schemas/SkillName" - } - }, - { - "name": "Foundry-Features", - "in": "header", - "required": true, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", - "schema": { - "type": "string", - "enum": [ - "Skills=V1Preview" - ] - } - }, - { - "name": "api-version", - "in": "query", - "required": true, - "description": "The API version to use for this operation.", - "schema": { - "type": "string" + "x-oaiMeta": { + "name": "List fine-tuning jobs", + "group": "fine-tuning", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/fine_tuning/jobs?limit=2&metadata[key]=value \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\npage = client.fine_tuning.jobs.list()\npage = page.data[0]\nprint(page.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const list = await openai.fineTuning.jobs.list();\n\n for await (const fineTune of list) {\n console.log(fineTune);\n }\n}\n\nmain();", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const fineTuningJob of client.fineTuning.jobs.list()) {\n console.log(fineTuningJob.id);\n}", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.FineTuning.Jobs.List(context.TODO(), openai.FineTuningJobListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", page)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.finetuning.jobs.JobListPage;\nimport com.openai.models.finetuning.jobs.JobListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n JobListPage page = client.fineTuning().jobs().list();\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\npage = openai.fine_tuning.jobs.list\n\nputs(page)" }, - "explode": false + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc123\",\n \"model\": \"gpt-4o-mini-2024-07-18\",\n \"created_at\": 1721764800,\n \"fine_tuned_model\": null,\n \"organization_id\": \"org-123\",\n \"result_files\": [],\n \"status\": \"queued\",\n \"validation_file\": null,\n \"training_file\": \"file-abc123\",\n \"metadata\": {\n \"key\": \"value\"\n }\n },\n { ... },\n { ... }\n ], \"has_more\": true\n}\n" } - ], + }, + "x-ms-list": true + }, + "post": { + "operationId": "FineTuning_createFineTuningJob", + "summary": "Create a fine tuning job", + "description": "Creates a fine tuning job from the supplied request.", + "parameters": [], "responses": { "200": { "description": "The request has succeeded.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Skill" + "$ref": "#/components/schemas/OpenAI.FineTuningJob" } } } @@ -15293,68 +15609,116 @@ } }, "tags": [ - "Skills" + "Fine-tuning" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "default_version": { - "type": "string", - "description": "The version identifier that the skill should point to. When set, the skill's default version will resolve to this version instead of the latest." - } - }, - "required": [ - "default_version" - ] + "$ref": "#/components/schemas/OpenAI.CreateFineTuningJobRequest" } } - } + }, + "description": "The request body." }, - "x-ms-foundry-meta": { - "required_previews": [ - "Skills=V1Preview" + "x-oaiMeta": { + "name": "Create fine-tuning job", + "group": "fine-tuning", + "examples": [ + { + "title": "Default", + "request": { + "curl": "curl https://api.openai.com/v1/fine_tuning/jobs \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"training_file\": \"file-BK7bzQj3FfZFXr7DbL6xJwfo\",\n \"model\": \"gpt-4o-mini\"\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfine_tuning_job = client.fine_tuning.jobs.create(\n model=\"gpt-4o-mini\",\n training_file=\"file-abc123\",\n)\nprint(fine_tuning_job.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const fineTune = await openai.fineTuning.jobs.create({\n training_file: \"file-abc123\"\n });\n\n console.log(fineTune);\n}\n\nmain();\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst fineTuningJob = await client.fineTuning.jobs.create({\n model: 'gpt-4o-mini',\n training_file: 'file-abc123',\n});\n\nconsole.log(fineTuningJob.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tfineTuningJob, err := client.FineTuning.Jobs.New(context.TODO(), openai.FineTuningJobNewParams{\n\t\tModel: openai.FineTuningJobNewParamsModelGPT4oMini,\n\t\tTrainingFile: \"file-abc123\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", fineTuningJob.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.finetuning.jobs.FineTuningJob;\nimport com.openai.models.finetuning.jobs.JobCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n JobCreateParams params = JobCreateParams.builder()\n .model(JobCreateParams.Model.GPT_4O_MINI)\n .trainingFile(\"file-abc123\")\n .build();\n FineTuningJob fineTuningJob = client.fineTuning().jobs().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nfine_tuning_job = openai.fine_tuning.jobs.create(model: :\"gpt-4o-mini\", training_file: \"file-abc123\")\n\nputs(fine_tuning_job)" + }, + "response": "{\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc123\",\n \"model\": \"gpt-4o-mini-2024-07-18\",\n \"created_at\": 1721764800,\n \"fine_tuned_model\": null,\n \"organization_id\": \"org-123\",\n \"result_files\": [],\n \"status\": \"queued\",\n \"validation_file\": null,\n \"training_file\": \"file-abc123\",\n \"method\": {\n \"type\": \"supervised\",\n \"supervised\": {\n \"hyperparameters\": {\n \"batch_size\": \"auto\",\n \"learning_rate_multiplier\": \"auto\",\n \"n_epochs\": \"auto\",\n }\n }\n },\n \"metadata\": null\n}\n" + }, + { + "title": "Epochs", + "request": { + "curl": "curl https://api.openai.com/v1/fine_tuning/jobs \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"training_file\": \"file-abc123\",\n \"model\": \"gpt-4o-mini\",\n \"method\": {\n \"type\": \"supervised\",\n \"supervised\": {\n \"hyperparameters\": {\n \"n_epochs\": 2\n }\n }\n }\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfine_tuning_job = client.fine_tuning.jobs.create(\n model=\"gpt-4o-mini\",\n training_file=\"file-abc123\",\n)\nprint(fine_tuning_job.id)", + "javascript": "import OpenAI from \"openai\";\nimport { SupervisedMethod, SupervisedHyperparameters } from \"openai/resources/fine-tuning/methods\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const fineTune = await openai.fineTuning.jobs.create({\n training_file: \"file-abc123\",\n model: \"gpt-4o-mini\",\n method: {\n type: \"supervised\",\n supervised: {\n hyperparameters: {\n n_epochs: 2\n }\n }\n }\n });\n\n console.log(fineTune);\n}\n\nmain();\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst fineTuningJob = await client.fineTuning.jobs.create({\n model: 'gpt-4o-mini',\n training_file: 'file-abc123',\n});\n\nconsole.log(fineTuningJob.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tfineTuningJob, err := client.FineTuning.Jobs.New(context.TODO(), openai.FineTuningJobNewParams{\n\t\tModel: openai.FineTuningJobNewParamsModelGPT4oMini,\n\t\tTrainingFile: \"file-abc123\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", fineTuningJob.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.finetuning.jobs.FineTuningJob;\nimport com.openai.models.finetuning.jobs.JobCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n JobCreateParams params = JobCreateParams.builder()\n .model(JobCreateParams.Model.GPT_4O_MINI)\n .trainingFile(\"file-abc123\")\n .build();\n FineTuningJob fineTuningJob = client.fineTuning().jobs().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nfine_tuning_job = openai.fine_tuning.jobs.create(model: :\"gpt-4o-mini\", training_file: \"file-abc123\")\n\nputs(fine_tuning_job)" + }, + "response": "{\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc123\",\n \"model\": \"gpt-4o-mini\",\n \"created_at\": 1721764800,\n \"fine_tuned_model\": null,\n \"organization_id\": \"org-123\",\n \"result_files\": [],\n \"status\": \"queued\",\n \"validation_file\": null,\n \"training_file\": \"file-abc123\",\n \"hyperparameters\": {\n \"batch_size\": \"auto\",\n \"learning_rate_multiplier\": \"auto\",\n \"n_epochs\": 2\n },\n \"method\": {\n \"type\": \"supervised\",\n \"supervised\": {\n \"hyperparameters\": {\n \"batch_size\": \"auto\",\n \"learning_rate_multiplier\": \"auto\",\n \"n_epochs\": 2\n }\n }\n },\n \"metadata\": null,\n \"error\": {\n \"code\": null,\n \"message\": null,\n \"param\": null\n },\n \"finished_at\": null,\n \"seed\": 683058546,\n \"trained_tokens\": null,\n \"estimated_finish\": null,\n \"integrations\": [],\n \"user_provided_suffix\": null,\n \"usage_metrics\": null,\n \"shared_with_openai\": false\n}\n" + }, + { + "title": "DPO", + "request": { + "curl": "curl https://api.openai.com/v1/fine_tuning/jobs \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"training_file\": \"file-abc123\",\n \"validation_file\": \"file-abc123\",\n \"model\": \"gpt-4o-mini\",\n \"method\": {\n \"type\": \"dpo\",\n \"dpo\": {\n \"hyperparameters\": {\n \"beta\": 0.1\n }\n }\n }\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfine_tuning_job = client.fine_tuning.jobs.create(\n model=\"gpt-4o-mini\",\n training_file=\"file-abc123\",\n)\nprint(fine_tuning_job.id)", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst fineTuningJob = await client.fineTuning.jobs.create({\n model: 'gpt-4o-mini',\n training_file: 'file-abc123',\n});\n\nconsole.log(fineTuningJob.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tfineTuningJob, err := client.FineTuning.Jobs.New(context.TODO(), openai.FineTuningJobNewParams{\n\t\tModel: openai.FineTuningJobNewParamsModelGPT4oMini,\n\t\tTrainingFile: \"file-abc123\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", fineTuningJob.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.finetuning.jobs.FineTuningJob;\nimport com.openai.models.finetuning.jobs.JobCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n JobCreateParams params = JobCreateParams.builder()\n .model(JobCreateParams.Model.GPT_4O_MINI)\n .trainingFile(\"file-abc123\")\n .build();\n FineTuningJob fineTuningJob = client.fineTuning().jobs().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nfine_tuning_job = openai.fine_tuning.jobs.create(model: :\"gpt-4o-mini\", training_file: \"file-abc123\")\n\nputs(fine_tuning_job)" + }, + "response": "{\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc\",\n \"model\": \"gpt-4o-mini\",\n \"created_at\": 1746130590,\n \"fine_tuned_model\": null,\n \"organization_id\": \"org-abc\",\n \"result_files\": [],\n \"status\": \"queued\",\n \"validation_file\": \"file-123\",\n \"training_file\": \"file-abc\",\n \"method\": {\n \"type\": \"dpo\",\n \"dpo\": {\n \"hyperparameters\": {\n \"beta\": 0.1,\n \"batch_size\": \"auto\",\n \"learning_rate_multiplier\": \"auto\",\n \"n_epochs\": \"auto\"\n }\n }\n },\n \"metadata\": null,\n \"error\": {\n \"code\": null,\n \"message\": null,\n \"param\": null\n },\n \"finished_at\": null,\n \"hyperparameters\": null,\n \"seed\": 1036326793,\n \"estimated_finish\": null,\n \"integrations\": [],\n \"user_provided_suffix\": null,\n \"usage_metrics\": null,\n \"shared_with_openai\": false\n}\n" + }, + { + "title": "Reinforcement", + "request": { + "curl": "curl https://api.openai.com/v1/fine_tuning/jobs \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"training_file\": \"file-abc\",\n \"validation_file\": \"file-123\",\n \"model\": \"o4-mini\",\n \"method\": {\n \"type\": \"reinforcement\",\n \"reinforcement\": {\n \"grader\": {\n \"type\": \"string_check\",\n \"name\": \"Example string check grader\",\n \"input\": \"{{sample.output_text}}\",\n \"reference\": \"{{item.label}}\",\n \"operation\": \"eq\"\n },\n \"hyperparameters\": {\n \"reasoning_effort\": \"medium\"\n }\n }\n }\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfine_tuning_job = client.fine_tuning.jobs.create(\n model=\"gpt-4o-mini\",\n training_file=\"file-abc123\",\n)\nprint(fine_tuning_job.id)", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst fineTuningJob = await client.fineTuning.jobs.create({\n model: 'gpt-4o-mini',\n training_file: 'file-abc123',\n});\n\nconsole.log(fineTuningJob.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tfineTuningJob, err := client.FineTuning.Jobs.New(context.TODO(), openai.FineTuningJobNewParams{\n\t\tModel: openai.FineTuningJobNewParamsModelGPT4oMini,\n\t\tTrainingFile: \"file-abc123\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", fineTuningJob.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.finetuning.jobs.FineTuningJob;\nimport com.openai.models.finetuning.jobs.JobCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n JobCreateParams params = JobCreateParams.builder()\n .model(JobCreateParams.Model.GPT_4O_MINI)\n .trainingFile(\"file-abc123\")\n .build();\n FineTuningJob fineTuningJob = client.fineTuning().jobs().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nfine_tuning_job = openai.fine_tuning.jobs.create(model: :\"gpt-4o-mini\", training_file: \"file-abc123\")\n\nputs(fine_tuning_job)" + }, + "response": "{\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc123\",\n \"model\": \"o4-mini\",\n \"created_at\": 1721764800,\n \"finished_at\": null,\n \"fine_tuned_model\": null,\n \"organization_id\": \"org-123\",\n \"result_files\": [],\n \"status\": \"validating_files\",\n \"validation_file\": \"file-123\",\n \"training_file\": \"file-abc\",\n \"trained_tokens\": null,\n \"error\": {},\n \"user_provided_suffix\": null,\n \"seed\": 950189191,\n \"estimated_finish\": null,\n \"integrations\": [],\n \"method\": {\n \"type\": \"reinforcement\",\n \"reinforcement\": {\n \"hyperparameters\": {\n \"batch_size\": \"auto\",\n \"learning_rate_multiplier\": \"auto\",\n \"n_epochs\": \"auto\",\n \"eval_interval\": \"auto\",\n \"eval_samples\": \"auto\",\n \"compute_multiplier\": \"auto\",\n \"reasoning_effort\": \"medium\"\n },\n \"grader\": {\n \"type\": \"string_check\",\n \"name\": \"Example string check grader\",\n \"input\": \"{{sample.output_text}}\",\n \"reference\": \"{{item.label}}\",\n \"operation\": \"eq\"\n },\n \"response_format\": null\n }\n },\n \"metadata\": null,\n \"usage_metrics\": null,\n \"shared_with_openai\": false\n}\n\n" + }, + { + "title": "Validation file", + "request": { + "curl": "curl https://api.openai.com/v1/fine_tuning/jobs \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"training_file\": \"file-abc123\",\n \"validation_file\": \"file-abc123\",\n \"model\": \"gpt-4o-mini\"\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfine_tuning_job = client.fine_tuning.jobs.create(\n model=\"gpt-4o-mini\",\n training_file=\"file-abc123\",\n)\nprint(fine_tuning_job.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const fineTune = await openai.fineTuning.jobs.create({\n training_file: \"file-abc123\",\n validation_file: \"file-abc123\"\n });\n\n console.log(fineTune);\n}\n\nmain();\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst fineTuningJob = await client.fineTuning.jobs.create({\n model: 'gpt-4o-mini',\n training_file: 'file-abc123',\n});\n\nconsole.log(fineTuningJob.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tfineTuningJob, err := client.FineTuning.Jobs.New(context.TODO(), openai.FineTuningJobNewParams{\n\t\tModel: openai.FineTuningJobNewParamsModelGPT4oMini,\n\t\tTrainingFile: \"file-abc123\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", fineTuningJob.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.finetuning.jobs.FineTuningJob;\nimport com.openai.models.finetuning.jobs.JobCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n JobCreateParams params = JobCreateParams.builder()\n .model(JobCreateParams.Model.GPT_4O_MINI)\n .trainingFile(\"file-abc123\")\n .build();\n FineTuningJob fineTuningJob = client.fineTuning().jobs().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nfine_tuning_job = openai.fine_tuning.jobs.create(model: :\"gpt-4o-mini\", training_file: \"file-abc123\")\n\nputs(fine_tuning_job)" + }, + "response": "{\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc123\",\n \"model\": \"gpt-4o-mini-2024-07-18\",\n \"created_at\": 1721764800,\n \"fine_tuned_model\": null,\n \"organization_id\": \"org-123\",\n \"result_files\": [],\n \"status\": \"queued\",\n \"validation_file\": \"file-abc123\",\n \"training_file\": \"file-abc123\",\n \"method\": {\n \"type\": \"supervised\",\n \"supervised\": {\n \"hyperparameters\": {\n \"batch_size\": \"auto\",\n \"learning_rate_multiplier\": \"auto\",\n \"n_epochs\": \"auto\",\n }\n }\n },\n \"metadata\": null\n}\n" + }, + { + "title": "W&B Integration", + "request": { + "curl": "curl https://api.openai.com/v1/fine_tuning/jobs \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"training_file\": \"file-abc123\",\n \"validation_file\": \"file-abc123\",\n \"model\": \"gpt-4o-mini\",\n \"integrations\": [\n {\n \"type\": \"wandb\",\n \"wandb\": {\n \"project\": \"my-wandb-project\",\n \"name\": \"ft-run-display-name\"\n \"tags\": [\n \"first-experiment\", \"v2\"\n ]\n }\n }\n ]\n }'\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst fineTuningJob = await client.fineTuning.jobs.create({\n model: 'gpt-4o-mini',\n training_file: 'file-abc123',\n});\n\nconsole.log(fineTuningJob.id);", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfine_tuning_job = client.fine_tuning.jobs.create(\n model=\"gpt-4o-mini\",\n training_file=\"file-abc123\",\n)\nprint(fine_tuning_job.id)", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tfineTuningJob, err := client.FineTuning.Jobs.New(context.TODO(), openai.FineTuningJobNewParams{\n\t\tModel: openai.FineTuningJobNewParamsModelGPT4oMini,\n\t\tTrainingFile: \"file-abc123\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", fineTuningJob.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.finetuning.jobs.FineTuningJob;\nimport com.openai.models.finetuning.jobs.JobCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n JobCreateParams params = JobCreateParams.builder()\n .model(JobCreateParams.Model.GPT_4O_MINI)\n .trainingFile(\"file-abc123\")\n .build();\n FineTuningJob fineTuningJob = client.fineTuning().jobs().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nfine_tuning_job = openai.fine_tuning.jobs.create(model: :\"gpt-4o-mini\", training_file: \"file-abc123\")\n\nputs(fine_tuning_job)" + }, + "response": "{\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc123\",\n \"model\": \"gpt-4o-mini-2024-07-18\",\n \"created_at\": 1721764800,\n \"fine_tuned_model\": null,\n \"organization_id\": \"org-123\",\n \"result_files\": [],\n \"status\": \"queued\",\n \"validation_file\": \"file-abc123\",\n \"training_file\": \"file-abc123\",\n \"integrations\": [\n {\n \"type\": \"wandb\",\n \"wandb\": {\n \"project\": \"my-wandb-project\",\n \"entity\": None,\n \"run_id\": \"ftjob-abc123\"\n }\n }\n ],\n \"method\": {\n \"type\": \"supervised\",\n \"supervised\": {\n \"hyperparameters\": {\n \"batch_size\": \"auto\",\n \"learning_rate_multiplier\": \"auto\",\n \"n_epochs\": \"auto\",\n }\n }\n },\n \"metadata\": null\n}\n" + } ] } - }, - "delete": { - "operationId": "Skills_deleteSkill", - "summary": "Delete a skill", - "description": "Removes the specified skill and its associated versions.", + } + }, + "/openai/v1/fine_tuning/jobs/{fine_tuning_job_id}": { + "get": { + "operationId": "FineTuning_retrieveFineTuningJob", + "summary": "Get a fine tuning job", + "description": "Retrieves a fine tuning job by its identifier.", "parameters": [ { - "name": "name", + "name": "fine_tuning_job_id", "in": "path", "required": true, - "description": "The unique name of the skill.", - "schema": { - "$ref": "#/components/schemas/SkillName" - } - }, - { - "name": "Foundry-Features", - "in": "header", - "required": true, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", - "schema": { - "type": "string", - "enum": [ - "Skills=V1Preview" - ] - } - }, - { - "name": "api-version", - "in": "query", - "required": true, - "description": "The API version to use for this operation.", + "description": "The ID of the fine-tuning job.", "schema": { "type": "string" - }, - "explode": false + } } ], "responses": { @@ -15363,7 +15727,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/DeleteSkillResponse" + "$ref": "#/components/schemas/OpenAI.FineTuningJob" } } } @@ -15390,60 +15754,49 @@ } }, "tags": [ - "Skills" + "Fine-tuning" ], - "x-ms-foundry-meta": { - "required_previews": [ - "Skills=V1Preview" - ] + "x-oaiMeta": { + "name": "Retrieve fine-tuning job", + "group": "fine-tuning", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfine_tuning_job = client.fine_tuning.jobs.retrieve(\n \"ft-AF1WoRqd3aJAHsqc9NY7iL8F\",\n)\nprint(fine_tuning_job.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const fineTune = await openai.fineTuning.jobs.retrieve(\"ftjob-abc123\");\n\n console.log(fineTune);\n}\n\nmain();\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst fineTuningJob = await client.fineTuning.jobs.retrieve('ft-AF1WoRqd3aJAHsqc9NY7iL8F');\n\nconsole.log(fineTuningJob.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tfineTuningJob, err := client.FineTuning.Jobs.Get(context.TODO(), \"ft-AF1WoRqd3aJAHsqc9NY7iL8F\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", fineTuningJob.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.finetuning.jobs.FineTuningJob;\nimport com.openai.models.finetuning.jobs.JobRetrieveParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n FineTuningJob fineTuningJob = client.fineTuning().jobs().retrieve(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nfine_tuning_job = openai.fine_tuning.jobs.retrieve(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\")\n\nputs(fine_tuning_job)" + }, + "response": "{\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc123\",\n \"model\": \"davinci-002\",\n \"created_at\": 1692661014,\n \"finished_at\": 1692661190,\n \"fine_tuned_model\": \"ft:davinci-002:my-org:custom_suffix:7q8mpxmy\",\n \"organization_id\": \"org-123\",\n \"result_files\": [\n \"file-abc123\"\n ],\n \"status\": \"succeeded\",\n \"validation_file\": null,\n \"training_file\": \"file-abc123\",\n \"hyperparameters\": {\n \"n_epochs\": 4,\n \"batch_size\": 1,\n \"learning_rate_multiplier\": 1.0\n },\n \"trained_tokens\": 5768,\n \"integrations\": [],\n \"seed\": 0,\n \"estimated_finish\": 0,\n \"method\": {\n \"type\": \"supervised\",\n \"supervised\": {\n \"hyperparameters\": {\n \"n_epochs\": 4,\n \"batch_size\": 1,\n \"learning_rate_multiplier\": 1.0\n }\n }\n }\n}\n" + } } } }, - "/skills/{name}/content": { - "get": { - "operationId": "getSkillContent", - "summary": "Download the zip content for the default version of a skill", - "description": "Downloads the zip content for the default version of a skill.", + "/openai/v1/fine_tuning/jobs/{fine_tuning_job_id}/cancel": { + "post": { + "operationId": "FineTuning_cancelFineTuningJob", + "summary": "Cancel a fine tuning job", + "description": "Cancels a fine tuning job by its identifier.", "parameters": [ { - "name": "name", + "name": "fine_tuning_job_id", "in": "path", "required": true, - "description": "The name of the skill.", - "schema": { - "$ref": "#/components/schemas/SkillName" - } - }, - { - "name": "Foundry-Features", - "in": "header", - "required": true, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", - "schema": { - "type": "string", - "enum": [ - "Skills=V1Preview" - ] - } - }, - { - "name": "api-version", - "in": "query", - "required": true, - "description": "The API version to use for this operation.", + "description": "The ID of the fine-tuning job to cancel.", "schema": { "type": "string" - }, - "explode": false + } } ], "responses": { "200": { - "description": "The response body for downloading a skill package.", + "description": "The request has succeeded.", "content": { - "application/zip": { + "application/json": { "schema": { - "contentMediaType": "application/zip" + "$ref": "#/components/schemas/OpenAI.FineTuningJob" } } } @@ -15470,60 +15823,69 @@ } }, "tags": [ - "Skills" + "Fine-tuning" ], - "x-ms-foundry-meta": { - "required_previews": [ - "Skills=V1Preview" - ] + "x-oaiMeta": { + "name": "Cancel fine-tuning", + "group": "fine-tuning", + "examples": { + "request": { + "curl": "curl -X POST https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/cancel \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfine_tuning_job = client.fine_tuning.jobs.cancel(\n \"ft-AF1WoRqd3aJAHsqc9NY7iL8F\",\n)\nprint(fine_tuning_job.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const fineTune = await openai.fineTuning.jobs.cancel(\"ftjob-abc123\");\n\n console.log(fineTune);\n}\nmain();", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst fineTuningJob = await client.fineTuning.jobs.cancel('ft-AF1WoRqd3aJAHsqc9NY7iL8F');\n\nconsole.log(fineTuningJob.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tfineTuningJob, err := client.FineTuning.Jobs.Cancel(context.TODO(), \"ft-AF1WoRqd3aJAHsqc9NY7iL8F\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", fineTuningJob.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.finetuning.jobs.FineTuningJob;\nimport com.openai.models.finetuning.jobs.JobCancelParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n FineTuningJob fineTuningJob = client.fineTuning().jobs().cancel(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nfine_tuning_job = openai.fine_tuning.jobs.cancel(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\")\n\nputs(fine_tuning_job)" + }, + "response": "{\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc123\",\n \"model\": \"gpt-4o-mini-2024-07-18\",\n \"created_at\": 1721764800,\n \"fine_tuned_model\": null,\n \"organization_id\": \"org-123\",\n \"result_files\": [],\n \"status\": \"cancelled\",\n \"validation_file\": \"file-abc123\",\n \"training_file\": \"file-abc123\"\n}\n" + } } } }, - "/skills/{name}/versions": { - "post": { - "operationId": "createSkillVersion_createSkillVersionFromFiles", + "/openai/v1/fine_tuning/jobs/{fine_tuning_job_id}/checkpoints": { + "get": { + "operationId": "FineTuning_listFineTuningJobCheckpoints", + "summary": "List fine tuning job checkpoints", + "description": "Lists fine tuning job checkpoints matching the request filters.", "parameters": [ { - "name": "name", + "name": "fine_tuning_job_id", "in": "path", "required": true, - "description": "The name of the skill. If the skill does not exist, it will be created.", + "description": "The ID of the fine-tuning job to get checkpoints for.", "schema": { - "$ref": "#/components/schemas/SkillName" + "type": "string" } }, { - "name": "Foundry-Features", - "in": "header", - "required": true, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", + "name": "after", + "in": "query", + "required": false, + "description": "Identifier for the last checkpoint ID from the previous pagination request.", "schema": { - "type": "string", - "enum": [ - "Skills=V1Preview" - ] - } + "type": "string" + }, + "x-ms-list-continuation-token": true }, { - "name": "api-version", + "name": "limit", "in": "query", - "required": true, - "description": "The API version to use for this operation.", + "required": false, + "description": "Number of checkpoints to retrieve.", "schema": { - "type": "string" - }, - "explode": false + "$ref": "#/components/schemas/integer", + "default": 10 + } } ], - "description": "Creates a new version of a skill. If the skill does not exist, it will be created. Creates a new version of a skill from uploaded files via multipart form data.", - "summary": "Create a new version of a skill Create a skill version from uploaded files", "responses": { "200": { "description": "The request has succeeded.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/SkillVersion" + "$ref": "#/components/schemas/OpenAI.ListFineTuningJobCheckpointsResponse" } } } @@ -15549,127 +15911,61 @@ } } }, - "x-ms-description-override": "Creates a new version of a skill. If the skill does not exist, it will be created.", - "x-ms-summary-override": "Create a new version of a skill", - "x-ms-foundry-meta": { - "required_previews": [ - "Skills=V1Preview" - ] - }, "tags": [ - "Skills" + "Fine-tuning" ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "inline_content": { - "$ref": "#/components/schemas/SkillInlineContent", - "description": "Inline skill content for simple skills without file uploads. Foundry-specific extension." - }, - "default": { - "type": "boolean", - "description": "Whether to set this version as the default." - } - } - } + "x-oaiMeta": { + "name": "List fine-tuning checkpoints", + "group": "fine-tuning", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/checkpoints \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const fineTuningJobCheckpoint of client.fineTuning.jobs.checkpoints.list(\n 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',\n)) {\n console.log(fineTuningJobCheckpoint.id);\n}", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\npage = client.fine_tuning.jobs.checkpoints.list(\n fine_tuning_job_id=\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\",\n)\npage = page.data[0]\nprint(page.id)", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.FineTuning.Jobs.Checkpoints.List(\n\t\tcontext.TODO(),\n\t\t\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\",\n\t\topenai.FineTuningJobCheckpointListParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", page)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.finetuning.jobs.checkpoints.CheckpointListPage;\nimport com.openai.models.finetuning.jobs.checkpoints.CheckpointListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n CheckpointListPage page = client.fineTuning().jobs().checkpoints().list(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\npage = openai.fine_tuning.jobs.checkpoints.list(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\")\n\nputs(page)" }, - "multipart/form-data": { - "schema": { - "$ref": "#/components/schemas/CreateSkillVersionFromFilesBody" - }, - "encoding": { - "files": { - "contentType": "*/*" - }, - "default": { - "contentType": "text/plain" - } - } - } + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"object\": \"fine_tuning.job.checkpoint\",\n \"id\": \"ftckpt_zc4Q7MP6XxulcVzj4MZdwsAB\",\n \"created_at\": 1721764867,\n \"fine_tuned_model_checkpoint\": \"ft:gpt-4o-mini-2024-07-18:my-org:custom-suffix:96olL566:ckpt-step-2000\",\n \"metrics\": {\n \"full_valid_loss\": 0.134,\n \"full_valid_mean_token_accuracy\": 0.874\n },\n \"fine_tuning_job_id\": \"ftjob-abc123\",\n \"step_number\": 2000\n },\n {\n \"object\": \"fine_tuning.job.checkpoint\",\n \"id\": \"ftckpt_enQCFmOTGj3syEpYVhBRLTSy\",\n \"created_at\": 1721764800,\n \"fine_tuned_model_checkpoint\": \"ft:gpt-4o-mini-2024-07-18:my-org:custom-suffix:7q8mpxmy:ckpt-step-1000\",\n \"metrics\": {\n \"full_valid_loss\": 0.167,\n \"full_valid_mean_token_accuracy\": 0.781\n },\n \"fine_tuning_job_id\": \"ftjob-abc123\",\n \"step_number\": 1000\n }\n ],\n \"first_id\": \"ftckpt_zc4Q7MP6XxulcVzj4MZdwsAB\",\n \"last_id\": \"ftckpt_enQCFmOTGj3syEpYVhBRLTSy\",\n \"has_more\": true\n}\n" } - } - }, + }, + "x-ms-list": true + } + }, + "/openai/v1/fine_tuning/jobs/{fine_tuning_job_id}/events": { "get": { - "operationId": "listSkillVersions", - "summary": "List skill versions", - "description": "Returns the available versions for the specified skill.", + "operationId": "FineTuning_listFineTuningEvents", + "summary": "List fine tuning events", + "description": "Lists fine tuning events matching the request filters.", "parameters": [ { - "name": "name", + "name": "fine_tuning_job_id", "in": "path", "required": true, - "description": "The name of the skill to list versions for.", + "description": "The ID of the fine-tuning job to get events for.", "schema": { - "$ref": "#/components/schemas/SkillName" + "type": "string" } }, - { - "name": "limit", - "in": "query", - "required": false, - "description": "A limit on the number of objects to be returned. Limit can range between 1 and 100, and the\ndefault is 20.", - "schema": { - "type": "integer", - "format": "int32", - "default": 20 - }, - "explode": false - }, - { - "name": "order", - "in": "query", - "required": false, - "description": "Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`\nfor descending order.", - "schema": { - "$ref": "#/components/schemas/PageOrder" - }, - "explode": false - }, { "name": "after", "in": "query", "required": false, - "description": "A cursor for use in pagination. `after` is an object ID that defines your place in the list.\nFor instance, if you make a list request and receive 100 objects, ending with obj_foo, your\nsubsequent call can include after=obj_foo in order to fetch the next page of the list.", + "description": "Identifier for the last event from the previous pagination request.", "schema": { "type": "string" }, - "explode": false + "x-ms-list-continuation-token": true }, { - "name": "before", + "name": "limit", "in": "query", "required": false, - "description": "A cursor for use in pagination. `before` is an object ID that defines your place in the list.\nFor instance, if you make a list request and receive 100 objects, ending with obj_foo, your\nsubsequent call can include before=obj_foo in order to fetch the previous page of the list.", - "schema": { - "type": "string" - }, - "explode": false - }, - { - "name": "Foundry-Features", - "in": "header", - "required": true, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", + "description": "Number of events to retrieve.", "schema": { - "type": "string", - "enum": [ - "Skills=V1Preview" - ] + "$ref": "#/components/schemas/integer", + "default": 20 } - }, - { - "name": "api-version", - "in": "query", - "required": true, - "description": "The API version to use for this operation.", - "schema": { - "type": "string" - }, - "explode": false } ], "responses": { @@ -15678,33 +15974,7 @@ "content": { "application/json": { "schema": { - "type": "object", - "required": [ - "data", - "has_more" - ], - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/SkillVersion" - }, - "description": "The requested list of items." - }, - "first_id": { - "type": "string", - "description": "The first ID represented in this list." - }, - "last_id": { - "type": "string", - "description": "The last ID represented in this list." - }, - "has_more": { - "type": "boolean", - "description": "A value indicating whether there are additional values available not captured in this list." - } - }, - "description": "The response data for a requested list of items." + "$ref": "#/components/schemas/OpenAI.ListFineTuningJobEventsResponse" } } } @@ -15731,60 +16001,41 @@ } }, "tags": [ - "Skills" + "Fine-tuning" ], - "x-ms-foundry-meta": { - "required_previews": [ - "Skills=V1Preview" - ] - } + "x-oaiMeta": { + "name": "List fine-tuning events", + "group": "fine-tuning", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/events \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\npage = client.fine_tuning.jobs.list_events(\n fine_tuning_job_id=\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\",\n)\npage = page.data[0]\nprint(page.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const list = await openai.fineTuning.list_events(id=\"ftjob-abc123\", limit=2);\n\n for await (const fineTune of list) {\n console.log(fineTune);\n }\n}\n\nmain();", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const fineTuningJobEvent of client.fineTuning.jobs.listEvents(\n 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',\n)) {\n console.log(fineTuningJobEvent.id);\n}", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.FineTuning.Jobs.ListEvents(\n\t\tcontext.TODO(),\n\t\t\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\",\n\t\topenai.FineTuningJobListEventsParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", page)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.finetuning.jobs.JobListEventsPage;\nimport com.openai.models.finetuning.jobs.JobListEventsParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n JobListEventsPage page = client.fineTuning().jobs().listEvents(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\npage = openai.fine_tuning.jobs.list_events(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\")\n\nputs(page)" + }, + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"object\": \"fine_tuning.job.event\",\n \"id\": \"ft-event-ddTJfwuMVpfLXseO0Am0Gqjm\",\n \"created_at\": 1721764800,\n \"level\": \"info\",\n \"message\": \"Fine tuning job successfully completed\",\n \"data\": null,\n \"type\": \"message\"\n },\n {\n \"object\": \"fine_tuning.job.event\",\n \"id\": \"ft-event-tyiGuB72evQncpH87xe505Sv\",\n \"created_at\": 1721764800,\n \"level\": \"info\",\n \"message\": \"New fine-tuned model created: ft:gpt-4o-mini:openai::7p4lURel\",\n \"data\": null,\n \"type\": \"message\"\n }\n ],\n \"has_more\": true\n}\n" + } + }, + "x-ms-list": true } }, - "/skills/{name}/versions/{version}": { - "get": { - "operationId": "getSkillVersion", - "summary": "Retrieve a specific version of a skill", - "description": "Retrieves the specified version of a skill by name and version identifier.", + "/openai/v1/fine_tuning/jobs/{fine_tuning_job_id}/pause": { + "post": { + "operationId": "FineTuning_pauseFineTuningJob", + "summary": "Pause a fine tuning job", + "description": "Pauses a fine tuning job.", "parameters": [ { - "name": "name", - "in": "path", - "required": true, - "description": "The name of the skill.", - "schema": { - "$ref": "#/components/schemas/SkillName" - } - }, - { - "name": "version", + "name": "fine_tuning_job_id", "in": "path", "required": true, - "description": "The version identifier to retrieve.", + "description": "The ID of the fine-tuning job to pause.", "schema": { "type": "string" } - }, - { - "name": "Foundry-Features", - "in": "header", - "required": true, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", - "schema": { - "type": "string", - "enum": [ - "Skills=V1Preview" - ] - } - }, - { - "name": "api-version", - "in": "query", - "required": true, - "description": "The API version to use for this operation.", - "schema": { - "type": "string" - }, - "explode": false } ], "responses": { @@ -15793,7 +16044,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/SkillVersion" + "$ref": "#/components/schemas/OpenAI.FineTuningJob" } } } @@ -15820,58 +16071,40 @@ } }, "tags": [ - "Skills" + "Fine-tuning" ], - "x-ms-foundry-meta": { - "required_previews": [ - "Skills=V1Preview" - ] + "x-oaiMeta": { + "name": "Pause fine-tuning", + "group": "fine-tuning", + "examples": { + "request": { + "curl": "curl -X POST https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/pause \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfine_tuning_job = client.fine_tuning.jobs.pause(\n \"ft-AF1WoRqd3aJAHsqc9NY7iL8F\",\n)\nprint(fine_tuning_job.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const fineTune = await openai.fineTuning.jobs.pause(\"ftjob-abc123\");\n\n console.log(fineTune);\n}\nmain();", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst fineTuningJob = await client.fineTuning.jobs.pause('ft-AF1WoRqd3aJAHsqc9NY7iL8F');\n\nconsole.log(fineTuningJob.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tfineTuningJob, err := client.FineTuning.Jobs.Pause(context.TODO(), \"ft-AF1WoRqd3aJAHsqc9NY7iL8F\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", fineTuningJob.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.finetuning.jobs.FineTuningJob;\nimport com.openai.models.finetuning.jobs.JobPauseParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n FineTuningJob fineTuningJob = client.fineTuning().jobs().pause(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nfine_tuning_job = openai.fine_tuning.jobs.pause(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\")\n\nputs(fine_tuning_job)" + }, + "response": "{\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc123\",\n \"model\": \"gpt-4o-mini-2024-07-18\",\n \"created_at\": 1721764800,\n \"fine_tuned_model\": null,\n \"organization_id\": \"org-123\",\n \"result_files\": [],\n \"status\": \"paused\",\n \"validation_file\": \"file-abc123\",\n \"training_file\": \"file-abc123\"\n}\n" + } } - }, - "delete": { - "operationId": "deleteSkillVersion", - "summary": "Delete a specific version of a skill", - "description": "Removes the specified version of a skill.", + } + }, + "/openai/v1/fine_tuning/jobs/{fine_tuning_job_id}/resume": { + "post": { + "operationId": "FineTuning_resumeFineTuningJob", + "summary": "Resume a fine tuning job", + "description": "Resumes a fine tuning job.", "parameters": [ { - "name": "name", - "in": "path", - "required": true, - "description": "The name of the skill.", - "schema": { - "$ref": "#/components/schemas/SkillName" - } - }, - { - "name": "version", + "name": "fine_tuning_job_id", "in": "path", "required": true, - "description": "The version identifier to delete.", + "description": "The ID of the fine-tuning job to resume.", "schema": { "type": "string" } - }, - { - "name": "Foundry-Features", - "in": "header", - "required": true, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", - "schema": { - "type": "string", - "enum": [ - "Skills=V1Preview" - ] - } - }, - { - "name": "api-version", - "in": "query", - "required": true, - "description": "The API version to use for this operation.", - "schema": { - "type": "string" - }, - "explode": false } ], "responses": { @@ -15880,7 +16113,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/DeleteSkillVersionResponse" + "$ref": "#/components/schemas/OpenAI.FineTuningJob" } } } @@ -15907,69 +16140,168 @@ } }, "tags": [ - "Skills" + "Fine-tuning" ], - "x-ms-foundry-meta": { - "required_previews": [ - "Skills=V1Preview" - ] + "x-oaiMeta": { + "name": "Resume fine-tuning", + "group": "fine-tuning", + "examples": { + "request": { + "curl": "curl -X POST https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/resume \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfine_tuning_job = client.fine_tuning.jobs.resume(\n \"ft-AF1WoRqd3aJAHsqc9NY7iL8F\",\n)\nprint(fine_tuning_job.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const fineTune = await openai.fineTuning.jobs.resume(\"ftjob-abc123\");\n\n console.log(fineTune);\n}\nmain();", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst fineTuningJob = await client.fineTuning.jobs.resume('ft-AF1WoRqd3aJAHsqc9NY7iL8F');\n\nconsole.log(fineTuningJob.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tfineTuningJob, err := client.FineTuning.Jobs.Resume(context.TODO(), \"ft-AF1WoRqd3aJAHsqc9NY7iL8F\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", fineTuningJob.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.finetuning.jobs.FineTuningJob;\nimport com.openai.models.finetuning.jobs.JobResumeParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n FineTuningJob fineTuningJob = client.fineTuning().jobs().resume(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nfine_tuning_job = openai.fine_tuning.jobs.resume(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\")\n\nputs(fine_tuning_job)" + }, + "response": "{\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc123\",\n \"model\": \"gpt-4o-mini-2024-07-18\",\n \"created_at\": 1721764800,\n \"fine_tuned_model\": null,\n \"organization_id\": \"org-123\",\n \"result_files\": [],\n \"status\": \"queued\",\n \"validation_file\": \"file-abc123\",\n \"training_file\": \"file-abc123\"\n}\n" + } } } }, - "/skills/{name}/versions/{version}/content": { - "get": { - "operationId": "getSkillVersionContent", - "summary": "Download the zip content for a specific version of a skill", - "description": "Downloads the zip content for a specific version of a skill.", - "parameters": [ - { - "name": "name", - "in": "path", - "required": true, - "description": "The name of the skill.", - "schema": { - "$ref": "#/components/schemas/SkillName" + "/openai/v1/images/edits": { + "post": { + "operationId": "Images_createImageEditMultipart_Images_createImageEditJson", + "parameters": [], + "description": "Creates an image edit multipart from the supplied request. Creates an image edit json from the supplied request.", + "summary": "Create an image edit multipart Create an image edit json", + "responses": { + "200": { + "description": "The request has succeeded.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAI.ImagesResponse" + } + } } }, - { - "name": "version", - "in": "path", - "required": true, - "description": "The version to download content for.", - "schema": { - "type": "string" + "4XX": { + "description": "Client error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } } }, - { - "name": "Foundry-Features", - "in": "header", - "required": true, - "description": "A feature flag opt-in required when using preview operations or modifying persisted preview resources.", - "schema": { - "type": "string", - "enum": [ - "Skills=V1Preview" - ] + "5XX": { + "description": "Server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } } - }, - { - "name": "api-version", - "in": "query", - "required": true, - "description": "The API version to use for this operation.", - "schema": { - "type": "string" - }, - "explode": false } + }, + "x-ms-request-body-description-override": "The request body.", + "x-oaiMeta": { + "name": "Create image edit", + "group": "images", + "examples": [ + { + "title": "Edit image", + "request": { + "curl": "curl -s -D >(grep -i x-request-id >&2) \\\n -o >(jq -r '.data[0].b64_json' | base64 --decode > gift-basket.png) \\\n -X POST \"https://api.openai.com/v1/images/edits\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -F \"model=gpt-image-1.5\" \\\n -F \"image[]=@body-lotion.png\" \\\n -F \"image[]=@bath-bomb.png\" \\\n -F \"image[]=@incense-kit.png\" \\\n -F \"image[]=@soap.png\" \\\n -F 'prompt=Create a lovely gift basket with these four items in it'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor image in client.images.edit(\n image=b\"Example data\",\n prompt=\"A cute baby sea otter wearing a beret\",\n):\n print(image)", + "javascript": "import fs from \"fs\";\nimport OpenAI, { toFile } from \"openai\";\n\nconst client = new OpenAI();\n\nconst imageFiles = [\n \"bath-bomb.png\",\n \"body-lotion.png\",\n \"incense-kit.png\",\n \"soap.png\",\n];\n\nconst images = await Promise.all(\n imageFiles.map(async (file) =>\n await toFile(fs.createReadStream(file), null, {\n type: \"image/png\",\n })\n ),\n);\n\nconst rsp = await client.images.edit({\n model: \"gpt-image-1.5\",\n image: images,\n prompt: \"Create a lovely gift basket with these four items in it\",\n});\n\n// Save the image to a file\nconst image_base64 = rsp.data[0].b64_json;\nconst image_bytes = Buffer.from(image_base64, \"base64\");\nfs.writeFileSync(\"basket.png\", image_bytes);\n", + "node.js": "import fs from 'fs';\nimport OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst imagesResponse = await client.images.edit({\n image: fs.createReadStream('path/to/file'),\n prompt: 'A cute baby sea otter wearing a beret',\n});\n\nconsole.log(imagesResponse);", + "go": "package main\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\timagesResponse, err := client.Images.Edit(context.TODO(), openai.ImageEditParams{\n\t\tImage: openai.ImageEditParamsImageUnion{\n\t\t\tOfFile: io.Reader(bytes.NewBuffer([]byte(\"Example data\"))),\n\t\t},\n\t\tPrompt: \"A cute baby sea otter wearing a beret\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", imagesResponse)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.images.ImageEditParams;\nimport com.openai.models.images.ImagesResponse;\nimport java.io.ByteArrayInputStream;\nimport java.io.InputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ImageEditParams params = ImageEditParams.builder()\n .image(new ByteArrayInputStream(\"Example data\".getBytes()))\n .prompt(\"A cute baby sea otter wearing a beret\")\n .build();\n ImagesResponse imagesResponse = client.images().edit(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nimages_response = openai.images.edit(image: StringIO.new(\"Example data\"), prompt: \"A cute baby sea otter wearing a beret\")\n\nputs(images_response)" + } + }, + { + "title": "Streaming", + "request": { + "curl": "curl -s -N -X POST \"https://api.openai.com/v1/images/edits\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -F \"model=gpt-image-1.5\" \\\n -F \"image[]=@body-lotion.png\" \\\n -F \"image[]=@bath-bomb.png\" \\\n -F \"image[]=@incense-kit.png\" \\\n -F \"image[]=@soap.png\" \\\n -F 'prompt=Create a lovely gift basket with these four items in it' \\\n -F \"stream=true\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor image in client.images.edit(\n image=b\"Example data\",\n prompt=\"A cute baby sea otter wearing a beret\",\n):\n print(image)", + "javascript": "import fs from \"fs\";\nimport OpenAI, { toFile } from \"openai\";\n\nconst client = new OpenAI();\n\nconst imageFiles = [\n \"bath-bomb.png\",\n \"body-lotion.png\",\n \"incense-kit.png\",\n \"soap.png\",\n];\n\nconst images = await Promise.all(\n imageFiles.map(async (file) =>\n await toFile(fs.createReadStream(file), null, {\n type: \"image/png\",\n })\n ),\n);\n\nconst stream = await client.images.edit({\n model: \"gpt-image-1.5\",\n image: images,\n prompt: \"Create a lovely gift basket with these four items in it\",\n stream: true,\n});\n\nfor await (const event of stream) {\n console.log(event);\n}\n", + "node.js": "import fs from 'fs';\nimport OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst imagesResponse = await client.images.edit({\n image: fs.createReadStream('path/to/file'),\n prompt: 'A cute baby sea otter wearing a beret',\n});\n\nconsole.log(imagesResponse);", + "go": "package main\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\timagesResponse, err := client.Images.Edit(context.TODO(), openai.ImageEditParams{\n\t\tImage: openai.ImageEditParamsImageUnion{\n\t\t\tOfFile: io.Reader(bytes.NewBuffer([]byte(\"Example data\"))),\n\t\t},\n\t\tPrompt: \"A cute baby sea otter wearing a beret\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", imagesResponse)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.images.ImageEditParams;\nimport com.openai.models.images.ImagesResponse;\nimport java.io.ByteArrayInputStream;\nimport java.io.InputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ImageEditParams params = ImageEditParams.builder()\n .image(new ByteArrayInputStream(\"Example data\".getBytes()))\n .prompt(\"A cute baby sea otter wearing a beret\")\n .build();\n ImagesResponse imagesResponse = client.images().edit(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nimages_response = openai.images.edit(image: StringIO.new(\"Example data\"), prompt: \"A cute baby sea otter wearing a beret\")\n\nputs(images_response)" + }, + "response": "event: image_edit.partial_image\ndata: {\"type\":\"image_edit.partial_image\",\"b64_json\":\"...\",\"partial_image_index\":0}\n\nevent: image_edit.completed\ndata: {\"type\":\"image_edit.completed\",\"b64_json\":\"...\",\"usage\":{\"total_tokens\":100,\"input_tokens\":50,\"output_tokens\":50,\"input_tokens_details\":{\"text_tokens\":10,\"image_tokens\":40}}}\n" + } + ] + }, + "tags": [ + "Images" ], + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/OpenAI.CreateImageEditRequest" + }, + "encoding": { + "image": { + "contentType": "application/octet-stream, application/json" + }, + "background": { + "contentType": "application/json" + }, + "model": { + "contentType": "application/json" + }, + "n": { + "contentType": "application/json" + }, + "size": { + "contentType": "application/json" + }, + "response_format": { + "contentType": "application/json" + }, + "output_format": { + "contentType": "application/json" + }, + "output_compression": { + "contentType": "application/json" + }, + "input_fidelity": { + "contentType": "application/json" + }, + "stream": { + "contentType": "application/json" + }, + "partial_images": { + "contentType": "application/json" + }, + "quality": { + "contentType": "application/json" + } + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAI.EditImageBodyJsonParam" + } + } + }, + "description": "The multipart request body. The request body." + } + } + }, + "/openai/v1/images/generations": { + "post": { + "operationId": "Images_createImage", + "summary": "Create an image", + "description": "Creates an image from the supplied request.", + "parameters": [], "responses": { "200": { - "description": "The response body for downloading a skill package.", + "description": "The request has succeeded.", "content": { - "application/zip": { + "application/json": { "schema": { - "contentMediaType": "application/zip" + "$ref": "#/components/schemas/OpenAI.ImagesResponse" } } } @@ -15996,107 +16328,151 @@ } }, "tags": [ - "Skills" + "Images" ], - "x-ms-foundry-meta": { - "required_previews": [ - "Skills=V1Preview" + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAI.CreateImageRequest" + } + } + }, + "description": "The request body." + }, + "x-oaiMeta": { + "name": "Create image", + "group": "images", + "examples": [ + { + "title": "Generate image", + "request": { + "curl": "curl https://api.openai.com/v1/images/generations \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"gpt-image-1.5\",\n \"prompt\": \"A cute baby sea otter\",\n \"n\": 1,\n \"size\": \"1024x1024\"\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor image in client.images.generate(\n prompt=\"A cute baby sea otter\",\n):\n print(image)", + "javascript": "import OpenAI from \"openai\";\nimport { writeFile } from \"fs/promises\";\n\nconst client = new OpenAI();\n\nconst img = await client.images.generate({\n model: \"gpt-image-1.5\",\n prompt: \"A cute baby sea otter\",\n n: 1,\n size: \"1024x1024\"\n});\n\nconst imageBuffer = Buffer.from(img.data[0].b64_json, \"base64\");\nawait writeFile(\"output.png\", imageBuffer);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst imagesResponse = await client.images.generate({ prompt: 'A cute baby sea otter' });\n\nconsole.log(imagesResponse);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\timagesResponse, err := client.Images.Generate(context.TODO(), openai.ImageGenerateParams{\n\t\tPrompt: \"A cute baby sea otter\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", imagesResponse)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.images.ImageGenerateParams;\nimport com.openai.models.images.ImagesResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ImageGenerateParams params = ImageGenerateParams.builder()\n .prompt(\"A cute baby sea otter\")\n .build();\n ImagesResponse imagesResponse = client.images().generate(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nimages_response = openai.images.generate(prompt: \"A cute baby sea otter\")\n\nputs(images_response)" + }, + "response": "{\n \"created\": 1713833628,\n \"data\": [\n {\n \"b64_json\": \"...\"\n }\n ],\n \"usage\": {\n \"total_tokens\": 100,\n \"input_tokens\": 50,\n \"output_tokens\": 50,\n \"input_tokens_details\": {\n \"text_tokens\": 10,\n \"image_tokens\": 40\n }\n }\n}\n" + }, + { + "title": "Streaming", + "request": { + "curl": "curl https://api.openai.com/v1/images/generations \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"gpt-image-1.5\",\n \"prompt\": \"A cute baby sea otter\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"stream\": true\n }' \\\n --no-buffer\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor image in client.images.generate(\n prompt=\"A cute baby sea otter\",\n):\n print(image)", + "javascript": "import OpenAI from \"openai\";\n\nconst client = new OpenAI();\n\nconst stream = await client.images.generate({\n model: \"gpt-image-1.5\",\n prompt: \"A cute baby sea otter\",\n n: 1,\n size: \"1024x1024\",\n stream: true,\n});\n\nfor await (const event of stream) {\n console.log(event);\n}\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst imagesResponse = await client.images.generate({ prompt: 'A cute baby sea otter' });\n\nconsole.log(imagesResponse);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\timagesResponse, err := client.Images.Generate(context.TODO(), openai.ImageGenerateParams{\n\t\tPrompt: \"A cute baby sea otter\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", imagesResponse)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.images.ImageGenerateParams;\nimport com.openai.models.images.ImagesResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ImageGenerateParams params = ImageGenerateParams.builder()\n .prompt(\"A cute baby sea otter\")\n .build();\n ImagesResponse imagesResponse = client.images().generate(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nimages_response = openai.images.generate(prompt: \"A cute baby sea otter\")\n\nputs(images_response)" + }, + "response": "event: image_generation.partial_image\ndata: {\"type\":\"image_generation.partial_image\",\"b64_json\":\"...\",\"partial_image_index\":0}\n\nevent: image_generation.completed\ndata: {\"type\":\"image_generation.completed\",\"b64_json\":\"...\",\"usage\":{\"total_tokens\":100,\"input_tokens\":50,\"output_tokens\":50,\"input_tokens_details\":{\"text_tokens\":10,\"image_tokens\":40}}}\n" + } ] } } }, - "/toolboxes": { - "get": { - "operationId": "listToolboxes", - "summary": "List toolboxes", - "description": "Returns the toolboxes available in the current project.", - "parameters": [ - { - "name": "limit", - "in": "query", - "required": false, - "description": "A limit on the number of objects to be returned. Limit can range between 1 and 100, and the\ndefault is 20.", - "schema": { - "type": "integer", - "format": "int32", - "default": 20 - }, - "explode": false - }, - { - "name": "order", - "in": "query", - "required": false, - "description": "Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`\nfor descending order.", - "schema": { - "$ref": "#/components/schemas/PageOrder" - }, - "explode": false - }, - { - "name": "after", - "in": "query", - "required": false, - "description": "A cursor for use in pagination. `after` is an object ID that defines your place in the list.\nFor instance, if you make a list request and receive 100 objects, ending with obj_foo, your\nsubsequent call can include after=obj_foo in order to fetch the next page of the list.", - "schema": { - "type": "string" - }, - "explode": false + "/openai/v1/images/variations": { + "post": { + "operationId": "Images_createImageVariation", + "summary": "Create an image variation", + "description": "Creates an image variation from the supplied request.", + "parameters": [], + "responses": { + "200": { + "description": "The request has succeeded.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAI.ImagesResponse" + } + } + } }, - { - "name": "before", - "in": "query", - "required": false, - "description": "A cursor for use in pagination. `before` is an object ID that defines your place in the list.\nFor instance, if you make a list request and receive 100 objects, ending with obj_foo, your\nsubsequent call can include before=obj_foo in order to fetch the previous page of the list.", - "schema": { - "type": "string" - }, - "explode": false + "4XX": { + "description": "Client error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } }, - { - "name": "api-version", - "in": "query", - "required": true, - "description": "The API version to use for this operation.", - "schema": { - "type": "string" - }, - "explode": false + "5XX": { + "description": "Server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } } + }, + "tags": [ + "Images" ], + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/OpenAI.CreateImageVariationRequest" + }, + "encoding": { + "model": { + "contentType": "application/json" + }, + "n": { + "contentType": "application/json" + }, + "response_format": { + "contentType": "application/json" + }, + "size": { + "contentType": "application/json" + } + } + } + }, + "description": "The multipart request body." + }, + "x-oaiMeta": { + "name": "Create image variation", + "group": "images", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/images/variations \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -F image=\"@otter.png\" \\\n -F n=2 \\\n -F size=\"1024x1024\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nimages_response = client.images.create_variation(\n image=b\"Example data\",\n)\nprint(images_response.created)", + "javascript": "import fs from \"fs\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const image = await openai.images.createVariation({\n image: fs.createReadStream(\"otter.png\"),\n });\n\n console.log(image.data);\n}\nmain();", + "csharp": "using System;\n\nusing OpenAI.Images;\n\nImageClient client = new(\n model: \"dall-e-2\",\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nGeneratedImage image = client.GenerateImageVariation(imageFilePath: \"otter.png\");\n\nConsole.WriteLine(image.ImageUri);\n", + "node.js": "import fs from 'fs';\nimport OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst imagesResponse = await client.images.createVariation({\n image: fs.createReadStream('otter.png'),\n});\n\nconsole.log(imagesResponse.created);", + "go": "package main\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\timagesResponse, err := client.Images.NewVariation(context.TODO(), openai.ImageNewVariationParams{\n\t\tImage: io.Reader(bytes.NewBuffer([]byte(\"Example data\"))),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", imagesResponse.Created)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.images.ImageCreateVariationParams;\nimport com.openai.models.images.ImagesResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ImageCreateVariationParams params = ImageCreateVariationParams.builder()\n .image(new ByteArrayInputStream(\"Example data\".getBytes()))\n .build();\n ImagesResponse imagesResponse = client.images().createVariation(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nimages_response = openai.images.create_variation(image: StringIO.new(\"Example data\"))\n\nputs(images_response)" + }, + "response": "{\n \"created\": 1589478378,\n \"data\": [\n {\n \"url\": \"https://...\"\n },\n {\n \"url\": \"https://...\"\n }\n ]\n}\n" + } + } + } + }, + "/openai/v1/models": { + "get": { + "operationId": "OpenAIModels_listModels", + "summary": "List models", + "description": "Lists models matching the request filters.", + "parameters": [], "responses": { "200": { "description": "The request has succeeded.", "content": { "application/json": { "schema": { - "type": "object", - "required": [ - "data", - "has_more" - ], - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ToolboxObject" - }, - "description": "The requested list of items." - }, - "first_id": { - "type": "string", - "description": "The first ID represented in this list." - }, - "last_id": { - "type": "string", - "description": "The last ID represented in this list." - }, - "has_more": { - "type": "boolean", - "description": "A value indicating whether there are additional values available not captured in this list." - } - }, - "description": "The response data for a requested list of items." + "$ref": "#/components/schemas/OpenAI.ListModelsResponse" } } } @@ -16123,34 +16499,42 @@ } }, "tags": [ - "Toolboxes" - ] + "Models" + ], + "x-oaiMeta": { + "name": "List models", + "group": "models", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/models \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\npage = client.models.list()\npage = page.data[0]\nprint(page.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const list = await openai.models.list();\n\n for await (const model of list) {\n console.log(model);\n }\n}\nmain();", + "csharp": "using System;\n\nusing OpenAI.Models;\n\nOpenAIModelClient client = new(\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nforeach (var model in client.GetModels().Value)\n{\n Console.WriteLine(model.Id);\n}\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const model of client.models.list()) {\n console.log(model.id);\n}", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.Models.List(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", page)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.models.ModelListPage;\nimport com.openai.models.models.ModelListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ModelListPage page = client.models().list();\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\npage = openai.models.list\n\nputs(page)" + }, + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"model-id-0\",\n \"object\": \"model\",\n \"created\": 1686935002,\n \"owned_by\": \"organization-owner\"\n },\n {\n \"id\": \"model-id-1\",\n \"object\": \"model\",\n \"created\": 1686935002,\n \"owned_by\": \"organization-owner\",\n },\n {\n \"id\": \"model-id-2\",\n \"object\": \"model\",\n \"created\": 1686935002,\n \"owned_by\": \"openai\"\n },\n ]\n}\n" + } + }, + "x-ms-list": true } }, - "/toolboxes/{name}": { - "get": { - "operationId": "getToolbox", - "summary": "Retrieve a toolbox", - "description": "Retrieves the specified toolbox and its current configuration.", + "/openai/v1/models/{model}": { + "delete": { + "operationId": "OpenAIModels_deleteModel", + "summary": "Delete a model", + "description": "Deletes a model by its identifier.", "parameters": [ { - "name": "name", + "name": "model", "in": "path", "required": true, - "description": "The name of the toolbox to retrieve.", + "description": "The model to delete", "schema": { "type": "string" } - }, - { - "name": "api-version", - "in": "query", - "required": true, - "description": "The API version to use for this operation.", - "schema": { - "type": "string" - }, - "explode": false } ], "responses": { @@ -16159,7 +16543,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ToolboxObject" + "$ref": "#/components/schemas/OpenAI.DeleteModelResponse" } } } @@ -16186,26 +16570,39 @@ } }, "tags": [ - "Toolboxes" - ] + "Models" + ], + "x-oaiMeta": { + "name": "Delete a fine-tuned model", + "group": "models", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/models/ft:gpt-4o-mini:acemeco:suffix:abc123 \\\n -X DELETE \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nmodel_deleted = client.models.delete(\n \"ft:gpt-4o-mini:acemeco:suffix:abc123\",\n)\nprint(model_deleted.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const model = await openai.models.delete(\"ft:gpt-4o-mini:acemeco:suffix:abc123\");\n\n console.log(model);\n}\nmain();", + "csharp": "using System;\nusing System.ClientModel;\n\nusing OpenAI.Models;\n\nOpenAIModelClient client = new(\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nClientResult success = client.DeleteModel(\"ft:gpt-4o-mini:acemeco:suffix:abc123\");\nConsole.WriteLine(success);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst modelDeleted = await client.models.delete('ft:gpt-4o-mini:acemeco:suffix:abc123');\n\nconsole.log(modelDeleted.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tmodelDeleted, err := client.Models.Delete(context.TODO(), \"ft:gpt-4o-mini:acemeco:suffix:abc123\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", modelDeleted.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.models.ModelDeleteParams;\nimport com.openai.models.models.ModelDeleted;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ModelDeleted modelDeleted = client.models().delete(\"ft:gpt-4o-mini:acemeco:suffix:abc123\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nmodel_deleted = openai.models.delete(\"ft:gpt-4o-mini:acemeco:suffix:abc123\")\n\nputs(model_deleted)" + }, + "response": "{\n \"id\": \"ft:gpt-4o-mini:acemeco:suffix:abc123\",\n \"object\": \"model\",\n \"deleted\": true\n}\n" + } + } }, - "patch": { - "operationId": "updateToolbox", - "summary": "Update a toolbox to point to a specific version", - "description": "Updates the toolbox's default version pointer to the specified version.", + "get": { + "operationId": "OpenAIModels_retrieveModel", + "summary": "Get a model", + "description": "Retrieves a model by its identifier.", "parameters": [ { - "$ref": "#/components/parameters/UpdateToolboxRequest.name" - }, - { - "name": "api-version", - "in": "query", + "name": "model", + "in": "path", "required": true, - "description": "The API version to use for this operation.", + "description": "The ID of the model to use for this request", "schema": { "type": "string" - }, - "explode": false + } } ], "responses": { @@ -16214,7 +16611,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ToolboxObject" + "$ref": "#/components/schemas/OpenAI.Model" } } } @@ -16241,47 +16638,139 @@ } }, "tags": [ - "Toolboxes" + "Models" + ], + "x-oaiMeta": { + "name": "Retrieve model", + "group": "models", + "examples": { + "request": { + "curl": "curl https://api.openai.com/v1/models/VAR_chat_model_id \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nmodel = client.models.retrieve(\n \"gpt-4o-mini\",\n)\nprint(model.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const model = await openai.models.retrieve(\"VAR_chat_model_id\");\n\n console.log(model);\n}\n\nmain();", + "csharp": "using System;\nusing System.ClientModel;\n\nusing OpenAI.Models;\n\n OpenAIModelClient client = new(\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nClientResult model = client.GetModel(\"babbage-002\");\nConsole.WriteLine(model.Value.Id);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst model = await client.models.retrieve('gpt-4o-mini');\n\nconsole.log(model.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tmodel, err := client.Models.Get(context.TODO(), \"gpt-4o-mini\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", model.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.models.Model;\nimport com.openai.models.models.ModelRetrieveParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n Model model = client.models().retrieve(\"gpt-4o-mini\");\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nmodel = openai.models.retrieve(\"gpt-4o-mini\")\n\nputs(model)" + }, + "response": "{\n \"id\": \"VAR_chat_model_id\",\n \"object\": \"model\",\n \"created\": 1686935002,\n \"owned_by\": \"openai\"\n}\n" + } + } + } + }, + "/openai/v1/moderations": { + "post": { + "operationId": "Moderations_createModeration", + "summary": "Create a moderation", + "description": "Creates a moderation from the supplied request.", + "parameters": [], + "responses": { + "200": { + "description": "The request has succeeded.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAI.CreateModerationResponse" + } + } + } + }, + "4XX": { + "description": "Client error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } + }, + "5XX": { + "description": "Server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + } + } + }, + "tags": [ + "Moderations" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/UpdateToolboxRequest" + "$ref": "#/components/schemas/OpenAI.CreateModerationRequest" } } - } - } - }, - "delete": { - "operationId": "deleteToolbox", - "summary": "Delete a toolbox", - "description": "Removes the specified toolbox along with all of its versions.", - "parameters": [ - { - "name": "name", - "in": "path", - "required": true, - "description": "The name of the toolbox to delete.", - "schema": { - "type": "string" - } }, - { - "name": "api-version", - "in": "query", - "required": true, - "description": "The API version to use for this operation.", - "schema": { - "type": "string" + "description": "The request body." + }, + "x-oaiMeta": { + "name": "Create moderation", + "group": "moderations", + "examples": [ + { + "title": "Single string", + "request": { + "curl": "curl https://api.openai.com/v1/moderations \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"input\": \"I want to kill them.\"\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nmoderation = client.moderations.create(\n input=\"I want to kill them.\",\n)\nprint(moderation.id)", + "javascript": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const moderation = await openai.moderations.create({ input: \"I want to kill them.\" });\n\n console.log(moderation);\n}\nmain();\n", + "csharp": "using System;\nusing System.ClientModel;\n\nusing OpenAI.Moderations;\n\nModerationClient client = new(\n model: \"omni-moderation-latest\",\n apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")\n);\n\nClientResult moderation = client.ClassifyText(\"I want to kill them.\");\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst moderation = await client.moderations.create({ input: 'I want to kill them.' });\n\nconsole.log(moderation.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tmoderation, err := client.Moderations.New(context.TODO(), openai.ModerationNewParams{\n\t\tInput: openai.ModerationNewParamsInputUnion{\n\t\t\tOfString: openai.String(\"I want to kill them.\"),\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", moderation.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.moderations.ModerationCreateParams;\nimport com.openai.models.moderations.ModerationCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ModerationCreateParams params = ModerationCreateParams.builder()\n .input(\"I want to kill them.\")\n .build();\n ModerationCreateResponse moderation = client.moderations().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nmoderation = openai.moderations.create(input: \"I want to kill them.\")\n\nputs(moderation)" + }, + "response": "{\n \"id\": \"modr-AB8CjOTu2jiq12hp1AQPfeqFWaORR\",\n \"model\": \"text-moderation-007\",\n \"results\": [\n {\n \"flagged\": true,\n \"categories\": {\n \"sexual\": false,\n \"hate\": false,\n \"harassment\": true,\n \"self-harm\": false,\n \"sexual/minors\": false,\n \"hate/threatening\": false,\n \"violence/graphic\": false,\n \"self-harm/intent\": false,\n \"self-harm/instructions\": false,\n \"harassment/threatening\": true,\n \"violence\": true\n },\n \"category_scores\": {\n \"sexual\": 0.000011726012417057063,\n \"hate\": 0.22706663608551025,\n \"harassment\": 0.5215635299682617,\n \"self-harm\": 2.227119921371923e-6,\n \"sexual/minors\": 7.107352217872176e-8,\n \"hate/threatening\": 0.023547329008579254,\n \"violence/graphic\": 0.00003391829886822961,\n \"self-harm/intent\": 1.646940972932498e-6,\n \"self-harm/instructions\": 1.1198755256458526e-9,\n \"harassment/threatening\": 0.5694745779037476,\n \"violence\": 0.9971134662628174\n }\n }\n ]\n}\n" }, - "explode": false - } - ], + { + "title": "Image and text", + "request": { + "curl": "curl https://api.openai.com/v1/moderations \\\n -X POST \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"omni-moderation-latest\",\n \"input\": [\n { \"type\": \"text\", \"text\": \"...text to classify goes here...\" },\n {\n \"type\": \"image_url\",\n \"image_url\": {\n \"url\": \"https://example.com/image.png\"\n }\n }\n ]\n }'\n", + "python": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nmoderation = client.moderations.create(\n input=\"I want to kill them.\",\n)\nprint(moderation.id)", + "javascript": "import OpenAI from \"openai\";\nconst openai = new OpenAI();\n\nconst moderation = await openai.moderations.create({\n model: \"omni-moderation-latest\",\n input: [\n { type: \"text\", text: \"...text to classify goes here...\" },\n {\n type: \"image_url\",\n image_url: {\n url: \"https://example.com/image.png\"\n // can also use base64 encoded image URLs\n // url: \"data:image/jpeg;base64,abcdefg...\"\n }\n }\n ],\n});\n\nconsole.log(moderation);\n", + "node.js": "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst moderation = await client.moderations.create({ input: 'I want to kill them.' });\n\nconsole.log(moderation.id);", + "go": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tmoderation, err := client.Moderations.New(context.TODO(), openai.ModerationNewParams{\n\t\tInput: openai.ModerationNewParamsInputUnion{\n\t\t\tOfString: openai.String(\"I want to kill them.\"),\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\n\", moderation.ID)\n}\n", + "java": "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.moderations.ModerationCreateParams;\nimport com.openai.models.moderations.ModerationCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ModerationCreateParams params = ModerationCreateParams.builder()\n .input(\"I want to kill them.\")\n .build();\n ModerationCreateResponse moderation = client.moderations().create(params);\n }\n}", + "ruby": "require \"openai\"\n\nopenai = OpenAI::Client.new(api_key: \"My API Key\")\n\nmoderation = openai.moderations.create(input: \"I want to kill them.\")\n\nputs(moderation)" + }, + "response": "{\n \"id\": \"modr-0d9740456c391e43c445bf0f010940c7\",\n \"model\": \"omni-moderation-latest\",\n \"results\": [\n {\n \"flagged\": true,\n \"categories\": {\n \"harassment\": true,\n \"harassment/threatening\": true,\n \"sexual\": false,\n \"hate\": false,\n \"hate/threatening\": false,\n \"illicit\": false,\n \"illicit/violent\": false,\n \"self-harm/intent\": false,\n \"self-harm/instructions\": false,\n \"self-harm\": false,\n \"sexual/minors\": false,\n \"violence\": true,\n \"violence/graphic\": true\n },\n \"category_scores\": {\n \"harassment\": 0.8189693396524255,\n \"harassment/threatening\": 0.804985420696006,\n \"sexual\": 1.573112165348997e-6,\n \"hate\": 0.007562942636942845,\n \"hate/threatening\": 0.004208854591835476,\n \"illicit\": 0.030535955153511665,\n \"illicit/violent\": 0.008925306722380033,\n \"self-harm/intent\": 0.00023023930975076432,\n \"self-harm/instructions\": 0.0002293869201073356,\n \"self-harm\": 0.012598046106750154,\n \"sexual/minors\": 2.212566909570261e-8,\n \"violence\": 0.9999992735124786,\n \"violence/graphic\": 0.843064871157054\n },\n \"category_applied_input_types\": {\n \"harassment\": [\n \"text\"\n ],\n \"harassment/threatening\": [\n \"text\"\n ],\n \"sexual\": [\n \"text\",\n \"image\"\n ],\n \"hate\": [\n \"text\"\n ],\n \"hate/threatening\": [\n \"text\"\n ],\n \"illicit\": [\n \"text\"\n ],\n \"illicit/violent\": [\n \"text\"\n ],\n \"self-harm/intent\": [\n \"text\",\n \"image\"\n ],\n \"self-harm/instructions\": [\n \"text\",\n \"image\"\n ],\n \"self-harm\": [\n \"text\",\n \"image\"\n ],\n \"sexual/minors\": [\n \"text\"\n ],\n \"violence\": [\n \"text\",\n \"image\"\n ],\n \"violence/graphic\": [\n \"text\",\n \"image\"\n ]\n }\n }\n ]\n}\n" + } + ] + } + } + }, + "/openai/v1/realtime/calls": { + "post": { + "operationId": "Realtime_create-realtime-call", + "summary": "Create a Realtime call", + "description": "Creates a Realtime API call over WebRTC and returns the SDP answer needed to complete the peer connection.", + "parameters": [], "responses": { - "204": { - "description": "There is no content to send for this request, but the headers may be useful. " + "201": { + "description": "The request has succeeded and a new resource has been created as a result.", + "headers": { + "location": { + "required": false, + "description": "The location request header.", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/sdp": { + "schema": { + "type": "string" + } + } + } }, "4XX": { "description": "Client error", @@ -16305,47 +16794,57 @@ } }, "tags": [ - "Toolboxes" - ] + "Realtime" + ], + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/OpenAI.RealtimeCallCreateRequest" + }, + "encoding": { + "session": { + "contentType": "application/json" + } + } + } + }, + "description": "The request body." + }, + "x-oaiMeta": { + "name": "Create call", + "group": "realtime", + "returns": "Returns `201 Created` with the SDP answer in the response body. The\n`Location` response header includes the call ID for follow-up requests,\ne.g., establishing a monitoring WebSocket or hanging up the call.", + "examples": { + "request": { + "curl": "curl -X POST https://api.openai.com/v1/realtime/calls \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -F \"sdp=