diff --git a/providers/src/openai/v00.00.00000/provider.yaml b/providers/src/openai/v00.00.00000/provider.yaml index eb94e74a..c1404fc4 100644 --- a/providers/src/openai/v00.00.00000/provider.yaml +++ b/providers/src/openai/v00.00.00000/provider.yaml @@ -3,158 +3,104 @@ name: openai version: v00.00.00000 providerServices: assistants: - id: 'assistants:v00.00.00000' + id: assistants:v00.00.00000 name: assistants preferred: true service: $ref: openai/v00.00.00000/services/assistants.yaml - title: OpenAI API - Assistants + title: assistants API version: v00.00.00000 - description: Build Assistants That Can Call Models And Use Tools. - audio: - id: 'audio:v00.00.00000' - name: audio + description: openai API + batches: + id: batches:v00.00.00000 + name: batches preferred: true service: - $ref: openai/v00.00.00000/services/audio.yaml - title: OpenAI API - Audio + $ref: openai/v00.00.00000/services/batches.yaml + title: batches API version: v00.00.00000 - description: Turn Audio Into Text Or Text Into Audio. - audit_logs: - id: 'audit_logs:v00.00.00000' - name: audit_logs + description: openai API + containers: + id: containers:v00.00.00000 + name: containers preferred: true service: - $ref: openai/v00.00.00000/services/audit_logs.yaml - title: OpenAI API - Audit Logs + $ref: openai/v00.00.00000/services/containers.yaml + title: containers API version: v00.00.00000 - description: List User Actions And Configuration Changes Within This Organization. - batch: - id: 'batch:v00.00.00000' - name: batch + description: openai API + conversations: + id: conversations:v00.00.00000 + name: conversations preferred: true service: - $ref: openai/v00.00.00000/services/batch.yaml - title: OpenAI API - Batch + $ref: openai/v00.00.00000/services/conversations.yaml + title: conversations API version: v00.00.00000 - description: Create Large Batches Of API Requests To Run Asynchronously. - chat: - id: 'chat:v00.00.00000' - name: chat + description: openai API + evals: + id: evals:v00.00.00000 + name: evals preferred: true service: - $ref: openai/v00.00.00000/services/chat.yaml - title: OpenAI API - Chat + $ref: openai/v00.00.00000/services/evals.yaml + title: evals API version: v00.00.00000 - description: 'Given A List Of Messages Comprising A Conversation, The Model Will Return A Response.' - completions: - id: 'completions:v00.00.00000' - name: completions - preferred: true - service: - $ref: openai/v00.00.00000/services/completions.yaml - title: OpenAI API - Completions - version: v00.00.00000 - description: 'Given A Prompt, The Model Will Return One Or More Predicted Completions, And Can Also Return The Probabilities Of Alternative Tokens At Each Position.' - embeddings: - id: 'embeddings:v00.00.00000' - name: embeddings - preferred: true - service: - $ref: openai/v00.00.00000/services/embeddings.yaml - title: OpenAI API - Embeddings - version: v00.00.00000 - description: Get A Vector Representation Of A Given Input That Can Be Easily Consumed By Machine Learning Models And Algorithms. + description: openai API files: - id: 'files:v00.00.00000' + id: files:v00.00.00000 name: files preferred: true service: $ref: openai/v00.00.00000/services/files.yaml - title: OpenAI API - Files + title: files API version: v00.00.00000 - description: Files Are Used To Upload Documents That Can Be Used With Features Like Assistants And Fine-Tuning. + description: openai API fine_tuning: - id: 'fine_tuning:v00.00.00000' + id: fine_tuning:v00.00.00000 name: fine_tuning preferred: true service: $ref: openai/v00.00.00000/services/fine_tuning.yaml - title: OpenAI API - Fine Tuning - version: v00.00.00000 - description: Manage Fine-Tuning Jobs To Tailor A Model To Your Specific Training Data. - images: - id: 'images:v00.00.00000' - name: images - preferred: true - service: - $ref: openai/v00.00.00000/services/images.yaml - title: OpenAI API - Images + title: fine_tuning API version: v00.00.00000 - description: 'Given A Prompt And/Or An Input Image, The Model Will Generate A New Image.' - invites: - id: 'invites:v00.00.00000' - name: invites - preferred: true - service: - $ref: openai/v00.00.00000/services/invites.yaml - title: OpenAI API - Invites - version: v00.00.00000 - description: Invites + description: openai API models: - id: 'models:v00.00.00000' + id: models:v00.00.00000 name: models preferred: true service: $ref: openai/v00.00.00000/services/models.yaml - title: OpenAI API - Models + title: models API version: v00.00.00000 - description: List And Describe The Various Models Available In The API. - moderations: - id: 'moderations:v00.00.00000' - name: moderations + description: openai API + skills: + id: skills:v00.00.00000 + name: skills preferred: true service: - $ref: openai/v00.00.00000/services/moderations.yaml - title: OpenAI API - Moderations + $ref: openai/v00.00.00000/services/skills.yaml + title: skills API version: v00.00.00000 - description: 'Given Text And/Or Image Inputs, Classifies If Those Inputs Are Potentially Harmful.' - projects: - id: 'projects:v00.00.00000' - name: projects - preferred: true - service: - $ref: openai/v00.00.00000/services/projects.yaml - title: OpenAI API - Projects - version: v00.00.00000 - description: Projects + description: openai API uploads: - id: 'uploads:v00.00.00000' + id: uploads:v00.00.00000 name: uploads preferred: true service: $ref: openai/v00.00.00000/services/uploads.yaml - title: OpenAI API - Uploads - version: v00.00.00000 - description: Use Uploads To Upload Large Files In Multiple Parts. - users: - id: 'users:v00.00.00000' - name: users - preferred: true - service: - $ref: openai/v00.00.00000/services/users.yaml - title: OpenAI API - Users + title: uploads API version: v00.00.00000 - description: Users + description: openai API vector_stores: - id: 'vector_stores:v00.00.00000' + id: vector_stores:v00.00.00000 name: vector_stores preferred: true service: $ref: openai/v00.00.00000/services/vector_stores.yaml - title: OpenAI API - Vector Stores + title: vector_stores API version: v00.00.00000 - description: Vector Stores + description: openai API config: auth: type: bearer diff --git a/providers/src/openai/v00.00.00000/services/assistants.yaml b/providers/src/openai/v00.00.00000/services/assistants.yaml index 188dcda6..4fe784ba 100644 --- a/providers/src/openai/v00.00.00000/services/assistants.yaml +++ b/providers/src/openai/v00.00.00000/services/assistants.yaml @@ -1,4438 +1,4356 @@ -openapi: 3.0.0 -servers: - - url: 'https://api.openai.com/v1' +openapi: 3.1.0 info: + title: assistants API + description: openai API version: 2.3.0 - termsOfService: 'https://openai.com/policies/terms-of-use' - contact: - name: OpenAI Support - url: 'https://help.openai.com/' - license: - name: MIT - url: 'https://github.com/openai/openai-openapi/blob/master/LICENSE' - title: OpenAI API - assistants - description: Build Assistants that can call models and use tools. -security: - - ApiKeyAuth: [] -tags: - - name: Assistants - description: Build Assistants that can call models and use tools. - - name: Audio - description: Turn audio into text or text into audio. - - name: Chat - description: 'Given a list of messages comprising a conversation, the model will return a response.' - - name: Completions - description: 'Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.' - - name: Embeddings - description: Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. - - name: Fine-tuning - description: Manage fine-tuning jobs to tailor a model to your specific training data. - - name: Batch - description: Create large batches of API requests to run asynchronously. - - name: Files - description: Files are used to upload documents that can be used with features like Assistants and Fine-tuning. - - name: Uploads - description: Use Uploads to upload large files in multiple parts. - - name: Images - description: 'Given a prompt and/or an input image, the model will generate a new image.' - - name: Models - description: List and describe the various models available in the API. - - name: Moderations - description: 'Given text and/or image inputs, classifies if those inputs are potentially harmful.' - - name: Audit Logs - description: List user actions and configuration changes within this organization. -components: - schemas: - ListAssistantsResponse: - type: object - properties: - object: - type: string - example: list - data: - type: array - items: - $ref: '#/components/schemas/AssistantObject' - first_id: - type: string - example: asst_abc123 - last_id: - type: string - example: asst_abc456 - has_more: - type: boolean - example: false - required: - - object - - data - - first_id - - last_id - - has_more +paths: + /assistants: + get: + operationId: listAssistants + tags: + - Assistants + summary: Returns a list of assistants. + deprecated: true + parameters: + - name: limit + in: query + description: >- + A limit on the number of objects to be returned. Limit can range + between 1 and 100, and the default is 20. + + + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: > + Sort order by the `created_at` timestamp of the objects. `asc` for + ascending order and `desc` for descending order. + schema: + type: string + default: desc + enum: + - asc + - desc + - name: after + in: query + 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 + - name: before + in: query + 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 + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ListAssistantsResponse' x-oaiMeta: - name: List assistants response object - group: chat - example: | - { - "object": "list", - "data": [ + name: List assistants + group: assistants + examples: + request: + curl: | + curl "https://api.openai.com/v1/assistants?order=desc&limit=20" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "OpenAI-Beta: assistants=v2" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.beta.assistants.list() + page = page.data[0] + print(page.id) + javascript: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const myAssistants = await openai.beta.assistants.list({ + order: "desc", + limit: "20", + }); + + console.log(myAssistants.data); + } + + main(); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const assistant of client.beta.assistants.list()) { + console.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\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.assistants.AssistantListPage; + import com.openai.models.beta.assistants.AssistantListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + AssistantListPage page = client.beta().assistants().list(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + page = openai.beta.assistants.list + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "id": "asst_abc123", + "object": "assistant", + "created_at": 1698982736, + "name": "Coding Tutor", + "description": null, + "model": "gpt-4o", + "instructions": "You are a helpful assistant designed to make me better at coding!", + "tools": [], + "tool_resources": {}, + "metadata": {}, + "top_p": 1.0, + "temperature": 1.0, + "response_format": "auto" + }, + { + "id": "asst_abc456", + "object": "assistant", + "created_at": 1698982718, + "name": "My Assistant", + "description": null, + "model": "gpt-4o", + "instructions": "You are a helpful assistant designed to make me better at coding!", + "tools": [], + "tool_resources": {}, + "metadata": {}, + "top_p": 1.0, + "temperature": 1.0, + "response_format": "auto" + }, + { + "id": "asst_abc789", + "object": "assistant", + "created_at": 1698982643, + "name": null, + "description": null, + "model": "gpt-4o", + "instructions": null, + "tools": [], + "tool_resources": {}, + "metadata": {}, + "top_p": 1.0, + "temperature": 1.0, + "response_format": "auto" + } + ], + "first_id": "asst_abc123", + "last_id": "asst_abc789", + "has_more": false + } + post: + operationId: createAssistant + tags: + - Assistants + summary: Create an assistant with a model and instructions. + deprecated: true + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateAssistantRequest' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/AssistantObject' + x-oaiMeta: + name: Create assistant + group: assistants + examples: + - title: Code Interpreter + request: + curl: | + curl "https://api.openai.com/v1/assistants" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.", + "name": "Math Tutor", + "tools": [{"type": "code_interpreter"}], + "model": "gpt-4o" + }' + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + assistant = client.beta.assistants.create( + model="gpt-4o", + ) + print(assistant.id) + javascript: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const myAssistant = await openai.beta.assistants.create({ + instructions: + "You are a personal math tutor. When asked a question, write and run Python code to answer the question.", + name: "Math Tutor", + tools: [{ type: "code_interpreter" }], + model: "gpt-4o", + }); + + console.log(myAssistant); + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const assistant = await client.beta.assistants.create({ model: + 'gpt-4o' }); + + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.ChatModel; + import com.openai.models.beta.assistants.Assistant; + import com.openai.models.beta.assistants.AssistantCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + AssistantCreateParams params = AssistantCreateParams.builder() + .model(ChatModel.GPT_4O) + .build(); + Assistant assistant = client.beta().assistants().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + assistant = openai.beta.assistants.create(model: :"gpt-4o") + + puts(assistant) + response: | { "id": "asst_abc123", "object": "assistant", - "created_at": 1698982736, - "name": "Coding Tutor", + "created_at": 1698984975, + "name": "Math Tutor", "description": null, "model": "gpt-4o", - "instructions": "You are a helpful assistant designed to make me better at coding!", - "tools": [], - "tool_resources": {}, - "metadata": {}, - "top_p": 1.0, - "temperature": 1.0, - "response_format": "auto" - }, - { - "id": "asst_abc456", - "object": "assistant", - "created_at": 1698982718, - "name": "My Assistant", - "description": null, - "model": "gpt-4o", - "instructions": "You are a helpful assistant designed to make me better at coding!", - "tools": [], - "tool_resources": {}, + "instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.", + "tools": [ + { + "type": "code_interpreter" + } + ], "metadata": {}, "top_p": 1.0, "temperature": 1.0, "response_format": "auto" - }, + } + - title: Files + request: + curl: | + curl https://api.openai.com/v1/assistants \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies.", + "tools": [{"type": "file_search"}], + "tool_resources": {"file_search": {"vector_store_ids": ["vs_123"]}}, + "model": "gpt-4o" + }' + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + assistant = client.beta.assistants.create( + model="gpt-4o", + ) + print(assistant.id) + javascript: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const myAssistant = await openai.beta.assistants.create({ + instructions: + "You are an HR bot, and you have access to files to answer employee questions about company policies.", + name: "HR Helper", + tools: [{ type: "file_search" }], + tool_resources: { + file_search: { + vector_store_ids: ["vs_123"] + } + }, + model: "gpt-4o" + }); + + console.log(myAssistant); + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const assistant = await client.beta.assistants.create({ model: + 'gpt-4o' }); + + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.ChatModel; + import com.openai.models.beta.assistants.Assistant; + import com.openai.models.beta.assistants.AssistantCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + AssistantCreateParams params = AssistantCreateParams.builder() + .model(ChatModel.GPT_4O) + .build(); + Assistant assistant = client.beta().assistants().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + assistant = openai.beta.assistants.create(model: :"gpt-4o") + + puts(assistant) + response: | { - "id": "asst_abc789", + "id": "asst_abc123", "object": "assistant", - "created_at": 1698982643, - "name": null, + "created_at": 1699009403, + "name": "HR Helper", "description": null, "model": "gpt-4o", - "instructions": null, - "tools": [], - "tool_resources": {}, + "instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies.", + "tools": [ + { + "type": "file_search" + } + ], + "tool_resources": { + "file_search": { + "vector_store_ids": ["vs_123"] + } + }, "metadata": {}, "top_p": 1.0, "temperature": 1.0, "response_format": "auto" } - ], - "first_id": "asst_abc123", - "last_id": "asst_abc789", - "has_more": false - } - AssistantObject: - type: object - title: Assistant - description: Represents an `assistant` that can call the model and use tools. - properties: - id: - description: 'The identifier, which can be referenced in API endpoints.' - type: string - object: - description: 'The object type, which is always `assistant`.' - type: string - enum: - - assistant - created_at: - description: The Unix timestamp (in seconds) for when the assistant was created. - type: integer - name: - description: | - The name of the assistant. The maximum length is 256 characters. - type: string - maxLength: 256 - nullable: true - description: - description: | - The description of the assistant. The maximum length is 512 characters. - type: string - maxLength: 512 - nullable: true - model: - description: | - ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. - type: string - instructions: - description: | - The system instructions that the assistant uses. The maximum length is 256,000 characters. - type: string - maxLength: 256000 - nullable: true - tools: - description: | - A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. - default: [] - type: array - maxItems: 128 - items: - oneOf: - - $ref: '#/components/schemas/AssistantToolsCode' - - $ref: '#/components/schemas/AssistantToolsFileSearch' - - $ref: '#/components/schemas/AssistantToolsFunction' - x-oaiExpandable: true - tool_resources: - type: object - description: | - A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - properties: - code_interpreter: - type: object - properties: - file_ids: - type: array - description: | - A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter`` tool. There can be a maximum of 20 files associated with the tool. - default: [] - maxItems: 20 - items: - type: string - file_search: - type: object - properties: - vector_store_ids: - type: array - description: | - The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. - maxItems: 1 - items: - type: string - nullable: true - metadata: - description: | - Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true - temperature: - description: | - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - type: number - minimum: 0 - maximum: 2 - default: 1 - example: 1 - nullable: true - top_p: - type: number - minimum: 0 - maximum: 1 - default: 1 - example: 1 - nullable: true - description: | - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. - response_format: - $ref: '#/components/schemas/AssistantsApiResponseFormatOption' - nullable: true - required: - - id - - object - - created_at - - name - - description - - model - - instructions - - tools - - metadata + parameters: + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + /assistants/{assistant_id}: + get: + operationId: getAssistant + tags: + - Assistants + summary: Retrieves an assistant. + deprecated: true + parameters: + - in: path + name: assistant_id + required: true + schema: + type: string + description: The ID of the assistant to retrieve. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/AssistantObject' x-oaiMeta: - name: The assistant object - beta: true - example: | - { - "id": "asst_abc123", - "object": "assistant", - "created_at": 1698984975, - "name": "Math Tutor", - "description": null, - "model": "gpt-4o", - "instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.", - "tools": [ - { - "type": "code_interpreter" - } - ], - "metadata": {}, - "top_p": 1.0, - "temperature": 1.0, - "response_format": "auto" - } - AssistantToolsCode: - type: object - title: Code interpreter tool - properties: - type: - type: string - description: 'The type of tool being defined: `code_interpreter`' - enum: - - code_interpreter - required: - - type - AssistantToolsFileSearch: - type: object - title: FileSearch tool - properties: - type: - type: string - description: 'The type of tool being defined: `file_search`' - enum: - - file_search - file_search: - type: object - description: Overrides for the file search tool. - properties: - max_num_results: - type: integer - minimum: 1 - maximum: 50 - description: | - The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. + name: Retrieve assistant + group: assistants + examples: + request: + curl: | + curl https://api.openai.com/v1/assistants/asst_abc123 \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "OpenAI-Beta: assistants=v2" + python: |- + import os + from openai import OpenAI - Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. - ranking_options: - $ref: '#/components/schemas/FileSearchRankingOptions' - required: - - type - AssistantToolsFunction: - type: object - title: Function tool - properties: - type: - type: string - description: 'The type of tool being defined: `function`' - enum: - - function - function: - $ref: '#/components/schemas/FunctionObject' - required: - - type - - function - AssistantsApiResponseFormatOption: - description: | - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4 Turbo](/docs/models/gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + assistant = client.beta.assistants.retrieve( + "assistant_id", + ) + print(assistant.id) + javascript: |- + import OpenAI from "openai"; - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + const openai = new OpenAI(); - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. + async function main() { + const myAssistant = await openai.beta.assistants.retrieve( + "asst_abc123" + ); - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - oneOf: - - type: string - description: | - `auto` is the default value - enum: - - auto - - $ref: '#/components/schemas/ResponseFormatText' - - $ref: '#/components/schemas/ResponseFormatJsonObject' - - $ref: '#/components/schemas/ResponseFormatJsonSchema' - x-oaiExpandable: true - FileSearchRankingOptions: - title: File search tool call ranking options - type: object - description: | - The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. + console.log(myAssistant); + } - See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. - properties: - ranker: - type: string - description: The ranker to use for the file search. If not specified will use the `auto` ranker. - enum: - - auto - - default_2024_08_21 - score_threshold: - type: number - description: The score threshold for the file search. All values must be a floating point number between 0 and 1. - minimum: 0 - maximum: 1 - required: - - score_threshold - FunctionObject: - type: object - properties: - description: - type: string - description: 'A description of what the function does, used by the model to choose when and how to call the function.' - name: - type: string - description: 'The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.' - parameters: - $ref: '#/components/schemas/FunctionParameters' - strict: - type: boolean - nullable: true - default: false - description: 'Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](docs/guides/function-calling).' - required: - - name - ResponseFormatText: - type: object - properties: - type: - type: string - description: 'The type of response format being defined: `text`' - enum: - - text - required: - - type - ResponseFormatJsonObject: - type: object - properties: - type: - type: string - description: 'The type of response format being defined: `json_object`' - enum: - - json_object - required: - - type - ResponseFormatJsonSchema: - type: object - properties: - type: - type: string - description: 'The type of response format being defined: `json_schema`' - enum: - - json_schema - json_schema: - type: object - properties: - description: - type: string - description: 'A description of what the response format is for, used by the model to determine how to respond in the format.' - name: - type: string - description: 'The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.' - schema: - $ref: '#/components/schemas/ResponseFormatJsonSchemaSchema' - strict: - type: boolean - nullable: true - default: false - description: 'Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs).' - required: - - type - - name - required: - - type - - json_schema - FunctionParameters: - type: object - description: |- - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. + main(); + node.js: >- + import OpenAI from 'openai'; - Omitting `parameters` defines a function with an empty parameter list. - additionalProperties: true - ResponseFormatJsonSchemaSchema: - type: object - description: 'The schema for the response format, described as a JSON Schema object.' - additionalProperties: true - CreateAssistantRequest: - type: object - additionalProperties: false - properties: - model: - description: | - ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. - example: gpt-4o - anyOf: - - type: string - - type: string - enum: - - gpt-4o - - gpt-4o-2024-08-06 - - gpt-4o-2024-05-13 - - gpt-4o-2024-08-06 - - gpt-4o-mini - - gpt-4o-mini-2024-07-18 - - gpt-4-turbo - - gpt-4-turbo-2024-04-09 - - gpt-4-0125-preview - - gpt-4-turbo-preview - - gpt-4-1106-preview - - gpt-4-vision-preview - - gpt-4 - - gpt-4-0314 - - gpt-4-0613 - - gpt-4-32k - - gpt-4-32k-0314 - - gpt-4-32k-0613 - - gpt-3.5-turbo - - gpt-3.5-turbo-16k - - gpt-3.5-turbo-0613 - - gpt-3.5-turbo-1106 - - gpt-3.5-turbo-0125 - - gpt-3.5-turbo-16k-0613 - x-oaiTypeLabel: string - name: - description: | - The name of the assistant. The maximum length is 256 characters. - type: string - nullable: true - maxLength: 256 - description: - description: | - The description of the assistant. The maximum length is 512 characters. - type: string - nullable: true - maxLength: 512 - instructions: - description: | - The system instructions that the assistant uses. The maximum length is 256,000 characters. - type: string - nullable: true - maxLength: 256000 - tools: - description: | - A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. - default: [] - type: array - maxItems: 128 - items: - oneOf: - - $ref: '#/components/schemas/AssistantToolsCode' - - $ref: '#/components/schemas/AssistantToolsFileSearch' - - $ref: '#/components/schemas/AssistantToolsFunction' - x-oaiExpandable: true - tool_resources: - type: object - description: | - A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - properties: - code_interpreter: - type: object - properties: - file_ids: - type: array - description: | - A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. - default: [] - maxItems: 20 - items: - type: string - file_search: - type: object - properties: - vector_store_ids: - type: array - description: | - The [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. - maxItems: 1 - items: - type: string - vector_stores: - type: array - description: | - A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this assistant. There can be a maximum of 1 vector store attached to the assistant. - maxItems: 1 - items: - type: object - properties: - file_ids: - type: array - description: | - A list of [file](/docs/api-reference/files) IDs to add to the vector store. There can be a maximum of 10000 files in a vector store. - maxItems: 10000 - items: - type: string - chunking_strategy: - type: object - description: 'The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy.' - oneOf: - - type: object - title: Auto Chunking Strategy - description: The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`. - additionalProperties: false - properties: - type: - type: string - description: Always `auto`. - enum: - - auto - required: - - type - - type: object - title: Static Chunking Strategy - additionalProperties: false - properties: - type: - type: string - description: Always `static`. - enum: - - static - static: - type: object - additionalProperties: false - properties: - max_chunk_size_tokens: - type: integer - minimum: 100 - maximum: 4096 - description: The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`. - chunk_overlap_tokens: - type: integer - description: | - The number of tokens that overlap between chunks. The default value is `400`. - Note that the overlap must not exceed half of `max_chunk_size_tokens`. - required: - - max_chunk_size_tokens - - chunk_overlap_tokens - required: - - type - - static - x-oaiExpandable: true - metadata: - type: object - description: | - Set of 16 key-value pairs that can be attached to a vector store. This can be useful for storing additional information about the vector store in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - x-oaiTypeLabel: map - oneOf: - - required: - - vector_store_ids - - required: - - vector_stores - nullable: true - metadata: - description: | - Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true - temperature: - description: | - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - type: number - minimum: 0 - maximum: 2 - default: 1 - example: 1 - nullable: true - top_p: - type: number - minimum: 0 - maximum: 1 - default: 1 - example: 1 - nullable: true - description: | - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); - We generally recommend altering this or temperature but not both. - response_format: - $ref: '#/components/schemas/AssistantsApiResponseFormatOption' - nullable: true - required: - - model - ModifyAssistantRequest: - type: object - additionalProperties: false - properties: - model: - description: | - ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. - anyOf: - - type: string - name: - description: | - The name of the assistant. The maximum length is 256 characters. - type: string - nullable: true - maxLength: 256 - description: - description: | - The description of the assistant. The maximum length is 512 characters. - type: string - nullable: true - maxLength: 512 - instructions: - description: | - The system instructions that the assistant uses. The maximum length is 256,000 characters. - type: string - nullable: true - maxLength: 256000 - tools: - description: | - A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. - default: [] - type: array - maxItems: 128 - items: - oneOf: - - $ref: '#/components/schemas/AssistantToolsCode' - - $ref: '#/components/schemas/AssistantToolsFileSearch' - - $ref: '#/components/schemas/AssistantToolsFunction' - x-oaiExpandable: true - tool_resources: - type: object - description: | - A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - properties: - code_interpreter: - type: object - properties: - file_ids: - type: array - description: | - Overrides the list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. - default: [] - maxItems: 20 - items: - type: string - file_search: - type: object - properties: - vector_store_ids: - type: array - description: | - Overrides the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. - maxItems: 1 - items: - type: string - nullable: true - metadata: - description: | - Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true - temperature: - description: | - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - type: number - minimum: 0 - maximum: 2 - default: 1 - example: 1 - nullable: true - top_p: - type: number - minimum: 0 - maximum: 1 - default: 1 - example: 1 - nullable: true - description: | - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - We generally recommend altering this or temperature but not both. - response_format: - $ref: '#/components/schemas/AssistantsApiResponseFormatOption' - nullable: true - DeleteAssistantResponse: - type: object - properties: - id: - type: string - deleted: - type: boolean - object: - type: string - enum: - - assistant.deleted - required: - - id - - object - - deleted - CreateThreadRequest: - type: object - additionalProperties: false - properties: - messages: - description: 'A list of [messages](/docs/api-reference/messages) to start the thread with.' - type: array - items: - $ref: '#/components/schemas/CreateMessageRequest' - tool_resources: - type: object - description: | - A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - properties: - code_interpreter: - type: object - properties: - file_ids: - type: array - description: | - A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. - default: [] - maxItems: 20 - items: - type: string - file_search: - type: object - properties: - vector_store_ids: - type: array - description: | - The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread. - maxItems: 1 - items: - type: string - vector_stores: - type: array - description: | - A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread. - maxItems: 1 - items: - type: object - properties: - file_ids: - type: array - description: | - A list of [file](/docs/api-reference/files) IDs to add to the vector store. There can be a maximum of 10000 files in a vector store. - maxItems: 10000 - items: - type: string - chunking_strategy: - type: object - description: 'The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy.' - oneOf: - - type: object - title: Auto Chunking Strategy - description: The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`. - additionalProperties: false - properties: - type: - type: string - description: Always `auto`. - enum: - - auto - required: - - type - - type: object - title: Static Chunking Strategy - additionalProperties: false - properties: - type: - type: string - description: Always `static`. - enum: - - static - static: - type: object - additionalProperties: false - properties: - max_chunk_size_tokens: - type: integer - minimum: 100 - maximum: 4096 - description: The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`. - chunk_overlap_tokens: - type: integer - description: | - The number of tokens that overlap between chunks. The default value is `400`. + const assistant = await + client.beta.assistants.retrieve('assistant_id'); - Note that the overlap must not exceed half of `max_chunk_size_tokens`. - required: - - max_chunk_size_tokens - - chunk_overlap_tokens - required: - - type - - static - x-oaiExpandable: true - metadata: - type: object - description: | - Set of 16 key-value pairs that can be attached to a vector store. This can be useful for storing additional information about the vector store in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - x-oaiTypeLabel: map - x-oaiExpandable: true - oneOf: - - required: - - vector_store_ids - - required: - - vector_stores - nullable: true - metadata: - description: | - Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true - ThreadObject: - type: object - title: Thread - description: 'Represents a thread that contains [messages](/docs/api-reference/messages).' - properties: - id: - description: 'The identifier, which can be referenced in API endpoints.' - type: string - object: - description: 'The object type, which is always `thread`.' - type: string - enum: - - thread - created_at: - description: The Unix timestamp (in seconds) for when the thread was created. - type: integer - tool_resources: - type: object - description: | - A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - properties: - code_interpreter: - type: object - properties: - file_ids: - type: array - description: | - A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. - default: [] - maxItems: 20 - items: - type: string - file_search: - type: object - properties: - vector_store_ids: - type: array - description: | - The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread. - maxItems: 1 - items: - type: string - nullable: true - metadata: - description: | - Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true - required: - - id - - object - - created_at - - tool_resources - - metadata + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.assistants.Assistant; + import com.openai.models.beta.assistants.AssistantRetrieveParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Assistant assistant = client.beta().assistants().retrieve("assistant_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + assistant = openai.beta.assistants.retrieve("assistant_id") + + puts(assistant) + response: | + { + "id": "asst_abc123", + "object": "assistant", + "created_at": 1699009709, + "name": "HR Helper", + "description": null, + "model": "gpt-4o", + "instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies.", + "tools": [ + { + "type": "file_search" + } + ], + "metadata": {}, + "top_p": 1.0, + "temperature": 1.0, + "response_format": "auto" + } + post: + operationId: modifyAssistant + tags: + - Assistants + summary: Modifies an assistant. + deprecated: true + parameters: + - in: path + name: assistant_id + required: true + schema: + type: string + description: The ID of the assistant to modify. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ModifyAssistantRequest' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/AssistantObject' x-oaiMeta: - name: The thread object - beta: true - example: | - { - "id": "thread_abc123", - "object": "thread", - "created_at": 1698107661, - "metadata": {} - } - CreateMessageRequest: - type: object - additionalProperties: false - required: - - role - - content - properties: - role: - type: string - enum: - - user - - assistant - description: | - The role of the entity that is creating the message. Allowed values include: - - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages. - - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation. + name: Modify assistant + group: assistants + examples: + request: + curl: | + curl https://api.openai.com/v1/assistants/asst_abc123 \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "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.", + "tools": [{"type": "file_search"}], + "model": "gpt-4o" + }' + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + assistant = client.beta.assistants.update( + assistant_id="assistant_id", + ) + print(assistant.id) + javascript: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const myUpdatedAssistant = await openai.beta.assistants.update( + "asst_abc123", + { + 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.", + name: "HR Helper", + tools: [{ type: "file_search" }], + model: "gpt-4o" + } + ); + + console.log(myUpdatedAssistant); + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const assistant = await + client.beta.assistants.update('assistant_id'); + + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.assistants.Assistant; + import com.openai.models.beta.assistants.AssistantUpdateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Assistant assistant = client.beta().assistants().update("assistant_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + assistant = openai.beta.assistants.update("assistant_id") + + puts(assistant) + response: | + { + "id": "asst_123", + "object": "assistant", + "created_at": 1699009709, + "name": "HR Helper", + "description": null, + "model": "gpt-4o", + "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.", + "tools": [ + { + "type": "file_search" + } + ], + "tool_resources": { + "file_search": { + "vector_store_ids": [] + } + }, + "metadata": {}, + "top_p": 1.0, + "temperature": 1.0, + "response_format": "auto" + } + delete: + operationId: deleteAssistant + tags: + - Assistants + summary: Delete an assistant. + deprecated: true + parameters: + - in: path + name: assistant_id + required: true + schema: + type: string + description: The ID of the assistant to delete. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/DeleteAssistantResponse' + x-oaiMeta: + name: Delete assistant + group: assistants + examples: + request: + curl: | + curl https://api.openai.com/v1/assistants/asst_abc123 \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "OpenAI-Beta: assistants=v2" \ + -X DELETE + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + assistant_deleted = client.beta.assistants.delete( + "assistant_id", + ) + print(assistant_deleted.id) + javascript: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const response = await openai.beta.assistants.delete("asst_abc123"); + + console.log(response); + } + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const assistantDeleted = await + client.beta.assistants.delete('assistant_id'); + + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.assistants.AssistantDeleteParams; + import com.openai.models.beta.assistants.AssistantDeleted; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + AssistantDeleted assistantDeleted = client.beta().assistants().delete("assistant_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + assistant_deleted = openai.beta.assistants.delete("assistant_id") + + puts(assistant_deleted) + response: | + { + "id": "asst_abc123", + "object": "assistant.deleted", + "deleted": true + } + /threads: + post: + operationId: createThread + tags: + - Assistants + summary: Create a thread. + requestBody: content: - oneOf: - - type: string - description: The text contents of the message. - title: Text content - - type: array - description: 'An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](/docs/models/overview).' - title: Array of content parts - items: - oneOf: - - $ref: '#/components/schemas/MessageContentImageFileObject' - - $ref: '#/components/schemas/MessageContentImageUrlObject' - - $ref: '#/components/schemas/MessageRequestContentTextObject' - x-oaiExpandable: true - minItems: 1 - x-oaiExpandable: true - attachments: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - description: The tools to add this file to. - type: array - items: - oneOf: - - $ref: '#/components/schemas/AssistantToolsCode' - - $ref: '#/components/schemas/AssistantToolsFileSearchTypeOnly' - x-oaiExpandable: true - description: 'A list of files attached to the message, and the tools they should be added to.' - required: - - file_id - - tools - nullable: true - metadata: - description: | - Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true - MessageContentImageFileObject: - title: Image file - type: object - description: 'References an image [File](/docs/api-reference/files) in the content of a message.' - properties: - type: - description: Always `image_file`. - type: string - enum: - - image_file - image_file: - type: object - properties: - file_id: - description: 'The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content.' - type: string - detail: - type: string - description: 'Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`.' - enum: - - auto - - low - - high - default: auto - required: - - file_id - required: - - type - - image_file - MessageContentImageUrlObject: - title: Image URL - type: object - description: References an image URL in the content of a message. - properties: - type: - type: string - enum: - - image_url - description: The type of the content part. - image_url: - type: object - properties: - url: - type: string - description: 'The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.' - format: uri - detail: - type: string - description: 'Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto`' - enum: - - auto - - low - - high - default: auto - required: - - url - required: - - type - - image_url - MessageRequestContentTextObject: - title: Text - type: object - description: The text content that is part of a message. - properties: - type: - description: Always `text`. - type: string - enum: - - text - text: - type: string - description: Text content to be sent to the model - required: - - type - - text - AssistantToolsFileSearchTypeOnly: - type: object - title: FileSearch tool - properties: - type: - type: string - description: 'The type of tool being defined: `file_search`' - enum: - - file_search - required: - - type - CreateThreadAndRunRequest: - type: object - additionalProperties: false - properties: - assistant_id: - description: 'The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run.' - type: string - thread: - $ref: '#/components/schemas/CreateThreadRequest' - description: 'If no thread is provided, an empty thread will be created.' - model: - description: 'The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used.' - example: gpt-4o - anyOf: - - type: string - - type: string - enum: - - gpt-4o - - gpt-4o-2024-08-06 - - gpt-4o-2024-05-13 - - gpt-4o-2024-08-06 - - gpt-4o-mini - - gpt-4o-mini-2024-07-18 - - gpt-4-turbo - - gpt-4-turbo-2024-04-09 - - gpt-4-0125-preview - - gpt-4-turbo-preview - - gpt-4-1106-preview - - gpt-4-vision-preview - - gpt-4 - - gpt-4-0314 - - gpt-4-0613 - - gpt-4-32k - - gpt-4-32k-0314 - - gpt-4-32k-0613 - - gpt-3.5-turbo - - gpt-3.5-turbo-16k - - gpt-3.5-turbo-0613 - - gpt-3.5-turbo-1106 - - gpt-3.5-turbo-0125 - - gpt-3.5-turbo-16k-0613 - x-oaiTypeLabel: string - nullable: true - instructions: - description: Override the default system message of the assistant. This is useful for modifying the behavior on a per-run basis. - type: string - nullable: true - tools: - description: Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. - nullable: true - type: array - maxItems: 20 - items: - oneOf: - - $ref: '#/components/schemas/AssistantToolsCode' - - $ref: '#/components/schemas/AssistantToolsFileSearch' - - $ref: '#/components/schemas/AssistantToolsFunction' - tool_resources: - type: object - description: | - A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - properties: - code_interpreter: - type: object - properties: - file_ids: - type: array - description: | - A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. - default: [] - maxItems: 20 - items: - type: string - file_search: - type: object - properties: - vector_store_ids: - type: array - description: | - The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. - maxItems: 1 - items: - type: string - nullable: true - metadata: - description: | - Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true - temperature: - type: number - minimum: 0 - maximum: 2 - default: 1 - example: 1 - nullable: true - description: | - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - top_p: - type: number - minimum: 0 - maximum: 1 - default: 1 - example: 1 - nullable: true - description: | - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + application/json: + schema: + $ref: '#/components/schemas/CreateThreadRequest' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ThreadObject' + x-oaiMeta: + name: Create thread + group: threads + beta: true + examples: + - title: Empty + request: + curl: | + curl https://api.openai.com/v1/threads \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "OpenAI-Beta: assistants=v2" \ + -d '' + python: |- + import os + from openai import OpenAI - We generally recommend altering this or temperature but not both. - stream: - type: boolean - nullable: true - description: | - If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message. - max_prompt_tokens: - type: integer - nullable: true - description: | - The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. - minimum: 256 - max_completion_tokens: - type: integer - nullable: true - description: | - The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. - minimum: 256 - truncation_strategy: - $ref: '#/components/schemas/TruncationObject' - nullable: true - tool_choice: - $ref: '#/components/schemas/AssistantsApiToolChoiceOption' - nullable: true - parallel_tool_calls: - $ref: '#/components/schemas/ParallelToolCalls' - response_format: - $ref: '#/components/schemas/AssistantsApiResponseFormatOption' - nullable: true - required: - - assistant_id - RunObject: - type: object - title: A run on a thread - description: 'Represents an execution run on a [thread](/docs/api-reference/threads).' - properties: - id: - description: 'The identifier, which can be referenced in API endpoints.' - type: string - object: - description: 'The object type, which is always `thread.run`.' - type: string - enum: - - thread.run - created_at: - description: The Unix timestamp (in seconds) for when the run was created. - type: integer - thread_id: - description: 'The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run.' - type: string - assistant_id: - description: 'The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run.' - type: string - status: - description: 'The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`.' - type: string - enum: - - queued - - in_progress - - requires_action - - cancelling - - cancelled - - failed - - completed - - incomplete - - expired - required_action: - type: object - description: Details on the action required to continue the run. Will be `null` if no action is required. - nullable: true - properties: - type: - description: 'For now, this is always `submit_tool_outputs`.' - type: string - enum: - - submit_tool_outputs - submit_tool_outputs: - type: object - description: Details on the tool outputs needed for this run to continue. - properties: - tool_calls: - type: array - description: A list of the relevant tool calls. - items: - $ref: '#/components/schemas/RunToolCallObject' - required: - - tool_calls - required: - - type - - submit_tool_outputs - last_error: - type: object - description: The last error associated with this run. Will be `null` if there are no errors. - nullable: true - properties: - code: - type: string - description: 'One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`.' - enum: - - server_error - - rate_limit_exceeded - - invalid_prompt - message: - type: string - description: A human-readable description of the error. - required: - - code - - message - expires_at: - description: The Unix timestamp (in seconds) for when the run will expire. - type: integer - nullable: true - started_at: - description: The Unix timestamp (in seconds) for when the run was started. - type: integer - nullable: true - cancelled_at: - description: The Unix timestamp (in seconds) for when the run was cancelled. - type: integer - nullable: true - failed_at: - description: The Unix timestamp (in seconds) for when the run failed. - type: integer - nullable: true - completed_at: - description: The Unix timestamp (in seconds) for when the run was completed. - type: integer - nullable: true - incomplete_details: - description: Details on why the run is incomplete. Will be `null` if the run is not incomplete. - type: object - nullable: true - properties: - reason: - description: The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run. - type: string - enum: - - max_completion_tokens - - max_prompt_tokens - model: - description: 'The model that the [assistant](/docs/api-reference/assistants) used for this run.' - type: string - instructions: - description: 'The instructions that the [assistant](/docs/api-reference/assistants) used for this run.' - type: string - tools: - description: 'The list of tools that the [assistant](/docs/api-reference/assistants) used for this run.' - default: [] - type: array - maxItems: 20 - items: - oneOf: - - $ref: '#/components/schemas/AssistantToolsCode' - - $ref: '#/components/schemas/AssistantToolsFileSearch' - - $ref: '#/components/schemas/AssistantToolsFunction' - x-oaiExpandable: true - metadata: - description: | - Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true - usage: - $ref: '#/components/schemas/RunCompletionUsage' - temperature: - description: 'The sampling temperature used for this run. If not set, defaults to 1.' - type: number - nullable: true - top_p: - description: 'The nucleus sampling value used for this run. If not set, defaults to 1.' - type: number - nullable: true - max_prompt_tokens: - type: integer - nullable: true - description: | - The maximum number of prompt tokens specified to have been used over the course of the run. - minimum: 256 - max_completion_tokens: - type: integer - nullable: true - description: | - The maximum number of completion tokens specified to have been used over the course of the run. - minimum: 256 - truncation_strategy: - $ref: '#/components/schemas/TruncationObject' - nullable: true - tool_choice: - $ref: '#/components/schemas/AssistantsApiToolChoiceOption' - nullable: true - parallel_tool_calls: - $ref: '#/components/schemas/ParallelToolCalls' - response_format: - $ref: '#/components/schemas/AssistantsApiResponseFormatOption' - nullable: true - required: - - id - - object - - created_at - - thread_id - - assistant_id - - status - - required_action - - last_error - - expires_at - - started_at - - cancelled_at - - failed_at - - completed_at - - model - - instructions - - tools - - metadata - - usage - - incomplete_details - - max_prompt_tokens - - max_completion_tokens - - truncation_strategy - - tool_choice - - parallel_tool_calls - - response_format + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + thread = client.beta.threads.create() + print(thread.id) + javascript: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const emptyThread = await openai.beta.threads.create(); + + console.log(emptyThread); + } + + main(); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const thread = await client.beta.threads.create(); + + console.log(thread.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\tthread, err := client.Beta.Threads.New(context.TODO(), openai.BetaThreadNewParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", thread.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.threads.Thread; + import com.openai.models.beta.threads.ThreadCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Thread thread = client.beta().threads().create(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + thread = openai.beta.threads.create + + puts(thread) + response: | + { + "id": "thread_abc123", + "object": "thread", + "created_at": 1699012949, + "metadata": {}, + "tool_resources": {} + } + - title: Messages + request: + curl: | + curl https://api.openai.com/v1/threads \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "messages": [{ + "role": "user", + "content": "Hello, what is AI?" + }, { + "role": "user", + "content": "How does AI work? Explain it in simple terms." + }] + }' + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + thread = client.beta.threads.create() + print(thread.id) + javascript: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const messageThread = await openai.beta.threads.create({ + messages: [ + { + role: "user", + content: "Hello, what is AI?" + }, + { + role: "user", + content: "How does AI work? Explain it in simple terms.", + }, + ], + }); + + console.log(messageThread); + } + + main(); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const thread = await client.beta.threads.create(); + + console.log(thread.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\tthread, err := client.Beta.Threads.New(context.TODO(), openai.BetaThreadNewParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", thread.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.threads.Thread; + import com.openai.models.beta.threads.ThreadCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Thread thread = client.beta().threads().create(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + thread = openai.beta.threads.create + + puts(thread) + response: | + { + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, + "metadata": {}, + "tool_resources": {} + } + parameters: + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + deprecated: true + /threads/runs: + post: + operationId: createThreadAndRun + tags: + - Assistants + summary: Create a thread and run it in one request. + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateThreadAndRunRequest' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/RunObject' x-oaiMeta: - name: The run object + name: Create thread and run + group: threads beta: true - example: | - { - "id": "run_abc123", - "object": "thread.run", - "created_at": 1698107661, - "assistant_id": "asst_abc123", - "thread_id": "thread_abc123", - "status": "completed", - "started_at": 1699073476, - "expires_at": null, - "cancelled_at": null, - "failed_at": null, - "completed_at": 1699073498, - "last_error": null, - "model": "gpt-4o", - "instructions": null, - "tools": [{"type": "file_search"}, {"type": "code_interpreter"}], - "metadata": {}, - "incomplete_details": null, - "usage": { - "prompt_tokens": 123, - "completion_tokens": 456, - "total_tokens": 579 - }, - "temperature": 1.0, - "top_p": 1.0, - "max_prompt_tokens": 1000, - "max_completion_tokens": 1000, - "truncation_strategy": { - "type": "auto", - "last_messages": null - }, - "response_format": "auto", - "tool_choice": "auto", - "parallel_tool_calls": true - } - TruncationObject: - type: object - title: Thread Truncation Controls - description: Controls for how a thread will be truncated prior to the run. Use this to control the intial context window of the run. - properties: - type: - type: string - description: 'The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`.' - enum: - - auto - - last_messages - last_messages: - type: integer - description: The number of most recent messages from the thread when constructing the context for the run. - minimum: 1 - nullable: true - required: - - type - AssistantsApiToolChoiceOption: - description: | - Controls which (if any) tool is called by the model. - `none` means the model will not call any tools and instead generates a message. - `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools before responding to the user. - Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - oneOf: - - type: string - description: | - `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. - enum: - - none - - auto - - required - - $ref: '#/components/schemas/AssistantsNamedToolChoice' - x-oaiExpandable: true - ParallelToolCalls: - description: 'Whether to enable [parallel function calling](/docs/guides/function-calling/parallel-function-calling) during tool use.' - type: boolean - default: true - RunToolCallObject: - type: object - description: Tool call objects - properties: - id: - type: string - description: 'The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint.' - type: - type: string - description: 'The type of tool call the output is required for. For now, this is always `function`.' - enum: - - function - function: - type: object - description: The function definition. - properties: - name: - type: string - description: The name of the function. - arguments: - type: string - description: The arguments that the model expects you to pass to the function. - required: - - name - - arguments - required: - - id - - type - - function - RunCompletionUsage: - type: object - description: 'Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.).' - properties: - completion_tokens: - type: integer - description: Number of completion tokens used over the course of the run. - prompt_tokens: - type: integer - description: Number of prompt tokens used over the course of the run. - total_tokens: - type: integer - description: Total number of tokens used (prompt + completion). - required: - - prompt_tokens - - completion_tokens - - total_tokens - nullable: true - AssistantsNamedToolChoice: - type: object - description: Specifies a tool the model should use. Use to force the model to call a specific tool. - properties: - type: - type: string - enum: - - function - - code_interpreter - - file_search - description: 'The type of the tool. If type is `function`, the function name must be set' - function: - type: object - properties: - name: - type: string - description: The name of the function to call. - required: - - name - required: - - type - ModifyThreadRequest: - type: object - additionalProperties: false - properties: - tool_resources: - type: object - description: | - A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - properties: - code_interpreter: - type: object - properties: - file_ids: - type: array - description: | - A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. - default: [] - maxItems: 20 - items: - type: string - file_search: - type: object - properties: - vector_store_ids: - type: array - description: | - The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread. - maxItems: 1 - items: - type: string - nullable: true - metadata: - description: | - Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true - DeleteThreadResponse: - type: object - properties: - id: - type: string - deleted: - type: boolean - object: - type: string - enum: - - thread.deleted - required: - - id - - object - - deleted - ListMessagesResponse: - properties: - object: - type: string - example: list - data: - type: array - items: - $ref: '#/components/schemas/MessageObject' - first_id: - type: string - example: msg_abc123 - last_id: - type: string - example: msg_abc123 - has_more: - type: boolean - example: false - required: - - object - - data - - first_id - - last_id - - has_more - MessageObject: - type: object - title: The message object - description: 'Represents a message within a [thread](/docs/api-reference/threads).' - properties: - id: - description: 'The identifier, which can be referenced in API endpoints.' - type: string - object: - description: 'The object type, which is always `thread.message`.' - type: string - enum: - - thread.message - created_at: - description: The Unix timestamp (in seconds) for when the message was created. - type: integer - thread_id: - description: 'The [thread](/docs/api-reference/threads) ID that this message belongs to.' - type: string - status: - description: 'The status of the message, which can be either `in_progress`, `incomplete`, or `completed`.' - type: string - enum: - - in_progress - - incomplete - - completed - incomplete_details: - description: 'On an incomplete message, details about why the message is incomplete.' - type: object - properties: - reason: - type: string - description: The reason the message is incomplete. - enum: - - content_filter - - max_tokens - - run_cancelled - - run_expired - - run_failed - nullable: true - required: - - reason - completed_at: - description: The Unix timestamp (in seconds) for when the message was completed. - type: integer - nullable: true - incomplete_at: - description: The Unix timestamp (in seconds) for when the message was marked as incomplete. - type: integer - nullable: true - role: - description: The entity that produced the message. One of `user` or `assistant`. - type: string - enum: - - user - - assistant - content: - description: The content of the message in array of text and/or images. - type: array - items: - oneOf: - - $ref: '#/components/schemas/MessageContentImageFileObject' - - $ref: '#/components/schemas/MessageContentImageUrlObject' - - $ref: '#/components/schemas/MessageContentTextObject' - - $ref: '#/components/schemas/MessageContentRefusalObject' - x-oaiExpandable: true - assistant_id: - description: 'If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message.' - type: string - nullable: true - run_id: - description: 'The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints.' - type: string - nullable: true - attachments: - type: array - items: - type: object - properties: - file_id: - type: string - description: The ID of the file to attach to the message. - tools: - description: The tools to add this file to. - type: array - items: - oneOf: - - $ref: '#/components/schemas/AssistantToolsCode' - - $ref: '#/components/schemas/AssistantToolsFileSearchTypeOnly' - x-oaiExpandable: true - description: 'A list of files attached to the message, and the tools they were added to.' - nullable: true - metadata: - description: | - Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true - required: - - id - - object - - created_at - - thread_id - - status - - incomplete_details - - completed_at - - incomplete_at - - role - - content - - assistant_id - - run_id - - attachments - - metadata - x-oaiMeta: - name: The message object - beta: true - example: | - { - "id": "msg_abc123", - "object": "thread.message", - "created_at": 1698983503, - "thread_id": "thread_abc123", - "role": "assistant", - "content": [ - { - "type": "text", - "text": { - "value": "Hi! How can I help you today?", - "annotations": [] - } - } - ], - "assistant_id": "asst_abc123", - "run_id": "run_abc123", - "attachments": [], - "metadata": {} - } - MessageContentTextObject: - title: Text - type: object - description: The text content that is part of a message. - properties: - type: - description: Always `text`. - type: string - enum: - - text - text: - type: object - properties: - value: - description: The data that makes up the text. - type: string - annotations: - type: array - items: - oneOf: - - $ref: '#/components/schemas/MessageContentTextAnnotationsFileCitationObject' - - $ref: '#/components/schemas/MessageContentTextAnnotationsFilePathObject' - x-oaiExpandable: true - required: - - value - - annotations - required: - - type - - text - MessageContentRefusalObject: - title: Refusal - type: object - description: The refusal content generated by the assistant. - properties: - type: - description: Always `refusal`. - type: string - enum: - - refusal - refusal: - type: string - nullable: false - required: - - type - - refusal - MessageContentTextAnnotationsFileCitationObject: - title: File citation - type: object - description: A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. - properties: - type: - description: Always `file_citation`. - type: string - enum: - - file_citation - text: - description: The text in the message content that needs to be replaced. - type: string - file_citation: - type: object - properties: - file_id: - description: The ID of the specific File the citation is from. - type: string - required: - - file_id - start_index: - type: integer - minimum: 0 - end_index: - type: integer - minimum: 0 - required: - - type - - text - - file_citation - - start_index - - end_index - MessageContentTextAnnotationsFilePathObject: - title: File path - type: object - description: A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - properties: - type: - description: Always `file_path`. - type: string - enum: - - file_path - text: - description: The text in the message content that needs to be replaced. - type: string - file_path: - type: object - properties: - file_id: - description: The ID of the file that was generated. - type: string - required: - - file_id - start_index: - type: integer - minimum: 0 - end_index: - type: integer - minimum: 0 - required: - - type - - text - - file_path - - start_index - - end_index - ModifyMessageRequest: - type: object - additionalProperties: false - properties: - metadata: - description: | - Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true - DeleteMessageResponse: - type: object - properties: - id: - type: string - deleted: - type: boolean - object: - type: string - enum: - - thread.message.deleted - required: - - id - - object - - deleted - ListRunsResponse: - type: object - properties: - object: - type: string - example: list - data: - type: array - items: - $ref: '#/components/schemas/RunObject' - first_id: - type: string - example: run_abc123 - last_id: - type: string - example: run_abc456 - has_more: - type: boolean - example: false - required: - - object - - data - - first_id - - last_id - - has_more - CreateRunRequest: - type: object - additionalProperties: false - properties: - assistant_id: - description: 'The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run.' - type: string - model: - description: 'The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used.' - example: gpt-4o - anyOf: - - type: string - - type: string - enum: - - gpt-4o - - gpt-4o-2024-08-06 - - gpt-4o-2024-05-13 - - gpt-4o-2024-08-06 - - gpt-4o-mini - - gpt-4o-mini-2024-07-18 - - gpt-4-turbo - - gpt-4-turbo-2024-04-09 - - gpt-4-0125-preview - - gpt-4-turbo-preview - - gpt-4-1106-preview - - gpt-4-vision-preview - - gpt-4 - - gpt-4-0314 - - gpt-4-0613 - - gpt-4-32k - - gpt-4-32k-0314 - - gpt-4-32k-0613 - - gpt-3.5-turbo - - gpt-3.5-turbo-16k - - gpt-3.5-turbo-0613 - - gpt-3.5-turbo-1106 - - gpt-3.5-turbo-0125 - - gpt-3.5-turbo-16k-0613 - x-oaiTypeLabel: string - nullable: true - instructions: - description: 'Overrides the [instructions](/docs/api-reference/assistants/createAssistant) of the assistant. This is useful for modifying the behavior on a per-run basis.' - type: string - nullable: true - additional_instructions: - description: Appends additional instructions at the end of the instructions for the run. This is useful for modifying the behavior on a per-run basis without overriding other instructions. - type: string - nullable: true - additional_messages: - description: Adds additional messages to the thread before creating the run. - type: array - items: - $ref: '#/components/schemas/CreateMessageRequest' - nullable: true - tools: - description: Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. - nullable: true - type: array - maxItems: 20 - items: - oneOf: - - $ref: '#/components/schemas/AssistantToolsCode' - - $ref: '#/components/schemas/AssistantToolsFileSearch' - - $ref: '#/components/schemas/AssistantToolsFunction' - x-oaiExpandable: true - metadata: - description: | - Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true - temperature: - type: number - minimum: 0 - maximum: 2 - default: 1 - example: 1 - nullable: true - description: | - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - top_p: - type: number - minimum: 0 - maximum: 1 - default: 1 - example: 1 - nullable: true - description: | - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. - stream: - type: boolean - nullable: true - description: | - If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message. - max_prompt_tokens: - type: integer - nullable: true - description: | - The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. - minimum: 256 - max_completion_tokens: - type: integer - nullable: true - description: | - The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. - minimum: 256 - truncation_strategy: - $ref: '#/components/schemas/TruncationObject' - nullable: true - tool_choice: - $ref: '#/components/schemas/AssistantsApiToolChoiceOption' - nullable: true - parallel_tool_calls: - $ref: '#/components/schemas/ParallelToolCalls' - response_format: - $ref: '#/components/schemas/AssistantsApiResponseFormatOption' - nullable: true - required: - - assistant_id - ModifyRunRequest: - type: object - additionalProperties: false - properties: - metadata: - description: | - Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true - ListRunStepsResponse: - properties: - object: - type: string - example: list - data: - type: array - items: - $ref: '#/components/schemas/RunStepObject' - first_id: - type: string - example: step_abc123 - last_id: - type: string - example: step_abc456 - has_more: - type: boolean - example: false - required: - - object - - data - - first_id - - last_id - - has_more - RunStepObject: - type: object - title: Run steps - description: | - Represents a step in execution of a run. - properties: - id: - description: 'The identifier of the run step, which can be referenced in API endpoints.' - type: string - object: - description: 'The object type, which is always `thread.run.step`.' - type: string - enum: - - thread.run.step - created_at: - description: The Unix timestamp (in seconds) for when the run step was created. - type: integer - assistant_id: - description: 'The ID of the [assistant](/docs/api-reference/assistants) associated with the run step.' - type: string - thread_id: - description: 'The ID of the [thread](/docs/api-reference/threads) that was run.' - type: string - run_id: - description: 'The ID of the [run](/docs/api-reference/runs) that this run step is a part of.' - type: string - type: - description: 'The type of run step, which can be either `message_creation` or `tool_calls`.' - type: string - enum: - - message_creation - - tool_calls - status: - description: 'The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`.' - type: string - enum: - - in_progress - - cancelled - - failed - - completed - - expired - step_details: - type: object - description: The details of the run step. - oneOf: - - $ref: '#/components/schemas/RunStepDetailsMessageCreationObject' - - $ref: '#/components/schemas/RunStepDetailsToolCallsObject' - x-oaiExpandable: true - last_error: - type: object - description: The last error associated with this run step. Will be `null` if there are no errors. - nullable: true - properties: - code: - type: string - description: One of `server_error` or `rate_limit_exceeded`. - enum: - - server_error - - rate_limit_exceeded - message: - type: string - description: A human-readable description of the error. - required: - - code - - message - expired_at: - description: The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired. - type: integer - nullable: true - cancelled_at: - description: The Unix timestamp (in seconds) for when the run step was cancelled. - type: integer - nullable: true - failed_at: - description: The Unix timestamp (in seconds) for when the run step failed. - type: integer - nullable: true - completed_at: - description: The Unix timestamp (in seconds) for when the run step completed. - type: integer - nullable: true - metadata: - description: | - Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true - usage: - $ref: '#/components/schemas/RunStepCompletionUsage' - required: - - id - - object - - created_at - - assistant_id - - thread_id - - run_id - - type - - status - - step_details - - last_error - - expired_at - - cancelled_at - - failed_at - - completed_at - - metadata - - usage - x-oaiMeta: - name: The run step object - beta: true - example: | - { - "id": "step_abc123", - "object": "thread.run.step", - "created_at": 1699063291, - "run_id": "run_abc123", - "assistant_id": "asst_abc123", - "thread_id": "thread_abc123", - "type": "message_creation", - "status": "completed", - "cancelled_at": null, - "completed_at": 1699063291, - "expired_at": null, - "failed_at": null, - "last_error": null, - "step_details": { - "type": "message_creation", - "message_creation": { - "message_id": "msg_abc123" - } - }, - "usage": { - "prompt_tokens": 123, - "completion_tokens": 456, - "total_tokens": 579 - } - } - RunStepDetailsMessageCreationObject: - title: Message creation - type: object - description: Details of the message creation by the run step. - properties: - type: - description: Always `message_creation`. - type: string - enum: - - message_creation - message_creation: - type: object - properties: - message_id: - type: string - description: The ID of the message that was created by this run step. - required: - - message_id - required: - - type - - message_creation - RunStepDetailsToolCallsObject: - title: Tool calls - type: object - description: Details of the tool call. - properties: - type: - description: Always `tool_calls`. - type: string - enum: - - tool_calls - tool_calls: - type: array - description: | - An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. - items: - oneOf: - - $ref: '#/components/schemas/RunStepDetailsToolCallsCodeObject' - - $ref: '#/components/schemas/RunStepDetailsToolCallsFileSearchObject' - - $ref: '#/components/schemas/RunStepDetailsToolCallsFunctionObject' - x-oaiExpandable: true - required: - - type - - tool_calls - RunStepCompletionUsage: - type: object - description: Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. - properties: - completion_tokens: - type: integer - description: Number of completion tokens used over the course of the run step. - prompt_tokens: - type: integer - description: Number of prompt tokens used over the course of the run step. - total_tokens: - type: integer - description: Total number of tokens used (prompt + completion). - required: - - prompt_tokens - - completion_tokens - - total_tokens - nullable: true - RunStepDetailsToolCallsCodeObject: - title: Code Interpreter tool call - type: object - description: Details of the Code Interpreter tool call the run step was involved in. - properties: - id: - type: string - description: The ID of the tool call. - type: - type: string - description: The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - enum: - - code_interpreter - code_interpreter: - type: object - description: The Code Interpreter tool call definition. - required: - - input - - outputs - properties: - input: - type: string - description: The input to the Code Interpreter tool call. - outputs: - type: array - description: 'The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type.' - items: - type: object - oneOf: - - $ref: '#/components/schemas/RunStepDetailsToolCallsCodeOutputLogsObject' - - $ref: '#/components/schemas/RunStepDetailsToolCallsCodeOutputImageObject' - x-oaiExpandable: true - required: - - id - - type - - code_interpreter - RunStepDetailsToolCallsFileSearchObject: - title: File search tool call - type: object - properties: - id: - type: string - description: The ID of the tool call object. - type: - type: string - description: The type of tool call. This is always going to be `file_search` for this type of tool call. - enum: - - file_search - file_search: - type: object - description: 'For now, this is always going to be an empty object.' - x-oaiTypeLabel: map - properties: - ranking_options: - $ref: '#/components/schemas/RunStepDetailsToolCallsFileSearchRankingOptionsObject' - results: - type: array - description: The results of the file search. - items: - $ref: '#/components/schemas/RunStepDetailsToolCallsFileSearchResultObject' - required: - - id - - type - - file_search - RunStepDetailsToolCallsFunctionObject: - type: object - title: Function tool call - properties: - id: - type: string - description: The ID of the tool call object. - type: - type: string - description: The type of tool call. This is always going to be `function` for this type of tool call. - enum: - - function - function: - type: object - description: The definition of the function that was called. - properties: - name: - type: string - description: The name of the function. - arguments: - type: string - description: The arguments passed to the function. - output: - type: string - description: 'The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet.' - nullable: true - required: - - name - - arguments - - output - required: - - id - - type - - function - RunStepDetailsToolCallsCodeOutputLogsObject: - title: Code Interpreter log output - type: object - description: Text output from the Code Interpreter tool call as part of a run step. - properties: - type: - description: Always `logs`. - type: string - enum: - - logs - logs: - type: string - description: The text output from the Code Interpreter tool call. - required: - - type - - logs - RunStepDetailsToolCallsCodeOutputImageObject: - title: Code Interpreter image output - type: object - properties: - type: - description: Always `image`. - type: string - enum: - - image - image: - type: object - properties: - file_id: - description: 'The [file](/docs/api-reference/files) ID of the image.' - type: string - required: - - file_id - required: - - type - - image - RunStepDetailsToolCallsFileSearchRankingOptionsObject: - title: File search tool call ranking options - type: object - description: The ranking options for the file search. - properties: - ranker: - type: string - description: The ranker used for the file search. - enum: - - default_2024_08_21 - score_threshold: - type: number - description: The score threshold for the file search. All values must be a floating point number between 0 and 1. - minimum: 0 - maximum: 1 - required: - - ranker - - score_threshold - RunStepDetailsToolCallsFileSearchResultObject: - title: File search tool call result - type: object - description: A result instance of the file search. - x-oaiTypeLabel: map - properties: - file_id: - type: string - description: The ID of the file that result was found in. - file_name: - type: string - description: The name of the file that result was found in. - score: - type: number - description: The score of the result. All values must be a floating point number between 0 and 1. - minimum: 0 - maximum: 1 - content: - type: array - description: The content of the result that was found. The content is only included if requested via the include query parameter. - items: - type: object - properties: - type: - type: string - description: The type of the content. - enum: - - text - text: - type: string - description: The text content of the file. - required: - - file_id - - file_name - - score - SubmitToolOutputsRunRequest: - type: object - additionalProperties: false - properties: - tool_outputs: - description: A list of tools for which the outputs are being submitted. - type: array - items: - type: object - properties: - tool_call_id: - type: string - description: The ID of the tool call in the `required_action` object within the run object the output is being submitted for. - output: - type: string - description: The output of the tool call to be submitted to continue the run. - stream: - type: boolean - nullable: true - description: | - If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message. - required: - - tool_outputs - responses: {} - securitySchemes: - ApiKeyAuth: - type: http - scheme: bearer - x-stackQL-resources: - assistants: - id: openai.assistants.assistants - name: assistants - title: Assistants - methods: - list_assistants: - operation: - $ref: '#/paths/~1assistants/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ListAssistantsResponse' - objectKey: $.data - create_assistant: - operation: - $ref: '#/paths/~1assistants/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/AssistantObject' - get_assistant: - operation: - $ref: '#/paths/~1assistants~1{assistant_id}/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/AssistantObject' - modify_assistant: - operation: - $ref: '#/paths/~1assistants~1{assistant_id}/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/AssistantObject' - delete_assistant: - operation: - $ref: '#/paths/~1assistants~1{assistant_id}/delete' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/DeleteAssistantResponse' - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/assistants/methods/get_assistant' - - $ref: '#/components/x-stackQL-resources/assistants/methods/list_assistants' - insert: - - $ref: '#/components/x-stackQL-resources/assistants/methods/create_assistant' - update: - - $ref: '#/components/x-stackQL-resources/assistants/methods/modify_assistant' - replace: [] - delete: - - $ref: '#/components/x-stackQL-resources/assistants/methods/delete_assistant' - threads: - id: openai.assistants.threads - name: threads - title: Threads - methods: - create_thread: - operation: - $ref: '#/paths/~1threads/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ThreadObject' - create_thread_and_run: - operation: - $ref: '#/paths/~1threads~1runs/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/RunObject' - get_thread: - operation: - $ref: '#/paths/~1threads~1{thread_id}/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ThreadObject' - modify_thread: - operation: - $ref: '#/paths/~1threads~1{thread_id}/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ThreadObject' - delete_thread: - operation: - $ref: '#/paths/~1threads~1{thread_id}/delete' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/DeleteThreadResponse' - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/threads/methods/get_thread' - insert: - - $ref: '#/components/x-stackQL-resources/threads/methods/create_thread' - update: - - $ref: '#/components/x-stackQL-resources/threads/methods/modify_thread' - replace: [] - delete: - - $ref: '#/components/x-stackQL-resources/threads/methods/delete_thread' - messages: - id: openai.assistants.messages - name: messages - title: Messages - methods: - list_messages: - operation: - $ref: '#/paths/~1threads~1{thread_id}~1messages/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ListMessagesResponse' - create_message: - operation: - $ref: '#/paths/~1threads~1{thread_id}~1messages/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/MessageObject' - get_message: - operation: - $ref: '#/paths/~1threads~1{thread_id}~1messages~1{message_id}/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/MessageObject' - modify_message: - operation: - $ref: '#/paths/~1threads~1{thread_id}~1messages~1{message_id}/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/MessageObject' - delete_message: - operation: - $ref: '#/paths/~1threads~1{thread_id}~1messages~1{message_id}/delete' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/DeleteMessageResponse' - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/messages/methods/get_message' - - $ref: '#/components/x-stackQL-resources/messages/methods/list_messages' - insert: - - $ref: '#/components/x-stackQL-resources/messages/methods/create_message' - update: - - $ref: '#/components/x-stackQL-resources/messages/methods/modify_message' - replace: [] - delete: - - $ref: '#/components/x-stackQL-resources/messages/methods/delete_message' - runs: - id: openai.assistants.runs - name: runs - title: Runs - methods: - list_runs: - operation: - $ref: '#/paths/~1threads~1{thread_id}~1runs/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ListRunsResponse' - objectKey: $.data - create_run: - operation: - $ref: '#/paths/~1threads~1{thread_id}~1runs/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/RunObject' - get_run: - operation: - $ref: '#/paths/~1threads~1{thread_id}~1runs~1{run_id}/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/RunObject' - modify_run: - operation: - $ref: '#/paths/~1threads~1{thread_id}~1runs~1{run_id}/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/RunObject' - cancel_run: - operation: - $ref: '#/paths/~1threads~1{thread_id}~1runs~1{run_id}~1cancel/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/RunObject' - submit_tool_ouputs_to_run: - operation: - $ref: '#/paths/~1threads~1{thread_id}~1runs~1{run_id}~1submit_tool_outputs/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/RunObject' - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/runs/methods/get_run' - - $ref: '#/components/x-stackQL-resources/runs/methods/list_runs' - insert: - - $ref: '#/components/x-stackQL-resources/runs/methods/create_run' - update: - - $ref: '#/components/x-stackQL-resources/runs/methods/modify_run' - replace: [] - delete: [] - run_steps: - id: openai.assistants.run_steps - name: run_steps - title: Run Steps - methods: - list_run_steps: - operation: - $ref: '#/paths/~1threads~1{thread_id}~1runs~1{run_id}~1steps/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ListRunStepsResponse' - get_run_step: - operation: - $ref: '#/paths/~1threads~1{thread_id}~1runs~1{run_id}~1steps~1{step_id}/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/RunStepObject' - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/run_steps/methods/get_run_step' - - $ref: '#/components/x-stackQL-resources/run_steps/methods/list_run_steps' - insert: [] - update: [] - replace: [] - delete: [] -paths: - /assistants: - get: - operationId: listAssistants - tags: - - Assistants - summary: Returns a list of assistants. - parameters: - - name: limit - in: query - description: | - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - required: false - schema: - type: integer - default: 20 - - name: order - in: query - description: | - Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. - schema: - type: string - default: desc - enum: - - asc - - desc - - name: after - in: query - 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 - - name: before - in: query - 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, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - schema: - type: string - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ListAssistantsResponse' - x-oaiMeta: - name: List assistants - group: assistants - beta: true - returns: 'A list of [assistant](/docs/api-reference/assistants/object) objects.' examples: - request: - curl: | - curl "https://api.openai.com/v1/assistants?order=desc&limit=20" \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from openai import OpenAI - client = OpenAI() + - title: Default + request: + curl: | + curl https://api.openai.com/v1/threads/runs \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "assistant_id": "asst_abc123", + "thread": { + "messages": [ + {"role": "user", "content": "Explain deep learning to a 5 year old."} + ] + } + }' + python: |- + import os + from openai import OpenAI - my_assistants = client.beta.assistants.list( - order="desc", - limit="20", - ) - print(my_assistants.data) - node.js: |- - import OpenAI from "openai"; + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + for thread in client.beta.threads.create_and_run( + assistant_id="assistant_id", + ): + print(thread) + javascript: | + import OpenAI from "openai"; - const openai = new OpenAI(); + const openai = new OpenAI(); - async function main() { - const myAssistants = await openai.beta.assistants.list({ - order: "desc", - limit: "20", + async function main() { + const run = await openai.beta.threads.createAndRun({ + assistant_id: "asst_abc123", + thread: { + messages: [ + { role: "user", content: "Explain deep learning to a 5 year old." }, + ], + }, + }); + + console.log(run); + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted }); - console.log(myAssistants.data); - } - main(); - response: | - { - "object": "list", - "data": [ - { - "id": "asst_abc123", - "object": "assistant", - "created_at": 1698982736, - "name": "Coding Tutor", - "description": null, - "model": "gpt-4o", - "instructions": "You are a helpful assistant designed to make me better at coding!", - "tools": [], - "tool_resources": {}, - "metadata": {}, - "top_p": 1.0, - "temperature": 1.0, - "response_format": "auto" - }, - { - "id": "asst_abc456", - "object": "assistant", - "created_at": 1698982718, - "name": "My Assistant", - "description": null, - "model": "gpt-4o", - "instructions": "You are a helpful assistant designed to make me better at coding!", - "tools": [], - "tool_resources": {}, - "metadata": {}, - "top_p": 1.0, - "temperature": 1.0, - "response_format": "auto" - }, - { - "id": "asst_abc789", - "object": "assistant", - "created_at": 1698982643, - "name": null, - "description": null, - "model": "gpt-4o", - "instructions": null, - "tools": [], - "tool_resources": {}, - "metadata": {}, - "top_p": 1.0, - "temperature": 1.0, - "response_format": "auto" + const run = await client.beta.threads.createAndRun({ + assistant_id: 'assistant_id' }); + + + console.log(run.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\trun, err := client.Beta.Threads.NewAndRun(context.TODO(), openai.BetaThreadNewAndRunParams{\n\t\tAssistantID: \"assistant_id\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.threads.ThreadCreateAndRunParams; + import com.openai.models.beta.threads.runs.Run; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ThreadCreateAndRunParams params = ThreadCreateAndRunParams.builder() + .assistantId("assistant_id") + .build(); + Run run = client.beta().threads().createAndRun(params); + } } - ], - "first_id": "asst_abc123", - "last_id": "asst_abc789", - "has_more": false - } - post: - operationId: createAssistant - tags: - - Assistants - summary: Create an assistant with a model and instructions. - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CreateAssistantRequest' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/AssistantObject' - x-oaiMeta: - name: Create assistant - group: assistants - beta: true - returns: 'An [assistant](/docs/api-reference/assistants/object) object.' - examples: - - title: Code Interpreter + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + run = openai.beta.threads.create_and_run(assistant_id: + "assistant_id") + + + puts(run) + response: | + { + "id": "run_abc123", + "object": "thread.run", + "created_at": 1699076792, + "assistant_id": "asst_abc123", + "thread_id": "thread_abc123", + "status": "queued", + "started_at": null, + "expires_at": 1699077392, + "cancelled_at": null, + "failed_at": null, + "completed_at": null, + "required_action": null, + "last_error": null, + "model": "gpt-4o", + "instructions": "You are a helpful assistant.", + "tools": [], + "tool_resources": {}, + "metadata": {}, + "temperature": 1.0, + "top_p": 1.0, + "max_completion_tokens": null, + "max_prompt_tokens": null, + "truncation_strategy": { + "type": "auto", + "last_messages": null + }, + "incomplete_details": null, + "usage": null, + "response_format": "auto", + "tool_choice": "auto", + "parallel_tool_calls": true + } + - title: Streaming request: curl: | - curl "https://api.openai.com/v1/assistants" \ - -H "Content-Type: application/json" \ + curl https://api.openai.com/v1/threads/runs \ -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" \ -d '{ - "instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.", - "name": "Math Tutor", - "tools": [{"type": "code_interpreter"}], - "model": "gpt-4o" + "assistant_id": "asst_123", + "thread": { + "messages": [ + {"role": "user", "content": "Hello"} + ] + }, + "stream": true }' - python: | + python: |- + import os from openai import OpenAI - client = OpenAI() - my_assistant = client.beta.assistants.create( - instructions="You are a personal math tutor. When asked a question, write and run Python code to answer the question.", - name="Math Tutor", - tools=[{"type": "code_interpreter"}], - model="gpt-4o", - ) - print(my_assistant) - node.js: |- - import OpenAI from "openai"; + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + for thread in client.beta.threads.create_and_run( + assistant_id="assistant_id", + ): + print(thread) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const stream = await openai.beta.threads.createAndRun({ + assistant_id: "asst_123", + thread: { + messages: [ + { role: "user", content: "Hello" }, + ], + }, + stream: true + }); + + for await (const event of stream) { + console.log(event); + } + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const run = await client.beta.threads.createAndRun({ + assistant_id: 'assistant_id' }); + + + console.log(run.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\trun, err := client.Beta.Threads.NewAndRun(context.TODO(), openai.BetaThreadNewAndRunParams{\n\t\tAssistantID: \"assistant_id\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.threads.ThreadCreateAndRunParams; + import com.openai.models.beta.threads.runs.Run; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ThreadCreateAndRunParams params = ThreadCreateAndRunParams.builder() + .assistantId("assistant_id") + .build(); + Run run = client.beta().threads().createAndRun(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + run = openai.beta.threads.create_and_run(assistant_id: + "assistant_id") + + + puts(run) + response: > + event: thread.created + + data: + {"id":"thread_123","object":"thread","created_at":1710348075,"metadata":{}} + + + event: thread.run.created + + data: + {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true} + + + event: thread.run.queued + + data: + {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true} + + + event: thread.run.in_progress + + data: + {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true} + + + event: thread.run.step.created + + data: + {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} + + + event: thread.run.step.in_progress + + data: + {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} + + + event: thread.message.created + + data: + {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[], + "metadata":{}} + + + event: thread.message.in_progress + + data: + {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[], + "metadata":{}} + + + event: thread.message.delta + + data: + {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}} + + + ... + + + event: thread.message.delta - const openai = new OpenAI(); + data: + {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" + today"}}]}} - async function main() { - const myAssistant = await openai.beta.assistants.create({ - instructions: - "You are a personal math tutor. When asked a question, write and run Python code to answer the question.", - name: "Math Tutor", - tools: [{ type: "code_interpreter" }], - model: "gpt-4o", - }); - console.log(myAssistant); - } + event: thread.message.delta - main(); - response: | - { - "id": "asst_abc123", - "object": "assistant", - "created_at": 1698984975, - "name": "Math Tutor", - "description": null, - "model": "gpt-4o", - "instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.", - "tools": [ - { - "type": "code_interpreter" - } - ], - "metadata": {}, - "top_p": 1.0, - "temperature": 1.0, - "response_format": "auto" - } - - title: Files + data: + {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}} + + + event: thread.message.completed + + data: + {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710348077,"role":"assistant","content":[{"type":"text","text":{"value":"Hello! + How can I assist you today?","annotations":[]}}], "metadata":{}} + + + event: thread.run.step.completed + + data: + {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710348077,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31}} + + + event: thread.run.completed + + {"id":"run_123","object":"thread.run","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1713226836,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1713226837,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":345,"completion_tokens":11,"total_tokens":356},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true} + + + event: done + + data: [DONE] + - title: Streaming with Functions request: curl: | - curl https://api.openai.com/v1/assistants \ - -H "Content-Type: application/json" \ + curl https://api.openai.com/v1/threads/runs \ -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" \ -d '{ - "instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies.", - "tools": [{"type": "file_search"}], - "tool_resources": {"file_search": {"vector_store_ids": ["vs_123"]}}, - "model": "gpt-4o" + "assistant_id": "asst_abc123", + "thread": { + "messages": [ + {"role": "user", "content": "What is the weather like in San Francisco?"} + ] + }, + "tools": [ + { + "type": "function", + "function": { + "name": "get_current_weather", + "description": "Get the current weather in a given location", + "parameters": { + "type": "object", + "properties": { + "location": { + "type": "string", + "description": "The city and state, e.g. San Francisco, CA" + }, + "unit": { + "type": "string", + "enum": ["celsius", "fahrenheit"] + } + }, + "required": ["location"] + } + } + } + ], + "stream": true }' - python: | + python: |- + import os from openai import OpenAI - client = OpenAI() - - my_assistant = client.beta.assistants.create( - instructions="You are an HR bot, and you have access to files to answer employee questions about company policies.", - name="HR Helper", - tools=[{"type": "file_search"}], - tool_resources={"file_search": {"vector_store_ids": ["vs_123"]}}, - model="gpt-4o" + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted ) - print(my_assistant) - node.js: |- + for thread in client.beta.threads.create_and_run( + assistant_id="assistant_id", + ): + print(thread) + javascript: | import OpenAI from "openai"; const openai = new OpenAI(); - async function main() { - const myAssistant = await openai.beta.assistants.create({ - instructions: - "You are an HR bot, and you have access to files to answer employee questions about company policies.", - name: "HR Helper", - tools: [{ type: "file_search" }], - tool_resources: { - file_search: { - vector_store_ids: ["vs_123"] + const tools = [ + { + "type": "function", + "function": { + "name": "get_current_weather", + "description": "Get the current weather in a given location", + "parameters": { + "type": "object", + "properties": { + "location": { + "type": "string", + "description": "The city and state, e.g. San Francisco, CA", + }, + "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}, + }, + "required": ["location"], + }, } + } + ]; + + async function main() { + const stream = await openai.beta.threads.createAndRun({ + assistant_id: "asst_123", + thread: { + messages: [ + { role: "user", content: "What is the weather like in San Francisco?" }, + ], }, - model: "gpt-4o" + tools: tools, + stream: true }); - console.log(myAssistant); + for await (const event of stream) { + console.log(event); + } } main(); - response: | - { - "id": "asst_abc123", - "object": "assistant", - "created_at": 1699009403, - "name": "HR Helper", - "description": null, - "model": "gpt-4o", - "instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies.", - "tools": [ - { - "type": "file_search" - } - ], - "tool_resources": { - "file_search": { - "vector_store_ids": ["vs_123"] - } - }, - "metadata": {}, - "top_p": 1.0, - "temperature": 1.0, - "response_format": "auto" - } - '/assistants/{assistant_id}': + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const run = await client.beta.threads.createAndRun({ + assistant_id: 'assistant_id' }); + + + console.log(run.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\trun, err := client.Beta.Threads.NewAndRun(context.TODO(), openai.BetaThreadNewAndRunParams{\n\t\tAssistantID: \"assistant_id\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.threads.ThreadCreateAndRunParams; + import com.openai.models.beta.threads.runs.Run; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ThreadCreateAndRunParams params = ThreadCreateAndRunParams.builder() + .assistantId("assistant_id") + .build(); + Run run = client.beta().threads().createAndRun(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + run = openai.beta.threads.create_and_run(assistant_id: + "assistant_id") + + + puts(run) + response: > + event: thread.created + + data: + {"id":"thread_123","object":"thread","created_at":1710351818,"metadata":{}} + + + event: thread.run.created + + data: + {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get + the current weather in a given + location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The + city and state, e.g. San Francisco, + CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + + + event: thread.run.queued + + data: + {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get + the current weather in a given + location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The + city and state, e.g. San Francisco, + CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + + + event: thread.run.in_progress + + data: + {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710351818,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get + the current weather in a given + location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The + city and state, e.g. San Francisco, + CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + + + event: thread.run.step.created + + data: + {"id":"step_001","object":"thread.run.step","created_at":1710351819,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"tool_calls","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710352418,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[]},"usage":null} + + + event: thread.run.step.in_progress + + data: + {"id":"step_001","object":"thread.run.step","created_at":1710351819,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"tool_calls","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710352418,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[]},"usage":null} + + + event: thread.run.step.delta + + data: + {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"id":"call_XXNp8YGaFrjrSjgqxtC8JJ1B","type":"function","function":{"name":"get_current_weather","arguments":"","output":null}}]}}} + + + event: thread.run.step.delta + + data: + {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"{\""}}]}}} + + + event: thread.run.step.delta + + data: + {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"location"}}]}}} + + + ... + + + event: thread.run.step.delta + + data: + {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"ahrenheit"}}]}}} + + + event: thread.run.step.delta + + data: + {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"\"}"}}]}}} + + + event: thread.run.requires_action + + data: + {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"requires_action","started_at":1710351818,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":{"type":"submit_tool_outputs","submit_tool_outputs":{"tool_calls":[{"id":"call_XXNp8YGaFrjrSjgqxtC8JJ1B","type":"function","function":{"name":"get_current_weather","arguments":"{\"location\":\"San + Francisco, + CA\",\"unit\":\"fahrenheit\"}"}}]}},"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get + the current weather in a given + location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The + city and state, e.g. San Francisco, + CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":345,"completion_tokens":11,"total_tokens":356},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + + + event: done + + data: [DONE] + parameters: + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + deprecated: true + /threads/{thread_id}: get: - operationId: getAssistant + operationId: getThread tags: - Assistants - summary: Retrieves an assistant. + summary: Retrieves a thread. parameters: - in: path - name: assistant_id + name: thread_id required: true schema: type: string - description: The ID of the assistant to retrieve. + description: The ID of the thread to retrieve. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string responses: '200': description: OK content: application/json: schema: - $ref: '#/components/schemas/AssistantObject' + $ref: '#/components/schemas/ThreadObject' x-oaiMeta: - name: Retrieve assistant - group: assistants + name: Retrieve thread + group: threads beta: true - returns: 'The [assistant](/docs/api-reference/assistants/object) object matching the specified ID.' examples: request: curl: | - curl https://api.openai.com/v1/assistants/asst_abc123 \ + curl https://api.openai.com/v1/threads/thread_abc123 \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "OpenAI-Beta: assistants=v2" - python: | + python: |- + import os from openai import OpenAI - client = OpenAI() - my_assistant = client.beta.assistants.retrieve("asst_abc123") - print(my_assistant) - node.js: |- + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + thread = client.beta.threads.retrieve( + "thread_id", + ) + print(thread.id) + javascript: |- import OpenAI from "openai"; const openai = new OpenAI(); async function main() { - const myAssistant = await openai.beta.assistants.retrieve( - "asst_abc123" + const myThread = await openai.beta.threads.retrieve( + "thread_abc123" ); - console.log(myAssistant); + console.log(myThread); } main(); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const thread = await client.beta.threads.retrieve('thread_id'); + + console.log(thread.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\tthread, err := client.Beta.Threads.Get(context.TODO(), \"thread_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", thread.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.threads.Thread; + import com.openai.models.beta.threads.ThreadRetrieveParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Thread thread = client.beta().threads().retrieve("thread_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + thread = openai.beta.threads.retrieve("thread_id") + + puts(thread) response: | { - "id": "asst_abc123", - "object": "assistant", - "created_at": 1699009709, - "name": "HR Helper", - "description": null, - "model": "gpt-4o", - "instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies.", - "tools": [ - { - "type": "file_search" - } - ], + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, "metadata": {}, - "top_p": 1.0, - "temperature": 1.0, - "response_format": "auto" + "tool_resources": { + "code_interpreter": { + "file_ids": [] + } + } } + deprecated: true post: - operationId: modifyAssistant + operationId: modifyThread tags: - Assistants - summary: Modifies an assistant. + summary: Modifies a thread. parameters: - in: path - name: assistant_id + name: thread_id required: true schema: type: string - description: The ID of the assistant to modify. + description: The ID of the thread to modify. Only the `metadata` can be modified. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string requestBody: required: true content: application/json: schema: - $ref: '#/components/schemas/ModifyAssistantRequest' + $ref: '#/components/schemas/ModifyThreadRequest' responses: '200': description: OK content: application/json: schema: - $ref: '#/components/schemas/AssistantObject' + $ref: '#/components/schemas/ThreadObject' x-oaiMeta: - name: Modify assistant - group: assistants + name: Modify thread + group: threads beta: true - returns: 'The modified [assistant](/docs/api-reference/assistants/object) object.' examples: request: curl: | - curl https://api.openai.com/v1/assistants/asst_abc123 \ + curl https://api.openai.com/v1/threads/thread_abc123 \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "OpenAI-Beta: assistants=v2" \ -d '{ - "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.", - "tools": [{"type": "file_search"}], - "model": "gpt-4o" + "metadata": { + "modified": "true", + "user": "abc123" + } }' - python: | + python: |- + import os from openai import OpenAI - client = OpenAI() - - my_updated_assistant = client.beta.assistants.update( - "asst_abc123", - 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.", - name="HR Helper", - tools=[{"type": "file_search"}], - model="gpt-4o" - ) - print(my_updated_assistant) - node.js: |- + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + thread = client.beta.threads.update( + thread_id="thread_id", + ) + print(thread.id) + javascript: |- import OpenAI from "openai"; const openai = new OpenAI(); async function main() { - const myUpdatedAssistant = await openai.beta.assistants.update( - "asst_abc123", + const updatedThread = await openai.beta.threads.update( + "thread_abc123", { - 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.", - name: "HR Helper", - tools: [{ type: "file_search" }], - model: "gpt-4o" + metadata: { modified: "true", user: "abc123" }, } ); - console.log(myUpdatedAssistant); + console.log(updatedThread); } main(); - response: | - { - "id": "asst_123", - "object": "assistant", - "created_at": 1699009709, - "name": "HR Helper", - "description": null, - "model": "gpt-4o", - "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.", - "tools": [ - { - "type": "file_search" - } - ], - "tool_resources": { - "file_search": { - "vector_store_ids": [] - } - }, - "metadata": {}, - "top_p": 1.0, - "temperature": 1.0, - "response_format": "auto" - } - delete: - operationId: deleteAssistant - tags: - - Assistants - summary: Delete an assistant. - parameters: - - in: path - name: assistant_id - required: true - schema: - type: string - description: The ID of the assistant to delete. - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/DeleteAssistantResponse' - x-oaiMeta: - name: Delete assistant - group: assistants - beta: true - returns: Deletion status - examples: - request: - curl: | - curl https://api.openai.com/v1/assistants/asst_abc123 \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "OpenAI-Beta: assistants=v2" \ - -X DELETE - python: | - from openai import OpenAI - client = OpenAI() - - response = client.beta.assistants.delete("asst_abc123") - print(response) - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const response = await openai.beta.assistants.del("asst_abc123"); - - console.log(response); - } - main(); - response: | - { - "id": "asst_abc123", - "object": "assistant.deleted", - "deleted": true - } - /threads: - post: - operationId: createThread - tags: - - Assistants - summary: Create a thread. - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/CreateThreadRequest' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ThreadObject' - x-oaiMeta: - name: Create thread - group: threads - beta: true - returns: 'A [thread](/docs/api-reference/threads) object.' - examples: - - title: Empty - request: - curl: | - curl https://api.openai.com/v1/threads \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "OpenAI-Beta: assistants=v2" \ - -d '' - python: | - from openai import OpenAI - client = OpenAI() - - empty_thread = client.beta.threads.create() - print(empty_thread) - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const emptyThread = await openai.beta.threads.create(); - - console.log(emptyThread); - } - - main(); - response: | - { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699012949, - "metadata": {}, - "tool_resources": {} - } - - title: Messages - request: - curl: | - curl https://api.openai.com/v1/threads \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "OpenAI-Beta: assistants=v2" \ - -d '{ - "messages": [{ - "role": "user", - "content": "Hello, what is AI?" - }, { - "role": "user", - "content": "How does AI work? Explain it in simple terms." - }] - }' - python: | - from openai import OpenAI - client = OpenAI() - - message_thread = client.beta.threads.create( - messages=[ - { - "role": "user", - "content": "Hello, what is AI?" - }, - { - "role": "user", - "content": "How does AI work? Explain it in simple terms." - }, - ] - ) + node.js: |- + import OpenAI from 'openai'; - print(message_thread) - node.js: |- - import OpenAI from "openai"; + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); - const openai = new OpenAI(); + const thread = await client.beta.threads.update('thread_id'); - async function main() { - const messageThread = await openai.beta.threads.create({ - messages: [ - { - role: "user", - content: "Hello, what is AI?" - }, - { - role: "user", - content: "How does AI work? Explain it in simple terms.", - }, - ], - }); + console.log(thread.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\tthread, err := client.Beta.Threads.Update(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\topenai.BetaThreadUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", thread.ID)\n}\n" + java: |- + package com.openai.example; - console.log(messageThread); - } + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.threads.Thread; + import com.openai.models.beta.threads.ThreadUpdateParams; - main(); - response: | - { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699014083, - "metadata": {}, - "tool_resources": {} + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Thread thread = client.beta().threads().update("thread_id"); + } } - /threads/runs: - post: - operationId: createThreadAndRun + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + thread = openai.beta.threads.update("thread_id") + + puts(thread) + response: | + { + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, + "metadata": { + "modified": "true", + "user": "abc123" + }, + "tool_resources": {} + } + deprecated: true + delete: + operationId: deleteThread tags: - Assistants - summary: Create a thread and run it in one request. - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CreateThreadAndRunRequest' + summary: Delete a thread. + parameters: + - in: path + name: thread_id + required: true + schema: + type: string + description: The ID of the thread to delete. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string responses: '200': description: OK content: application/json: schema: - $ref: '#/components/schemas/RunObject' + $ref: '#/components/schemas/DeleteThreadResponse' x-oaiMeta: - name: Create thread and run + name: Delete thread group: threads beta: true - returns: 'A [run](/docs/api-reference/runs/object) object.' examples: - - title: Default - request: - curl: | - curl https://api.openai.com/v1/threads/runs \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" \ - -d '{ - "assistant_id": "asst_abc123", - "thread": { - "messages": [ - {"role": "user", "content": "Explain deep learning to a 5 year old."} - ] - } - }' - python: | - from openai import OpenAI - client = OpenAI() + request: + curl: | + curl https://api.openai.com/v1/threads/thread_abc123 \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "OpenAI-Beta: assistants=v2" \ + -X DELETE + python: |- + import os + from openai import OpenAI - run = client.beta.threads.create_and_run( - assistant_id="asst_abc123", - thread={ - "messages": [ - {"role": "user", "content": "Explain deep learning to a 5 year old."} - ] - } - ) + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + thread_deleted = client.beta.threads.delete( + "thread_id", + ) + print(thread_deleted.id) + javascript: |- + import OpenAI from "openai"; - print(run) - node.js: | - import OpenAI from "openai"; + const openai = new OpenAI(); - const openai = new OpenAI(); + async function main() { + const response = await openai.beta.threads.delete("thread_abc123"); - async function main() { - const run = await openai.beta.threads.createAndRun({ - assistant_id: "asst_abc123", - thread: { - messages: [ - { role: "user", content: "Explain deep learning to a 5 year old." }, - ], - }, - }); + console.log(response); + } + main(); + node.js: >- + import OpenAI from 'openai'; - console.log(run); - } - main(); - response: | - { - "id": "run_abc123", - "object": "thread.run", - "created_at": 1699076792, - "assistant_id": "asst_abc123", - "thread_id": "thread_abc123", - "status": "queued", - "started_at": null, - "expires_at": 1699077392, - "cancelled_at": null, - "failed_at": null, - "completed_at": null, - "required_action": null, - "last_error": null, - "model": "gpt-4o", - "instructions": "You are a helpful assistant.", - "tools": [], - "tool_resources": {}, - "metadata": {}, - "temperature": 1.0, - "top_p": 1.0, - "max_completion_tokens": null, - "max_prompt_tokens": null, - "truncation_strategy": { - "type": "auto", - "last_messages": null - }, - "incomplete_details": null, - "usage": null, - "response_format": "auto", - "tool_choice": "auto", - "parallel_tool_calls": true + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const threadDeleted = await + client.beta.threads.delete('thread_id'); + + + console.log(threadDeleted.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\tthreadDeleted, err := client.Beta.Threads.Delete(context.TODO(), \"thread_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", threadDeleted.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.threads.ThreadDeleteParams; + import com.openai.models.beta.threads.ThreadDeleted; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ThreadDeleted threadDeleted = client.beta().threads().delete("thread_id"); + } } - - title: Streaming - request: - curl: | - curl https://api.openai.com/v1/threads/runs \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" \ - -d '{ - "assistant_id": "asst_123", - "thread": { - "messages": [ - {"role": "user", "content": "Hello"} - ] - }, - "stream": true - }' - python: | - from openai import OpenAI - client = OpenAI() + ruby: |- + require "openai" - stream = client.beta.threads.create_and_run( - assistant_id="asst_123", - thread={ - "messages": [ - {"role": "user", "content": "Hello"} - ] - }, - stream=True - ) + openai = OpenAI::Client.new(api_key: "My API Key") - for event in stream: - print(event) - node.js: | - import OpenAI from "openai"; + thread_deleted = openai.beta.threads.delete("thread_id") - const openai = new OpenAI(); + puts(thread_deleted) + response: | + { + "id": "thread_abc123", + "object": "thread.deleted", + "deleted": true + } + deprecated: true + /threads/{thread_id}/messages: + get: + operationId: listMessages + tags: + - Assistants + summary: Returns a list of messages for a given thread. + parameters: + - in: path + name: thread_id + required: true + schema: + type: string + description: >- + The ID of the [thread](/docs/api-reference/threads) the messages + belong to. + - name: limit + in: query + description: >- + A limit on the number of objects to be returned. Limit can range + between 1 and 100, and the default is 20. - async function main() { - const stream = await openai.beta.threads.createAndRun({ - assistant_id: "asst_123", - thread: { - messages: [ - { role: "user", content: "Hello" }, - ], - }, - stream: true - }); - for await (const event of stream) { - console.log(event); - } - } + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: > + Sort order by the `created_at` timestamp of the objects. `asc` for + ascending order and `desc` for descending order. + schema: + type: string + default: desc + enum: + - asc + - desc + - name: after + in: query + 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 + - name: before + in: query + 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 + - name: run_id + in: query + description: | + Filter messages by the run ID that generated them. + schema: + type: string + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ListMessagesResponse' + x-oaiMeta: + name: List messages + group: threads + beta: true + examples: + request: + curl: | + curl https://api.openai.com/v1/threads/thread_abc123/messages \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "OpenAI-Beta: assistants=v2" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.beta.threads.messages.list( + thread_id="thread_id", + ) + page = page.data[0] + print(page.id) + javascript: |- + import OpenAI from "openai"; - main(); - response: | - event: thread.created - data: {"id":"thread_123","object":"thread","created_at":1710348075,"metadata":{}} + const openai = new OpenAI(); - event: thread.run.created - data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true} + async function main() { + const threadMessages = await openai.beta.threads.messages.list( + "thread_abc123" + ); - event: thread.run.queued - data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true} + console.log(threadMessages.data); + } - event: thread.run.in_progress - data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true} + main(); + node.js: >- + import OpenAI from 'openai'; - event: thread.run.step.created - data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} - event: thread.run.step.in_progress - data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); - event: thread.message.created - data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[], "metadata":{}} - event: thread.message.in_progress - data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[], "metadata":{}} + // Automatically fetches more pages as needed. - event: thread.message.delta - data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}} + for await (const message of + client.beta.threads.messages.list('thread_id')) { + console.log(message.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.Beta.Threads.Messages.List(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\topenai.BetaThreadMessageListParams{},\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; - ... + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.threads.messages.MessageListPage; + import com.openai.models.beta.threads.messages.MessageListParams; - event: thread.message.delta - data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" today"}}]}} + public final class Main { + private Main() {} - event: thread.message.delta - data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}} + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); - event: thread.message.completed - data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710348077,"role":"assistant","content":[{"type":"text","text":{"value":"Hello! How can I assist you today?","annotations":[]}}], "metadata":{}} + MessageListPage page = client.beta().threads().messages().list("thread_id"); + } + } + ruby: |- + require "openai" - event: thread.run.step.completed - data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710348077,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31}} + openai = OpenAI::Client.new(api_key: "My API Key") - event: thread.run.completed - {"id":"run_123","object":"thread.run","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1713226836,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1713226837,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":345,"completion_tokens":11,"total_tokens":356},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true} + page = openai.beta.threads.messages.list("thread_id") - event: done - data: [DONE] - - title: Streaming with Functions - request: - curl: | - curl https://api.openai.com/v1/threads/runs \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" \ - -d '{ - "assistant_id": "asst_abc123", - "thread": { - "messages": [ - {"role": "user", "content": "What is the weather like in San Francisco?"} - ] - }, - "tools": [ - { - "type": "function", - "function": { - "name": "get_current_weather", - "description": "Get the current weather in a given location", - "parameters": { - "type": "object", - "properties": { - "location": { - "type": "string", - "description": "The city and state, e.g. San Francisco, CA" - }, - "unit": { - "type": "string", - "enum": ["celsius", "fahrenheit"] - } - }, - "required": ["location"] - } - } + puts(page) + response: | + { + "object": "list", + "data": [ + { + "id": "msg_abc123", + "object": "thread.message", + "created_at": 1699016383, + "assistant_id": null, + "thread_id": "thread_abc123", + "run_id": null, + "role": "user", + "content": [ + { + "type": "text", + "text": { + "value": "How does AI work? Explain it in simple terms.", + "annotations": [] } - ], - "stream": true + } + ], + "attachments": [], + "metadata": {} + }, + { + "id": "msg_abc456", + "object": "thread.message", + "created_at": 1699016383, + "assistant_id": null, + "thread_id": "thread_abc123", + "run_id": null, + "role": "user", + "content": [ + { + "type": "text", + "text": { + "value": "Hello, what is AI?", + "annotations": [] + } + } + ], + "attachments": [], + "metadata": {} + } + ], + "first_id": "msg_abc123", + "last_id": "msg_abc456", + "has_more": false + } + deprecated: true + post: + operationId: createMessage + tags: + - Assistants + summary: Create a message. + parameters: + - in: path + name: thread_id + required: true + schema: + type: string + description: >- + The ID of the [thread](/docs/api-reference/threads) to create a + message for. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateMessageRequest' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/MessageObject' + x-oaiMeta: + name: Create message + group: threads + beta: true + examples: + request: + curl: | + curl https://api.openai.com/v1/threads/thread_abc123/messages \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "role": "user", + "content": "How does AI work? Explain it in simple terms." }' - python: | - from openai import OpenAI - client = OpenAI() + python: |- + import os + from openai import OpenAI - tools = [ - { - "type": "function", - "function": { - "name": "get_current_weather", - "description": "Get the current weather in a given location", - "parameters": { - "type": "object", - "properties": { - "location": { - "type": "string", - "description": "The city and state, e.g. San Francisco, CA", - }, - "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}, - }, - "required": ["location"], - }, - } - } - ] + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + message = client.beta.threads.messages.create( + thread_id="thread_id", + content="string", + role="user", + ) + print(message.id) + javascript: |- + import OpenAI from "openai"; - stream = client.beta.threads.create_and_run( - thread={ - "messages": [ - {"role": "user", "content": "What is the weather like in San Francisco?"} - ] - }, - assistant_id="asst_abc123", - tools=tools, - stream=True - ) + const openai = new OpenAI(); - for event in stream: - print(event) - node.js: | - import OpenAI from "openai"; + async function main() { + const threadMessages = await openai.beta.threads.messages.create( + "thread_abc123", + { role: "user", content: "How does AI work? Explain it in simple terms." } + ); - const openai = new OpenAI(); + console.log(threadMessages); + } - const tools = [ - { - "type": "function", - "function": { - "name": "get_current_weather", - "description": "Get the current weather in a given location", - "parameters": { - "type": "object", - "properties": { - "location": { - "type": "string", - "description": "The city and state, e.g. San Francisco, CA", - }, - "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}, - }, - "required": ["location"], - }, - } - } - ]; + main(); + node.js: >- + import OpenAI from 'openai'; - async function main() { - const stream = await openai.beta.threads.createAndRun({ - assistant_id: "asst_123", - thread: { - messages: [ - { role: "user", content: "What is the weather like in San Francisco?" }, - ], - }, - tools: tools, - stream: true - }); - for await (const event of stream) { - console.log(event); - } - } + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); - main(); - response: | - event: thread.created - data: {"id":"thread_123","object":"thread","created_at":1710351818,"metadata":{}} - event: thread.run.created - data: {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + const message = await + client.beta.threads.messages.create('thread_id', { + content: 'string', + role: 'user', + }); + + + console.log(message.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\tmessage, err := client.Beta.Threads.Messages.New(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\topenai.BetaThreadMessageNewParams{\n\t\t\tContent: openai.BetaThreadMessageNewParamsContentUnion{\n\t\t\t\tOfString: openai.String(\"string\"),\n\t\t\t},\n\t\t\tRole: openai.BetaThreadMessageNewParamsRoleUser,\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", message.ID)\n}\n" + java: >- + package com.openai.example; + - event: thread.run.queued - data: {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + import com.openai.client.OpenAIClient; - event: thread.run.in_progress - data: {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710351818,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + import com.openai.client.okhttp.OpenAIOkHttpClient; - event: thread.run.step.created - data: {"id":"step_001","object":"thread.run.step","created_at":1710351819,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"tool_calls","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710352418,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[]},"usage":null} + import com.openai.models.beta.threads.messages.Message; - event: thread.run.step.in_progress - data: {"id":"step_001","object":"thread.run.step","created_at":1710351819,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"tool_calls","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710352418,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[]},"usage":null} + import + com.openai.models.beta.threads.messages.MessageCreateParams; - event: thread.run.step.delta - data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"id":"call_XXNp8YGaFrjrSjgqxtC8JJ1B","type":"function","function":{"name":"get_current_weather","arguments":"","output":null}}]}}} - event: thread.run.step.delta - data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"{\""}}]}}} + public final class Main { + private Main() {} - event: thread.run.step.delta - data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"location"}}]}}} + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); - ... + MessageCreateParams params = MessageCreateParams.builder() + .threadId("thread_id") + .content("string") + .role(MessageCreateParams.Role.USER) + .build(); + Message message = client.beta().threads().messages().create(params); + } + } + ruby: >- + require "openai" - event: thread.run.step.delta - data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"ahrenheit"}}]}}} - event: thread.run.step.delta - data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"\"}"}}]}}} + openai = OpenAI::Client.new(api_key: "My API Key") - event: thread.run.requires_action - data: {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"requires_action","started_at":1710351818,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":{"type":"submit_tool_outputs","submit_tool_outputs":{"tool_calls":[{"id":"call_XXNp8YGaFrjrSjgqxtC8JJ1B","type":"function","function":{"name":"get_current_weather","arguments":"{\"location\":\"San Francisco, CA\",\"unit\":\"fahrenheit\"}"}}]}},"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":345,"completion_tokens":11,"total_tokens":356},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} - event: done - data: [DONE] - '/threads/{thread_id}': + message = openai.beta.threads.messages.create("thread_id", + content: "string", role: :user) + + + puts(message) + response: | + { + "id": "msg_abc123", + "object": "thread.message", + "created_at": 1713226573, + "assistant_id": null, + "thread_id": "thread_abc123", + "run_id": null, + "role": "user", + "content": [ + { + "type": "text", + "text": { + "value": "How does AI work? Explain it in simple terms.", + "annotations": [] + } + } + ], + "attachments": [], + "metadata": {} + } + deprecated: true + /threads/{thread_id}/messages/{message_id}: get: - operationId: getThread + operationId: getMessage tags: - Assistants - summary: Retrieves a thread. + summary: Retrieve a message. parameters: - in: path name: thread_id required: true schema: type: string - description: The ID of the thread to retrieve. + description: >- + The ID of the [thread](/docs/api-reference/threads) to which this + message belongs. + - in: path + name: message_id + required: true + schema: + type: string + description: The ID of the message to retrieve. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string responses: '200': description: OK content: application/json: schema: - $ref: '#/components/schemas/ThreadObject' + $ref: '#/components/schemas/MessageObject' x-oaiMeta: - name: Retrieve thread + name: Retrieve message group: threads beta: true - returns: 'The [thread](/docs/api-reference/threads/object) object matching the specified ID.' examples: request: - curl: | - curl https://api.openai.com/v1/threads/thread_abc123 \ + curl: > + curl + https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 + \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "OpenAI-Beta: assistants=v2" - python: | + python: |- + import os from openai import OpenAI - client = OpenAI() - my_thread = client.beta.threads.retrieve("thread_abc123") - print(my_thread) - node.js: |- + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + message = client.beta.threads.messages.retrieve( + message_id="message_id", + thread_id="thread_id", + ) + print(message.id) + javascript: |- import OpenAI from "openai"; const openai = new OpenAI(); async function main() { - const myThread = await openai.beta.threads.retrieve( - "thread_abc123" + const message = await openai.beta.threads.messages.retrieve( + "msg_abc123", + { thread_id: "thread_abc123" } ); - console.log(myThread); + console.log(message); } main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const message = await + client.beta.threads.messages.retrieve('message_id', { + thread_id: 'thread_id', + }); + + + console.log(message.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\tmessage, err := client.Beta.Threads.Messages.Get(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\t\"message_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", message.ID)\n}\n" + java: >- + package com.openai.example; + + + import com.openai.client.OpenAIClient; + + import com.openai.client.okhttp.OpenAIOkHttpClient; + + import com.openai.models.beta.threads.messages.Message; + + import + com.openai.models.beta.threads.messages.MessageRetrieveParams; + + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + MessageRetrieveParams params = MessageRetrieveParams.builder() + .threadId("thread_id") + .messageId("message_id") + .build(); + Message message = client.beta().threads().messages().retrieve(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + message = openai.beta.threads.messages.retrieve("message_id", + thread_id: "thread_id") + + + puts(message) response: | { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699014083, - "metadata": {}, - "tool_resources": { - "code_interpreter": { - "file_ids": [] + "id": "msg_abc123", + "object": "thread.message", + "created_at": 1699017614, + "assistant_id": null, + "thread_id": "thread_abc123", + "run_id": null, + "role": "user", + "content": [ + { + "type": "text", + "text": { + "value": "How does AI work? Explain it in simple terms.", + "annotations": [] + } } - } + ], + "attachments": [], + "metadata": {} } + deprecated: true post: - operationId: modifyThread + operationId: modifyMessage tags: - Assistants - summary: Modifies a thread. + summary: Modifies a message. parameters: - in: path name: thread_id required: true schema: type: string - description: The ID of the thread to modify. Only the `metadata` can be modified. + description: The ID of the thread to which this message belongs. + - in: path + name: message_id + required: true + schema: + type: string + description: The ID of the message to modify. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string requestBody: required: true content: application/json: schema: - $ref: '#/components/schemas/ModifyThreadRequest' + $ref: '#/components/schemas/ModifyMessageRequest' responses: '200': description: OK content: application/json: schema: - $ref: '#/components/schemas/ThreadObject' + $ref: '#/components/schemas/MessageObject' x-oaiMeta: - name: Modify thread + name: Modify message + group: threads + beta: true + examples: + request: + curl: > + curl + https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 + \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "metadata": { + "modified": "true", + "user": "abc123" + } + }' + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + message = client.beta.threads.messages.update( + message_id="message_id", + thread_id="thread_id", + ) + print(message.id) + javascript: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const message = await openai.beta.threads.messages.update( + "thread_abc123", + "msg_abc123", + { + metadata: { + modified: "true", + user: "abc123", + }, + } + }' + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const message = await + client.beta.threads.messages.update('message_id', { thread_id: + 'thread_id' }); + + + console.log(message.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\tmessage, err := client.Beta.Threads.Messages.Update(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\t\"message_id\",\n\t\topenai.BetaThreadMessageUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", message.ID)\n}\n" + java: >- + package com.openai.example; + + + import com.openai.client.OpenAIClient; + + import com.openai.client.okhttp.OpenAIOkHttpClient; + + import com.openai.models.beta.threads.messages.Message; + + import + com.openai.models.beta.threads.messages.MessageUpdateParams; + + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + MessageUpdateParams params = MessageUpdateParams.builder() + .threadId("thread_id") + .messageId("message_id") + .build(); + Message message = client.beta().threads().messages().update(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + message = openai.beta.threads.messages.update("message_id", + thread_id: "thread_id") + + + puts(message) + response: | + { + "id": "msg_abc123", + "object": "thread.message", + "created_at": 1699017614, + "assistant_id": null, + "thread_id": "thread_abc123", + "run_id": null, + "role": "user", + "content": [ + { + "type": "text", + "text": { + "value": "How does AI work? Explain it in simple terms.", + "annotations": [] + } + } + ], + "file_ids": [], + "metadata": { + "modified": "true", + "user": "abc123" + } + } + deprecated: true + delete: + operationId: deleteMessage + tags: + - Assistants + summary: Deletes a message. + parameters: + - in: path + name: thread_id + required: true + schema: + type: string + description: The ID of the thread to which this message belongs. + - in: path + name: message_id + required: true + schema: + type: string + description: The ID of the message to delete. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/DeleteMessageResponse' + x-oaiMeta: + name: Delete message group: threads beta: true - returns: 'The modified [thread](/docs/api-reference/threads/object) object matching the specified ID.' examples: request: - curl: | - curl https://api.openai.com/v1/threads/thread_abc123 \ + curl: > + curl -X DELETE + https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 + \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "OpenAI-Beta: assistants=v2" \ - -d '{ - "metadata": { - "modified": "true", - "user": "abc123" - } - }' - python: | + -H "OpenAI-Beta: assistants=v2" + python: |- + import os from openai import OpenAI - client = OpenAI() - my_updated_thread = client.beta.threads.update( - "thread_abc123", - metadata={ - "modified": "true", - "user": "abc123" - } + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted ) - print(my_updated_thread) - node.js: |- + message_deleted = client.beta.threads.messages.delete( + message_id="message_id", + thread_id="thread_id", + ) + print(message_deleted.id) + javascript: |- import OpenAI from "openai"; const openai = new OpenAI(); async function main() { - const updatedThread = await openai.beta.threads.update( - "thread_abc123", - { - metadata: { modified: "true", user: "abc123" }, - } + const deletedMessage = await openai.beta.threads.messages.delete( + "msg_abc123", + { thread_id: "thread_abc123" } ); - console.log(updatedThread); + console.log(deletedMessage); } + node.js: >- + import OpenAI from 'openai'; - main(); + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const messageDeleted = await + client.beta.threads.messages.delete('message_id', { + thread_id: 'thread_id', + }); + + + console.log(messageDeleted.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\tmessageDeleted, err := client.Beta.Threads.Messages.Delete(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\t\"message_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", messageDeleted.ID)\n}\n" + java: >- + package com.openai.example; + + + import com.openai.client.OpenAIClient; + + import com.openai.client.okhttp.OpenAIOkHttpClient; + + import + com.openai.models.beta.threads.messages.MessageDeleteParams; + + import com.openai.models.beta.threads.messages.MessageDeleted; + + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + MessageDeleteParams params = MessageDeleteParams.builder() + .threadId("thread_id") + .messageId("message_id") + .build(); + MessageDeleted messageDeleted = client.beta().threads().messages().delete(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + message_deleted = + openai.beta.threads.messages.delete("message_id", thread_id: + "thread_id") + + + puts(message_deleted) response: | { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699014083, - "metadata": { - "modified": "true", - "user": "abc123" - }, - "tool_resources": {} + "id": "msg_abc123", + "object": "thread.message.deleted", + "deleted": true } - delete: - operationId: deleteThread + deprecated: true + /threads/{thread_id}/runs: + get: + operationId: listRuns tags: - Assistants - summary: Delete a thread. + summary: Returns a list of runs belonging to a thread. parameters: - - in: path - name: thread_id + - name: thread_id + in: path required: true schema: type: string - description: The ID of the thread to delete. + description: The ID of the thread the run belongs to. + - name: limit + in: query + description: >- + A limit on the number of objects to be returned. Limit can range + between 1 and 100, and the default is 20. + + + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: > + Sort order by the `created_at` timestamp of the objects. `asc` for + ascending order and `desc` for descending order. + schema: + type: string + default: desc + enum: + - asc + - desc + - name: after + in: query + 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 + - name: before + in: query + 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 + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string responses: '200': description: OK content: application/json: schema: - $ref: '#/components/schemas/DeleteThreadResponse' + $ref: '#/components/schemas/ListRunsResponse' x-oaiMeta: - name: Delete thread + name: List runs group: threads beta: true - returns: Deletion status examples: request: curl: | - curl https://api.openai.com/v1/threads/thread_abc123 \ - -H "Content-Type: application/json" \ + curl https://api.openai.com/v1/threads/thread_abc123/runs \ -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "OpenAI-Beta: assistants=v2" \ - -X DELETE - python: | + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + python: |- + import os from openai import OpenAI - client = OpenAI() - response = client.beta.threads.delete("thread_abc123") - print(response) - node.js: |- + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.beta.threads.runs.list( + thread_id="thread_id", + ) + page = page.data[0] + print(page.id) + javascript: | import OpenAI from "openai"; const openai = new OpenAI(); async function main() { - const response = await openai.beta.threads.del("thread_abc123"); + const runs = await openai.beta.threads.runs.list( + "thread_abc123" + ); - console.log(response); + console.log(runs); } + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + // Automatically fetches more pages as needed. + + for await (const run of + client.beta.threads.runs.list('thread_id')) { + console.log(run.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.Beta.Threads.Runs.List(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\topenai.BetaThreadRunListParams{},\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.threads.runs.RunListPage; + import com.openai.models.beta.threads.runs.RunListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RunListPage page = client.beta().threads().runs().list("thread_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + page = openai.beta.threads.runs.list("thread_id") + + puts(page) response: | { - "id": "thread_abc123", - "object": "thread.deleted", - "deleted": true + "object": "list", + "data": [ + { + "id": "run_abc123", + "object": "thread.run", + "created_at": 1699075072, + "assistant_id": "asst_abc123", + "thread_id": "thread_abc123", + "status": "completed", + "started_at": 1699075072, + "expires_at": null, + "cancelled_at": null, + "failed_at": null, + "completed_at": 1699075073, + "last_error": null, + "model": "gpt-4o", + "instructions": null, + "incomplete_details": null, + "tools": [ + { + "type": "code_interpreter" + } + ], + "tool_resources": { + "code_interpreter": { + "file_ids": [ + "file-abc123", + "file-abc456" + ] + } + }, + "metadata": {}, + "usage": { + "prompt_tokens": 123, + "completion_tokens": 456, + "total_tokens": 579 + }, + "temperature": 1.0, + "top_p": 1.0, + "max_prompt_tokens": 1000, + "max_completion_tokens": 1000, + "truncation_strategy": { + "type": "auto", + "last_messages": null + }, + "response_format": "auto", + "tool_choice": "auto", + "parallel_tool_calls": true + }, + { + "id": "run_abc456", + "object": "thread.run", + "created_at": 1699063290, + "assistant_id": "asst_abc123", + "thread_id": "thread_abc123", + "status": "completed", + "started_at": 1699063290, + "expires_at": null, + "cancelled_at": null, + "failed_at": null, + "completed_at": 1699063291, + "last_error": null, + "model": "gpt-4o", + "instructions": null, + "incomplete_details": null, + "tools": [ + { + "type": "code_interpreter" + } + ], + "tool_resources": { + "code_interpreter": { + "file_ids": [ + "file-abc123", + "file-abc456" + ] + } + }, + "metadata": {}, + "usage": { + "prompt_tokens": 123, + "completion_tokens": 456, + "total_tokens": 579 + }, + "temperature": 1.0, + "top_p": 1.0, + "max_prompt_tokens": 1000, + "max_completion_tokens": 1000, + "truncation_strategy": { + "type": "auto", + "last_messages": null + }, + "response_format": "auto", + "tool_choice": "auto", + "parallel_tool_calls": true + } + ], + "first_id": "run_abc123", + "last_id": "run_abc456", + "has_more": false } - '/threads/{thread_id}/messages': - get: - operationId: listMessages + deprecated: true + post: + operationId: createRun tags: - Assistants - summary: Returns a list of messages for a given thread. + summary: Create a run. parameters: - in: path - name: thread_id - required: true - schema: - type: string - description: 'The ID of the [thread](/docs/api-reference/threads) the messages belong to.' - - name: limit - in: query - description: | - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - required: false - schema: - type: integer - default: 20 - - name: order - in: query - description: | - Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. + name: thread_id + required: true schema: type: string - default: desc - enum: - - asc - - desc - - name: after + description: The ID of the thread to run. + - name: include[] in: query - 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. + description: > + A list of additional fields to include in the response. Currently + the only supported value is + `step_details.tool_calls[*].file_search.results[*].content` to fetch + the file search result content. + + + See the [file search tool + documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) + for more information. schema: - type: string - - name: before - in: query - 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, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + type: array + items: + type: string + enum: + - step_details.tool_calls[*].file_search.results[*].content + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. schema: type: string - - name: run_id - in: query - description: | - Filter messages by the run ID that generated them. + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. schema: type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateRunRequest' responses: '200': description: OK content: application/json: schema: - $ref: '#/components/schemas/ListMessagesResponse' + $ref: '#/components/schemas/RunObject' x-oaiMeta: - name: List messages + name: Create run group: threads beta: true - returns: 'A list of [message](/docs/api-reference/messages) objects.' examples: - request: - curl: | - curl https://api.openai.com/v1/threads/thread_abc123/messages \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from openai import OpenAI - client = OpenAI() + - title: Default + request: + curl: | + curl https://api.openai.com/v1/threads/thread_abc123/runs \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "assistant_id": "asst_abc123" + }' + python: |- + import os + from openai import OpenAI - thread_messages = client.beta.threads.messages.list("thread_abc123") - print(thread_messages.data) - node.js: |- - import OpenAI from "openai"; + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + for run in client.beta.threads.runs.create( + thread_id="thread_id", + assistant_id="assistant_id", + ): + print(run) + javascript: | + import OpenAI from "openai"; - const openai = new OpenAI(); + const openai = new OpenAI(); + + async function main() { + const run = await openai.beta.threads.runs.create( + "thread_abc123", + { assistant_id: "asst_abc123" } + ); + + console.log(run); + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const run = await client.beta.threads.runs.create('thread_id', { + assistant_id: 'assistant_id' }); + + + console.log(run.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\trun, err := client.Beta.Threads.Runs.New(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\topenai.BetaThreadRunNewParams{\n\t\t\tAssistantID: \"assistant_id\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.threads.runs.Run; + import com.openai.models.beta.threads.runs.RunCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RunCreateParams params = RunCreateParams.builder() + .threadId("thread_id") + .assistantId("assistant_id") + .build(); + Run run = client.beta().threads().runs().create(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + run = openai.beta.threads.runs.create("thread_id", assistant_id: + "assistant_id") + + + puts(run) + response: | + { + "id": "run_abc123", + "object": "thread.run", + "created_at": 1699063290, + "assistant_id": "asst_abc123", + "thread_id": "thread_abc123", + "status": "queued", + "started_at": 1699063290, + "expires_at": null, + "cancelled_at": null, + "failed_at": null, + "completed_at": 1699063291, + "last_error": null, + "model": "gpt-4o", + "instructions": null, + "incomplete_details": null, + "tools": [ + { + "type": "code_interpreter" + } + ], + "metadata": {}, + "usage": null, + "temperature": 1.0, + "top_p": 1.0, + "max_prompt_tokens": 1000, + "max_completion_tokens": 1000, + "truncation_strategy": { + "type": "auto", + "last_messages": null + }, + "response_format": "auto", + "tool_choice": "auto", + "parallel_tool_calls": true + } + - title: Streaming + request: + curl: | + curl https://api.openai.com/v1/threads/thread_123/runs \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "assistant_id": "asst_123", + "stream": true + }' + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + for run in client.beta.threads.runs.create( + thread_id="thread_id", + assistant_id="assistant_id", + ): + print(run) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const stream = await openai.beta.threads.runs.create( + "thread_123", + { assistant_id: "asst_123", stream: true } + ); + + for await (const event of stream) { + console.log(event); + } + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const run = await client.beta.threads.runs.create('thread_id', { + assistant_id: 'assistant_id' }); + + + console.log(run.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\trun, err := client.Beta.Threads.Runs.New(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\topenai.BetaThreadRunNewParams{\n\t\t\tAssistantID: \"assistant_id\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.threads.runs.Run; + import com.openai.models.beta.threads.runs.RunCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RunCreateParams params = RunCreateParams.builder() + .threadId("thread_id") + .assistantId("assistant_id") + .build(); + Run run = client.beta().threads().runs().create(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + run = openai.beta.threads.runs.create("thread_id", assistant_id: + "assistant_id") + + + puts(run) + response: > + event: thread.run.created + + data: + {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710331240,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + + + event: thread.run.queued + + data: + {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710331240,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + + + event: thread.run.in_progress + + data: + {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710330641,"expires_at":1710331240,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + + + event: thread.run.step.created + + data: + {"id":"step_001","object":"thread.run.step","created_at":1710330641,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710331240,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} + + + event: thread.run.step.in_progress + + data: + {"id":"step_001","object":"thread.run.step","created_at":1710330641,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710331240,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} + + + event: thread.message.created + + data: + {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} + + + event: thread.message.in_progress + + data: + {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} + + + event: thread.message.delta + + data: + {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}} + + + ... + + + event: thread.message.delta + + data: + {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" + today"}}]}} + + + event: thread.message.delta + + data: + {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}} + + + event: thread.message.completed + + data: + {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710330642,"role":"assistant","content":[{"type":"text","text":{"value":"Hello! + How can I assist you today?","annotations":[]}}],"metadata":{}} + + + event: thread.run.step.completed + + data: + {"id":"step_001","object":"thread.run.step","created_at":1710330641,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710330642,"expires_at":1710331240,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31}} + + + event: thread.run.completed + + data: + {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1710330641,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1710330642,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + + + event: done + + data: [DONE] + - title: Streaming with Functions + request: + curl: | + curl https://api.openai.com/v1/threads/thread_abc123/runs \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "assistant_id": "asst_abc123", + "tools": [ + { + "type": "function", + "function": { + "name": "get_current_weather", + "description": "Get the current weather in a given location", + "parameters": { + "type": "object", + "properties": { + "location": { + "type": "string", + "description": "The city and state, e.g. San Francisco, CA" + }, + "unit": { + "type": "string", + "enum": ["celsius", "fahrenheit"] + } + }, + "required": ["location"] + } + } + } + ], + "stream": true + }' + python: |- + import os + from openai import OpenAI - async function main() { - const threadMessages = await openai.beta.threads.messages.list( - "thread_abc123" - ); + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + for run in client.beta.threads.runs.create( + thread_id="thread_id", + assistant_id="assistant_id", + ): + print(run) + javascript: | + import OpenAI from "openai"; - console.log(threadMessages.data); - } + const openai = new OpenAI(); - main(); - response: | - { - "object": "list", - "data": [ - { - "id": "msg_abc123", - "object": "thread.message", - "created_at": 1699016383, - "assistant_id": null, - "thread_id": "thread_abc123", - "run_id": null, - "role": "user", - "content": [ + const tools = [ { - "type": "text", - "text": { - "value": "How does AI work? Explain it in simple terms.", - "annotations": [] + "type": "function", + "function": { + "name": "get_current_weather", + "description": "Get the current weather in a given location", + "parameters": { + "type": "object", + "properties": { + "location": { + "type": "string", + "description": "The city and state, e.g. San Francisco, CA", + }, + "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}, + }, + "required": ["location"], + }, } } - ], - "attachments": [], - "metadata": {} - }, - { - "id": "msg_abc456", - "object": "thread.message", - "created_at": 1699016383, - "assistant_id": null, - "thread_id": "thread_abc123", - "run_id": null, - "role": "user", - "content": [ + ]; + + async function main() { + const stream = await openai.beta.threads.runs.create( + "thread_abc123", { - "type": "text", - "text": { - "value": "Hello, what is AI?", - "annotations": [] - } + assistant_id: "asst_abc123", + tools: tools, + stream: true } - ], - "attachments": [], - "metadata": {} + ); + + for await (const event of stream) { + console.log(event); + } } - ], - "first_id": "msg_abc123", - "last_id": "msg_abc456", - "has_more": false - } - post: - operationId: createMessage - tags: - - Assistants - summary: Create a message. - parameters: - - in: path - name: thread_id - required: true - schema: - type: string - description: 'The ID of the [thread](/docs/api-reference/threads) to create a message for.' - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CreateMessageRequest' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/MessageObject' - x-oaiMeta: - name: Create message - group: threads - beta: true - returns: 'A [message](/docs/api-reference/messages/object) object.' - examples: - request: - curl: | - curl https://api.openai.com/v1/threads/thread_abc123/messages \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "OpenAI-Beta: assistants=v2" \ - -d '{ - "role": "user", - "content": "How does AI work? Explain it in simple terms." - }' - python: | - from openai import OpenAI - client = OpenAI() - thread_message = client.beta.threads.messages.create( - "thread_abc123", - role="user", - content="How does AI work? Explain it in simple terms.", - ) - print(thread_message) - node.js: |- - import OpenAI from "openai"; + main(); + node.js: >- + import OpenAI from 'openai'; - const openai = new OpenAI(); - async function main() { - const threadMessages = await openai.beta.threads.messages.create( - "thread_abc123", - { role: "user", content: "How does AI work? Explain it in simple terms." } - ); + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); - console.log(threadMessages); - } - main(); - response: | - { - "id": "msg_abc123", - "object": "thread.message", - "created_at": 1713226573, - "assistant_id": null, - "thread_id": "thread_abc123", - "run_id": null, - "role": "user", - "content": [ - { - "type": "text", - "text": { - "value": "How does AI work? Explain it in simple terms.", - "annotations": [] - } + const run = await client.beta.threads.runs.create('thread_id', { + assistant_id: 'assistant_id' }); + + + console.log(run.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\trun, err := client.Beta.Threads.Runs.New(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\topenai.BetaThreadRunNewParams{\n\t\t\tAssistantID: \"assistant_id\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.threads.runs.Run; + import com.openai.models.beta.threads.runs.RunCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RunCreateParams params = RunCreateParams.builder() + .threadId("thread_id") + .assistantId("assistant_id") + .build(); + Run run = client.beta().threads().runs().create(params); + } } - ], - "attachments": [], - "metadata": {} - } - '/threads/{thread_id}/messages/{message_id}': + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + run = openai.beta.threads.runs.create("thread_id", assistant_id: + "assistant_id") + + + puts(run) + response: > + event: thread.run.created + + data: + {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + + + event: thread.run.queued + + data: + {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + + + event: thread.run.in_progress + + data: + {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710348075,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + + + event: thread.run.step.created + + data: + {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} + + + event: thread.run.step.in_progress + + data: + {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} + + + event: thread.message.created + + data: + {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} + + + event: thread.message.in_progress + + data: + {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} + + + event: thread.message.delta + + data: + {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}} + + + ... + + + event: thread.message.delta + + data: + {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" + today"}}]}} + + + event: thread.message.delta + + data: + {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}} + + + event: thread.message.completed + + data: + {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710348077,"role":"assistant","content":[{"type":"text","text":{"value":"Hello! + How can I assist you today?","annotations":[]}}],"metadata":{}} + + + event: thread.run.step.completed + + data: + {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710348077,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31}} + + + event: thread.run.completed + + data: + {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1710348075,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1710348077,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + + + event: done + + data: [DONE] + deprecated: true + /threads/{thread_id}/runs/{run_id}: get: - operationId: getMessage + operationId: getRun tags: - Assistants - summary: Retrieve a message. + summary: Retrieves a run. parameters: - in: path name: thread_id required: true schema: type: string - description: 'The ID of the [thread](/docs/api-reference/threads) to which this message belongs.' + description: The ID of the [thread](/docs/api-reference/threads) that was run. - in: path - name: message_id + name: run_id required: true schema: type: string - description: The ID of the message to retrieve. + description: The ID of the run to retrieve. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string responses: '200': description: OK content: application/json: schema: - $ref: '#/components/schemas/MessageObject' + $ref: '#/components/schemas/RunObject' x-oaiMeta: - name: Retrieve message + name: Retrieve run group: threads beta: true - returns: 'The [message](/docs/api-reference/messages/object) object matching the specified ID.' examples: request: - curl: | - curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \ - -H "Content-Type: application/json" \ + curl: > + curl + https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123 \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "OpenAI-Beta: assistants=v2" - python: | + python: |- + import os from openai import OpenAI - client = OpenAI() - message = client.beta.threads.messages.retrieve( - message_id="msg_abc123", - thread_id="thread_abc123", + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted ) - print(message) - node.js: |- + run = client.beta.threads.runs.retrieve( + run_id="run_id", + thread_id="thread_id", + ) + print(run.id) + javascript: | import OpenAI from "openai"; const openai = new OpenAI(); async function main() { - const message = await openai.beta.threads.messages.retrieve( - "thread_abc123", - "msg_abc123" + const run = await openai.beta.threads.runs.retrieve( + "run_abc123", + { thread_id: "thread_abc123" } ); - console.log(message); + console.log(run); } main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const run = await client.beta.threads.runs.retrieve('run_id', { + thread_id: 'thread_id' }); + + + console.log(run.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\trun, err := client.Beta.Threads.Runs.Get(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\t\"run_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.threads.runs.Run; + import com.openai.models.beta.threads.runs.RunRetrieveParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RunRetrieveParams params = RunRetrieveParams.builder() + .threadId("thread_id") + .runId("run_id") + .build(); + Run run = client.beta().threads().runs().retrieve(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + run = openai.beta.threads.runs.retrieve("run_id", thread_id: + "thread_id") + + + puts(run) response: | { - "id": "msg_abc123", - "object": "thread.message", - "created_at": 1699017614, - "assistant_id": null, + "id": "run_abc123", + "object": "thread.run", + "created_at": 1699075072, + "assistant_id": "asst_abc123", "thread_id": "thread_abc123", - "run_id": null, - "role": "user", - "content": [ + "status": "completed", + "started_at": 1699075072, + "expires_at": null, + "cancelled_at": null, + "failed_at": null, + "completed_at": 1699075073, + "last_error": null, + "model": "gpt-4o", + "instructions": null, + "incomplete_details": null, + "tools": [ { - "type": "text", - "text": { - "value": "How does AI work? Explain it in simple terms.", - "annotations": [] - } + "type": "code_interpreter" } ], - "attachments": [], - "metadata": {} + "metadata": {}, + "usage": { + "prompt_tokens": 123, + "completion_tokens": 456, + "total_tokens": 579 + }, + "temperature": 1.0, + "top_p": 1.0, + "max_prompt_tokens": 1000, + "max_completion_tokens": 1000, + "truncation_strategy": { + "type": "auto", + "last_messages": null + }, + "response_format": "auto", + "tool_choice": "auto", + "parallel_tool_calls": true } + deprecated: true post: - operationId: modifyMessage + operationId: modifyRun tags: - Assistants - summary: Modifies a message. + summary: Modifies a run. parameters: - in: path name: thread_id required: true schema: type: string - description: The ID of the thread to which this message belongs. + description: The ID of the [thread](/docs/api-reference/threads) that was run. - in: path - name: message_id + name: run_id required: true schema: type: string - description: The ID of the message to modify. + description: The ID of the run to modify. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string requestBody: required: true content: application/json: schema: - $ref: '#/components/schemas/ModifyMessageRequest' + $ref: '#/components/schemas/ModifyRunRequest' responses: '200': description: OK content: application/json: schema: - $ref: '#/components/schemas/MessageObject' + $ref: '#/components/schemas/RunObject' x-oaiMeta: - name: Modify message + name: Modify run group: threads beta: true - returns: 'The modified [message](/docs/api-reference/messages/object) object.' examples: request: - curl: | - curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \ - -H "Content-Type: application/json" \ + curl: > + curl + https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123 \ -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" \ -d '{ - "metadata": { - "modified": "true", - "user": "abc123" - } - }' - python: | + "metadata": { + "user_id": "user_abc123" + } + }' + python: |- + import os from openai import OpenAI - client = OpenAI() - message = client.beta.threads.messages.update( - message_id="msg_abc12", - thread_id="thread_abc123", - metadata={ - "modified": "true", - "user": "abc123", - }, + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted ) - print(message) - node.js: |- + run = client.beta.threads.runs.update( + run_id="run_id", + thread_id="thread_id", + ) + print(run.id) + javascript: | import OpenAI from "openai"; const openai = new OpenAI(); async function main() { - const message = await openai.beta.threads.messages.update( - "thread_abc123", - "msg_abc123", + const run = await openai.beta.threads.runs.update( + "run_abc123", { + thread_id: "thread_abc123", metadata: { - modified: "true", - user: "abc123", + user_id: "user_abc123", }, } - }' + ); + + console.log(run); + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const run = await client.beta.threads.runs.update('run_id', { + thread_id: 'thread_id' }); + + + console.log(run.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\trun, err := client.Beta.Threads.Runs.Update(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\t\"run_id\",\n\t\topenai.BetaThreadRunUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.threads.runs.Run; + import com.openai.models.beta.threads.runs.RunUpdateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RunUpdateParams params = RunUpdateParams.builder() + .threadId("thread_id") + .runId("run_id") + .build(); + Run run = client.beta().threads().runs().update(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + run = openai.beta.threads.runs.update("run_id", thread_id: + "thread_id") + + + puts(run) response: | { - "id": "msg_abc123", - "object": "thread.message", - "created_at": 1699017614, - "assistant_id": null, + "id": "run_abc123", + "object": "thread.run", + "created_at": 1699075072, + "assistant_id": "asst_abc123", "thread_id": "thread_abc123", - "run_id": null, - "role": "user", - "content": [ + "status": "completed", + "started_at": 1699075072, + "expires_at": null, + "cancelled_at": null, + "failed_at": null, + "completed_at": 1699075073, + "last_error": null, + "model": "gpt-4o", + "instructions": null, + "incomplete_details": null, + "tools": [ { - "type": "text", - "text": { - "value": "How does AI work? Explain it in simple terms.", - "annotations": [] - } + "type": "code_interpreter" } ], - "file_ids": [], + "tool_resources": { + "code_interpreter": { + "file_ids": [ + "file-abc123", + "file-abc456" + ] + } + }, "metadata": { - "modified": "true", - "user": "abc123" - } + "user_id": "user_abc123" + }, + "usage": { + "prompt_tokens": 123, + "completion_tokens": 456, + "total_tokens": 579 + }, + "temperature": 1.0, + "top_p": 1.0, + "max_prompt_tokens": 1000, + "max_completion_tokens": 1000, + "truncation_strategy": { + "type": "auto", + "last_messages": null + }, + "response_format": "auto", + "tool_choice": "auto", + "parallel_tool_calls": true } - delete: - operationId: deleteMessage + deprecated: true + /threads/{thread_id}/runs/{run_id}/cancel: + post: + operationId: cancelRun tags: - Assistants - summary: Deletes a message. + summary: Cancels a run that is `in_progress`. parameters: - in: path name: thread_id required: true schema: type: string - description: The ID of the thread to which this message belongs. + description: The ID of the thread to which this run belongs. - in: path - name: message_id + name: run_id required: true schema: type: string - description: The ID of the message to delete. + description: The ID of the run to cancel. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string responses: '200': description: OK content: application/json: schema: - $ref: '#/components/schemas/DeleteMessageResponse' + $ref: '#/components/schemas/RunObject' x-oaiMeta: - name: Delete message + name: Cancel a run group: threads beta: true - returns: Deletion status examples: request: - curl: | - curl -X DELETE https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \ - -H "Content-Type: application/json" \ + curl: > + curl + https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/cancel + \ -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "OpenAI-Beta: assistants=v2" - python: | + -H "OpenAI-Beta: assistants=v2" \ + -X POST + python: |- + import os from openai import OpenAI - client = OpenAI() - deleted_message = client.beta.threads.messages.delete( - message_id="msg_abc12", - thread_id="thread_abc123", - ) - print(deleted_message) - node.js: |- - import OpenAI from "openai"; + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + run = client.beta.threads.runs.cancel( + run_id="run_id", + thread_id="thread_id", + ) + print(run.id) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const run = await openai.beta.threads.runs.cancel( + "run_abc123", + { thread_id: "thread_abc123" } + ); + + console.log(run); + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const run = await client.beta.threads.runs.cancel('run_id', { + thread_id: 'thread_id' }); + + + console.log(run.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\trun, err := client.Beta.Threads.Runs.Cancel(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\t\"run_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.threads.runs.Run; + import com.openai.models.beta.threads.runs.RunCancelParams; - const openai = new OpenAI(); + public final class Main { + private Main() {} - async function main() { - const deletedMessage = await openai.beta.threads.messages.del( - "thread_abc123", - "msg_abc123" - ); + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); - console.log(deletedMessage); + RunCancelParams params = RunCancelParams.builder() + .threadId("thread_id") + .runId("run_id") + .build(); + Run run = client.beta().threads().runs().cancel(params); + } } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + run = openai.beta.threads.runs.cancel("run_id", thread_id: + "thread_id") + + + puts(run) response: | { - "id": "msg_abc123", - "object": "thread.message.deleted", - "deleted": true + "id": "run_abc123", + "object": "thread.run", + "created_at": 1699076126, + "assistant_id": "asst_abc123", + "thread_id": "thread_abc123", + "status": "cancelling", + "started_at": 1699076126, + "expires_at": 1699076726, + "cancelled_at": null, + "failed_at": null, + "completed_at": null, + "last_error": null, + "model": "gpt-4o", + "instructions": "You summarize books.", + "tools": [ + { + "type": "file_search" + } + ], + "tool_resources": { + "file_search": { + "vector_store_ids": ["vs_123"] + } + }, + "metadata": {}, + "usage": null, + "temperature": 1.0, + "top_p": 1.0, + "response_format": "auto", + "tool_choice": "auto", + "parallel_tool_calls": true } - '/threads/{thread_id}/runs': + deprecated: true + /threads/{thread_id}/runs/{run_id}/steps: get: - operationId: listRuns + operationId: listRunSteps tags: - Assistants - summary: Returns a list of runs belonging to a thread. + summary: Returns a list of run steps belonging to a run. parameters: - name: thread_id in: path required: true schema: type: string - description: The ID of the thread the run belongs to. + description: The ID of the thread the run and run steps belong to. + - name: run_id + in: path + required: true + schema: + type: string + description: The ID of the run the run steps belong to. - name: limit in: query - description: | - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default 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. + + + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. required: false schema: type: integer default: 20 - name: order in: query - description: | - Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. + description: > + Sort order by the `created_at` timestamp of the objects. `asc` for + ascending order and `desc` for descending order. schema: type: string default: desc @@ -4441,14 +4359,57 @@ paths: - desc - name: after in: query - 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. + 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 - name: before in: query - 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, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + 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 + - name: include[] + in: query + description: > + A list of additional fields to include in the response. Currently + the only supported value is + `step_details.tool_calls[*].file_search.results[*].content` to fetch + the file search result content. + + + See the [file search tool + documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) + for more information. + schema: + type: array + items: + type: string + enum: + - step_details.tool_calls[*].file_search.results[*].content + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. schema: type: string responses: @@ -4457,175 +4418,375 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ListRunsResponse' + $ref: '#/components/schemas/ListRunStepsResponse' x-oaiMeta: - name: List runs + name: List run steps group: threads beta: true - returns: 'A list of [run](/docs/api-reference/runs/object) objects.' examples: request: - curl: | - curl https://api.openai.com/v1/threads/thread_abc123/runs \ + curl: > + curl + https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/steps + \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" - python: | + python: |- + import os from openai import OpenAI - client = OpenAI() - runs = client.beta.threads.runs.list( - "thread_abc123" + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted ) - - print(runs) - node.js: | + page = client.beta.threads.runs.steps.list( + run_id="run_id", + thread_id="thread_id", + ) + page = page.data[0] + print(page.id) + javascript: | import OpenAI from "openai"; - const openai = new OpenAI(); async function main() { - const runs = await openai.beta.threads.runs.list( - "thread_abc123" + const runStep = await openai.beta.threads.runs.steps.list( + "run_abc123", + { thread_id: "thread_abc123" } ); - - console.log(runs); + console.log(runStep); } main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + // Automatically fetches more pages as needed. + + for await (const runStep of + client.beta.threads.runs.steps.list('run_id', { + thread_id: 'thread_id', + })) { + console.log(runStep.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.Beta.Threads.Runs.Steps.List(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\t\"run_id\",\n\t\topenai.BetaThreadRunStepListParams{},\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.beta.threads.runs.steps.StepListPage; + import com.openai.models.beta.threads.runs.steps.StepListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + StepListParams params = StepListParams.builder() + .threadId("thread_id") + .runId("run_id") + .build(); + StepListPage page = client.beta().threads().runs().steps().list(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + page = openai.beta.threads.runs.steps.list("run_id", thread_id: + "thread_id") + + + puts(page) response: | { "object": "list", "data": [ { - "id": "run_abc123", - "object": "thread.run", - "created_at": 1699075072, - "assistant_id": "asst_abc123", - "thread_id": "thread_abc123", - "status": "completed", - "started_at": 1699075072, - "expires_at": null, - "cancelled_at": null, - "failed_at": null, - "completed_at": 1699075073, - "last_error": null, - "model": "gpt-4o", - "instructions": null, - "incomplete_details": null, - "tools": [ - { - "type": "code_interpreter" - } - ], - "tool_resources": { - "code_interpreter": { - "file_ids": [ - "file-abc123", - "file-abc456" - ] - } - }, - "metadata": {}, - "usage": { - "prompt_tokens": 123, - "completion_tokens": 456, - "total_tokens": 579 - }, - "temperature": 1.0, - "top_p": 1.0, - "max_prompt_tokens": 1000, - "max_completion_tokens": 1000, - "truncation_strategy": { - "type": "auto", - "last_messages": null - }, - "response_format": "auto", - "tool_choice": "auto", - "parallel_tool_calls": true - }, - { - "id": "run_abc456", - "object": "thread.run", - "created_at": 1699063290, + "id": "step_abc123", + "object": "thread.run.step", + "created_at": 1699063291, + "run_id": "run_abc123", "assistant_id": "asst_abc123", "thread_id": "thread_abc123", + "type": "message_creation", "status": "completed", - "started_at": 1699063290, - "expires_at": null, "cancelled_at": null, - "failed_at": null, "completed_at": 1699063291, + "expired_at": null, + "failed_at": null, "last_error": null, - "model": "gpt-4o", - "instructions": null, - "incomplete_details": null, - "tools": [ - { - "type": "code_interpreter" - } - ], - "tool_resources": { - "code_interpreter": { - "file_ids": [ - "file-abc123", - "file-abc456" - ] + "step_details": { + "type": "message_creation", + "message_creation": { + "message_id": "msg_abc123" } }, - "metadata": {}, "usage": { "prompt_tokens": 123, "completion_tokens": 456, "total_tokens": 579 - }, - "temperature": 1.0, - "top_p": 1.0, - "max_prompt_tokens": 1000, - "max_completion_tokens": 1000, - "truncation_strategy": { - "type": "auto", - "last_messages": null - }, - "response_format": "auto", - "tool_choice": "auto", - "parallel_tool_calls": true + } + } + ], + "first_id": "step_abc123", + "last_id": "step_abc456", + "has_more": false + } + deprecated: true + /threads/{thread_id}/runs/{run_id}/steps/{step_id}: + get: + operationId: getRunStep + tags: + - Assistants + summary: Retrieves a run step. + parameters: + - in: path + name: thread_id + required: true + schema: + type: string + description: The ID of the thread to which the run and run step belongs. + - in: path + name: run_id + required: true + schema: + type: string + description: The ID of the run to which the run step belongs. + - in: path + name: step_id + required: true + schema: + type: string + description: The ID of the run step to retrieve. + - name: include[] + in: query + description: > + A list of additional fields to include in the response. Currently + the only supported value is + `step_details.tool_calls[*].file_search.results[*].content` to fetch + the file search result content. + + + See the [file search tool + documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) + for more information. + schema: + type: array + items: + type: string + enum: + - step_details.tool_calls[*].file_search.results[*].content + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/RunStepObject' + x-oaiMeta: + name: Retrieve run step + group: threads + beta: true + examples: + request: + curl: > + curl + https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/steps/step_abc123 + \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + run_step = client.beta.threads.runs.steps.retrieve( + step_id="step_id", + thread_id="thread_id", + run_id="run_id", + ) + print(run_step.id) + javascript: | + import OpenAI from "openai"; + const openai = new OpenAI(); + + async function main() { + const runStep = await openai.beta.threads.runs.steps.retrieve( + "step_abc123", + { thread_id: "thread_abc123", run_id: "run_abc123" } + ); + console.log(runStep); + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const runStep = await + client.beta.threads.runs.steps.retrieve('step_id', { + thread_id: 'thread_id', + run_id: 'run_id', + }); + + + console.log(runStep.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\trunStep, err := client.Beta.Threads.Runs.Steps.Get(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\t\"run_id\",\n\t\t\"step_id\",\n\t\topenai.BetaThreadRunStepGetParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", runStep.ID)\n}\n" + java: >- + package com.openai.example; + + + import com.openai.client.OpenAIClient; + + import com.openai.client.okhttp.OpenAIOkHttpClient; + + import com.openai.models.beta.threads.runs.steps.RunStep; + + import + com.openai.models.beta.threads.runs.steps.StepRetrieveParams; + + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + StepRetrieveParams params = StepRetrieveParams.builder() + .threadId("thread_id") + .runId("run_id") + .stepId("step_id") + .build(); + RunStep runStep = client.beta().threads().runs().steps().retrieve(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + run_step = openai.beta.threads.runs.steps.retrieve("step_id", + thread_id: "thread_id", run_id: "run_id") + + + puts(run_step) + response: | + { + "id": "step_abc123", + "object": "thread.run.step", + "created_at": 1699063291, + "run_id": "run_abc123", + "assistant_id": "asst_abc123", + "thread_id": "thread_abc123", + "type": "message_creation", + "status": "completed", + "cancelled_at": null, + "completed_at": 1699063291, + "expired_at": null, + "failed_at": null, + "last_error": null, + "step_details": { + "type": "message_creation", + "message_creation": { + "message_id": "msg_abc123" } - ], - "first_id": "run_abc123", - "last_id": "run_abc456", - "has_more": false + }, + "usage": { + "prompt_tokens": 123, + "completion_tokens": 456, + "total_tokens": 579 + } } + deprecated: true + /threads/{thread_id}/runs/{run_id}/submit_tool_outputs: post: - operationId: createRun + operationId: submitToolOuputsToRun tags: - Assistants - summary: Create a run. + summary: > + When a run has the `status: "requires_action"` and + `required_action.type` is `submit_tool_outputs`, this endpoint can be + used to submit the outputs from the tool calls once they're all + completed. All outputs must be submitted in a single request. parameters: - in: path name: thread_id required: true schema: type: string - description: The ID of the thread to run. - - name: 'include[]' - in: query - description: | - A list of additional fields to include in the response. Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. - - See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + description: >- + The ID of the [thread](/docs/api-reference/threads) to which this + run belongs. + - in: path + name: run_id + required: true schema: - type: array - items: - type: string - enum: - - 'step_details.tool_calls[*].file_search.results[*].content' + type: string + description: The ID of the run that requires the tool output submission. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string requestBody: required: true content: application/json: schema: - $ref: '#/components/schemas/CreateRunRequest' + $ref: '#/components/schemas/SubmitToolOutputsRunRequest' responses: '200': description: OK @@ -4634,66 +4795,158 @@ paths: schema: $ref: '#/components/schemas/RunObject' x-oaiMeta: - name: Create run + name: Submit tool outputs to run group: threads beta: true - returns: 'A [run](/docs/api-reference/runs/object) object.' examples: - title: Default request: - curl: | - curl https://api.openai.com/v1/threads/thread_abc123/runs \ + curl: > + curl + https://api.openai.com/v1/threads/thread_123/runs/run_123/submit_tool_outputs + \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" \ -d '{ - "assistant_id": "asst_abc123" + "tool_outputs": [ + { + "tool_call_id": "call_001", + "output": "70 degrees and sunny." + } + ] }' - python: | + python: |- + import os from openai import OpenAI - client = OpenAI() - run = client.beta.threads.runs.create( - thread_id="thread_abc123", - assistant_id="asst_abc123" + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted ) - - print(run) - node.js: | + for run in client.beta.threads.runs.submit_tool_outputs( + run_id="run_id", + thread_id="thread_id", + tool_outputs=[{}], + ): + print(run) + javascript: | import OpenAI from "openai"; const openai = new OpenAI(); async function main() { - const run = await openai.beta.threads.runs.create( - "thread_abc123", - { assistant_id: "asst_abc123" } + const run = await openai.beta.threads.runs.submitToolOutputs( + "run_123", + { + thread_id: "thread_123", + tool_outputs: [ + { + tool_call_id: "call_001", + output: "70 degrees and sunny.", + }, + ], + } ); console.log(run); } main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const run = await + client.beta.threads.runs.submitToolOutputs('run_id', { + thread_id: 'thread_id', + tool_outputs: [{}], + }); + + + console.log(run.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\trun, err := client.Beta.Threads.Runs.SubmitToolOutputs(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\t\"run_id\",\n\t\topenai.BetaThreadRunSubmitToolOutputsParams{\n\t\t\tToolOutputs: []openai.BetaThreadRunSubmitToolOutputsParamsToolOutput{{}},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" + java: >- + package com.openai.example; + + + import com.openai.client.OpenAIClient; + + import com.openai.client.okhttp.OpenAIOkHttpClient; + + import com.openai.models.beta.threads.runs.Run; + + import + com.openai.models.beta.threads.runs.RunSubmitToolOutputsParams; + + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RunSubmitToolOutputsParams params = RunSubmitToolOutputsParams.builder() + .threadId("thread_id") + .runId("run_id") + .addToolOutput(RunSubmitToolOutputsParams.ToolOutput.builder().build()) + .build(); + Run run = client.beta().threads().runs().submitToolOutputs(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + run = openai.beta.threads.runs.submit_tool_outputs("run_id", + thread_id: "thread_id", tool_outputs: [{}]) + + + puts(run) response: | { - "id": "run_abc123", + "id": "run_123", "object": "thread.run", - "created_at": 1699063290, - "assistant_id": "asst_abc123", - "thread_id": "thread_abc123", + "created_at": 1699075592, + "assistant_id": "asst_123", + "thread_id": "thread_123", "status": "queued", - "started_at": 1699063290, - "expires_at": null, + "started_at": 1699075592, + "expires_at": 1699076192, "cancelled_at": null, "failed_at": null, - "completed_at": 1699063291, + "completed_at": null, "last_error": null, "model": "gpt-4o", "instructions": null, - "incomplete_details": null, "tools": [ { - "type": "code_interpreter" + "type": "function", + "function": { + "name": "get_current_weather", + "description": "Get the current weather in a given location", + "parameters": { + "type": "object", + "properties": { + "location": { + "type": "string", + "description": "The city and state, e.g. San Francisco, CA" + }, + "unit": { + "type": "string", + "enum": ["celsius", "fahrenheit"] + } + }, + "required": ["location"] + } + } } ], "metadata": {}, @@ -4712,36 +4965,52 @@ paths: } - title: Streaming request: - curl: | - curl https://api.openai.com/v1/threads/thread_123/runs \ + curl: > + curl + https://api.openai.com/v1/threads/thread_123/runs/run_123/submit_tool_outputs + \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" \ -d '{ - "assistant_id": "asst_123", + "tool_outputs": [ + { + "tool_call_id": "call_001", + "output": "70 degrees and sunny." + } + ], "stream": true }' - python: | + python: |- + import os from openai import OpenAI - client = OpenAI() - stream = client.beta.threads.runs.create( - thread_id="thread_123", - assistant_id="asst_123", - stream=True + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted ) - - for event in stream: - print(event) - node.js: | + for run in client.beta.threads.runs.submit_tool_outputs( + run_id="run_id", + thread_id="thread_id", + tool_outputs=[{}], + ): + print(run) + javascript: | import OpenAI from "openai"; const openai = new OpenAI(); async function main() { - const stream = await openai.beta.threads.runs.create( - "thread_123", - { assistant_id: "asst_123", stream: true } + const stream = await openai.beta.threads.runs.submitToolOutputs( + "run_123", + { + thread_id: "thread_123", + tool_outputs: [ + { + tool_call_id: "call_001", + output: "70 degrees and sunny.", + }, + ], + } ); for await (const event of stream) { @@ -4749,1031 +5018,3969 @@ paths: } } - main(); - response: | - event: thread.run.created - data: {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710331240,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const run = await + client.beta.threads.runs.submitToolOutputs('run_id', { + thread_id: 'thread_id', + tool_outputs: [{}], + }); + + + console.log(run.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\trun, err := client.Beta.Threads.Runs.SubmitToolOutputs(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\t\"run_id\",\n\t\topenai.BetaThreadRunSubmitToolOutputsParams{\n\t\t\tToolOutputs: []openai.BetaThreadRunSubmitToolOutputsParamsToolOutput{{}},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" + java: >- + package com.openai.example; + + + import com.openai.client.OpenAIClient; + + import com.openai.client.okhttp.OpenAIOkHttpClient; + + import com.openai.models.beta.threads.runs.Run; + + import + com.openai.models.beta.threads.runs.RunSubmitToolOutputsParams; + + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RunSubmitToolOutputsParams params = RunSubmitToolOutputsParams.builder() + .threadId("thread_id") + .runId("run_id") + .addToolOutput(RunSubmitToolOutputsParams.ToolOutput.builder().build()) + .build(); + Run run = client.beta().threads().runs().submitToolOutputs(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + run = openai.beta.threads.runs.submit_tool_outputs("run_id", + thread_id: "thread_id", tool_outputs: [{}]) + + + puts(run) + response: > + event: thread.run.step.completed + + data: + {"id":"step_001","object":"thread.run.step","created_at":1710352449,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"tool_calls","status":"completed","cancelled_at":null,"completed_at":1710352475,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[{"id":"call_iWr0kQ2EaYMaxNdl0v3KYkx7","type":"function","function":{"name":"get_current_weather","arguments":"{\"location\":\"San + Francisco, CA\",\"unit\":\"fahrenheit\"}","output":"70 degrees and + sunny."}}]},"usage":{"prompt_tokens":291,"completion_tokens":24,"total_tokens":315}} + + + event: thread.run.queued + + data: + {"id":"run_123","object":"thread.run","created_at":1710352447,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":1710352448,"expires_at":1710353047,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get + the current weather in a given + location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The + city and state, e.g. San Francisco, + CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + + + event: thread.run.in_progress + + data: + {"id":"run_123","object":"thread.run","created_at":1710352447,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710352475,"expires_at":1710353047,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get + the current weather in a given + location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The + city and state, e.g. San Francisco, + CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + + + event: thread.run.step.created + + data: + {"id":"step_002","object":"thread.run.step","created_at":1710352476,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_002"}},"usage":null} + + + event: thread.run.step.in_progress + + data: + {"id":"step_002","object":"thread.run.step","created_at":1710352476,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_002"}},"usage":null} + + + event: thread.message.created + + data: + {"id":"msg_002","object":"thread.message","created_at":1710352476,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} + + + event: thread.message.in_progress - event: thread.run.queued - data: {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710331240,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + data: + {"id":"msg_002","object":"thread.message","created_at":1710352476,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} - event: thread.run.in_progress - data: {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710330641,"expires_at":1710331240,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} - event: thread.run.step.created - data: {"id":"step_001","object":"thread.run.step","created_at":1710330641,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710331240,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} + event: thread.message.delta - event: thread.run.step.in_progress - data: {"id":"step_001","object":"thread.run.step","created_at":1710330641,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710331240,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} + data: + {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"The","annotations":[]}}]}} - event: thread.message.created - data: {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} - event: thread.message.in_progress - data: {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} + event: thread.message.delta + + data: + {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" + current"}}]}} + event: thread.message.delta - data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}} + + data: + {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" + weather"}}]}} + ... + event: thread.message.delta - data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" today"}}]}} + + data: + {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" + sunny"}}]}} + event: thread.message.delta - data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}} + + data: + {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"."}}]}} + event: thread.message.completed - data: {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710330642,"role":"assistant","content":[{"type":"text","text":{"value":"Hello! How can I assist you today?","annotations":[]}}],"metadata":{}} - event: thread.run.step.completed - data: {"id":"step_001","object":"thread.run.step","created_at":1710330641,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710330642,"expires_at":1710331240,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31}} + data: + {"id":"msg_002","object":"thread.message","created_at":1710352476,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710352477,"role":"assistant","content":[{"type":"text","text":{"value":"The + current weather in San Francisco, CA is 70 degrees Fahrenheit and + sunny.","annotations":[]}}],"metadata":{}} + + + event: thread.run.step.completed + + data: + {"id":"step_002","object":"thread.run.step","created_at":1710352476,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710352477,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_002"}},"usage":{"prompt_tokens":329,"completion_tokens":18,"total_tokens":347}} + + + event: thread.run.completed + + data: + {"id":"run_123","object":"thread.run","created_at":1710352447,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1710352475,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1710352477,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get + the current weather in a given + location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The + city and state, e.g. San Francisco, + CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + + + event: done + + data: [DONE] + deprecated: true +components: + schemas: + ListAssistantsResponse: + type: object + properties: + object: + type: string + example: list + data: + type: array + items: + $ref: '#/components/schemas/AssistantObject' + first_id: + type: string + example: asst_abc123 + last_id: + type: string + example: asst_abc456 + has_more: + type: boolean + example: false + required: + - object + - data + - first_id + - last_id + - has_more + x-oaiMeta: + name: List assistants response object + group: chat + example: | + { + "object": "list", + "data": [ + { + "id": "asst_abc123", + "object": "assistant", + "created_at": 1698982736, + "name": "Coding Tutor", + "description": null, + "model": "gpt-4o", + "instructions": "You are a helpful assistant designed to make me better at coding!", + "tools": [], + "tool_resources": {}, + "metadata": {}, + "top_p": 1.0, + "temperature": 1.0, + "response_format": "auto" + }, + { + "id": "asst_abc456", + "object": "assistant", + "created_at": 1698982718, + "name": "My Assistant", + "description": null, + "model": "gpt-4o", + "instructions": "You are a helpful assistant designed to make me better at coding!", + "tools": [], + "tool_resources": {}, + "metadata": {}, + "top_p": 1.0, + "temperature": 1.0, + "response_format": "auto" + }, + { + "id": "asst_abc789", + "object": "assistant", + "created_at": 1698982643, + "name": null, + "description": null, + "model": "gpt-4o", + "instructions": null, + "tools": [], + "tool_resources": {}, + "metadata": {}, + "top_p": 1.0, + "temperature": 1.0, + "response_format": "auto" + } + ], + "first_id": "asst_abc123", + "last_id": "asst_abc789", + "has_more": false + } + CreateAssistantRequest: + type: object + additionalProperties: false + properties: + model: + description: > + ID of the model to use. You can use the [List + models](/docs/api-reference/models/list) API to see all of your + available models, or see our [Model overview](/docs/models) for + descriptions of them. + example: gpt-4o + x-oaiTypeLabel: string + type: string + enum: + - gpt-5 + - gpt-5-mini + - gpt-5-nano + - gpt-5-2025-08-07 + - gpt-5-mini-2025-08-07 + - gpt-5-nano-2025-08-07 + - gpt-4.1 + - gpt-4.1-mini + - gpt-4.1-nano + - gpt-4.1-2025-04-14 + - gpt-4.1-mini-2025-04-14 + - gpt-4.1-nano-2025-04-14 + - o3-mini + - o3-mini-2025-01-31 + - o1 + - o1-2024-12-17 + - gpt-4o + - gpt-4o-2024-11-20 + - gpt-4o-2024-08-06 + - gpt-4o-2024-05-13 + - gpt-4o-mini + - gpt-4o-mini-2024-07-18 + - gpt-4.5-preview + - gpt-4.5-preview-2025-02-27 + - gpt-4-turbo + - gpt-4-turbo-2024-04-09 + - gpt-4-0125-preview + - gpt-4-turbo-preview + - gpt-4-1106-preview + - gpt-4-vision-preview + - gpt-4 + - gpt-4-0314 + - gpt-4-0613 + - gpt-4-32k + - gpt-4-32k-0314 + - gpt-4-32k-0613 + - gpt-3.5-turbo + - gpt-3.5-turbo-16k + - gpt-3.5-turbo-0613 + - gpt-3.5-turbo-1106 + - gpt-3.5-turbo-0125 + - gpt-3.5-turbo-16k-0613 + name: + description: | + The name of the assistant. The maximum length is 256 characters. + type: string + maxLength: 256 + description: + description: > + The description of the assistant. The maximum length is 512 + characters. + type: string + maxLength: 512 + instructions: + description: > + The system instructions that the assistant uses. The maximum length + is 256,000 characters. + type: string + maxLength: 256000 + reasoning_effort: + $ref: '#/components/schemas/ReasoningEffort' + tools: + description: > + A list of tool enabled on the assistant. There can be a maximum of + 128 tools per assistant. Tools can be of types `code_interpreter`, + `file_search`, or `function`. + default: [] + type: array + maxItems: 128 + items: + oneOf: + - $ref: '#/components/schemas/AssistantToolsCode' + - $ref: '#/components/schemas/AssistantToolsFileSearch' + - $ref: '#/components/schemas/AssistantToolsFunction' + tool_resources: + type: object + description: > + A set of resources that are used by the assistant's tools. The + resources are specific to the type of tool. For example, the + `code_interpreter` tool requires a list of file IDs, while the + `file_search` tool requires a list of vector store IDs. + properties: + code_interpreter: + type: object + properties: + file_ids: + type: array + description: > + A list of [file](/docs/api-reference/files) IDs made + available to the `code_interpreter` tool. There can be a + maximum of 20 files associated with the tool. + default: [] + maxItems: 20 + items: + type: string + file_search: + type: object + properties: + vector_store_ids: + type: array + description: > + The [vector store](/docs/api-reference/vector-stores/object) + attached to this assistant. There can be a maximum of 1 + vector store attached to the assistant. + maxItems: 1 + items: + type: string + vector_stores: + type: array + description: > + A helper to create a [vector + store](/docs/api-reference/vector-stores/object) with + file_ids and attach it to this assistant. There can be a + maximum of 1 vector store attached to the assistant. + maxItems: 1 + items: + type: object + properties: + file_ids: + type: array + description: > + A list of [file](/docs/api-reference/files) IDs to add + to the vector store. For vector stores created before + Nov 2025, there can be a maximum of 10,000 files in a + vector store. For vector stores created starting in + Nov 2025, the limit is 100,000,000 files. + maxItems: 100000000 + items: + type: string + chunking_strategy: + type: object + description: >- + The chunking strategy used to chunk the file(s). If + not set, will use the `auto` strategy. + oneOf: + - type: object + title: Auto Chunking Strategy + description: >- + The default strategy. This strategy currently uses + a `max_chunk_size_tokens` of `800` and + `chunk_overlap_tokens` of `400`. + additionalProperties: false + properties: + type: + type: string + description: Always `auto`. + enum: + - auto + x-stainless-const: true + required: + - type + - type: object + title: Static Chunking Strategy + additionalProperties: false + properties: + type: + type: string + description: Always `static`. + enum: + - static + x-stainless-const: true + static: + type: object + additionalProperties: false + properties: + max_chunk_size_tokens: + type: integer + minimum: 100 + maximum: 4096 + description: >- + The maximum number of tokens in each + chunk. The default value is `800`. The + minimum value is `100` and the maximum + value is `4096`. + chunk_overlap_tokens: + type: integer + description: > + The number of tokens that overlap between + chunks. The default value is `400`. + + + Note that the overlap must not exceed half + of `max_chunk_size_tokens`. + required: + - max_chunk_size_tokens + - chunk_overlap_tokens + required: + - type + - static + metadata: + $ref: '#/components/schemas/Metadata' + oneOf: + - required: + - vector_store_ids + - required: + - vector_stores + metadata: + $ref: '#/components/schemas/Metadata' + temperature: + description: > + What sampling temperature to use, between 0 and 2. Higher values + like 0.8 will make the output more random, while lower values like + 0.2 will make it more focused and deterministic. + type: number + minimum: 0 + maximum: 2 + default: 1 + example: 1 + top_p: + type: number + minimum: 0 + maximum: 1 + default: 1 + example: 1 + description: > + An alternative to sampling with temperature, called nucleus + sampling, where the model considers the results of the tokens with + top_p probability mass. So 0.1 means only the tokens comprising the + top 10% probability mass are considered. + + + We generally recommend altering this or temperature but not both. + response_format: + description: > + Specifies the format that the model must output. Compatible with + [GPT-4o](/docs/models#gpt-4o), [GPT-4 + Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo + models since `gpt-3.5-turbo-1106`. + + + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables + Structured Outputs which ensures the model will match your supplied + JSON schema. Learn more in the [Structured Outputs + guide](/docs/guides/structured-outputs). + + + Setting to `{ "type": "json_object" }` enables JSON mode, which + ensures the message the model generates is valid JSON. + + + **Important:** when using JSON mode, you **must** also instruct the + model to produce JSON yourself via a system or user message. Without + this, the model may generate an unending stream of whitespace until + the generation reaches the token limit, resulting in a long-running + and seemingly "stuck" request. Also note that the message content + may be partially cut off if `finish_reason="length"`, which + indicates the generation exceeded `max_tokens` or the conversation + exceeded the max context length. + type: string + enum: + - auto + x-stainless-const: true + title: Text + properties: + type: + type: string + description: The type of response format being defined. Always `text`. + enum: + - text + x-stainless-const: true + json_schema: + type: object + title: JSON schema + description: > + Structured Outputs configuration options, including a JSON + Schema. + properties: + description: + type: string + description: > + A description of what the response format is for, used by + the model to + + determine how to respond in the format. + name: + type: string + description: > + The name of the response format. Must be a-z, A-Z, 0-9, or + contain + + underscores and dashes, with a maximum length of 64. + schema: + $ref: '#/components/schemas/ResponseFormatJsonSchemaSchema' + strict: + anyOf: + - type: boolean + default: false + description: > + Whether to enable strict schema adherence when + generating the output. + + If set to true, the model will always follow the exact + schema defined + + in the `schema` field. Only a subset of JSON Schema is + supported when + + `strict` is `true`. To learn more, read the [Structured + Outputs + + guide](/docs/guides/structured-outputs). + - type: 'null' + required: + - name + required: + - type + - json_schema + required: + - model + AssistantObject: + type: object + title: Assistant + description: Represents an `assistant` that can call the model and use tools. + properties: + id: + description: The identifier, which can be referenced in API endpoints. + type: string + object: + description: The object type, which is always `assistant`. + type: string + enum: + - assistant + x-stainless-const: true + created_at: + description: The Unix timestamp (in seconds) for when the assistant was created. + type: integer + format: unixtime + name: + description: | + The name of the assistant. The maximum length is 256 characters. + type: string + maxLength: 256 + description: + description: > + The description of the assistant. The maximum length is 512 + characters. + type: string + maxLength: 512 + model: + description: > + ID of the model to use. You can use the [List + models](/docs/api-reference/models/list) API to see all of your + available models, or see our [Model overview](/docs/models) for + descriptions of them. + type: string + instructions: + description: > + The system instructions that the assistant uses. The maximum length + is 256,000 characters. + type: string + maxLength: 256000 + tools: + description: > + A list of tool enabled on the assistant. There can be a maximum of + 128 tools per assistant. Tools can be of types `code_interpreter`, + `file_search`, or `function`. + default: [] + type: array + maxItems: 128 + items: + oneOf: + - $ref: '#/components/schemas/AssistantToolsCode' + - $ref: '#/components/schemas/AssistantToolsFileSearch' + - $ref: '#/components/schemas/AssistantToolsFunction' + tool_resources: + type: object + description: > + A set of resources that are used by the assistant's tools. The + resources are specific to the type of tool. For example, the + `code_interpreter` tool requires a list of file IDs, while the + `file_search` tool requires a list of vector store IDs. + properties: + code_interpreter: + type: object + properties: + file_ids: + type: array + description: > + A list of [file](/docs/api-reference/files) IDs made + available to the `code_interpreter`` tool. There can be a + maximum of 20 files associated with the tool. + default: [] + maxItems: 20 + items: + type: string + file_search: + type: object + properties: + vector_store_ids: + type: array + description: > + The ID of the [vector + store](/docs/api-reference/vector-stores/object) attached to + this assistant. There can be a maximum of 1 vector store + attached to the assistant. + maxItems: 1 + items: + type: string + metadata: + $ref: '#/components/schemas/Metadata' + temperature: + description: > + What sampling temperature to use, between 0 and 2. Higher values + like 0.8 will make the output more random, while lower values like + 0.2 will make it more focused and deterministic. + type: number + minimum: 0 + maximum: 2 + default: 1 + example: 1 + top_p: + type: number + minimum: 0 + maximum: 1 + default: 1 + example: 1 + description: > + An alternative to sampling with temperature, called nucleus + sampling, where the model considers the results of the tokens with + top_p probability mass. So 0.1 means only the tokens comprising the + top 10% probability mass are considered. + - event: thread.run.completed - data: {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1710330641,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1710330642,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + We generally recommend altering this or temperature but not both. + response_format: + description: > + Specifies the format that the model must output. Compatible with + [GPT-4o](/docs/models#gpt-4o), [GPT-4 + Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo + models since `gpt-3.5-turbo-1106`. - event: done - data: [DONE] - - title: Streaming with Functions - request: - curl: | - curl https://api.openai.com/v1/threads/thread_abc123/runs \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" \ - -d '{ - "assistant_id": "asst_abc123", - "tools": [ - { - "type": "function", - "function": { - "name": "get_current_weather", - "description": "Get the current weather in a given location", - "parameters": { - "type": "object", - "properties": { - "location": { - "type": "string", - "description": "The city and state, e.g. San Francisco, CA" - }, - "unit": { - "type": "string", - "enum": ["celsius", "fahrenheit"] - } - }, - "required": ["location"] - } - } - } - ], - "stream": true - }' - python: | - from openai import OpenAI - client = OpenAI() - tools = [ - { - "type": "function", - "function": { - "name": "get_current_weather", - "description": "Get the current weather in a given location", - "parameters": { - "type": "object", - "properties": { - "location": { - "type": "string", - "description": "The city and state, e.g. San Francisco, CA", - }, - "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}, - }, - "required": ["location"], - }, - } - } - ] + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables + Structured Outputs which ensures the model will match your supplied + JSON schema. Learn more in the [Structured Outputs + guide](/docs/guides/structured-outputs). - stream = client.beta.threads.runs.create( - thread_id="thread_abc123", - assistant_id="asst_abc123", - tools=tools, - stream=True - ) - for event in stream: - print(event) - node.js: | - import OpenAI from "openai"; + Setting to `{ "type": "json_object" }` enables JSON mode, which + ensures the message the model generates is valid JSON. - const openai = new OpenAI(); - const tools = [ - { - "type": "function", - "function": { - "name": "get_current_weather", - "description": "Get the current weather in a given location", - "parameters": { - "type": "object", - "properties": { - "location": { - "type": "string", - "description": "The city and state, e.g. San Francisco, CA", - }, - "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}, - }, - "required": ["location"], - }, - } - } - ]; + **Important:** when using JSON mode, you **must** also instruct the + model to produce JSON yourself via a system or user message. Without + this, the model may generate an unending stream of whitespace until + the generation reaches the token limit, resulting in a long-running + and seemingly "stuck" request. Also note that the message content + may be partially cut off if `finish_reason="length"`, which + indicates the generation exceeded `max_tokens` or the conversation + exceeded the max context length. + type: string + enum: + - auto + x-stainless-const: true + title: Text + properties: + type: + type: string + description: The type of response format being defined. Always `text`. + enum: + - text + x-stainless-const: true + json_schema: + type: object + title: JSON schema + description: > + Structured Outputs configuration options, including a JSON + Schema. + properties: + description: + type: string + description: > + A description of what the response format is for, used by + the model to + + determine how to respond in the format. + name: + type: string + description: > + The name of the response format. Must be a-z, A-Z, 0-9, or + contain + + underscores and dashes, with a maximum length of 64. + schema: + $ref: '#/components/schemas/ResponseFormatJsonSchemaSchema' + strict: + anyOf: + - type: boolean + default: false + description: > + Whether to enable strict schema adherence when + generating the output. + + If set to true, the model will always follow the exact + schema defined + + in the `schema` field. Only a subset of JSON Schema is + supported when + + `strict` is `true`. To learn more, read the [Structured + Outputs + + guide](/docs/guides/structured-outputs). + - type: 'null' + required: + - name + required: + - type + - json_schema + required: + - id + - object + - created_at + - name + - description + - model + - instructions + - tools + - metadata + x-oaiMeta: + name: The assistant object + example: | + { + "id": "asst_abc123", + "object": "assistant", + "created_at": 1698984975, + "name": "Math Tutor", + "description": null, + "model": "gpt-4o", + "instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.", + "tools": [ + { + "type": "code_interpreter" + } + ], + "metadata": {}, + "top_p": 1.0, + "temperature": 1.0, + "response_format": "auto" + } + deprecated: true + ModifyAssistantRequest: + type: object + additionalProperties: false + properties: + model: + description: > + ID of the model to use. You can use the [List + models](/docs/api-reference/models/list) API to see all of your + available models, or see our [Model overview](/docs/models) for + descriptions of them. + type: string + enum: + - gpt-5 + - gpt-5-mini + - gpt-5-nano + - gpt-5-2025-08-07 + - gpt-5-mini-2025-08-07 + - gpt-5-nano-2025-08-07 + - gpt-4.1 + - gpt-4.1-mini + - gpt-4.1-nano + - gpt-4.1-2025-04-14 + - gpt-4.1-mini-2025-04-14 + - gpt-4.1-nano-2025-04-14 + - o3-mini + - o3-mini-2025-01-31 + - o1 + - o1-2024-12-17 + - gpt-4o + - gpt-4o-2024-11-20 + - gpt-4o-2024-08-06 + - gpt-4o-2024-05-13 + - gpt-4o-mini + - gpt-4o-mini-2024-07-18 + - gpt-4.5-preview + - gpt-4.5-preview-2025-02-27 + - gpt-4-turbo + - gpt-4-turbo-2024-04-09 + - gpt-4-0125-preview + - gpt-4-turbo-preview + - gpt-4-1106-preview + - gpt-4-vision-preview + - gpt-4 + - gpt-4-0314 + - gpt-4-0613 + - gpt-4-32k + - gpt-4-32k-0314 + - gpt-4-32k-0613 + - gpt-3.5-turbo + - gpt-3.5-turbo-16k + - gpt-3.5-turbo-0613 + - gpt-3.5-turbo-1106 + - gpt-3.5-turbo-0125 + - gpt-3.5-turbo-16k-0613 + reasoning_effort: + $ref: '#/components/schemas/ReasoningEffort' + name: + description: | + The name of the assistant. The maximum length is 256 characters. + type: string + maxLength: 256 + description: + description: > + The description of the assistant. The maximum length is 512 + characters. + type: string + maxLength: 512 + instructions: + description: > + The system instructions that the assistant uses. The maximum length + is 256,000 characters. + type: string + maxLength: 256000 + tools: + description: > + A list of tool enabled on the assistant. There can be a maximum of + 128 tools per assistant. Tools can be of types `code_interpreter`, + `file_search`, or `function`. + default: [] + type: array + maxItems: 128 + items: + oneOf: + - $ref: '#/components/schemas/AssistantToolsCode' + - $ref: '#/components/schemas/AssistantToolsFileSearch' + - $ref: '#/components/schemas/AssistantToolsFunction' + tool_resources: + type: object + description: > + A set of resources that are used by the assistant's tools. The + resources are specific to the type of tool. For example, the + `code_interpreter` tool requires a list of file IDs, while the + `file_search` tool requires a list of vector store IDs. + properties: + code_interpreter: + type: object + properties: + file_ids: + type: array + description: > + Overrides the list of [file](/docs/api-reference/files) IDs + made available to the `code_interpreter` tool. There can be + a maximum of 20 files associated with the tool. + default: [] + maxItems: 20 + items: + type: string + file_search: + type: object + properties: + vector_store_ids: + type: array + description: > + Overrides the [vector + store](/docs/api-reference/vector-stores/object) attached to + this assistant. There can be a maximum of 1 vector store + attached to the assistant. + maxItems: 1 + items: + type: string + metadata: + $ref: '#/components/schemas/Metadata' + temperature: + description: > + What sampling temperature to use, between 0 and 2. Higher values + like 0.8 will make the output more random, while lower values like + 0.2 will make it more focused and deterministic. + type: number + minimum: 0 + maximum: 2 + default: 1 + example: 1 + top_p: + type: number + minimum: 0 + maximum: 1 + default: 1 + example: 1 + description: > + An alternative to sampling with temperature, called nucleus + sampling, where the model considers the results of the tokens with + top_p probability mass. So 0.1 means only the tokens comprising the + top 10% probability mass are considered. - async function main() { - const stream = await openai.beta.threads.runs.create( - "thread_abc123", - { - assistant_id: "asst_abc123", - tools: tools, - stream: true - } - ); - for await (const event of stream) { - console.log(event); - } - } + We generally recommend altering this or temperature but not both. + response_format: + description: > + Specifies the format that the model must output. Compatible with + [GPT-4o](/docs/models#gpt-4o), [GPT-4 + Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo + models since `gpt-3.5-turbo-1106`. - main(); - response: | - event: thread.run.created - data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} - event: thread.run.queued - data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables + Structured Outputs which ensures the model will match your supplied + JSON schema. Learn more in the [Structured Outputs + guide](/docs/guides/structured-outputs). - event: thread.run.in_progress - data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710348075,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} - event: thread.run.step.created - data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} + Setting to `{ "type": "json_object" }` enables JSON mode, which + ensures the message the model generates is valid JSON. - event: thread.run.step.in_progress - data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} - event: thread.message.created - data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} + **Important:** when using JSON mode, you **must** also instruct the + model to produce JSON yourself via a system or user message. Without + this, the model may generate an unending stream of whitespace until + the generation reaches the token limit, resulting in a long-running + and seemingly "stuck" request. Also note that the message content + may be partially cut off if `finish_reason="length"`, which + indicates the generation exceeded `max_tokens` or the conversation + exceeded the max context length. + type: string + enum: + - auto + x-stainless-const: true + title: Text + properties: + type: + type: string + description: The type of response format being defined. Always `text`. + enum: + - text + x-stainless-const: true + json_schema: + type: object + title: JSON schema + description: > + Structured Outputs configuration options, including a JSON + Schema. + properties: + description: + type: string + description: > + A description of what the response format is for, used by + the model to + + determine how to respond in the format. + name: + type: string + description: > + The name of the response format. Must be a-z, A-Z, 0-9, or + contain + + underscores and dashes, with a maximum length of 64. + schema: + $ref: '#/components/schemas/ResponseFormatJsonSchemaSchema' + strict: + anyOf: + - type: boolean + default: false + description: > + Whether to enable strict schema adherence when + generating the output. + + If set to true, the model will always follow the exact + schema defined + + in the `schema` field. Only a subset of JSON Schema is + supported when + + `strict` is `true`. To learn more, read the [Structured + Outputs + + guide](/docs/guides/structured-outputs). + - type: 'null' + required: + - name + required: + - type + - json_schema + DeleteAssistantResponse: + type: object + properties: + id: + type: string + deleted: + type: boolean + object: + type: string + enum: + - assistant.deleted + x-stainless-const: true + required: + - id + - object + - deleted + CreateThreadRequest: + type: object + description: | + Options to create a new thread. If no thread is provided when running a + request, an empty thread will be created. + additionalProperties: false + properties: + messages: + description: >- + A list of [messages](/docs/api-reference/messages) to start the + thread with. + type: array + items: + $ref: '#/components/schemas/CreateMessageRequest' + tool_resources: + type: object + description: > + A set of resources that are made available to the assistant's tools + in this thread. The resources are specific to the type of tool. For + example, the `code_interpreter` tool requires a list of file IDs, + while the `file_search` tool requires a list of vector store IDs. + properties: + code_interpreter: + type: object + properties: + file_ids: + type: array + description: > + A list of [file](/docs/api-reference/files) IDs made + available to the `code_interpreter` tool. There can be a + maximum of 20 files associated with the tool. + default: [] + maxItems: 20 + items: + type: string + file_search: + type: object + properties: + vector_store_ids: + type: array + description: > + The [vector store](/docs/api-reference/vector-stores/object) + attached to this thread. There can be a maximum of 1 vector + store attached to the thread. + maxItems: 1 + items: + type: string + vector_stores: + type: array + description: > + A helper to create a [vector + store](/docs/api-reference/vector-stores/object) with + file_ids and attach it to this thread. There can be a + maximum of 1 vector store attached to the thread. + maxItems: 1 + items: + type: object + properties: + file_ids: + type: array + description: > + A list of [file](/docs/api-reference/files) IDs to add + to the vector store. For vector stores created before + Nov 2025, there can be a maximum of 10,000 files in a + vector store. For vector stores created starting in + Nov 2025, the limit is 100,000,000 files. + maxItems: 100000000 + items: + type: string + chunking_strategy: + type: object + description: >- + The chunking strategy used to chunk the file(s). If + not set, will use the `auto` strategy. + oneOf: + - type: object + title: Auto Chunking Strategy + description: >- + The default strategy. This strategy currently uses + a `max_chunk_size_tokens` of `800` and + `chunk_overlap_tokens` of `400`. + additionalProperties: false + properties: + type: + type: string + description: Always `auto`. + enum: + - auto + x-stainless-const: true + required: + - type + - type: object + title: Static Chunking Strategy + additionalProperties: false + properties: + type: + type: string + description: Always `static`. + enum: + - static + x-stainless-const: true + static: + type: object + additionalProperties: false + properties: + max_chunk_size_tokens: + type: integer + minimum: 100 + maximum: 4096 + description: >- + The maximum number of tokens in each + chunk. The default value is `800`. The + minimum value is `100` and the maximum + value is `4096`. + chunk_overlap_tokens: + type: integer + description: > + The number of tokens that overlap between + chunks. The default value is `400`. - event: thread.message.in_progress - data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} - event: thread.message.delta - data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}} + Note that the overlap must not exceed half + of `max_chunk_size_tokens`. + required: + - max_chunk_size_tokens + - chunk_overlap_tokens + required: + - type + - static + metadata: + $ref: '#/components/schemas/Metadata' + oneOf: + - required: + - vector_store_ids + - required: + - vector_stores + metadata: + $ref: '#/components/schemas/Metadata' + ThreadObject: + type: object + title: Thread + description: >- + Represents a thread that contains + [messages](/docs/api-reference/messages). + properties: + id: + description: The identifier, which can be referenced in API endpoints. + type: string + object: + description: The object type, which is always `thread`. + type: string + enum: + - thread + x-stainless-const: true + created_at: + description: The Unix timestamp (in seconds) for when the thread was created. + type: integer + format: unixtime + tool_resources: + type: object + description: > + A set of resources that are made available to the assistant's tools + in this thread. The resources are specific to the type of tool. For + example, the `code_interpreter` tool requires a list of file IDs, + while the `file_search` tool requires a list of vector store IDs. + properties: + code_interpreter: + type: object + properties: + file_ids: + type: array + description: > + A list of [file](/docs/api-reference/files) IDs made + available to the `code_interpreter` tool. There can be a + maximum of 20 files associated with the tool. + default: [] + maxItems: 20 + items: + type: string + file_search: + type: object + properties: + vector_store_ids: + type: array + description: > + The [vector store](/docs/api-reference/vector-stores/object) + attached to this thread. There can be a maximum of 1 vector + store attached to the thread. + maxItems: 1 + items: + type: string + metadata: + $ref: '#/components/schemas/Metadata' + required: + - id + - object + - created_at + - tool_resources + - metadata + x-oaiMeta: + name: The thread object + beta: true + example: | + { + "id": "thread_abc123", + "object": "thread", + "created_at": 1698107661, + "metadata": {} + } + CreateThreadAndRunRequest: + type: object + additionalProperties: false + properties: + assistant_id: + description: >- + The ID of the [assistant](/docs/api-reference/assistants) to use to + execute this run. + type: string + thread: + $ref: '#/components/schemas/CreateThreadRequest' + model: + description: >- + The ID of the [Model](/docs/api-reference/models) to be used to + execute this run. If a value is provided here, it will override the + model associated with the assistant. If not, the model associated + with the assistant will be used. + example: gpt-4o + x-oaiTypeLabel: string + nullable: true + type: string + enum: + - gpt-5 + - gpt-5-mini + - gpt-5-nano + - gpt-5-2025-08-07 + - gpt-5-mini-2025-08-07 + - gpt-5-nano-2025-08-07 + - gpt-4.1 + - gpt-4.1-mini + - gpt-4.1-nano + - gpt-4.1-2025-04-14 + - gpt-4.1-mini-2025-04-14 + - gpt-4.1-nano-2025-04-14 + - gpt-4o + - gpt-4o-2024-11-20 + - gpt-4o-2024-08-06 + - gpt-4o-2024-05-13 + - gpt-4o-mini + - gpt-4o-mini-2024-07-18 + - gpt-4.5-preview + - gpt-4.5-preview-2025-02-27 + - gpt-4-turbo + - gpt-4-turbo-2024-04-09 + - gpt-4-0125-preview + - gpt-4-turbo-preview + - gpt-4-1106-preview + - gpt-4-vision-preview + - gpt-4 + - gpt-4-0314 + - gpt-4-0613 + - gpt-4-32k + - gpt-4-32k-0314 + - gpt-4-32k-0613 + - gpt-3.5-turbo + - gpt-3.5-turbo-16k + - gpt-3.5-turbo-0613 + - gpt-3.5-turbo-1106 + - gpt-3.5-turbo-0125 + - gpt-3.5-turbo-16k-0613 + instructions: + description: >- + Override the default system message of the assistant. This is useful + for modifying the behavior on a per-run basis. + type: string + nullable: true + tools: + description: >- + Override the tools the assistant can use for this run. This is + useful for modifying the behavior on a per-run basis. + nullable: true + type: array + maxItems: 20 + items: + oneOf: + - $ref: '#/components/schemas/AssistantToolsCode' + - $ref: '#/components/schemas/AssistantToolsFileSearch' + - $ref: '#/components/schemas/AssistantToolsFunction' + tool_resources: + type: object + description: > + A set of resources that are used by the assistant's tools. The + resources are specific to the type of tool. For example, the + `code_interpreter` tool requires a list of file IDs, while the + `file_search` tool requires a list of vector store IDs. + properties: + code_interpreter: + type: object + properties: + file_ids: + type: array + description: > + A list of [file](/docs/api-reference/files) IDs made + available to the `code_interpreter` tool. There can be a + maximum of 20 files associated with the tool. + default: [] + maxItems: 20 + items: + type: string + file_search: + type: object + properties: + vector_store_ids: + type: array + description: > + The ID of the [vector + store](/docs/api-reference/vector-stores/object) attached to + this assistant. There can be a maximum of 1 vector store + attached to the assistant. + maxItems: 1 + items: + type: string + nullable: true + metadata: + $ref: '#/components/schemas/Metadata' + temperature: + type: number + minimum: 0 + maximum: 2 + default: 1 + example: 1 + nullable: true + description: > + What sampling temperature to use, between 0 and 2. Higher values + like 0.8 will make the output more random, while lower values like + 0.2 will make it more focused and deterministic. + top_p: + type: number + minimum: 0 + maximum: 1 + default: 1 + example: 1 + nullable: true + description: > + An alternative to sampling with temperature, called nucleus + sampling, where the model considers the results of the tokens with + top_p probability mass. So 0.1 means only the tokens comprising the + top 10% probability mass are considered. + + + We generally recommend altering this or temperature but not both. + stream: + type: boolean + nullable: true + description: > + If `true`, returns a stream of events that happen during the Run as + server-sent events, terminating when the Run enters a terminal state + with a `data: [DONE]` message. + max_prompt_tokens: + type: integer + nullable: true + description: > + The maximum number of prompt tokens that may be used over the course + of the run. The run will make a best effort to use only the number + of prompt tokens specified, across multiple turns of the run. If the + run exceeds the number of prompt tokens specified, the run will end + with status `incomplete`. See `incomplete_details` for more info. + minimum: 256 + max_completion_tokens: + type: integer + nullable: true + description: > + The maximum number of completion tokens that may be used over the + course of the run. The run will make a best effort to use only the + number of completion tokens specified, across multiple turns of the + run. If the run exceeds the number of completion tokens specified, + the run will end with status `incomplete`. See `incomplete_details` + for more info. + minimum: 256 + truncation_strategy: + type: object + title: Thread Truncation Controls + description: >- + Controls for how a thread will be truncated prior to the run. Use + this to control the initial context window of the run. + properties: + type: + type: string + description: >- + The truncation strategy to use for the thread. The default is + `auto`. If set to `last_messages`, the thread will be truncated + to the n most recent messages in the thread. When set to `auto`, + messages in the middle of the thread will be dropped to fit the + context length of the model, `max_prompt_tokens`. + enum: + - auto + - last_messages + last_messages: + type: integer + description: >- + The number of most recent messages from the thread when + constructing the context for the run. + minimum: 1 + required: + - type + nullable: true + tool_choice: + description: > + Controls which (if any) tool is called by the model. + + `none` means the model will not call any tools and instead generates + a message. - ... + `auto` is the default value and means the model can pick between + generating a message or calling one or more tools. - event: thread.message.delta - data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" today"}}]}} + `required` means the model must call one or more tools before + responding to the user. - event: thread.message.delta - data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}} + Specifying a particular tool like `{"type": "file_search"}` or + `{"type": "function", "function": {"name": "my_function"}}` forces + the model to call that tool. + type: string + enum: + - none + - auto + - required + properties: + type: + type: string + enum: + - function + - code_interpreter + - file_search + description: >- + The type of the tool. If type is `function`, the function name + must be set + function: + type: object + properties: + name: + type: string + description: The name of the function to call. + required: + - name + required: + - type + nullable: true + parallel_tool_calls: + $ref: '#/components/schemas/ParallelToolCalls' + response_format: + $ref: '#/components/schemas/AssistantsApiResponseFormatOption' + nullable: true + required: + - assistant_id + RunObject: + type: object + title: A run on a thread + description: Represents an execution run on a [thread](/docs/api-reference/threads). + properties: + id: + description: The identifier, which can be referenced in API endpoints. + type: string + object: + description: The object type, which is always `thread.run`. + type: string + enum: + - thread.run + x-stainless-const: true + created_at: + description: The Unix timestamp (in seconds) for when the run was created. + type: integer + format: unixtime + thread_id: + description: >- + The ID of the [thread](/docs/api-reference/threads) that was + executed on as a part of this run. + type: string + assistant_id: + description: >- + The ID of the [assistant](/docs/api-reference/assistants) used for + execution of this run. + type: string + status: + description: >- + The status of the run, which can be either `queued`, `in_progress`, + `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, + `incomplete`, or `expired`. + type: string + enum: + - queued + - in_progress + - requires_action + - cancelling + - cancelled + - failed + - completed + - incomplete + - expired + required_action: + type: object + description: >- + Details on the action required to continue the run. Will be `null` + if no action is required. + nullable: true + properties: + type: + description: For now, this is always `submit_tool_outputs`. + type: string + enum: + - submit_tool_outputs + x-stainless-const: true + submit_tool_outputs: + type: object + description: Details on the tool outputs needed for this run to continue. + properties: + tool_calls: + type: array + description: A list of the relevant tool calls. + items: + $ref: '#/components/schemas/RunToolCallObject' + required: + - tool_calls + required: + - type + - submit_tool_outputs + last_error: + type: object + description: >- + The last error associated with this run. Will be `null` if there are + no errors. + nullable: true + properties: + code: + type: string + description: >- + One of `server_error`, `rate_limit_exceeded`, or + `invalid_prompt`. + enum: + - server_error + - rate_limit_exceeded + - invalid_prompt + message: + type: string + description: A human-readable description of the error. + required: + - code + - message + expires_at: + description: The Unix timestamp (in seconds) for when the run will expire. + type: integer + format: unixtime + nullable: true + started_at: + description: The Unix timestamp (in seconds) for when the run was started. + type: integer + format: unixtime + nullable: true + cancelled_at: + description: The Unix timestamp (in seconds) for when the run was cancelled. + type: integer + format: unixtime + nullable: true + failed_at: + description: The Unix timestamp (in seconds) for when the run failed. + type: integer + format: unixtime + nullable: true + completed_at: + description: The Unix timestamp (in seconds) for when the run was completed. + type: integer + format: unixtime + nullable: true + incomplete_details: + description: >- + Details on why the run is incomplete. Will be `null` if the run is + not incomplete. + type: object + nullable: true + properties: + reason: + description: >- + The reason why the run is incomplete. This will point to which + specific token limit was reached over the course of the run. + type: string + enum: + - max_completion_tokens + - max_prompt_tokens + model: + description: >- + The model that the [assistant](/docs/api-reference/assistants) used + for this run. + type: string + instructions: + description: >- + The instructions that the + [assistant](/docs/api-reference/assistants) used for this run. + type: string + tools: + description: >- + The list of tools that the + [assistant](/docs/api-reference/assistants) used for this run. + default: [] + type: array + maxItems: 20 + items: + oneOf: + - $ref: '#/components/schemas/AssistantToolsCode' + - $ref: '#/components/schemas/AssistantToolsFileSearch' + - $ref: '#/components/schemas/AssistantToolsFunction' + metadata: + $ref: '#/components/schemas/Metadata' + usage: + $ref: '#/components/schemas/RunCompletionUsage' + temperature: + description: >- + The sampling temperature used for this run. If not set, defaults to + 1. + type: number + nullable: true + top_p: + description: >- + The nucleus sampling value used for this run. If not set, defaults + to 1. + type: number + nullable: true + max_prompt_tokens: + type: integer + nullable: true + description: > + The maximum number of prompt tokens specified to have been used over + the course of the run. + minimum: 256 + max_completion_tokens: + type: integer + nullable: true + description: > + The maximum number of completion tokens specified to have been used + over the course of the run. + minimum: 256 + truncation_strategy: + type: object + title: Thread Truncation Controls + description: >- + Controls for how a thread will be truncated prior to the run. Use + this to control the initial context window of the run. + properties: + type: + type: string + description: >- + The truncation strategy to use for the thread. The default is + `auto`. If set to `last_messages`, the thread will be truncated + to the n most recent messages in the thread. When set to `auto`, + messages in the middle of the thread will be dropped to fit the + context length of the model, `max_prompt_tokens`. + enum: + - auto + - last_messages + last_messages: + type: integer + description: >- + The number of most recent messages from the thread when + constructing the context for the run. + minimum: 1 + required: + - type + nullable: true + tool_choice: + description: > + Controls which (if any) tool is called by the model. - event: thread.message.completed - data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710348077,"role":"assistant","content":[{"type":"text","text":{"value":"Hello! How can I assist you today?","annotations":[]}}],"metadata":{}} + `none` means the model will not call any tools and instead generates + a message. - event: thread.run.step.completed - data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710348077,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31}} + `auto` is the default value and means the model can pick between + generating a message or calling one or more tools. - event: thread.run.completed - data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1710348075,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1710348077,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + `required` means the model must call one or more tools before + responding to the user. - event: done - data: [DONE] - '/threads/{thread_id}/runs/{run_id}': - get: - operationId: getRun - tags: - - Assistants - summary: Retrieves a run. - parameters: - - in: path - name: thread_id - required: true - schema: - type: string - description: 'The ID of the [thread](/docs/api-reference/threads) that was run.' - - in: path - name: run_id - required: true - schema: - type: string - description: The ID of the run to retrieve. - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/RunObject' + Specifying a particular tool like `{"type": "file_search"}` or + `{"type": "function", "function": {"name": "my_function"}}` forces + the model to call that tool. + type: string + enum: + - none + - auto + - required + properties: + type: + type: string + enum: + - function + - code_interpreter + - file_search + description: >- + The type of the tool. If type is `function`, the function name + must be set + function: + type: object + properties: + name: + type: string + description: The name of the function to call. + required: + - name + required: + - type + nullable: true + parallel_tool_calls: + $ref: '#/components/schemas/ParallelToolCalls' + response_format: + $ref: '#/components/schemas/AssistantsApiResponseFormatOption' + nullable: true + required: + - id + - object + - created_at + - thread_id + - assistant_id + - status + - required_action + - last_error + - expires_at + - started_at + - cancelled_at + - failed_at + - completed_at + - model + - instructions + - tools + - metadata + - usage + - incomplete_details + - max_prompt_tokens + - max_completion_tokens + - truncation_strategy + - tool_choice + - parallel_tool_calls + - response_format x-oaiMeta: - name: Retrieve run - group: threads + name: The run object beta: true - returns: 'The [run](/docs/api-reference/runs/object) object matching the specified ID.' - examples: - request: - curl: | - curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from openai import OpenAI - client = OpenAI() - - run = client.beta.threads.runs.retrieve( - thread_id="thread_abc123", - run_id="run_abc123" - ) - - print(run) - node.js: | - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const run = await openai.beta.threads.runs.retrieve( - "thread_abc123", - "run_abc123" - ); + example: | + { + "id": "run_abc123", + "object": "thread.run", + "created_at": 1698107661, + "assistant_id": "asst_abc123", + "thread_id": "thread_abc123", + "status": "completed", + "started_at": 1699073476, + "expires_at": null, + "cancelled_at": null, + "failed_at": null, + "completed_at": 1699073498, + "last_error": null, + "model": "gpt-4o", + "instructions": null, + "tools": [{"type": "file_search"}, {"type": "code_interpreter"}], + "metadata": {}, + "incomplete_details": null, + "usage": { + "prompt_tokens": 123, + "completion_tokens": 456, + "total_tokens": 579 + }, + "temperature": 1.0, + "top_p": 1.0, + "max_prompt_tokens": 1000, + "max_completion_tokens": 1000, + "truncation_strategy": { + "type": "auto", + "last_messages": null + }, + "response_format": "auto", + "tool_choice": "auto", + "parallel_tool_calls": true + } + ModifyThreadRequest: + type: object + additionalProperties: false + properties: + tool_resources: + type: object + description: > + A set of resources that are made available to the assistant's tools + in this thread. The resources are specific to the type of tool. For + example, the `code_interpreter` tool requires a list of file IDs, + while the `file_search` tool requires a list of vector store IDs. + properties: + code_interpreter: + type: object + properties: + file_ids: + type: array + description: > + A list of [file](/docs/api-reference/files) IDs made + available to the `code_interpreter` tool. There can be a + maximum of 20 files associated with the tool. + default: [] + maxItems: 20 + items: + type: string + file_search: + type: object + properties: + vector_store_ids: + type: array + description: > + The [vector store](/docs/api-reference/vector-stores/object) + attached to this thread. There can be a maximum of 1 vector + store attached to the thread. + maxItems: 1 + items: + type: string + metadata: + $ref: '#/components/schemas/Metadata' + DeleteThreadResponse: + type: object + properties: + id: + type: string + deleted: + type: boolean + object: + type: string + enum: + - thread.deleted + x-stainless-const: true + required: + - id + - object + - deleted + ListMessagesResponse: + properties: + object: + type: string + example: list + data: + type: array + items: + $ref: '#/components/schemas/MessageObject' + first_id: + type: string + example: msg_abc123 + last_id: + type: string + example: msg_abc123 + has_more: + type: boolean + example: false + required: + - object + - data + - first_id + - last_id + - has_more + type: object + CreateMessageRequest: + type: object + additionalProperties: false + required: + - role + - content + properties: + role: + type: string + enum: + - user + - assistant + description: > + The role of the entity that is creating the message. Allowed values + include: - console.log(run); - } + - `user`: Indicates the message is sent by an actual user and should + be used in most cases to represent user-generated messages. - main(); - response: | - { - "id": "run_abc123", - "object": "thread.run", - "created_at": 1699075072, - "assistant_id": "asst_abc123", - "thread_id": "thread_abc123", - "status": "completed", - "started_at": 1699075072, - "expires_at": null, - "cancelled_at": null, - "failed_at": null, - "completed_at": 1699075073, - "last_error": null, - "model": "gpt-4o", - "instructions": null, - "incomplete_details": null, - "tools": [ - { - "type": "code_interpreter" - } - ], - "metadata": {}, - "usage": { - "prompt_tokens": 123, - "completion_tokens": 456, - "total_tokens": 579 - }, - "temperature": 1.0, - "top_p": 1.0, - "max_prompt_tokens": 1000, - "max_completion_tokens": 1000, - "truncation_strategy": { - "type": "auto", - "last_messages": null - }, - "response_format": "auto", - "tool_choice": "auto", - "parallel_tool_calls": true - } - post: - operationId: modifyRun - tags: - - Assistants - summary: Modifies a run. - parameters: - - in: path - name: thread_id - required: true - schema: - type: string - description: 'The ID of the [thread](/docs/api-reference/threads) that was run.' - - in: path - name: run_id - required: true - schema: - type: string - description: The ID of the run to modify. - requestBody: - required: true + - `assistant`: Indicates the message is generated by the assistant. + Use this value to insert messages from the assistant into the + conversation. + content: + type: string + description: The text contents of the message. + title: Text content + items: + oneOf: + - $ref: '#/components/schemas/MessageContentImageFileObject' + - $ref: '#/components/schemas/MessageContentImageUrlObject' + - $ref: '#/components/schemas/MessageRequestContentTextObject' + minItems: 1 + attachments: + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + description: The tools to add this file to. + type: array + items: + oneOf: + - $ref: '#/components/schemas/AssistantToolsCode' + - $ref: '#/components/schemas/AssistantToolsFileSearchTypeOnly' + description: >- + A list of files attached to the message, and the tools they should + be added to. + required: + - file_id + - tools + metadata: + $ref: '#/components/schemas/Metadata' + MessageObject: + type: object + title: The message object + description: Represents a message within a [thread](/docs/api-reference/threads). + properties: + id: + description: The identifier, which can be referenced in API endpoints. + type: string + object: + description: The object type, which is always `thread.message`. + type: string + enum: + - thread.message + x-stainless-const: true + created_at: + description: The Unix timestamp (in seconds) for when the message was created. + type: integer + format: unixtime + thread_id: + description: >- + The [thread](/docs/api-reference/threads) ID that this message + belongs to. + type: string + status: + description: >- + The status of the message, which can be either `in_progress`, + `incomplete`, or `completed`. + type: string + enum: + - in_progress + - incomplete + - completed + incomplete_details: + description: >- + On an incomplete message, details about why the message is + incomplete. + type: object + properties: + reason: + type: string + description: The reason the message is incomplete. + enum: + - content_filter + - max_tokens + - run_cancelled + - run_expired + - run_failed + required: + - reason + completed_at: + description: The Unix timestamp (in seconds) for when the message was completed. + type: integer + format: unixtime + incomplete_at: + description: >- + The Unix timestamp (in seconds) for when the message was marked as + incomplete. + type: integer + format: unixtime + role: + description: The entity that produced the message. One of `user` or `assistant`. + type: string + enum: + - user + - assistant content: - application/json: - schema: - $ref: '#/components/schemas/ModifyRunRequest' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/RunObject' + description: The content of the message in array of text and/or images. + type: array + items: + oneOf: + - $ref: '#/components/schemas/MessageContentImageFileObject' + - $ref: '#/components/schemas/MessageContentImageUrlObject' + - $ref: '#/components/schemas/MessageContentTextObject' + - $ref: '#/components/schemas/MessageContentRefusalObject' + assistant_id: + description: >- + If applicable, the ID of the + [assistant](/docs/api-reference/assistants) that authored this + message. + type: string + run_id: + description: >- + The ID of the [run](/docs/api-reference/runs) associated with the + creation of this message. Value is `null` when messages are created + manually using the create message or create thread endpoints. + type: string + attachments: + type: array + items: + type: object + properties: + file_id: + type: string + description: The ID of the file to attach to the message. + tools: + description: The tools to add this file to. + type: array + items: + oneOf: + - $ref: '#/components/schemas/AssistantToolsCode' + - $ref: '#/components/schemas/AssistantToolsFileSearchTypeOnly' + description: >- + A list of files attached to the message, and the tools they were + added to. + metadata: + $ref: '#/components/schemas/Metadata' + required: + - id + - object + - created_at + - thread_id + - status + - incomplete_details + - completed_at + - incomplete_at + - role + - content + - assistant_id + - run_id + - attachments + - metadata x-oaiMeta: - name: Modify run - group: threads + name: The message object beta: true - returns: 'The modified [run](/docs/api-reference/runs/object) object matching the specified ID.' - examples: - request: - curl: | - curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" \ - -d '{ - "metadata": { - "user_id": "user_abc123" - } - }' - python: | - from openai import OpenAI - client = OpenAI() - - run = client.beta.threads.runs.update( - thread_id="thread_abc123", - run_id="run_abc123", - metadata={"user_id": "user_abc123"}, - ) - - print(run) - node.js: | - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const run = await openai.beta.threads.runs.update( - "thread_abc123", - "run_abc123", - { - metadata: { - user_id: "user_abc123", - }, - } - ); - - console.log(run); - } - - main(); - response: | - { - "id": "run_abc123", - "object": "thread.run", - "created_at": 1699075072, - "assistant_id": "asst_abc123", - "thread_id": "thread_abc123", - "status": "completed", - "started_at": 1699075072, - "expires_at": null, - "cancelled_at": null, - "failed_at": null, - "completed_at": 1699075073, - "last_error": null, - "model": "gpt-4o", - "instructions": null, - "incomplete_details": null, - "tools": [ - { - "type": "code_interpreter" - } - ], - "tool_resources": { - "code_interpreter": { - "file_ids": [ - "file-abc123", - "file-abc456" - ] + example: | + { + "id": "msg_abc123", + "object": "thread.message", + "created_at": 1698983503, + "thread_id": "thread_abc123", + "role": "assistant", + "content": [ + { + "type": "text", + "text": { + "value": "Hi! How can I help you today?", + "annotations": [] } - }, - "metadata": { - "user_id": "user_abc123" - }, - "usage": { - "prompt_tokens": 123, - "completion_tokens": 456, - "total_tokens": 579 - }, - "temperature": 1.0, - "top_p": 1.0, - "max_prompt_tokens": 1000, - "max_completion_tokens": 1000, - "truncation_strategy": { - "type": "auto", - "last_messages": null - }, - "response_format": "auto", - "tool_choice": "auto", - "parallel_tool_calls": true - } - '/threads/{thread_id}/runs/{run_id}/cancel': - post: - operationId: cancelRun - tags: - - Assistants - summary: Cancels a run that is `in_progress`. - parameters: - - in: path - name: thread_id - required: true - schema: - type: string - description: The ID of the thread to which this run belongs. - - in: path - name: run_id - required: true - schema: - type: string - description: The ID of the run to cancel. - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/RunObject' - x-oaiMeta: - name: Cancel a run - group: threads - beta: true - returns: 'The modified [run](/docs/api-reference/runs/object) object matching the specified ID.' - examples: - request: - curl: | - curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/cancel \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "OpenAI-Beta: assistants=v2" \ - -X POST - python: | - from openai import OpenAI - client = OpenAI() - - run = client.beta.threads.runs.cancel( - thread_id="thread_abc123", - run_id="run_abc123" - ) + } + ], + "assistant_id": "asst_abc123", + "run_id": "run_abc123", + "attachments": [], + "metadata": {} + } + ModifyMessageRequest: + type: object + additionalProperties: false + properties: + metadata: + $ref: '#/components/schemas/Metadata' + DeleteMessageResponse: + type: object + properties: + id: + type: string + deleted: + type: boolean + object: + type: string + enum: + - thread.message.deleted + x-stainless-const: true + required: + - id + - object + - deleted + ListRunsResponse: + type: object + properties: + object: + type: string + example: list + data: + type: array + items: + $ref: '#/components/schemas/RunObject' + first_id: + type: string + example: run_abc123 + last_id: + type: string + example: run_abc456 + has_more: + type: boolean + example: false + required: + - object + - data + - first_id + - last_id + - has_more + CreateRunRequest: + type: object + additionalProperties: false + properties: + assistant_id: + description: >- + The ID of the [assistant](/docs/api-reference/assistants) to use to + execute this run. + type: string + model: + description: >- + The ID of the [Model](/docs/api-reference/models) to be used to + execute this run. If a value is provided here, it will override the + model associated with the assistant. If not, the model associated + with the assistant will be used. + example: gpt-4o + x-oaiTypeLabel: string + nullable: true + type: string + enum: + - gpt-5 + - gpt-5-mini + - gpt-5-nano + - gpt-5-2025-08-07 + - gpt-5-mini-2025-08-07 + - gpt-5-nano-2025-08-07 + - gpt-4.1 + - gpt-4.1-mini + - gpt-4.1-nano + - gpt-4.1-2025-04-14 + - gpt-4.1-mini-2025-04-14 + - gpt-4.1-nano-2025-04-14 + - o3-mini + - o3-mini-2025-01-31 + - o1 + - o1-2024-12-17 + - gpt-4o + - gpt-4o-2024-11-20 + - gpt-4o-2024-08-06 + - gpt-4o-2024-05-13 + - gpt-4o-mini + - gpt-4o-mini-2024-07-18 + - gpt-4.5-preview + - gpt-4.5-preview-2025-02-27 + - gpt-4-turbo + - gpt-4-turbo-2024-04-09 + - gpt-4-0125-preview + - gpt-4-turbo-preview + - gpt-4-1106-preview + - gpt-4-vision-preview + - gpt-4 + - gpt-4-0314 + - gpt-4-0613 + - gpt-4-32k + - gpt-4-32k-0314 + - gpt-4-32k-0613 + - gpt-3.5-turbo + - gpt-3.5-turbo-16k + - gpt-3.5-turbo-0613 + - gpt-3.5-turbo-1106 + - gpt-3.5-turbo-0125 + - gpt-3.5-turbo-16k-0613 + reasoning_effort: + $ref: '#/components/schemas/ReasoningEffort' + instructions: + description: >- + Overrides the + [instructions](/docs/api-reference/assistants/createAssistant) of + the assistant. This is useful for modifying the behavior on a + per-run basis. + type: string + nullable: true + additional_instructions: + description: >- + Appends additional instructions at the end of the instructions for + the run. This is useful for modifying the behavior on a per-run + basis without overriding other instructions. + type: string + nullable: true + additional_messages: + description: Adds additional messages to the thread before creating the run. + type: array + items: + $ref: '#/components/schemas/CreateMessageRequest' + nullable: true + tools: + description: >- + Override the tools the assistant can use for this run. This is + useful for modifying the behavior on a per-run basis. + nullable: true + type: array + maxItems: 20 + items: + oneOf: + - $ref: '#/components/schemas/AssistantToolsCode' + - $ref: '#/components/schemas/AssistantToolsFileSearch' + - $ref: '#/components/schemas/AssistantToolsFunction' + metadata: + $ref: '#/components/schemas/Metadata' + temperature: + type: number + minimum: 0 + maximum: 2 + default: 1 + example: 1 + nullable: true + description: > + What sampling temperature to use, between 0 and 2. Higher values + like 0.8 will make the output more random, while lower values like + 0.2 will make it more focused and deterministic. + top_p: + type: number + minimum: 0 + maximum: 1 + default: 1 + example: 1 + nullable: true + description: > + An alternative to sampling with temperature, called nucleus + sampling, where the model considers the results of the tokens with + top_p probability mass. So 0.1 means only the tokens comprising the + top 10% probability mass are considered. - print(run) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + We generally recommend altering this or temperature but not both. + stream: + type: boolean + nullable: true + description: > + If `true`, returns a stream of events that happen during the Run as + server-sent events, terminating when the Run enters a terminal state + with a `data: [DONE]` message. + max_prompt_tokens: + type: integer + nullable: true + description: > + The maximum number of prompt tokens that may be used over the course + of the run. The run will make a best effort to use only the number + of prompt tokens specified, across multiple turns of the run. If the + run exceeds the number of prompt tokens specified, the run will end + with status `incomplete`. See `incomplete_details` for more info. + minimum: 256 + max_completion_tokens: + type: integer + nullable: true + description: > + The maximum number of completion tokens that may be used over the + course of the run. The run will make a best effort to use only the + number of completion tokens specified, across multiple turns of the + run. If the run exceeds the number of completion tokens specified, + the run will end with status `incomplete`. See `incomplete_details` + for more info. + minimum: 256 + truncation_strategy: + type: object + title: Thread Truncation Controls + description: >- + Controls for how a thread will be truncated prior to the run. Use + this to control the initial context window of the run. + properties: + type: + type: string + description: >- + The truncation strategy to use for the thread. The default is + `auto`. If set to `last_messages`, the thread will be truncated + to the n most recent messages in the thread. When set to `auto`, + messages in the middle of the thread will be dropped to fit the + context length of the model, `max_prompt_tokens`. + enum: + - auto + - last_messages + last_messages: + type: integer + description: >- + The number of most recent messages from the thread when + constructing the context for the run. + minimum: 1 + required: + - type + nullable: true + tool_choice: + description: > + Controls which (if any) tool is called by the model. - async function main() { - const run = await openai.beta.threads.runs.cancel( - "thread_abc123", - "run_abc123" - ); + `none` means the model will not call any tools and instead generates + a message. - console.log(run); - } + `auto` is the default value and means the model can pick between + generating a message or calling one or more tools. - main(); - response: | - { - "id": "run_abc123", - "object": "thread.run", - "created_at": 1699076126, - "assistant_id": "asst_abc123", - "thread_id": "thread_abc123", - "status": "cancelling", - "started_at": 1699076126, - "expires_at": 1699076726, - "cancelled_at": null, - "failed_at": null, - "completed_at": null, - "last_error": null, - "model": "gpt-4o", - "instructions": "You summarize books.", - "tools": [ - { - "type": "file_search" - } - ], - "tool_resources": { - "file_search": { - "vector_store_ids": ["vs_123"] - } - }, - "metadata": {}, - "usage": null, - "temperature": 1.0, - "top_p": 1.0, - "response_format": "auto", - "tool_choice": "auto", - "parallel_tool_calls": true - } - '/threads/{thread_id}/runs/{run_id}/steps': - get: - operationId: listRunSteps - tags: - - Assistants - summary: Returns a list of run steps belonging to a run. - parameters: - - name: thread_id - in: path - required: true - schema: - type: string - description: The ID of the thread the run and run steps belong to. - - name: run_id - in: path - required: true - schema: - type: string - description: The ID of the run the run steps belong to. - - name: limit - in: query - description: | - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - required: false - schema: - type: integer - default: 20 - - name: order - in: query - description: | - Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. - schema: - type: string - default: desc - enum: - - asc - - desc - - name: after - in: query - 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 - - name: before - in: query - 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, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - schema: - type: string - - name: 'include[]' - in: query - description: | - A list of additional fields to include in the response. Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. + `required` means the model must call one or more tools before + responding to the user. - See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. - schema: - type: array - items: + Specifying a particular tool like `{"type": "file_search"}` or + `{"type": "function", "function": {"name": "my_function"}}` forces + the model to call that tool. + type: string + enum: + - none + - auto + - required + properties: + type: + type: string + enum: + - function + - code_interpreter + - file_search + description: >- + The type of the tool. If type is `function`, the function name + must be set + function: + type: object + properties: + name: + type: string + description: The name of the function to call. + required: + - name + required: + - type + nullable: true + parallel_tool_calls: + $ref: '#/components/schemas/ParallelToolCalls' + response_format: + $ref: '#/components/schemas/AssistantsApiResponseFormatOption' + nullable: true + required: + - assistant_id + ModifyRunRequest: + type: object + additionalProperties: false + properties: + metadata: + $ref: '#/components/schemas/Metadata' + ListRunStepsResponse: + properties: + object: + type: string + example: list + data: + type: array + items: + $ref: '#/components/schemas/RunStepObject' + first_id: + type: string + example: step_abc123 + last_id: + type: string + example: step_abc456 + has_more: + type: boolean + example: false + required: + - object + - data + - first_id + - last_id + - has_more + type: object + RunStepObject: + type: object + title: Run steps + description: | + Represents a step in execution of a run. + properties: + id: + description: >- + The identifier of the run step, which can be referenced in API + endpoints. + type: string + object: + description: The object type, which is always `thread.run.step`. + type: string + enum: + - thread.run.step + x-stainless-const: true + created_at: + description: The Unix timestamp (in seconds) for when the run step was created. + type: integer + format: unixtime + assistant_id: + description: >- + The ID of the [assistant](/docs/api-reference/assistants) associated + with the run step. + type: string + thread_id: + description: The ID of the [thread](/docs/api-reference/threads) that was run. + type: string + run_id: + description: >- + The ID of the [run](/docs/api-reference/runs) that this run step is + a part of. + type: string + type: + description: >- + The type of run step, which can be either `message_creation` or + `tool_calls`. + type: string + enum: + - message_creation + - tool_calls + status: + description: >- + The status of the run step, which can be either `in_progress`, + `cancelled`, `failed`, `completed`, or `expired`. + type: string + enum: + - in_progress + - cancelled + - failed + - completed + - expired + step_details: + type: object + description: The details of the run step. + title: Message creation + properties: + type: + description: Always `message_creation`. type: string enum: - - 'step_details.tool_calls[*].file_search.results[*].content' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ListRunStepsResponse' - x-oaiMeta: - name: List run steps - group: threads - beta: true - returns: 'A list of [run step](/docs/api-reference/run-steps/step-object) objects.' - examples: - request: - curl: | - curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/steps \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from openai import OpenAI - client = OpenAI() - - run_steps = client.beta.threads.runs.steps.list( - thread_id="thread_abc123", - run_id="run_abc123" - ) - - print(run_steps) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); - - async function main() { - const runStep = await openai.beta.threads.runs.steps.list( - "thread_abc123", - "run_abc123" - ); - console.log(runStep); - } - - main(); - response: | - { - "object": "list", - "data": [ - { - "id": "step_abc123", - "object": "thread.run.step", - "created_at": 1699063291, - "run_id": "run_abc123", - "assistant_id": "asst_abc123", - "thread_id": "thread_abc123", - "type": "message_creation", - "status": "completed", - "cancelled_at": null, - "completed_at": 1699063291, - "expired_at": null, - "failed_at": null, - "last_error": null, - "step_details": { - "type": "message_creation", - "message_creation": { - "message_id": "msg_abc123" - } - }, - "usage": { - "prompt_tokens": 123, - "completion_tokens": 456, - "total_tokens": 579 - } - } - ], - "first_id": "step_abc123", - "last_id": "step_abc456", - "has_more": false - } - '/threads/{thread_id}/runs/{run_id}/steps/{step_id}': - get: - operationId: getRunStep - tags: - - Assistants - summary: Retrieves a run step. - parameters: - - in: path - name: thread_id - required: true - schema: - type: string - description: The ID of the thread to which the run and run step belongs. - - in: path - name: run_id - required: true - schema: - type: string - description: The ID of the run to which the run step belongs. - - in: path - name: step_id - required: true - schema: - type: string - description: The ID of the run step to retrieve. - - name: 'include[]' - in: query - description: | - A list of additional fields to include in the response. Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. - - See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. - schema: - type: array - items: + - message_creation + x-stainless-const: true + message_creation: + type: object + properties: + message_id: + type: string + description: The ID of the message that was created by this run step. + required: + - message_id + tool_calls: + type: array + description: > + An array of tool calls the run step was involved in. These can + be associated with one of three types of tools: + `code_interpreter`, `file_search`, or `function`. + items: + oneOf: + - $ref: '#/components/schemas/RunStepDetailsToolCallsCodeObject' + - $ref: >- + #/components/schemas/RunStepDetailsToolCallsFileSearchObject + - $ref: '#/components/schemas/RunStepDetailsToolCallsFunctionObject' + required: + - type + - message_creation + - tool_calls + last_error: + type: object + description: >- + The last error associated with this run step. Will be `null` if + there are no errors. + properties: + code: type: string + description: One of `server_error` or `rate_limit_exceeded`. enum: - - 'step_details.tool_calls[*].file_search.results[*].content' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/RunStepObject' + - server_error + - rate_limit_exceeded + message: + type: string + description: A human-readable description of the error. + required: + - code + - message + expired_at: + description: >- + The Unix timestamp (in seconds) for when the run step expired. A + step is considered expired if the parent run is expired. + type: integer + format: unixtime + cancelled_at: + description: The Unix timestamp (in seconds) for when the run step was cancelled. + type: integer + format: unixtime + failed_at: + description: The Unix timestamp (in seconds) for when the run step failed. + type: integer + format: unixtime + completed_at: + description: The Unix timestamp (in seconds) for when the run step completed. + type: integer + format: unixtime + metadata: + $ref: '#/components/schemas/Metadata' + usage: + $ref: '#/components/schemas/RunStepCompletionUsage' + required: + - id + - object + - created_at + - assistant_id + - thread_id + - run_id + - type + - status + - step_details + - last_error + - expired_at + - cancelled_at + - failed_at + - completed_at + - metadata + - usage x-oaiMeta: - name: Retrieve run step - group: threads + name: The run step object beta: true - returns: 'The [run step](/docs/api-reference/run-steps/step-object) object matching the specified ID.' - examples: - request: - curl: | - curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/steps/step_abc123 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from openai import OpenAI - client = OpenAI() - - run_step = client.beta.threads.runs.steps.retrieve( - thread_id="thread_abc123", - run_id="run_abc123", - step_id="step_abc123" - ) - - print(run_step) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); - - async function main() { - const runStep = await openai.beta.threads.runs.steps.retrieve( - "thread_abc123", - "run_abc123", - "step_abc123" - ); - console.log(runStep); + example: | + { + "id": "step_abc123", + "object": "thread.run.step", + "created_at": 1699063291, + "run_id": "run_abc123", + "assistant_id": "asst_abc123", + "thread_id": "thread_abc123", + "type": "message_creation", + "status": "completed", + "cancelled_at": null, + "completed_at": 1699063291, + "expired_at": null, + "failed_at": null, + "last_error": null, + "step_details": { + "type": "message_creation", + "message_creation": { + "message_id": "msg_abc123" } + }, + "usage": { + "prompt_tokens": 123, + "completion_tokens": 456, + "total_tokens": 579 + } + } + SubmitToolOutputsRunRequest: + type: object + additionalProperties: false + properties: + tool_outputs: + description: A list of tools for which the outputs are being submitted. + type: array + items: + type: object + properties: + tool_call_id: + type: string + description: >- + The ID of the tool call in the `required_action` object within + the run object the output is being submitted for. + output: + type: string + description: >- + The output of the tool call to be submitted to continue the + run. + stream: + type: boolean + description: > + If `true`, returns a stream of events that happen during the Run as + server-sent events, terminating when the Run enters a terminal state + with a `data: [DONE]` message. + required: + - tool_outputs + AssistantSupportedModels: + type: string + enum: + - gpt-5 + - gpt-5-mini + - gpt-5-nano + - gpt-5-2025-08-07 + - gpt-5-mini-2025-08-07 + - gpt-5-nano-2025-08-07 + - gpt-4.1 + - gpt-4.1-mini + - gpt-4.1-nano + - gpt-4.1-2025-04-14 + - gpt-4.1-mini-2025-04-14 + - gpt-4.1-nano-2025-04-14 + - o3-mini + - o3-mini-2025-01-31 + - o1 + - o1-2024-12-17 + - gpt-4o + - gpt-4o-2024-11-20 + - gpt-4o-2024-08-06 + - gpt-4o-2024-05-13 + - gpt-4o-mini + - gpt-4o-mini-2024-07-18 + - gpt-4.5-preview + - gpt-4.5-preview-2025-02-27 + - gpt-4-turbo + - gpt-4-turbo-2024-04-09 + - gpt-4-0125-preview + - gpt-4-turbo-preview + - gpt-4-1106-preview + - gpt-4-vision-preview + - gpt-4 + - gpt-4-0314 + - gpt-4-0613 + - gpt-4-32k + - gpt-4-32k-0314 + - gpt-4-32k-0613 + - gpt-3.5-turbo + - gpt-3.5-turbo-16k + - gpt-3.5-turbo-0613 + - gpt-3.5-turbo-1106 + - gpt-3.5-turbo-0125 + - gpt-3.5-turbo-16k-0613 + ReasoningEffort: + type: string + enum: + - none + - minimal + - low + - medium + - high + - xhigh + default: medium + description: > + Constrains effort on reasoning for + + [reasoning models](https://platform.openai.com/docs/guides/reasoning). + + Currently supported values are `none`, `minimal`, `low`, `medium`, + `high`, and `xhigh`. Reducing + + reasoning effort can result in faster responses and fewer tokens used + + on reasoning in a response. + + + - `gpt-5.1` defaults to `none`, which does not perform reasoning. The + supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, + and `high`. Tool calls are supported for all reasoning values in + gpt-5.1. + + - All models before `gpt-5.1` default to `medium` reasoning effort, and + do not support `none`. + + - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning + effort. + + - `xhigh` is supported for all models after `gpt-5.1-codex-max`. + AssistantToolsCode: + type: object + title: Code interpreter tool + properties: + type: + type: string + description: 'The type of tool being defined: `code_interpreter`' + enum: + - code_interpreter + x-stainless-const: true + required: + - type + AssistantToolsFileSearch: + type: object + title: FileSearch tool + properties: + type: + type: string + description: 'The type of tool being defined: `file_search`' + enum: + - file_search + x-stainless-const: true + file_search: + type: object + description: Overrides for the file search tool. + properties: + max_num_results: + type: integer + minimum: 1 + maximum: 50 + description: > + The maximum number of results the file search tool should + output. The default is 20 for `gpt-4*` models and 5 for + `gpt-3.5-turbo`. This number should be between 1 and 50 + inclusive. - main(); - response: | - { - "id": "step_abc123", - "object": "thread.run.step", - "created_at": 1699063291, - "run_id": "run_abc123", - "assistant_id": "asst_abc123", - "thread_id": "thread_abc123", - "type": "message_creation", - "status": "completed", - "cancelled_at": null, - "completed_at": 1699063291, - "expired_at": null, - "failed_at": null, - "last_error": null, - "step_details": { - "type": "message_creation", - "message_creation": { - "message_id": "msg_abc123" - } - }, - "usage": { - "prompt_tokens": 123, - "completion_tokens": 456, - "total_tokens": 579 - } - } - '/threads/{thread_id}/runs/{run_id}/submit_tool_outputs': - post: - operationId: submitToolOuputsToRun - tags: - - Assistants - summary: | - When a run has the `status: "requires_action"` and `required_action.type` is `submit_tool_outputs`, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request. - parameters: - - in: path - name: thread_id - required: true - schema: - type: string - description: 'The ID of the [thread](/docs/api-reference/threads) to which this run belongs.' - - in: path - name: run_id - required: true - schema: - type: string - description: The ID of the run that requires the tool output submission. - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/SubmitToolOutputsRunRequest' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/RunObject' - x-oaiMeta: - name: Submit tool outputs to run - group: threads - beta: true - returns: 'The modified [run](/docs/api-reference/runs/object) object matching the specified ID.' - examples: - - title: Default - request: - curl: | - curl https://api.openai.com/v1/threads/thread_123/runs/run_123/submit_tool_outputs \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" \ - -d '{ - "tool_outputs": [ - { - "tool_call_id": "call_001", - "output": "70 degrees and sunny." - } - ] - }' - python: | - from openai import OpenAI - client = OpenAI() - run = client.beta.threads.runs.submit_tool_outputs( - thread_id="thread_123", - run_id="run_123", - tool_outputs=[ - { - "tool_call_id": "call_001", - "output": "70 degrees and sunny." - } - ] - ) + Note that the file search tool may output fewer than + `max_num_results` results. See the [file search tool + documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) + for more information. + ranking_options: + $ref: '#/components/schemas/FileSearchRankingOptions' + required: + - type + AssistantToolsFunction: + type: object + title: Function tool + properties: + type: + type: string + description: 'The type of tool being defined: `function`' + enum: + - function + x-stainless-const: true + function: + $ref: '#/components/schemas/FunctionObject' + required: + - type + - function + Metadata: + type: object + description: > + Set of 16 key-value pairs that can be attached to an object. This can be - print(run) - node.js: | - import OpenAI from "openai"; + useful for storing additional information about the object in a + structured - const openai = new OpenAI(); + format, and querying for objects via API or the dashboard. - async function main() { - const run = await openai.beta.threads.runs.submitToolOutputs( - "thread_123", - "run_123", - { - tool_outputs: [ - { - tool_call_id: "call_001", - output: "70 degrees and sunny.", - }, - ], - } - ); - console.log(run); - } + Keys are strings with a maximum length of 64 characters. Values are + strings - main(); - response: | - { - "id": "run_123", - "object": "thread.run", - "created_at": 1699075592, - "assistant_id": "asst_123", - "thread_id": "thread_123", - "status": "queued", - "started_at": 1699075592, - "expires_at": 1699076192, - "cancelled_at": null, - "failed_at": null, - "completed_at": null, - "last_error": null, - "model": "gpt-4o", - "instructions": null, - "tools": [ - { - "type": "function", - "function": { - "name": "get_current_weather", - "description": "Get the current weather in a given location", - "parameters": { - "type": "object", - "properties": { - "location": { - "type": "string", - "description": "The city and state, e.g. San Francisco, CA" - }, - "unit": { - "type": "string", - "enum": ["celsius", "fahrenheit"] - } - }, - "required": ["location"] - } - } - } - ], - "metadata": {}, - "usage": null, - "temperature": 1.0, - "top_p": 1.0, - "max_prompt_tokens": 1000, - "max_completion_tokens": 1000, - "truncation_strategy": { - "type": "auto", - "last_messages": null - }, - "response_format": "auto", - "tool_choice": "auto", - "parallel_tool_calls": true - } - - title: Streaming - request: - curl: | - curl https://api.openai.com/v1/threads/thread_123/runs/run_123/submit_tool_outputs \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" \ - -d '{ - "tool_outputs": [ - { - "tool_call_id": "call_001", - "output": "70 degrees and sunny." - } - ], - "stream": true - }' - python: | - from openai import OpenAI - client = OpenAI() + with a maximum length of 512 characters. + additionalProperties: + type: string + x-oaiTypeLabel: map + AssistantsApiResponseFormatOption: + description: > + Specifies the format that the model must output. Compatible with + [GPT-4o](/docs/models#gpt-4o), [GPT-4 + Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models + since `gpt-3.5-turbo-1106`. + + + Setting to `{ "type": "json_schema", "json_schema": {...} }` enables + Structured Outputs which ensures the model will match your supplied JSON + schema. Learn more in the [Structured Outputs + guide](/docs/guides/structured-outputs). + + + Setting to `{ "type": "json_object" }` enables JSON mode, which ensures + the message the model generates is valid JSON. + + + **Important:** when using JSON mode, you **must** also instruct the + model to produce JSON yourself via a system or user message. Without + this, the model may generate an unending stream of whitespace until the + generation reaches the token limit, resulting in a long-running and + seemingly "stuck" request. Also note that the message content may be + partially cut off if `finish_reason="length"`, which indicates the + generation exceeded `max_tokens` or the conversation exceeded the max + context length. + type: string + enum: + - auto + x-stainless-const: true + title: Text + properties: + type: + type: string + description: The type of response format being defined. Always `text`. + enum: + - text + x-stainless-const: true + json_schema: + type: object + title: JSON schema + description: | + Structured Outputs configuration options, including a JSON Schema. + properties: + description: + type: string + description: > + A description of what the response format is for, used by the + model to - stream = client.beta.threads.runs.submit_tool_outputs( - thread_id="thread_123", - run_id="run_123", - tool_outputs=[ - { - "tool_call_id": "call_001", - "output": "70 degrees and sunny." - } - ], - stream=True - ) + determine how to respond in the format. + name: + type: string + description: > + The name of the response format. Must be a-z, A-Z, 0-9, or + contain - for event in stream: - print(event) - node.js: | - import OpenAI from "openai"; + underscores and dashes, with a maximum length of 64. + schema: + $ref: '#/components/schemas/ResponseFormatJsonSchemaSchema' + strict: + anyOf: + - type: boolean + default: false + description: > + Whether to enable strict schema adherence when generating + the output. - const openai = new OpenAI(); + If set to true, the model will always follow the exact + schema defined - async function main() { - const stream = await openai.beta.threads.runs.submitToolOutputs( - "thread_123", - "run_123", - { - tool_outputs: [ - { - tool_call_id: "call_001", - output: "70 degrees and sunny.", - }, - ], - } - ); + in the `schema` field. Only a subset of JSON Schema is + supported when - for await (const event of stream) { - console.log(event); - } - } + `strict` is `true`. To learn more, read the [Structured + Outputs - main(); - response: | - event: thread.run.step.completed - data: {"id":"step_001","object":"thread.run.step","created_at":1710352449,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"tool_calls","status":"completed","cancelled_at":null,"completed_at":1710352475,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[{"id":"call_iWr0kQ2EaYMaxNdl0v3KYkx7","type":"function","function":{"name":"get_current_weather","arguments":"{\"location\":\"San Francisco, CA\",\"unit\":\"fahrenheit\"}","output":"70 degrees and sunny."}}]},"usage":{"prompt_tokens":291,"completion_tokens":24,"total_tokens":315}} + guide](/docs/guides/structured-outputs). + - type: 'null' + required: + - name + required: + - type + - json_schema + TruncationObject: + type: object + title: Thread Truncation Controls + description: >- + Controls for how a thread will be truncated prior to the run. Use this + to control the initial context window of the run. + properties: + type: + type: string + description: >- + The truncation strategy to use for the thread. The default is + `auto`. If set to `last_messages`, the thread will be truncated to + the n most recent messages in the thread. When set to `auto`, + messages in the middle of the thread will be dropped to fit the + context length of the model, `max_prompt_tokens`. + enum: + - auto + - last_messages + last_messages: + type: integer + description: >- + The number of most recent messages from the thread when constructing + the context for the run. + minimum: 1 + required: + - type + AssistantsApiToolChoiceOption: + description: > + Controls which (if any) tool is called by the model. - event: thread.run.queued - data: {"id":"run_123","object":"thread.run","created_at":1710352447,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":1710352448,"expires_at":1710353047,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + `none` means the model will not call any tools and instead generates a + message. - event: thread.run.in_progress - data: {"id":"run_123","object":"thread.run","created_at":1710352447,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710352475,"expires_at":1710353047,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} + `auto` is the default value and means the model can pick between + generating a message or calling one or more tools. - event: thread.run.step.created - data: {"id":"step_002","object":"thread.run.step","created_at":1710352476,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_002"}},"usage":null} + `required` means the model must call one or more tools before responding + to the user. - event: thread.run.step.in_progress - data: {"id":"step_002","object":"thread.run.step","created_at":1710352476,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_002"}},"usage":null} + Specifying a particular tool like `{"type": "file_search"}` or `{"type": + "function", "function": {"name": "my_function"}}` forces the model to + call that tool. + type: string + enum: + - none + - auto + - required + properties: + type: + type: string + enum: + - function + - code_interpreter + - file_search + description: >- + The type of the tool. If type is `function`, the function name must + be set + function: + type: object + properties: + name: + type: string + description: The name of the function to call. + required: + - name + required: + - type + ParallelToolCalls: + description: >- + Whether to enable [parallel function + calling](/docs/guides/function-calling#configuring-parallel-function-calling) + during tool use. + type: boolean + default: true + RunToolCallObject: + type: object + description: Tool call objects + properties: + id: + type: string + description: >- + The ID of the tool call. This ID must be referenced when you submit + the tool outputs in using the [Submit tool outputs to + run](/docs/api-reference/runs/submitToolOutputs) endpoint. + type: + type: string + description: >- + The type of tool call the output is required for. For now, this is + always `function`. + enum: + - function + x-stainless-const: true + function: + type: object + description: The function definition. + properties: + name: + type: string + description: The name of the function. + arguments: + type: string + description: >- + The arguments that the model expects you to pass to the + function. + required: + - name + - arguments + required: + - id + - type + - function + RunCompletionUsage: + type: object + description: >- + Usage statistics related to the run. This value will be `null` if the + run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + properties: + completion_tokens: + type: integer + description: Number of completion tokens used over the course of the run. + prompt_tokens: + type: integer + description: Number of prompt tokens used over the course of the run. + total_tokens: + type: integer + description: Total number of tokens used (prompt + completion). + required: + - prompt_tokens + - completion_tokens + - total_tokens + MessageContentImageFileObject: + title: Image file + type: object + description: >- + References an image [File](/docs/api-reference/files) in the content of + a message. + properties: + type: + description: Always `image_file`. + type: string + enum: + - image_file + x-stainless-const: true + image_file: + type: object + properties: + file_id: + description: >- + The [File](/docs/api-reference/files) ID of the image in the + message content. Set `purpose="vision"` when uploading the File + if you need to later display the file content. + type: string + detail: + type: string + description: >- + Specifies the detail level of the image if specified by the + user. `low` uses fewer tokens, you can opt in to high resolution + using `high`. + enum: + - auto + - low + - high + default: auto + required: + - file_id + required: + - type + - image_file + MessageContentImageUrlObject: + title: Image URL + type: object + description: References an image URL in the content of a message. + properties: + type: + type: string + enum: + - image_url + description: The type of the content part. + x-stainless-const: true + image_url: + type: object + properties: + url: + type: string + description: >- + The external URL of the image, must be a supported image types: + jpeg, jpg, png, gif, webp. + format: uri + detail: + type: string + description: >- + Specifies the detail level of the image. `low` uses fewer + tokens, you can opt in to high resolution using `high`. Default + value is `auto` + enum: + - auto + - low + - high + default: auto + required: + - url + required: + - type + - image_url + MessageRequestContentTextObject: + title: Text + type: object + description: The text content that is part of a message. + properties: + type: + description: Always `text`. + type: string + enum: + - text + x-stainless-const: true + text: + type: string + description: Text content to be sent to the model + required: + - type + - text + AssistantToolsFileSearchTypeOnly: + type: object + title: FileSearch tool + properties: + type: + type: string + description: 'The type of tool being defined: `file_search`' + enum: + - file_search + x-stainless-const: true + required: + - type + MessageContentTextObject: + title: Text + type: object + description: The text content that is part of a message. + properties: + type: + description: Always `text`. + type: string + enum: + - text + x-stainless-const: true + text: + type: object + properties: + value: + description: The data that makes up the text. + type: string + annotations: + type: array + items: + oneOf: + - $ref: >- + #/components/schemas/MessageContentTextAnnotationsFileCitationObject + - $ref: >- + #/components/schemas/MessageContentTextAnnotationsFilePathObject + required: + - value + - annotations + required: + - type + - text + MessageContentRefusalObject: + title: Refusal + type: object + description: The refusal content generated by the assistant. + properties: + type: + description: Always `refusal`. + type: string + enum: + - refusal + x-stainless-const: true + refusal: + type: string + required: + - type + - refusal + RunStepDetailsMessageCreationObject: + title: Message creation + type: object + description: Details of the message creation by the run step. + properties: + type: + description: Always `message_creation`. + type: string + enum: + - message_creation + x-stainless-const: true + message_creation: + type: object + properties: + message_id: + type: string + description: The ID of the message that was created by this run step. + required: + - message_id + required: + - type + - message_creation + RunStepDetailsToolCallsObject: + title: Tool calls + type: object + description: Details of the tool call. + properties: + type: + description: Always `tool_calls`. + type: string + enum: + - tool_calls + x-stainless-const: true + tool_calls: + type: array + description: > + An array of tool calls the run step was involved in. These can be + associated with one of three types of tools: `code_interpreter`, + `file_search`, or `function`. + items: + oneOf: + - $ref: '#/components/schemas/RunStepDetailsToolCallsCodeObject' + - $ref: '#/components/schemas/RunStepDetailsToolCallsFileSearchObject' + - $ref: '#/components/schemas/RunStepDetailsToolCallsFunctionObject' + required: + - type + - tool_calls + RunStepCompletionUsage: + type: object + description: >- + Usage statistics related to the run step. This value will be `null` + while the run step's status is `in_progress`. + properties: + completion_tokens: + type: integer + description: Number of completion tokens used over the course of the run step. + prompt_tokens: + type: integer + description: Number of prompt tokens used over the course of the run step. + total_tokens: + type: integer + description: Total number of tokens used (prompt + completion). + required: + - prompt_tokens + - completion_tokens + - total_tokens + FileSearchRankingOptions: + title: File search tool call ranking options + type: object + description: > + The ranking options for the file search. If not specified, the file + search tool will use the `auto` ranker and a score_threshold of 0. - event: thread.message.created - data: {"id":"msg_002","object":"thread.message","created_at":1710352476,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} - event: thread.message.in_progress - data: {"id":"msg_002","object":"thread.message","created_at":1710352476,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} + See the [file search tool + documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) + for more information. + properties: + ranker: + $ref: '#/components/schemas/FileSearchRanker' + score_threshold: + type: number + description: >- + The score threshold for the file search. All values must be a + floating point number between 0 and 1. + minimum: 0 + maximum: 1 + required: + - score_threshold + FunctionObject: + type: object + properties: + description: + type: string + description: >- + A description of what the function does, used by the model to choose + when and how to call the function. + name: + type: string + description: >- + The name of the function to be called. Must be a-z, A-Z, 0-9, or + contain underscores and dashes, with a maximum length of 64. + parameters: + $ref: '#/components/schemas/FunctionParameters' + strict: + type: boolean + default: false + description: >- + Whether to enable strict schema adherence when generating the + function call. If set to true, the model will follow the exact + schema defined in the `parameters` field. Only a subset of JSON + Schema is supported when `strict` is `true`. Learn more about + Structured Outputs in the [function calling + guide](/docs/guides/function-calling). + required: + - name + ResponseFormatText: + type: object + title: Text + description: | + Default response format. Used to generate text responses. + properties: + type: + type: string + description: The type of response format being defined. Always `text`. + enum: + - text + x-stainless-const: true + required: + - type + ResponseFormatJsonObject: + type: object + title: JSON object + description: > + JSON object response format. An older method of generating JSON + responses. + + Using `json_schema` is recommended for models that support it. Note that + the - event: thread.message.delta - data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"The","annotations":[]}}]}} + model will not generate JSON without a system or user message + instructing it - event: thread.message.delta - data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" current"}}]}} + to do so. + properties: + type: + type: string + description: The type of response format being defined. Always `json_object`. + enum: + - json_object + x-stainless-const: true + required: + - type + ResponseFormatJsonSchema: + type: object + title: JSON schema + description: | + JSON Schema response format. Used to generate structured JSON responses. + Learn more about [Structured Outputs](/docs/guides/structured-outputs). + properties: + type: + type: string + description: The type of response format being defined. Always `json_schema`. + enum: + - json_schema + x-stainless-const: true + json_schema: + type: object + title: JSON schema + description: | + Structured Outputs configuration options, including a JSON Schema. + properties: + description: + type: string + description: > + A description of what the response format is for, used by the + model to - event: thread.message.delta - data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" weather"}}]}} + determine how to respond in the format. + name: + type: string + description: > + The name of the response format. Must be a-z, A-Z, 0-9, or + contain - ... + underscores and dashes, with a maximum length of 64. + schema: + $ref: '#/components/schemas/ResponseFormatJsonSchemaSchema' + strict: + anyOf: + - type: boolean + default: false + description: > + Whether to enable strict schema adherence when generating + the output. - event: thread.message.delta - data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" sunny"}}]}} + If set to true, the model will always follow the exact + schema defined - event: thread.message.delta - data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"."}}]}} + in the `schema` field. Only a subset of JSON Schema is + supported when - event: thread.message.completed - data: {"id":"msg_002","object":"thread.message","created_at":1710352476,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710352477,"role":"assistant","content":[{"type":"text","text":{"value":"The current weather in San Francisco, CA is 70 degrees Fahrenheit and sunny.","annotations":[]}}],"metadata":{}} + `strict` is `true`. To learn more, read the [Structured + Outputs - event: thread.run.step.completed - data: {"id":"step_002","object":"thread.run.step","created_at":1710352476,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710352477,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_002"}},"usage":{"prompt_tokens":329,"completion_tokens":18,"total_tokens":347}} + guide](/docs/guides/structured-outputs). + - type: 'null' + required: + - name + required: + - type + - json_schema + AssistantsNamedToolChoice: + type: object + description: >- + Specifies a tool the model should use. Use to force the model to call a + specific tool. + properties: + type: + type: string + enum: + - function + - code_interpreter + - file_search + description: >- + The type of the tool. If type is `function`, the function name must + be set + function: + type: object + properties: + name: + type: string + description: The name of the function to call. + required: + - name + required: + - type + MessageContentTextAnnotationsFileCitationObject: + title: File citation + type: object + description: >- + A citation within the message that points to a specific quote from a + specific File associated with the assistant or the message. Generated + when the assistant uses the "file_search" tool to search files. + properties: + type: + description: Always `file_citation`. + type: string + enum: + - file_citation + x-stainless-const: true + text: + description: The text in the message content that needs to be replaced. + type: string + file_citation: + type: object + properties: + file_id: + description: The ID of the specific File the citation is from. + type: string + required: + - file_id + start_index: + type: integer + minimum: 0 + end_index: + type: integer + minimum: 0 + required: + - type + - text + - file_citation + - start_index + - end_index + MessageContentTextAnnotationsFilePathObject: + title: File path + type: object + description: >- + A URL for the file that's generated when the assistant used the + `code_interpreter` tool to generate a file. + properties: + type: + description: Always `file_path`. + type: string + enum: + - file_path + x-stainless-const: true + text: + description: The text in the message content that needs to be replaced. + type: string + file_path: + type: object + properties: + file_id: + description: The ID of the file that was generated. + type: string + required: + - file_id + start_index: + type: integer + minimum: 0 + end_index: + type: integer + minimum: 0 + required: + - type + - text + - file_path + - start_index + - end_index + RunStepDetailsToolCallsCodeObject: + title: Code Interpreter tool call + type: object + description: Details of the Code Interpreter tool call the run step was involved in. + properties: + id: + type: string + description: The ID of the tool call. + type: + type: string + description: >- + The type of tool call. This is always going to be `code_interpreter` + for this type of tool call. + enum: + - code_interpreter + x-stainless-const: true + code_interpreter: + type: object + description: The Code Interpreter tool call definition. + required: + - input + - outputs + properties: + input: + type: string + description: The input to the Code Interpreter tool call. + outputs: + type: array + description: >- + The outputs from the Code Interpreter tool call. Code + Interpreter can output one or more items, including text + (`logs`) or images (`image`). Each of these are represented by a + different object type. + items: + type: object + oneOf: + - $ref: >- + #/components/schemas/RunStepDetailsToolCallsCodeOutputLogsObject + - $ref: >- + #/components/schemas/RunStepDetailsToolCallsCodeOutputImageObject + required: + - id + - type + - code_interpreter + RunStepDetailsToolCallsFileSearchObject: + title: File search tool call + type: object + properties: + id: + type: string + description: The ID of the tool call object. + type: + type: string + description: >- + The type of tool call. This is always going to be `file_search` for + this type of tool call. + enum: + - file_search + x-stainless-const: true + file_search: + type: object + description: For now, this is always going to be an empty object. + x-oaiTypeLabel: map + properties: + ranking_options: + $ref: >- + #/components/schemas/RunStepDetailsToolCallsFileSearchRankingOptionsObject + results: + type: array + description: The results of the file search. + items: + $ref: >- + #/components/schemas/RunStepDetailsToolCallsFileSearchResultObject + required: + - id + - type + - file_search + RunStepDetailsToolCallsFunctionObject: + type: object + title: Function tool call + properties: + id: + type: string + description: The ID of the tool call object. + type: + type: string + description: >- + The type of tool call. This is always going to be `function` for + this type of tool call. + enum: + - function + x-stainless-const: true + function: + type: object + description: The definition of the function that was called. + properties: + name: + type: string + description: The name of the function. + arguments: + type: string + description: The arguments passed to the function. + output: + anyOf: + - type: string + description: >- + The output of the function. This will be `null` if the + outputs have not been + [submitted](/docs/api-reference/runs/submitToolOutputs) yet. + - type: 'null' + required: + - name + - arguments + - output + required: + - id + - type + - function + FileSearchRanker: + type: string + description: >- + The ranker to use for the file search. If not specified will use the + `auto` ranker. + enum: + - auto + - default_2024_08_21 + FunctionParameters: + type: object + description: >- + The parameters the functions accepts, described as a JSON Schema object. + See the [guide](/docs/guides/function-calling) for examples, and the + [JSON Schema + reference](https://json-schema.org/understanding-json-schema/) for + documentation about the format. - event: thread.run.completed - data: {"id":"run_123","object":"thread.run","created_at":1710352447,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1710352475,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1710352477,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} - event: done - data: [DONE] + Omitting `parameters` defines a function with an empty parameter list. + additionalProperties: true + ResponseFormatJsonSchemaSchema: + type: object + title: JSON schema + description: | + The schema for the response format, described as a JSON Schema object. + Learn how to build JSON schemas [here](https://json-schema.org/). + additionalProperties: true + RunStepDetailsToolCallsCodeOutputLogsObject: + title: Code Interpreter log output + type: object + description: Text output from the Code Interpreter tool call as part of a run step. + properties: + type: + description: Always `logs`. + type: string + enum: + - logs + x-stainless-const: true + logs: + type: string + description: The text output from the Code Interpreter tool call. + required: + - type + - logs + RunStepDetailsToolCallsCodeOutputImageObject: + title: Code Interpreter image output + type: object + properties: + type: + description: Always `image`. + type: string + enum: + - image + x-stainless-const: true + image: + type: object + properties: + file_id: + description: The [file](/docs/api-reference/files) ID of the image. + type: string + required: + - file_id + required: + - type + - image + RunStepDetailsToolCallsFileSearchRankingOptionsObject: + title: File search tool call ranking options + type: object + description: The ranking options for the file search. + properties: + ranker: + $ref: '#/components/schemas/FileSearchRanker' + score_threshold: + type: number + description: >- + The score threshold for the file search. All values must be a + floating point number between 0 and 1. + minimum: 0 + maximum: 1 + required: + - ranker + - score_threshold + RunStepDetailsToolCallsFileSearchResultObject: + title: File search tool call result + type: object + description: A result instance of the file search. + x-oaiTypeLabel: map + properties: + file_id: + type: string + description: The ID of the file that result was found in. + file_name: + type: string + description: The name of the file that result was found in. + score: + type: number + description: >- + The score of the result. All values must be a floating point number + between 0 and 1. + minimum: 0 + maximum: 1 + content: + type: array + description: >- + The content of the result that was found. The content is only + included if requested via the include query parameter. + items: + type: object + properties: + type: + type: string + description: The type of the content. + enum: + - text + x-stainless-const: true + text: + type: string + description: The text content of the file. + required: + - file_id + - file_name + - score + x-stackQL-resources: + assistants: + id: openai.assistants.assistants + name: assistants + title: Assistants + methods: + list: + operation: + $ref: '#/paths/~1assistants/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1assistants/post' + response: + mediaType: application/json + openAPIDocKey: '200' + get: + operation: + $ref: '#/paths/~1assistants~1{assistant_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + update: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1assistants~1{assistant_id}/post' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1assistants~1{assistant_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/assistants/methods/get' + - $ref: '#/components/x-stackQL-resources/assistants/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/assistants/methods/create' + update: + - $ref: '#/components/x-stackQL-resources/assistants/methods/update' + delete: + - $ref: '#/components/x-stackQL-resources/assistants/methods/delete' + replace: [] + threads: + id: openai.assistants.threads + name: threads + title: Threads + methods: + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1threads/post' + response: + mediaType: application/json + openAPIDocKey: '200' + create_thread_and_run: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1threads~1runs/post' + response: + mediaType: application/json + openAPIDocKey: '200' + get: + operation: + $ref: '#/paths/~1threads~1{thread_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + update: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1threads~1{thread_id}/post' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1threads~1{thread_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/threads/methods/get' + insert: + - $ref: '#/components/x-stackQL-resources/threads/methods/create' + update: + - $ref: '#/components/x-stackQL-resources/threads/methods/update' + delete: + - $ref: '#/components/x-stackQL-resources/threads/methods/delete' + replace: [] + messages: + id: openai.assistants.messages + name: messages + title: Messages + methods: + list: + operation: + $ref: '#/paths/~1threads~1{thread_id}~1messages/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1threads~1{thread_id}~1messages/post' + response: + mediaType: application/json + openAPIDocKey: '200' + get: + operation: + $ref: '#/paths/~1threads~1{thread_id}~1messages~1{message_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + update: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1threads~1{thread_id}~1messages~1{message_id}/post' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1threads~1{thread_id}~1messages~1{message_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/messages/methods/get' + - $ref: '#/components/x-stackQL-resources/messages/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/messages/methods/create' + update: + - $ref: '#/components/x-stackQL-resources/messages/methods/update' + delete: + - $ref: '#/components/x-stackQL-resources/messages/methods/delete' + replace: [] + runs: + id: openai.assistants.runs + name: runs + title: Runs + methods: + list: + operation: + $ref: '#/paths/~1threads~1{thread_id}~1runs/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1threads~1{thread_id}~1runs/post' + response: + mediaType: application/json + openAPIDocKey: '200' + get: + operation: + $ref: '#/paths/~1threads~1{thread_id}~1runs~1{run_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + update: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1threads~1{thread_id}~1runs~1{run_id}/post' + response: + mediaType: application/json + openAPIDocKey: '200' + cancel: + operation: + $ref: '#/paths/~1threads~1{thread_id}~1runs~1{run_id}~1cancel/post' + response: + mediaType: application/json + openAPIDocKey: '200' + submit_tool_outputs: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: >- + #/paths/~1threads~1{thread_id}~1runs~1{run_id}~1submit_tool_outputs/post + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/runs/methods/get' + - $ref: '#/components/x-stackQL-resources/runs/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/runs/methods/create' + update: + - $ref: '#/components/x-stackQL-resources/runs/methods/update' + delete: [] + replace: [] + run_steps: + id: openai.assistants.run_steps + name: run_steps + title: Run Steps + methods: + list: + operation: + $ref: '#/paths/~1threads~1{thread_id}~1runs~1{run_id}~1steps/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + get: + operation: + $ref: >- + #/paths/~1threads~1{thread_id}~1runs~1{run_id}~1steps~1{step_id}/get + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/run_steps/methods/get' + - $ref: '#/components/x-stackQL-resources/run_steps/methods/list' + insert: [] + update: [] + delete: [] + replace: [] +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.last_id + location: body + queryParamPushdown: + top: + paramName: limit + maxValue: 100 diff --git a/providers/src/openai/v00.00.00000/services/audio.yaml b/providers/src/openai/v00.00.00000/services/audio.yaml deleted file mode 100644 index d1baafbe..00000000 --- a/providers/src/openai/v00.00.00000/services/audio.yaml +++ /dev/null @@ -1,736 +0,0 @@ -openapi: 3.0.0 -servers: - - url: 'https://api.openai.com/v1' -info: - version: 2.3.0 - termsOfService: 'https://openai.com/policies/terms-of-use' - contact: - name: OpenAI Support - url: 'https://help.openai.com/' - license: - name: MIT - url: 'https://github.com/openai/openai-openapi/blob/master/LICENSE' - title: OpenAI API - audio - description: Turn audio into text or text into audio. -security: - - ApiKeyAuth: [] -tags: - - name: Assistants - description: Build Assistants that can call models and use tools. - - name: Audio - description: Turn audio into text or text into audio. - - name: Chat - description: 'Given a list of messages comprising a conversation, the model will return a response.' - - name: Completions - description: 'Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.' - - name: Embeddings - description: Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. - - name: Fine-tuning - description: Manage fine-tuning jobs to tailor a model to your specific training data. - - name: Batch - description: Create large batches of API requests to run asynchronously. - - name: Files - description: Files are used to upload documents that can be used with features like Assistants and Fine-tuning. - - name: Uploads - description: Use Uploads to upload large files in multiple parts. - - name: Images - description: 'Given a prompt and/or an input image, the model will generate a new image.' - - name: Models - description: List and describe the various models available in the API. - - name: Moderations - description: 'Given text and/or image inputs, classifies if those inputs are potentially harmful.' - - name: Audit Logs - description: List user actions and configuration changes within this organization. -components: - schemas: - CreateSpeechRequest: - type: object - additionalProperties: false - properties: - model: - description: | - One of the available [TTS models](/docs/models/tts): `tts-1` or `tts-1-hd` - anyOf: - - type: string - - type: string - enum: - - tts-1 - - tts-1-hd - x-oaiTypeLabel: string - input: - type: string - description: The text to generate audio for. The maximum length is 4096 characters. - maxLength: 4096 - voice: - description: 'The voice to use when generating the audio. Supported voices are `alloy`, `echo`, `fable`, `onyx`, `nova`, and `shimmer`. Previews of the voices are available in the [Text to speech guide](/docs/guides/text-to-speech/voice-options).' - type: string - enum: - - alloy - - echo - - fable - - onyx - - nova - - shimmer - response_format: - description: 'The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.' - default: mp3 - type: string - enum: - - mp3 - - opus - - aac - - flac - - wav - - pcm - speed: - description: The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default. - type: number - default: 1 - minimum: 0.25 - maximum: 4 - required: - - model - - input - - voice - CreateTranscriptionRequest: - type: object - additionalProperties: false - properties: - file: - description: | - The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. - type: string - x-oaiTypeLabel: file - format: binary - model: - description: | - ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available. - example: whisper-1 - anyOf: - - type: string - - type: string - enum: - - whisper-1 - x-oaiTypeLabel: string - language: - description: | - The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency. - type: string - prompt: - description: | - An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language. - type: string - response_format: - $ref: '#/components/schemas/AudioResponseFormat' - temperature: - description: | - The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. - type: number - default: 0 - 'timestamp_granularities[]': - description: | - The timestamp granularities to populate for this transcription. `response_format` must be set `verbose_json` to use timestamp granularities. Either or both of these options are supported: `word`, or `segment`. Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency. - type: array - items: - type: string - enum: - - word - - segment - default: - - segment - required: - - file - - model - CreateTranscriptionResponseJson: - type: object - description: 'Represents a transcription response returned by model, based on the provided input.' - properties: - text: - type: string - description: The transcribed text. - required: - - text - x-oaiMeta: - name: The transcription object (JSON) - group: audio - example: | - { - "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." - } - CreateTranscriptionResponseVerboseJson: - type: object - description: 'Represents a verbose json transcription response returned by model, based on the provided input.' - properties: - language: - type: string - description: The language of the input audio. - duration: - type: string - description: The duration of the input audio. - text: - type: string - description: The transcribed text. - words: - type: array - description: Extracted words and their corresponding timestamps. - items: - $ref: '#/components/schemas/TranscriptionWord' - segments: - type: array - description: Segments of the transcribed text and their corresponding details. - items: - $ref: '#/components/schemas/TranscriptionSegment' - required: - - language - - duration - - text - x-oaiMeta: - name: The transcription object (Verbose JSON) - group: audio - example: | - { - "task": "transcribe", - "language": "english", - "duration": 8.470000267028809, - "text": "The beach was a popular spot on a hot summer day. People were swimming in the ocean, building sandcastles, and playing beach volleyball.", - "segments": [ - { - "id": 0, - "seek": 0, - "start": 0.0, - "end": 3.319999933242798, - "text": " The beach was a popular spot on a hot summer day.", - "tokens": [ - 50364, 440, 7534, 390, 257, 3743, 4008, 322, 257, 2368, 4266, 786, 13, 50530 - ], - "temperature": 0.0, - "avg_logprob": -0.2860786020755768, - "compression_ratio": 1.2363636493682861, - "no_speech_prob": 0.00985979475080967 - }, - ... - ] - } - AudioResponseFormat: - description: | - The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`. - type: string - enum: - - json - - text - - srt - - verbose_json - - vtt - default: json - TranscriptionWord: - type: object - properties: - word: - type: string - description: The text content of the word. - start: - type: number - format: float - description: Start time of the word in seconds. - end: - type: number - format: float - description: End time of the word in seconds. - required: - - word - - start - - end - TranscriptionSegment: - type: object - properties: - id: - type: integer - description: Unique identifier of the segment. - seek: - type: integer - description: Seek offset of the segment. - start: - type: number - format: float - description: Start time of the segment in seconds. - end: - type: number - format: float - description: End time of the segment in seconds. - text: - type: string - description: Text content of the segment. - tokens: - type: array - items: - type: integer - description: Array of token IDs for the text content. - temperature: - type: number - format: float - description: Temperature parameter used for generating the segment. - avg_logprob: - type: number - format: float - description: 'Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.' - compression_ratio: - type: number - format: float - description: 'Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.' - no_speech_prob: - type: number - format: float - description: 'Probability of no speech in the segment. If the value is higher than 1.0 and the `avg_logprob` is below -1, consider this segment silent.' - required: - - id - - seek - - start - - end - - text - - tokens - - temperature - - avg_logprob - - compression_ratio - - no_speech_prob - CreateTranslationRequest: - type: object - additionalProperties: false - properties: - file: - description: | - The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. - type: string - x-oaiTypeLabel: file - format: binary - model: - description: | - ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available. - example: whisper-1 - anyOf: - - type: string - - type: string - enum: - - whisper-1 - x-oaiTypeLabel: string - prompt: - description: | - An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English. - type: string - response_format: - $ref: '#/components/schemas/AudioResponseFormat' - temperature: - description: | - The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. - type: number - default: 0 - required: - - file - - model - CreateTranslationResponseJson: - type: object - properties: - text: - type: string - required: - - text - CreateTranslationResponseVerboseJson: - type: object - properties: - language: - type: string - description: The language of the output translation (always `english`). - duration: - type: string - description: The duration of the input audio. - text: - type: string - description: The translated text. - segments: - type: array - description: Segments of the translated text and their corresponding details. - items: - $ref: '#/components/schemas/TranscriptionSegment' - required: - - language - - duration - - text - responses: {} - securitySchemes: - ApiKeyAuth: - type: http - scheme: bearer - x-stackQL-resources: - speeches: - id: openai.audio.speeches - name: speeches - title: Speeches - methods: - create_speech: - operation: - $ref: '#/paths/~1audio~1speech/post' - response: - mediaType: application/json - openAPIDocKey: '200' - sqlVerbs: - select: [] - insert: - - $ref: '#/components/x-stackQL-resources/speeches/methods/create_speech' - update: [] - replace: [] - delete: [] - transcriptions: - id: openai.audio.transcriptions - name: transcriptions - title: Transcriptions - methods: - create_transcription: - operation: - $ref: '#/paths/~1audio~1transcriptions/post' - response: - mediaType: application/json - openAPIDocKey: '200' - sqlVerbs: - select: [] - insert: - - $ref: '#/components/x-stackQL-resources/transcriptions/methods/create_transcription' - update: [] - replace: [] - delete: [] - translations: - id: openai.audio.translations - name: translations - title: Translations - methods: - create_translation: - operation: - $ref: '#/paths/~1audio~1translations/post' - response: - mediaType: application/json - openAPIDocKey: '200' - sqlVerbs: - select: [] - insert: - - $ref: '#/components/x-stackQL-resources/translations/methods/create_translation' - update: [] - replace: [] - delete: [] -paths: - /audio/speech: - post: - operationId: createSpeech - tags: - - Audio - summary: Generates audio from the input text. - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CreateSpeechRequest' - responses: - '200': - description: OK - headers: - Transfer-Encoding: - schema: - type: string - description: chunked - content: - application/octet-stream: - schema: - type: string - format: binary - x-oaiMeta: - name: Create speech - group: audio - returns: The audio file content. - examples: - request: - curl: | - curl https://api.openai.com/v1/audio/speech \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -d '{ - "model": "tts-1", - "input": "The quick brown fox jumped over the lazy dog.", - "voice": "alloy" - }' \ - --output speech.mp3 - python: | - from pathlib import Path - import openai - - speech_file_path = Path(__file__).parent / "speech.mp3" - response = openai.audio.speech.create( - model="tts-1", - voice="alloy", - input="The quick brown fox jumped over the lazy dog." - ) - response.stream_to_file(speech_file_path) - node: | - import fs from "fs"; - import path from "path"; - import OpenAI from "openai"; - - const openai = new OpenAI(); - - const speechFile = path.resolve("./speech.mp3"); - - async function main() { - const mp3 = await openai.audio.speech.create({ - model: "tts-1", - voice: "alloy", - input: "Today is a wonderful day to build something people love!", - }); - console.log(speechFile); - const buffer = Buffer.from(await mp3.arrayBuffer()); - await fs.promises.writeFile(speechFile, buffer); - } - main(); - /audio/transcriptions: - post: - operationId: createTranscription - tags: - - Audio - summary: Transcribes audio into the input language. - requestBody: - required: true - content: - multipart/form-data: - schema: - $ref: '#/components/schemas/CreateTranscriptionRequest' - responses: - '200': - description: OK - content: - application/json: - schema: - oneOf: - - $ref: '#/components/schemas/CreateTranscriptionResponseJson' - - $ref: '#/components/schemas/CreateTranscriptionResponseVerboseJson' - x-oaiMeta: - name: Create transcription - group: audio - returns: 'The [transcription object](/docs/api-reference/audio/json-object) or a [verbose transcription object](/docs/api-reference/audio/verbose-json-object).' - examples: - - title: Default - request: - curl: | - curl https://api.openai.com/v1/audio/transcriptions \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: multipart/form-data" \ - -F file="@/path/to/file/audio.mp3" \ - -F model="whisper-1" - python: | - from openai import OpenAI - client = OpenAI() - - audio_file = open("speech.mp3", "rb") - transcript = client.audio.transcriptions.create( - model="whisper-1", - file=audio_file - ) - node: | - import fs from "fs"; - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const transcription = await openai.audio.transcriptions.create({ - file: fs.createReadStream("audio.mp3"), - model: "whisper-1", - }); - - console.log(transcription.text); - } - main(); - response: | - { - "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." - } - - title: Word timestamps - request: - curl: | - curl https://api.openai.com/v1/audio/transcriptions \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: multipart/form-data" \ - -F file="@/path/to/file/audio.mp3" \ - -F "timestamp_granularities[]=word" \ - -F model="whisper-1" \ - -F response_format="verbose_json" - python: | - from openai import OpenAI - client = OpenAI() - - audio_file = open("speech.mp3", "rb") - transcript = client.audio.transcriptions.create( - file=audio_file, - model="whisper-1", - response_format="verbose_json", - timestamp_granularities=["word"] - ) - - print(transcript.words) - node: | - import fs from "fs"; - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const transcription = await openai.audio.transcriptions.create({ - file: fs.createReadStream("audio.mp3"), - model: "whisper-1", - response_format: "verbose_json", - timestamp_granularities: ["word"] - }); - - console.log(transcription.text); - } - main(); - response: | - { - "task": "transcribe", - "language": "english", - "duration": 8.470000267028809, - "text": "The beach was a popular spot on a hot summer day. People were swimming in the ocean, building sandcastles, and playing beach volleyball.", - "words": [ - { - "word": "The", - "start": 0.0, - "end": 0.23999999463558197 - }, - ... - { - "word": "volleyball", - "start": 7.400000095367432, - "end": 7.900000095367432 - } - ] - } - - title: Segment timestamps - request: - curl: | - curl https://api.openai.com/v1/audio/transcriptions \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: multipart/form-data" \ - -F file="@/path/to/file/audio.mp3" \ - -F "timestamp_granularities[]=segment" \ - -F model="whisper-1" \ - -F response_format="verbose_json" - python: | - from openai import OpenAI - client = OpenAI() - - audio_file = open("speech.mp3", "rb") - transcript = client.audio.transcriptions.create( - file=audio_file, - model="whisper-1", - response_format="verbose_json", - timestamp_granularities=["segment"] - ) - - print(transcript.words) - node: | - import fs from "fs"; - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const transcription = await openai.audio.transcriptions.create({ - file: fs.createReadStream("audio.mp3"), - model: "whisper-1", - response_format: "verbose_json", - timestamp_granularities: ["segment"] - }); - - console.log(transcription.text); - } - main(); - response: | - { - "task": "transcribe", - "language": "english", - "duration": 8.470000267028809, - "text": "The beach was a popular spot on a hot summer day. People were swimming in the ocean, building sandcastles, and playing beach volleyball.", - "segments": [ - { - "id": 0, - "seek": 0, - "start": 0.0, - "end": 3.319999933242798, - "text": " The beach was a popular spot on a hot summer day.", - "tokens": [ - 50364, 440, 7534, 390, 257, 3743, 4008, 322, 257, 2368, 4266, 786, 13, 50530 - ], - "temperature": 0.0, - "avg_logprob": -0.2860786020755768, - "compression_ratio": 1.2363636493682861, - "no_speech_prob": 0.00985979475080967 - }, - ... - ] - } - /audio/translations: - post: - operationId: createTranslation - tags: - - Audio - summary: Translates audio into English. - requestBody: - required: true - content: - multipart/form-data: - schema: - $ref: '#/components/schemas/CreateTranslationRequest' - responses: - '200': - description: OK - content: - application/json: - schema: - oneOf: - - $ref: '#/components/schemas/CreateTranslationResponseJson' - - $ref: '#/components/schemas/CreateTranslationResponseVerboseJson' - x-oaiMeta: - name: Create translation - group: audio - returns: The translated text. - examples: - request: - curl: | - curl https://api.openai.com/v1/audio/translations \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: multipart/form-data" \ - -F file="@/path/to/file/german.m4a" \ - -F model="whisper-1" - python: | - from openai import OpenAI - client = OpenAI() - - audio_file = open("speech.mp3", "rb") - transcript = client.audio.translations.create( - model="whisper-1", - file=audio_file - ) - node: | - import fs from "fs"; - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const translation = await openai.audio.translations.create({ - file: fs.createReadStream("speech.mp3"), - model: "whisper-1", - }); - - console.log(translation.text); - } - main(); - response: | - { - "text": "Hello, my name is Wolfgang and I come from Germany. Where are you heading today?" - } diff --git a/providers/src/openai/v00.00.00000/services/audit_logs.yaml b/providers/src/openai/v00.00.00000/services/audit_logs.yaml deleted file mode 100644 index a0db372d..00000000 --- a/providers/src/openai/v00.00.00000/services/audit_logs.yaml +++ /dev/null @@ -1,614 +0,0 @@ -openapi: 3.0.0 -servers: - - url: 'https://api.openai.com/v1' -info: - version: 2.3.0 - termsOfService: 'https://openai.com/policies/terms-of-use' - contact: - name: OpenAI Support - url: 'https://help.openai.com/' - license: - name: MIT - url: 'https://github.com/openai/openai-openapi/blob/master/LICENSE' - title: OpenAI API - audit_logs - description: List user actions and configuration changes within this organization. -security: - - ApiKeyAuth: [] -tags: - - name: Assistants - description: Build Assistants that can call models and use tools. - - name: Audio - description: Turn audio into text or text into audio. - - name: Chat - description: 'Given a list of messages comprising a conversation, the model will return a response.' - - name: Completions - description: 'Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.' - - name: Embeddings - description: Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. - - name: Fine-tuning - description: Manage fine-tuning jobs to tailor a model to your specific training data. - - name: Batch - description: Create large batches of API requests to run asynchronously. - - name: Files - description: Files are used to upload documents that can be used with features like Assistants and Fine-tuning. - - name: Uploads - description: Use Uploads to upload large files in multiple parts. - - name: Images - description: 'Given a prompt and/or an input image, the model will generate a new image.' - - name: Models - description: List and describe the various models available in the API. - - name: Moderations - description: 'Given text and/or image inputs, classifies if those inputs are potentially harmful.' - - name: Audit Logs - description: List user actions and configuration changes within this organization. -components: - schemas: - AuditLogEventType: - type: string - description: The event type. - x-oaiExpandable: true - enum: - - api_key.created - - api_key.updated - - api_key.deleted - - invite.sent - - invite.accepted - - invite.deleted - - login.succeeded - - login.failed - - logout.succeeded - - logout.failed - - organization.updated - - project.created - - project.updated - - project.archived - - service_account.created - - service_account.updated - - service_account.deleted - - user.added - - user.updated - - user.deleted - ListAuditLogsResponse: - type: object - properties: - object: - type: string - enum: - - list - data: - type: array - items: - $ref: '#/components/schemas/AuditLog' - first_id: - type: string - example: audit_log-defb456h8dks - last_id: - type: string - example: audit_log-hnbkd8s93s - has_more: - type: boolean - required: - - object - - data - - first_id - - last_id - - has_more - AuditLog: - type: object - description: A log of a user action or configuration change within this organization. - properties: - id: - type: string - description: The ID of this log. - type: - $ref: '#/components/schemas/AuditLogEventType' - effective_at: - type: integer - description: The Unix timestamp (in seconds) of the event. - project: - type: object - description: The project that the action was scoped to. Absent for actions not scoped to projects. - properties: - id: - type: string - description: The project ID. - name: - type: string - description: The project title. - actor: - $ref: '#/components/schemas/AuditLogActor' - api_key.created: - type: object - description: The details for events with this `type`. - properties: - id: - type: string - description: The tracking ID of the API key. - data: - type: object - description: The payload used to create the API key. - properties: - scopes: - type: array - items: - type: string - description: 'A list of scopes allowed for the API key, e.g. `["api.model.request"]`' - api_key.updated: - type: object - description: The details for events with this `type`. - properties: - id: - type: string - description: The tracking ID of the API key. - changes_requested: - type: object - description: The payload used to update the API key. - properties: - scopes: - type: array - items: - type: string - description: 'A list of scopes allowed for the API key, e.g. `["api.model.request"]`' - api_key.deleted: - type: object - description: The details for events with this `type`. - properties: - id: - type: string - description: The tracking ID of the API key. - invite.sent: - type: object - description: The details for events with this `type`. - properties: - id: - type: string - description: The ID of the invite. - data: - type: object - description: The payload used to create the invite. - properties: - email: - type: string - description: The email invited to the organization. - role: - type: string - description: The role the email was invited to be. Is either `owner` or `member`. - invite.accepted: - type: object - description: The details for events with this `type`. - properties: - id: - type: string - description: The ID of the invite. - invite.deleted: - type: object - description: The details for events with this `type`. - properties: - id: - type: string - description: The ID of the invite. - login.failed: - type: object - description: The details for events with this `type`. - properties: - error_code: - type: string - description: The error code of the failure. - error_message: - type: string - description: The error message of the failure. - logout.failed: - type: object - description: The details for events with this `type`. - properties: - error_code: - type: string - description: The error code of the failure. - error_message: - type: string - description: The error message of the failure. - organization.updated: - type: object - description: The details for events with this `type`. - properties: - id: - type: string - description: The organization ID. - changes_requested: - type: object - description: The payload used to update the organization settings. - properties: - title: - type: string - description: The organization title. - description: - type: string - description: The organization description. - name: - type: string - description: The organization name. - settings: - type: object - properties: - threads_ui_visibility: - type: string - description: 'Visibility of the threads page which shows messages created with the Assistants API and Playground. One of `ANY_ROLE`, `OWNERS`, or `NONE`.' - usage_dashboard_visibility: - type: string - description: Visibility of the usage dashboard which shows activity and costs for your organization. One of `ANY_ROLE` or `OWNERS`. - project.created: - type: object - description: The details for events with this `type`. - properties: - id: - type: string - description: The project ID. - data: - type: object - description: The payload used to create the project. - properties: - name: - type: string - description: The project name. - title: - type: string - description: The title of the project as seen on the dashboard. - project.updated: - type: object - description: The details for events with this `type`. - properties: - id: - type: string - description: The project ID. - changes_requested: - type: object - description: The payload used to update the project. - properties: - title: - type: string - description: The title of the project as seen on the dashboard. - project.archived: - type: object - description: The details for events with this `type`. - properties: - id: - type: string - description: The project ID. - service_account.created: - type: object - description: The details for events with this `type`. - properties: - id: - type: string - description: The service account ID. - data: - type: object - description: The payload used to create the service account. - properties: - role: - type: string - description: The role of the service account. Is either `owner` or `member`. - service_account.updated: - type: object - description: The details for events with this `type`. - properties: - id: - type: string - description: The service account ID. - changes_requested: - type: object - description: The payload used to updated the service account. - properties: - role: - type: string - description: The role of the service account. Is either `owner` or `member`. - service_account.deleted: - type: object - description: The details for events with this `type`. - properties: - id: - type: string - description: The service account ID. - user.added: - type: object - description: The details for events with this `type`. - properties: - id: - type: string - description: The user ID. - data: - type: object - description: The payload used to add the user to the project. - properties: - role: - type: string - description: The role of the user. Is either `owner` or `member`. - user.updated: - type: object - description: The details for events with this `type`. - properties: - id: - type: string - description: The project ID. - changes_requested: - type: object - description: The payload used to update the user. - properties: - role: - type: string - description: The role of the user. Is either `owner` or `member`. - user.deleted: - type: object - description: The details for events with this `type`. - properties: - id: - type: string - description: The user ID. - required: - - id - - type - - effective_at - - actor - x-oaiMeta: - name: The audit log object - example: | - { - "id": "req_xxx_20240101", - "type": "api_key.created", - "effective_at": 1720804090, - "actor": { - "type": "session", - "session": { - "user": { - "id": "user-xxx", - "email": "user@example.com" - }, - "ip_address": "127.0.0.1", - "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" - } - }, - "api_key.created": { - "id": "key_xxxx", - "data": { - "scopes": ["resource.operation"] - } - } - } - AuditLogActor: - type: object - description: The actor who performed the audit logged action. - properties: - type: - type: string - description: The type of actor. Is either `session` or `api_key`. - enum: - - session - - api_key - session: - type: object - $ref: '#/components/schemas/AuditLogActorSession' - api_key: - type: object - $ref: '#/components/schemas/AuditLogActorApiKey' - AuditLogActorSession: - type: object - description: The session in which the audit logged action was performed. - properties: - user: - $ref: '#/components/schemas/AuditLogActorUser' - ip_address: - type: string - description: The IP address from which the action was performed. - AuditLogActorApiKey: - type: object - description: The API Key used to perform the audit logged action. - properties: - id: - type: string - description: The tracking id of the API key. - type: - type: string - description: The type of API key. Can be either `user` or `service_account`. - enum: - - user - - service_account - user: - $ref: '#/components/schemas/AuditLogActorUser' - service_account: - $ref: '#/components/schemas/AuditLogActorServiceAccount' - AuditLogActorUser: - type: object - description: The user who performed the audit logged action. - properties: - id: - type: string - description: The user id. - email: - type: string - description: The user email. - AuditLogActorServiceAccount: - type: object - description: The service account that performed the audit logged action. - properties: - id: - type: string - description: The service account id. - responses: {} - securitySchemes: - ApiKeyAuth: - type: http - scheme: bearer - x-stackQL-resources: - audit_logs: - id: openai.audit_logs.audit_logs - name: audit_logs - title: Audit Logs - methods: - list_audit_logs: - operation: - $ref: '#/paths/~1organization~1audit_logs/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ListAuditLogsResponse' - objectKey: $.data - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/audit_logs/methods/list_audit_logs' - insert: [] - update: [] - replace: [] - delete: [] -paths: - /organization/audit_logs: - get: - summary: List user actions and configuration changes within this organization. - operationId: list-audit-logs - tags: - - Audit Logs - parameters: - - name: effective_at - in: query - description: Return only events whose `effective_at` (Unix seconds) is in this range. - required: false - schema: - type: object - properties: - gt: - type: integer - description: Return only events whose `effective_at` (Unix seconds) is greater than this value. - gte: - type: integer - description: Return only events whose `effective_at` (Unix seconds) is greater than or equal to this value. - lt: - type: integer - description: Return only events whose `effective_at` (Unix seconds) is less than this value. - lte: - type: integer - description: Return only events whose `effective_at` (Unix seconds) is less than or equal to this value. - - name: 'project_ids[]' - in: query - description: Return only events for these projects. - required: false - schema: - type: array - items: - type: string - - name: 'event_types[]' - in: query - description: 'Return only events with a `type` in one of these values. For example, `project.created`. For all options, see the documentation for the [audit log object](/docs/api-reference/audit-logs/object).' - required: false - schema: - type: array - items: - $ref: '#/components/schemas/AuditLogEventType' - - name: 'actor_ids[]' - in: query - description: 'Return only events performed by these actors. Can be a user ID, a service account ID, or an api key tracking ID.' - required: false - schema: - type: array - items: - type: string - - name: 'actor_emails[]' - in: query - description: Return only events performed by users with these emails. - required: false - schema: - type: array - items: - type: string - - name: 'resource_ids[]' - in: query - description: 'Return only events performed on these targets. For example, a project ID updated.' - required: false - schema: - type: array - items: - type: string - - name: limit - in: query - description: | - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - required: false - schema: - type: integer - default: 20 - - name: after - in: query - 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 - - name: before - in: query - 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, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - schema: - type: string - responses: - '200': - description: Audit logs listed successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/ListAuditLogsResponse' - x-oaiMeta: - name: List audit logs - group: audit-logs - returns: 'A list of paginated [Audit Log](/docs/api-reference/audit-logs/object) objects.' - examples: - request: - curl: | - curl https://api.openai.com/v1/organization/audit_logs \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" \ - response: | - { - "object": "list", - "data": [ - { - "id": "audit_log-xxx_yyyymmdd", - "type": "project.archived", - "effective_at": 1722461446, - "actor": { - "type": "api_key", - "api_key": { - "type": "user", - "user": { - "id": "user-xxx", - "email": "user@example.com" - } - } - }, - "project.archived": { - "id": "proj_abc" - }, - }, - { - "id": "audit_log-yyy__20240101", - "type": "api_key.updated", - "effective_at": 1720804190, - "actor": { - "type": "session", - "session": { - "user": { - "id": "user-xxx", - "email": "user@example.com" - }, - "ip_address": "127.0.0.1", - "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" - } - }, - "api_key.updated": { - "id": "key_xxxx", - "data": { - "scopes": ["resource_2.operation_2"] - } - }, - } - ], - "first_id": "audit_log-xxx__20240101", - "last_id": "audit_log_yyy__20240101", - "has_more": true - } diff --git a/providers/src/openai/v00.00.00000/services/batch.yaml b/providers/src/openai/v00.00.00000/services/batch.yaml deleted file mode 100644 index b196e4a0..00000000 --- a/providers/src/openai/v00.00.00000/services/batch.yaml +++ /dev/null @@ -1,641 +0,0 @@ -openapi: 3.0.0 -servers: - - url: 'https://api.openai.com/v1' -info: - version: 2.3.0 - termsOfService: 'https://openai.com/policies/terms-of-use' - contact: - name: OpenAI Support - url: 'https://help.openai.com/' - license: - name: MIT - url: 'https://github.com/openai/openai-openapi/blob/master/LICENSE' - title: OpenAI API - batch - description: Create large batches of API requests to run asynchronously. -security: - - ApiKeyAuth: [] -tags: - - name: Assistants - description: Build Assistants that can call models and use tools. - - name: Audio - description: Turn audio into text or text into audio. - - name: Chat - description: 'Given a list of messages comprising a conversation, the model will return a response.' - - name: Completions - description: 'Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.' - - name: Embeddings - description: Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. - - name: Fine-tuning - description: Manage fine-tuning jobs to tailor a model to your specific training data. - - name: Batch - description: Create large batches of API requests to run asynchronously. - - name: Files - description: Files are used to upload documents that can be used with features like Assistants and Fine-tuning. - - name: Uploads - description: Use Uploads to upload large files in multiple parts. - - name: Images - description: 'Given a prompt and/or an input image, the model will generate a new image.' - - name: Models - description: List and describe the various models available in the API. - - name: Moderations - description: 'Given text and/or image inputs, classifies if those inputs are potentially harmful.' - - name: Audit Logs - description: List user actions and configuration changes within this organization. -components: - schemas: - Batch: - type: object - properties: - id: - type: string - object: - type: string - enum: - - batch - description: 'The object type, which is always `batch`.' - endpoint: - type: string - description: The OpenAI API endpoint used by the batch. - errors: - type: object - properties: - object: - type: string - description: 'The object type, which is always `list`.' - data: - type: array - items: - type: object - properties: - code: - type: string - description: An error code identifying the error type. - message: - type: string - description: A human-readable message providing more details about the error. - param: - type: string - description: 'The name of the parameter that caused the error, if applicable.' - nullable: true - line: - type: integer - description: 'The line number of the input file where the error occurred, if applicable.' - nullable: true - input_file_id: - type: string - description: The ID of the input file for the batch. - completion_window: - type: string - description: The time frame within which the batch should be processed. - status: - type: string - description: The current status of the batch. - enum: - - validating - - failed - - in_progress - - finalizing - - completed - - expired - - cancelling - - cancelled - output_file_id: - type: string - description: The ID of the file containing the outputs of successfully executed requests. - error_file_id: - type: string - description: The ID of the file containing the outputs of requests with errors. - created_at: - type: integer - description: The Unix timestamp (in seconds) for when the batch was created. - in_progress_at: - type: integer - description: The Unix timestamp (in seconds) for when the batch started processing. - expires_at: - type: integer - description: The Unix timestamp (in seconds) for when the batch will expire. - finalizing_at: - type: integer - description: The Unix timestamp (in seconds) for when the batch started finalizing. - completed_at: - type: integer - description: The Unix timestamp (in seconds) for when the batch was completed. - failed_at: - type: integer - description: The Unix timestamp (in seconds) for when the batch failed. - expired_at: - type: integer - description: The Unix timestamp (in seconds) for when the batch expired. - cancelling_at: - type: integer - description: The Unix timestamp (in seconds) for when the batch started cancelling. - cancelled_at: - type: integer - description: The Unix timestamp (in seconds) for when the batch was cancelled. - request_counts: - type: object - properties: - total: - type: integer - description: Total number of requests in the batch. - completed: - type: integer - description: Number of requests that have been completed successfully. - failed: - type: integer - description: Number of requests that have failed. - required: - - total - - completed - - failed - description: The request counts for different statuses within the batch. - metadata: - description: | - Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true - required: - - id - - object - - endpoint - - input_file_id - - completion_window - - status - - created_at - x-oaiMeta: - name: The batch object - example: | - { - "id": "batch_abc123", - "object": "batch", - "endpoint": "/v1/completions", - "errors": null, - "input_file_id": "file-abc123", - "completion_window": "24h", - "status": "completed", - "output_file_id": "file-cvaTdG", - "error_file_id": "file-HOWS94", - "created_at": 1711471533, - "in_progress_at": 1711471538, - "expires_at": 1711557933, - "finalizing_at": 1711493133, - "completed_at": 1711493163, - "failed_at": null, - "expired_at": null, - "cancelling_at": null, - "cancelled_at": null, - "request_counts": { - "total": 100, - "completed": 95, - "failed": 5 - }, - "metadata": { - "customer_id": "user_123456789", - "batch_description": "Nightly eval job", - } - } - ListBatchesResponse: - type: object - properties: - data: - type: array - items: - $ref: '#/components/schemas/Batch' - first_id: - type: string - example: batch_abc123 - last_id: - type: string - example: batch_abc456 - has_more: - type: boolean - object: - type: string - enum: - - list - required: - - object - - data - - has_more - responses: {} - securitySchemes: - ApiKeyAuth: - type: http - scheme: bearer - x-stackQL-resources: - batches: - id: openai.batch.batches - name: batches - title: Batches - methods: - create_batch: - operation: - $ref: '#/paths/~1batches/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/Batch' - list_batches: - operation: - $ref: '#/paths/~1batches/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ListBatchesResponse' - objectKey: $.data - retrieve_batch: - operation: - $ref: '#/paths/~1batches~1{batch_id}/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/Batch' - cancel_batch: - operation: - $ref: '#/paths/~1batches~1{batch_id}~1cancel/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/Batch' - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/batches/methods/retrieve_batch' - - $ref: '#/components/x-stackQL-resources/batches/methods/list_batches' - insert: - - $ref: '#/components/x-stackQL-resources/batches/methods/create_batch' - update: [] - replace: [] - delete: [] -paths: - /batches: - post: - summary: Creates and executes a batch from an uploaded file of requests - operationId: createBatch - tags: - - Batch - requestBody: - required: true - content: - application/json: - schema: - type: object - required: - - input_file_id - - endpoint - - completion_window - properties: - input_file_id: - type: string - description: | - The ID of an uploaded file that contains requests for the new batch. - - See [upload file](/docs/api-reference/files/create) for how to upload a file. - - Your input file must be formatted as a [JSONL file](/docs/api-reference/batch/request-input), and must be uploaded with the purpose `batch`. The file can contain up to 50,000 requests, and can be up to 100 MB in size. - endpoint: - type: string - enum: - - /v1/chat/completions - - /v1/embeddings - - /v1/completions - description: 'The endpoint to be used for all requests in the batch. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch.' - completion_window: - type: string - enum: - - 24h - description: The time frame within which the batch should be processed. Currently only `24h` is supported. - metadata: - type: object - additionalProperties: - type: string - description: Optional custom metadata for the batch. - nullable: true - responses: - '200': - description: Batch created successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/Batch' - x-oaiMeta: - name: Create batch - group: batch - returns: 'The created [Batch](/docs/api-reference/batch/object) object.' - examples: - request: - curl: | - curl https://api.openai.com/v1/batches \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -d '{ - "input_file_id": "file-abc123", - "endpoint": "/v1/chat/completions", - "completion_window": "24h" - }' - python: | - from openai import OpenAI - client = OpenAI() - - client.batches.create( - input_file_id="file-abc123", - endpoint="/v1/chat/completions", - completion_window="24h" - ) - node: | - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const batch = await openai.batches.create({ - input_file_id: "file-abc123", - endpoint: "/v1/chat/completions", - completion_window: "24h" - }); - - console.log(batch); - } - - main(); - response: | - { - "id": "batch_abc123", - "object": "batch", - "endpoint": "/v1/chat/completions", - "errors": null, - "input_file_id": "file-abc123", - "completion_window": "24h", - "status": "validating", - "output_file_id": null, - "error_file_id": null, - "created_at": 1711471533, - "in_progress_at": null, - "expires_at": null, - "finalizing_at": null, - "completed_at": null, - "failed_at": null, - "expired_at": null, - "cancelling_at": null, - "cancelled_at": null, - "request_counts": { - "total": 0, - "completed": 0, - "failed": 0 - }, - "metadata": { - "customer_id": "user_123456789", - "batch_description": "Nightly eval job", - } - } - get: - operationId: listBatches - tags: - - Batch - summary: List your organization's batches. - parameters: - - in: query - name: after - required: false - schema: - type: string - 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. - - name: limit - in: query - description: | - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - required: false - schema: - type: integer - default: 20 - responses: - '200': - description: Batch listed successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/ListBatchesResponse' - x-oaiMeta: - name: List batch - group: batch - returns: 'A list of paginated [Batch](/docs/api-reference/batch/object) objects.' - examples: - request: - curl: | - curl https://api.openai.com/v1/batches?limit=2 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" - python: | - from openai import OpenAI - client = OpenAI() - - client.batches.list() - node: | - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const list = await openai.batches.list(); - - for await (const batch of list) { - console.log(batch); - } - } - - main(); - response: | - { - "object": "list", - "data": [ - { - "id": "batch_abc123", - "object": "batch", - "endpoint": "/v1/chat/completions", - "errors": null, - "input_file_id": "file-abc123", - "completion_window": "24h", - "status": "completed", - "output_file_id": "file-cvaTdG", - "error_file_id": "file-HOWS94", - "created_at": 1711471533, - "in_progress_at": 1711471538, - "expires_at": 1711557933, - "finalizing_at": 1711493133, - "completed_at": 1711493163, - "failed_at": null, - "expired_at": null, - "cancelling_at": null, - "cancelled_at": null, - "request_counts": { - "total": 100, - "completed": 95, - "failed": 5 - }, - "metadata": { - "customer_id": "user_123456789", - "batch_description": "Nightly job", - } - }, - { ... }, - ], - "first_id": "batch_abc123", - "last_id": "batch_abc456", - "has_more": true - } - '/batches/{batch_id}': - get: - operationId: retrieveBatch - tags: - - Batch - summary: Retrieves a batch. - parameters: - - in: path - name: batch_id - required: true - schema: - type: string - description: The ID of the batch to retrieve. - responses: - '200': - description: Batch retrieved successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/Batch' - x-oaiMeta: - name: Retrieve batch - group: batch - returns: 'The [Batch](/docs/api-reference/batch/object) object matching the specified ID.' - examples: - request: - curl: | - curl https://api.openai.com/v1/batches/batch_abc123 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - python: | - from openai import OpenAI - client = OpenAI() - - client.batches.retrieve("batch_abc123") - node: | - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const batch = await openai.batches.retrieve("batch_abc123"); - - console.log(batch); - } - - main(); - response: | - { - "id": "batch_abc123", - "object": "batch", - "endpoint": "/v1/completions", - "errors": null, - "input_file_id": "file-abc123", - "completion_window": "24h", - "status": "completed", - "output_file_id": "file-cvaTdG", - "error_file_id": "file-HOWS94", - "created_at": 1711471533, - "in_progress_at": 1711471538, - "expires_at": 1711557933, - "finalizing_at": 1711493133, - "completed_at": 1711493163, - "failed_at": null, - "expired_at": null, - "cancelling_at": null, - "cancelled_at": null, - "request_counts": { - "total": 100, - "completed": 95, - "failed": 5 - }, - "metadata": { - "customer_id": "user_123456789", - "batch_description": "Nightly eval job", - } - } - '/batches/{batch_id}/cancel': - post: - operationId: cancelBatch - tags: - - Batch - summary: 'Cancels an in-progress batch. The batch will be in status `cancelling` for up to 10 minutes, before changing to `cancelled`, where it will have partial results (if any) available in the output file.' - parameters: - - in: path - name: batch_id - required: true - schema: - type: string - description: The ID of the batch to cancel. - responses: - '200': - description: Batch is cancelling. Returns the cancelling batch's details. - content: - application/json: - schema: - $ref: '#/components/schemas/Batch' - x-oaiMeta: - name: Cancel batch - group: batch - returns: 'The [Batch](/docs/api-reference/batch/object) object matching the specified ID.' - examples: - request: - curl: | - curl https://api.openai.com/v1/batches/batch_abc123/cancel \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -X POST - python: | - from openai import OpenAI - client = OpenAI() - - client.batches.cancel("batch_abc123") - node: | - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const batch = await openai.batches.cancel("batch_abc123"); - - console.log(batch); - } - - main(); - response: | - { - "id": "batch_abc123", - "object": "batch", - "endpoint": "/v1/chat/completions", - "errors": null, - "input_file_id": "file-abc123", - "completion_window": "24h", - "status": "cancelling", - "output_file_id": null, - "error_file_id": null, - "created_at": 1711471533, - "in_progress_at": 1711471538, - "expires_at": 1711557933, - "finalizing_at": null, - "completed_at": null, - "failed_at": null, - "expired_at": null, - "cancelling_at": 1711475133, - "cancelled_at": null, - "request_counts": { - "total": 100, - "completed": 23, - "failed": 1 - }, - "metadata": { - "customer_id": "user_123456789", - "batch_description": "Nightly eval job", - } - } diff --git a/providers/src/openai/v00.00.00000/services/batches.yaml b/providers/src/openai/v00.00.00000/services/batches.yaml new file mode 100644 index 00000000..2e312579 --- /dev/null +++ b/providers/src/openai/v00.00.00000/services/batches.yaml @@ -0,0 +1,1029 @@ +openapi: 3.1.0 +info: + title: batches API + description: openai API + version: 2.3.0 +paths: + /batches: + post: + summary: Creates and executes a batch from an uploaded file of requests + operationId: createBatch + tags: + - Batch + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - input_file_id + - endpoint + - completion_window + properties: + input_file_id: + type: string + description: > + The ID of an uploaded file that contains requests for the + new batch. + + + See [upload file](/docs/api-reference/files/create) for how + to upload a file. + + + Your input file must be formatted as a [JSONL + file](/docs/api-reference/batch/request-input), and must be + uploaded with the purpose `batch`. The file can contain up + to 50,000 requests, and can be up to 200 MB in size. + endpoint: + type: string + enum: + - /v1/responses + - /v1/chat/completions + - /v1/embeddings + - /v1/completions + - /v1/moderations + - /v1/images/generations + - /v1/images/edits + - /v1/videos + description: >- + The endpoint to be used for all requests in the batch. + Currently `/v1/responses`, `/v1/chat/completions`, + `/v1/embeddings`, `/v1/completions`, `/v1/moderations`, + `/v1/images/generations`, `/v1/images/edits`, and + `/v1/videos` are supported. Note that `/v1/embeddings` + batches are also restricted to a maximum of 50,000 embedding + inputs across all requests in the batch. + completion_window: + type: string + enum: + - 24h + description: >- + The time frame within which the batch should be processed. + Currently only `24h` is supported. + metadata: + $ref: '#/components/schemas/Metadata' + output_expires_after: + $ref: '#/components/schemas/BatchFileExpirationAfter' + responses: + '200': + description: Batch created successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/Batch' + x-oaiMeta: + name: Create batch + group: batch + examples: + request: + curl: | + curl https://api.openai.com/v1/batches \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "input_file_id": "file-abc123", + "endpoint": "/v1/chat/completions", + "completion_window": "24h" + }' + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + batch = client.batches.create( + completion_window="24h", + endpoint="/v1/responses", + input_file_id="input_file_id", + ) + print(batch.id) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const batch = await openai.batches.create({ + input_file_id: "file-abc123", + endpoint: "/v1/chat/completions", + completion_window: "24h" + }); + + console.log(batch); + } + + main(); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const batch = await client.batches.create({ + completion_window: '24h', + endpoint: '/v1/responses', + input_file_id: 'input_file_id', + }); + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.batches.Batch; + import com.openai.models.batches.BatchCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + BatchCreateParams params = BatchCreateParams.builder() + .completionWindow(BatchCreateParams.CompletionWindow._24H) + .endpoint(BatchCreateParams.Endpoint.V1_RESPONSES) + .inputFileId("input_file_id") + .build(); + Batch batch = client.batches().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + batch = openai.batches.create( + completion_window: :"24h", + endpoint: :"/v1/responses", + input_file_id: "input_file_id" + ) + + puts(batch) + response: | + { + "id": "batch_abc123", + "object": "batch", + "endpoint": "/v1/chat/completions", + "errors": null, + "input_file_id": "file-abc123", + "completion_window": "24h", + "status": "validating", + "output_file_id": null, + "error_file_id": null, + "created_at": 1711471533, + "in_progress_at": null, + "expires_at": null, + "finalizing_at": null, + "completed_at": null, + "failed_at": null, + "expired_at": null, + "cancelling_at": null, + "cancelled_at": null, + "request_counts": { + "total": 0, + "completed": 0, + "failed": 0 + }, + "metadata": { + "customer_id": "user_123456789", + "batch_description": "Nightly eval job", + } + } + parameters: + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + get: + operationId: listBatches + tags: + - Batch + summary: List your organization's batches. + parameters: + - in: query + name: after + required: false + schema: + type: string + 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. + - name: limit + in: query + description: >- + A limit on the number of objects to be returned. Limit can range + between 1 and 100, and the default is 20. + + + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. + required: false + schema: + type: integer + default: 20 + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: Batch listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ListBatchesResponse' + x-oaiMeta: + name: List batches + group: batch + examples: + request: + curl: | + curl https://api.openai.com/v1/batches?limit=2 \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.batches.list() + page = page.data[0] + print(page.id) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const list = await openai.batches.list(); + + for await (const batch of list) { + console.log(batch); + } + } + + main(); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const batch of client.batches.list()) { + console.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\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.batches.BatchListPage; + import com.openai.models.batches.BatchListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + BatchListPage page = client.batches().list(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + page = openai.batches.list + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "id": "batch_abc123", + "object": "batch", + "endpoint": "/v1/chat/completions", + "errors": null, + "input_file_id": "file-abc123", + "completion_window": "24h", + "status": "completed", + "output_file_id": "file-cvaTdG", + "error_file_id": "file-HOWS94", + "created_at": 1711471533, + "in_progress_at": 1711471538, + "expires_at": 1711557933, + "finalizing_at": 1711493133, + "completed_at": 1711493163, + "failed_at": null, + "expired_at": null, + "cancelling_at": null, + "cancelled_at": null, + "request_counts": { + "total": 100, + "completed": 95, + "failed": 5 + }, + "metadata": { + "customer_id": "user_123456789", + "batch_description": "Nightly job", + } + }, + { ... }, + ], + "first_id": "batch_abc123", + "last_id": "batch_abc456", + "has_more": true + } + /batches/{batch_id}: + get: + operationId: retrieveBatch + tags: + - Batch + summary: Retrieves a batch. + parameters: + - in: path + name: batch_id + required: true + schema: + type: string + description: The ID of the batch to retrieve. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: Batch retrieved successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/Batch' + x-oaiMeta: + name: Retrieve batch + group: batch + examples: + request: + curl: | + curl https://api.openai.com/v1/batches/batch_abc123 \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + batch = client.batches.retrieve( + "batch_id", + ) + print(batch.id) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const batch = await openai.batches.retrieve("batch_abc123"); + + console.log(batch); + } + + main(); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const batch = await client.batches.retrieve('batch_id'); + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.batches.Batch; + import com.openai.models.batches.BatchRetrieveParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Batch batch = client.batches().retrieve("batch_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + batch = openai.batches.retrieve("batch_id") + + puts(batch) + response: | + { + "id": "batch_abc123", + "object": "batch", + "endpoint": "/v1/completions", + "errors": null, + "input_file_id": "file-abc123", + "completion_window": "24h", + "status": "completed", + "output_file_id": "file-cvaTdG", + "error_file_id": "file-HOWS94", + "created_at": 1711471533, + "in_progress_at": 1711471538, + "expires_at": 1711557933, + "finalizing_at": 1711493133, + "completed_at": 1711493163, + "failed_at": null, + "expired_at": null, + "cancelling_at": null, + "cancelled_at": null, + "request_counts": { + "total": 100, + "completed": 95, + "failed": 5 + }, + "metadata": { + "customer_id": "user_123456789", + "batch_description": "Nightly eval job", + } + } + /batches/{batch_id}/cancel: + post: + operationId: cancelBatch + tags: + - Batch + summary: >- + Cancels an in-progress batch. The batch will be in status `cancelling` + for up to 10 minutes, before changing to `cancelled`, where it will have + partial results (if any) available in the output file. + parameters: + - in: path + name: batch_id + required: true + schema: + type: string + description: The ID of the batch to cancel. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: Batch is cancelling. Returns the cancelling batch's details. + content: + application/json: + schema: + $ref: '#/components/schemas/Batch' + x-oaiMeta: + name: Cancel batch + group: batch + examples: + request: + curl: | + curl https://api.openai.com/v1/batches/batch_abc123/cancel \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -X POST + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + batch = client.batches.cancel( + "batch_id", + ) + print(batch.id) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const batch = await openai.batches.cancel("batch_abc123"); + + console.log(batch); + } + + main(); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const batch = await client.batches.cancel('batch_id'); + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.batches.Batch; + import com.openai.models.batches.BatchCancelParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Batch batch = client.batches().cancel("batch_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + batch = openai.batches.cancel("batch_id") + + puts(batch) + response: | + { + "id": "batch_abc123", + "object": "batch", + "endpoint": "/v1/chat/completions", + "errors": null, + "input_file_id": "file-abc123", + "completion_window": "24h", + "status": "cancelling", + "output_file_id": null, + "error_file_id": null, + "created_at": 1711471533, + "in_progress_at": 1711471538, + "expires_at": 1711557933, + "finalizing_at": null, + "completed_at": null, + "failed_at": null, + "expired_at": null, + "cancelling_at": 1711475133, + "cancelled_at": null, + "request_counts": { + "total": 100, + "completed": 23, + "failed": 1 + }, + "metadata": { + "customer_id": "user_123456789", + "batch_description": "Nightly eval job", + } + } +components: + schemas: + Metadata: + type: object + description: > + Set of 16 key-value pairs that can be attached to an object. This can be + + useful for storing additional information about the object in a + structured + + format, and querying for objects via API or the dashboard. + + + Keys are strings with a maximum length of 64 characters. Values are + strings + + with a maximum length of 512 characters. + additionalProperties: + type: string + x-oaiTypeLabel: map + BatchFileExpirationAfter: + type: object + title: File expiration policy + description: >- + The expiration policy for the output and/or error file that are + generated for a batch. + properties: + anchor: + description: >- + Anchor timestamp after which the expiration policy applies. + Supported anchors: `created_at`. Note that the anchor is the file + creation time, not the time the batch is created. + type: string + enum: + - created_at + x-stainless-const: true + seconds: + description: >- + The number of seconds after the anchor time that the file will + expire. Must be between 3600 (1 hour) and 2592000 (30 days). + type: integer + format: int64 + minimum: 3600 + maximum: 2592000 + required: + - anchor + - seconds + Batch: + type: object + properties: + id: + type: string + object: + type: string + enum: + - batch + description: The object type, which is always `batch`. + x-stainless-const: true + endpoint: + type: string + description: The OpenAI API endpoint used by the batch. + model: + type: string + description: > + Model ID used to process the batch, like `gpt-5-2025-08-07`. OpenAI + + offers a wide range of models with different capabilities, + performance + + characteristics, and price points. Refer to the [model + + guide](/docs/models) to browse and compare available models. + errors: + type: object + properties: + object: + type: string + description: The object type, which is always `list`. + data: + type: array + items: + type: object + properties: + code: + type: string + description: An error code identifying the error type. + message: + type: string + description: >- + A human-readable message providing more details about the + error. + param: + anyOf: + - type: string + description: >- + The name of the parameter that caused the error, if + applicable. + - type: 'null' + line: + anyOf: + - type: integer + description: >- + The line number of the input file where the error + occurred, if applicable. + - type: 'null' + input_file_id: + type: string + description: The ID of the input file for the batch. + completion_window: + type: string + description: The time frame within which the batch should be processed. + status: + type: string + description: The current status of the batch. + enum: + - validating + - failed + - in_progress + - finalizing + - completed + - expired + - cancelling + - cancelled + output_file_id: + type: string + description: >- + The ID of the file containing the outputs of successfully executed + requests. + error_file_id: + type: string + description: The ID of the file containing the outputs of requests with errors. + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the batch was created. + in_progress_at: + type: integer + format: unixtime + description: >- + The Unix timestamp (in seconds) for when the batch started + processing. + expires_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the batch will expire. + finalizing_at: + type: integer + format: unixtime + description: >- + The Unix timestamp (in seconds) for when the batch started + finalizing. + completed_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the batch was completed. + failed_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the batch failed. + expired_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the batch expired. + cancelling_at: + type: integer + format: unixtime + description: >- + The Unix timestamp (in seconds) for when the batch started + cancelling. + cancelled_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the batch was cancelled. + request_counts: + type: object + properties: + total: + type: integer + description: Total number of requests in the batch. + completed: + type: integer + description: Number of requests that have been completed successfully. + failed: + type: integer + description: Number of requests that have failed. + required: + - total + - completed + - failed + description: The request counts for different statuses within the batch. + usage: + type: object + description: > + Represents token usage details including input tokens, output + tokens, a + + breakdown of output tokens, and the total tokens used. Only + populated on + + batches created after September 7, 2025. + properties: + input_tokens: + type: integer + description: The number of input tokens. + input_tokens_details: + type: object + description: A detailed breakdown of the input tokens. + properties: + cached_tokens: + type: integer + description: > + The number of tokens that were retrieved from the cache. + [More on + + prompt caching](/docs/guides/prompt-caching). + required: + - cached_tokens + output_tokens: + type: integer + description: The number of output tokens. + output_tokens_details: + type: object + description: A detailed breakdown of the output tokens. + properties: + reasoning_tokens: + type: integer + description: The number of reasoning tokens. + required: + - reasoning_tokens + total_tokens: + type: integer + description: The total number of tokens used. + required: + - input_tokens + - input_tokens_details + - output_tokens + - output_tokens_details + - total_tokens + metadata: + $ref: '#/components/schemas/Metadata' + required: + - id + - object + - endpoint + - input_file_id + - completion_window + - status + - created_at + x-oaiMeta: + name: The batch object + example: | + { + "id": "batch_abc123", + "object": "batch", + "endpoint": "/v1/completions", + "model": "gpt-5-2025-08-07", + "errors": null, + "input_file_id": "file-abc123", + "completion_window": "24h", + "status": "completed", + "output_file_id": "file-cvaTdG", + "error_file_id": "file-HOWS94", + "created_at": 1711471533, + "in_progress_at": 1711471538, + "expires_at": 1711557933, + "finalizing_at": 1711493133, + "completed_at": 1711493163, + "failed_at": null, + "expired_at": null, + "cancelling_at": null, + "cancelled_at": null, + "request_counts": { + "total": 100, + "completed": 95, + "failed": 5 + }, + "usage": { + "input_tokens": 1500, + "input_tokens_details": { + "cached_tokens": 1024 + }, + "output_tokens": 500, + "output_tokens_details": { + "reasoning_tokens": 300 + }, + "total_tokens": 2000 + }, + "metadata": { + "customer_id": "user_123456789", + "batch_description": "Nightly eval job", + } + } + ListBatchesResponse: + type: object + properties: + data: + type: array + items: + $ref: '#/components/schemas/Batch' + first_id: + type: string + example: batch_abc123 + last_id: + type: string + example: batch_abc456 + has_more: + type: boolean + object: + type: string + enum: + - list + x-stainless-const: true + required: + - object + - data + - has_more + x-stackQL-resources: + batches: + id: openai.batches.batches + name: batches + title: Batches + methods: + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1batches/post' + response: + mediaType: application/json + openAPIDocKey: '200' + list: + operation: + $ref: '#/paths/~1batches/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + get: + operation: + $ref: '#/paths/~1batches~1{batch_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + cancel: + operation: + $ref: '#/paths/~1batches~1{batch_id}~1cancel/post' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/batches/methods/get' + - $ref: '#/components/x-stackQL-resources/batches/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/batches/methods/create' + update: [] + delete: [] + replace: [] +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.last_id + location: body + queryParamPushdown: + top: + paramName: limit + maxValue: 100 diff --git a/providers/src/openai/v00.00.00000/services/chat.yaml b/providers/src/openai/v00.00.00000/services/chat.yaml deleted file mode 100644 index 50cb13ad..00000000 --- a/providers/src/openai/v00.00.00000/services/chat.yaml +++ /dev/null @@ -1,1803 +0,0 @@ -openapi: 3.0.0 -servers: - - url: 'https://api.openai.com/v1' -info: - version: 2.3.0 - termsOfService: 'https://openai.com/policies/terms-of-use' - contact: - name: OpenAI Support - url: 'https://help.openai.com/' - license: - name: MIT - url: 'https://github.com/openai/openai-openapi/blob/master/LICENSE' - title: OpenAI API - chat - description: 'Given a list of messages comprising a conversation, the model will return a response.' -security: - - ApiKeyAuth: [] -tags: - - name: Assistants - description: Build Assistants that can call models and use tools. - - name: Audio - description: Turn audio into text or text into audio. - - name: Chat - description: 'Given a list of messages comprising a conversation, the model will return a response.' - - name: Completions - description: 'Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.' - - name: Embeddings - description: Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. - - name: Fine-tuning - description: Manage fine-tuning jobs to tailor a model to your specific training data. - - name: Batch - description: Create large batches of API requests to run asynchronously. - - name: Files - description: Files are used to upload documents that can be used with features like Assistants and Fine-tuning. - - name: Uploads - description: Use Uploads to upload large files in multiple parts. - - name: Images - description: 'Given a prompt and/or an input image, the model will generate a new image.' - - name: Models - description: List and describe the various models available in the API. - - name: Moderations - description: 'Given text and/or image inputs, classifies if those inputs are potentially harmful.' - - name: Audit Logs - description: List user actions and configuration changes within this organization. -components: - schemas: - CreateChatCompletionRequest: - type: object - properties: - messages: - description: | - A list of messages comprising the conversation so far. Depending on the - [model](/docs/models) you use, different message types (modalities) are - supported, like [text](/docs/guides/text-generation), - [images](/docs/guides/vision), and [audio](/docs/guides/audio). - type: array - minItems: 1 - items: - $ref: '#/components/schemas/ChatCompletionRequestMessage' - model: - description: 'ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API.' - example: gpt-4o - anyOf: - - type: string - - type: string - enum: - - o1-preview - - o1-preview-2024-09-12 - - o1-mini - - o1-mini-2024-09-12 - - gpt-4o - - gpt-4o-2024-08-06 - - gpt-4o-2024-05-13 - - gpt-4o-2024-08-06 - - gpt-4o-realtime-preview - - gpt-4o-realtime-preview-2024-10-01 - - gpt-4o-audio-preview - - gpt-4o-audio-preview-2024-10-01 - - chatgpt-4o-latest - - gpt-4o-mini - - gpt-4o-mini-2024-07-18 - - gpt-4-turbo - - gpt-4-turbo-2024-04-09 - - gpt-4-0125-preview - - gpt-4-turbo-preview - - gpt-4-1106-preview - - gpt-4-vision-preview - - gpt-4 - - gpt-4-0314 - - gpt-4-0613 - - gpt-4-32k - - gpt-4-32k-0314 - - gpt-4-32k-0613 - - gpt-3.5-turbo - - gpt-3.5-turbo-16k - - gpt-3.5-turbo-0301 - - gpt-3.5-turbo-0613 - - gpt-3.5-turbo-1106 - - gpt-3.5-turbo-0125 - - gpt-3.5-turbo-16k-0613 - x-oaiTypeLabel: string - store: - type: boolean - default: false - nullable: true - description: | - Whether or not to store the output of this chat completion request - for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. - metadata: - type: object - nullable: true - description: | - Developer-defined tags and values used for filtering completions - in the [dashboard](https://platform.openai.com/chat-completions). - additionalProperties: - type: string - frequency_penalty: - type: number - default: 0 - minimum: -2 - maximum: 2 - nullable: true - description: | - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - logit_bias: - type: object - x-oaiTypeLabel: map - default: null - nullable: true - additionalProperties: - type: integer - description: | - Modify the likelihood of specified tokens appearing in the completion. - - Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. - logprobs: - description: 'Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`.' - type: boolean - default: false - nullable: true - top_logprobs: - description: 'An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used.' - type: integer - minimum: 0 - maximum: 20 - nullable: true - max_tokens: - description: | - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. - - This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). - type: integer - nullable: true - deprecated: true - max_completion_tokens: - description: | - An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). - type: integer - nullable: true - 'n': - type: integer - minimum: 1 - maximum: 128 - default: 1 - example: 1 - nullable: true - description: How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. - modalities: - $ref: '#/components/schemas/ChatCompletionModalities' - audio: - type: object - nullable: true - description: | - Parameters for audio output. Required when audio output is requested with - `modalities: ["audio"]`. [Learn more](/docs/guides/audio). - required: - - voice - - format - x-oaiExpandable: true - properties: - voice: - type: string - enum: - - alloy - - echo - - fable - - onyx - - nova - - shimmer - description: | - Specifies the voice type. Supported voices are `alloy`, `echo`, - `fable`, `onyx`, `nova`, and `shimmer`. - format: - type: string - enum: - - wav - - mp3 - - flac - - opus - - pcm16 - description: | - Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, - `opus`, or `pcm16`. - presence_penalty: - type: number - default: 0 - minimum: -2 - maximum: 2 - nullable: true - description: | - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - response_format: - description: | - An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. - - Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). - - Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - oneOf: - - $ref: '#/components/schemas/ResponseFormatText' - - $ref: '#/components/schemas/ResponseFormatJsonObject' - - $ref: '#/components/schemas/ResponseFormatJsonSchema' - x-oaiExpandable: true - seed: - type: integer - minimum: -9223372036854776000 - maximum: 9223372036854776000 - nullable: true - description: | - This feature is in Beta. - If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. - Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. - x-oaiMeta: - beta: true - service_tier: - description: | - Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: - - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - - When not set, the default behavior is 'auto'. - - When this parameter is set, the response body will include the `service_tier` utilized. - type: string - enum: - - auto - - default - nullable: true - default: auto - stop: - description: | - Up to 4 sequences where the API will stop generating further tokens. - default: null - oneOf: - - type: string - nullable: true - - type: array - minItems: 1 - maxItems: 4 - items: - type: string - stream: - description: | - If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions). - type: boolean - nullable: true - default: false - stream_options: - $ref: '#/components/schemas/ChatCompletionStreamOptions' - temperature: - type: number - minimum: 0 - maximum: 2 - default: 1 - example: 1 - nullable: true - description: | - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - - We generally recommend altering this or `top_p` but not both. - top_p: - type: number - minimum: 0 - maximum: 1 - default: 1 - example: 1 - nullable: true - description: | - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or `temperature` but not both. - tools: - type: array - description: | - A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. - items: - $ref: '#/components/schemas/ChatCompletionTool' - tool_choice: - $ref: '#/components/schemas/ChatCompletionToolChoiceOption' - parallel_tool_calls: - $ref: '#/components/schemas/ParallelToolCalls' - user: - type: string - example: user-1234 - description: | - A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - function_call: - deprecated: true - description: | - Deprecated in favor of `tool_choice`. - - Controls which (if any) function is called by the model. - `none` means the model will not call a function and instead generates a message. - `auto` means the model can pick between generating a message or calling a function. - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - - `none` is the default when no functions are present. `auto` is the default if functions are present. - oneOf: - - type: string - description: | - `none` means the model will not call a function and instead generates a message. `auto` means the model can pick between generating a message or calling a function. - enum: - - none - - auto - - $ref: '#/components/schemas/ChatCompletionFunctionCallOption' - x-oaiExpandable: true - functions: - deprecated: true - description: | - Deprecated in favor of `tools`. - - A list of functions the model may generate JSON inputs for. - type: array - minItems: 1 - maxItems: 128 - items: - $ref: '#/components/schemas/ChatCompletionFunctions' - required: - - model - - messages - CreateChatCompletionResponse: - type: object - description: 'Represents a chat completion response returned by model, based on the provided input.' - properties: - id: - type: string - description: A unique identifier for the chat completion. - choices: - type: array - description: A list of chat completion choices. Can be more than one if `n` is greater than 1. - items: - type: object - required: - - finish_reason - - index - - message - - logprobs - properties: - finish_reason: - type: string - description: | - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - `content_filter` if content was omitted due to a flag from our content filters, - `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - enum: - - stop - - length - - tool_calls - - content_filter - - function_call - index: - type: integer - description: The index of the choice in the list of choices. - message: - $ref: '#/components/schemas/ChatCompletionResponseMessage' - logprobs: - description: Log probability information for the choice. - type: object - nullable: true - properties: - content: - description: A list of message content tokens with log probability information. - type: array - items: - $ref: '#/components/schemas/ChatCompletionTokenLogprob' - nullable: true - refusal: - description: A list of message refusal tokens with log probability information. - type: array - items: - $ref: '#/components/schemas/ChatCompletionTokenLogprob' - nullable: true - required: - - content - - refusal - created: - type: integer - description: The Unix timestamp (in seconds) of when the chat completion was created. - model: - type: string - description: The model used for the chat completion. - service_tier: - description: The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. - type: string - enum: - - scale - - default - example: scale - nullable: true - system_fingerprint: - type: string - description: | - This fingerprint represents the backend configuration that the model runs with. - - Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - object: - type: string - description: 'The object type, which is always `chat.completion`.' - enum: - - chat.completion - usage: - $ref: '#/components/schemas/CompletionUsage' - required: - - choices - - created - - id - - model - - object - x-oaiMeta: - name: The chat completion object - group: chat - example: | - { - "id": "chatcmpl-123456", - "object": "chat.completion", - "created": 1728933352, - "model": "gpt-4o-2024-08-06", - "choices": [ - { - "index": 0, - "message": { - "role": "assistant", - "content": "Hi there! How can I assist you today?", - "refusal": null - }, - "logprobs": null, - "finish_reason": "stop" - } - ], - "usage": { - "prompt_tokens": 19, - "completion_tokens": 10, - "total_tokens": 29, - "prompt_tokens_details": { - "cached_tokens": 0 - }, - "completion_tokens_details": { - "reasoning_tokens": 0 - } - }, - "system_fingerprint": "fp_6b68a8204b" - } - ChatCompletionRequestMessage: - oneOf: - - $ref: '#/components/schemas/ChatCompletionRequestSystemMessage' - - $ref: '#/components/schemas/ChatCompletionRequestUserMessage' - - $ref: '#/components/schemas/ChatCompletionRequestAssistantMessage' - - $ref: '#/components/schemas/ChatCompletionRequestToolMessage' - - $ref: '#/components/schemas/ChatCompletionRequestFunctionMessage' - x-oaiExpandable: true - ChatCompletionModalities: - type: array - nullable: true - description: | - Output types that you would like the model to generate for this request. - Most models are capable of generating text, which is the default: - - `["text"]` - - The `gpt-4o-audio-preview` model can also be used to [generate audio](/docs/guides/audio). To - request that this model generate both text and audio responses, you can - use: - - `["text", "audio"]` - items: - type: string - enum: - - text - - audio - ResponseFormatText: - type: object - properties: - type: - type: string - description: 'The type of response format being defined: `text`' - enum: - - text - required: - - type - ResponseFormatJsonObject: - type: object - properties: - type: - type: string - description: 'The type of response format being defined: `json_object`' - enum: - - json_object - required: - - type - ResponseFormatJsonSchema: - type: object - properties: - type: - type: string - description: 'The type of response format being defined: `json_schema`' - enum: - - json_schema - json_schema: - type: object - properties: - description: - type: string - description: 'A description of what the response format is for, used by the model to determine how to respond in the format.' - name: - type: string - description: 'The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.' - schema: - $ref: '#/components/schemas/ResponseFormatJsonSchemaSchema' - strict: - type: boolean - nullable: true - default: false - description: 'Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs).' - required: - - type - - name - required: - - type - - json_schema - ChatCompletionStreamOptions: - description: | - Options for streaming response. Only set this when you set `stream: true`. - type: object - nullable: true - default: null - properties: - include_usage: - type: boolean - description: | - If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value. - ChatCompletionTool: - type: object - properties: - type: - type: string - enum: - - function - description: 'The type of the tool. Currently, only `function` is supported.' - function: - $ref: '#/components/schemas/FunctionObject' - required: - - type - - function - ChatCompletionToolChoiceOption: - description: | - Controls which (if any) tool is called by the model. - `none` means the model will not call any tool and instead generates a message. - `auto` means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools. - Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - - `none` is the default when no tools are present. `auto` is the default if tools are present. - oneOf: - - type: string - description: | - `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools. - enum: - - none - - auto - - required - - $ref: '#/components/schemas/ChatCompletionNamedToolChoice' - x-oaiExpandable: true - ParallelToolCalls: - description: 'Whether to enable [parallel function calling](/docs/guides/function-calling/parallel-function-calling) during tool use.' - type: boolean - default: true - ChatCompletionFunctionCallOption: - type: object - description: | - Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - properties: - name: - type: string - description: The name of the function to call. - required: - - name - ChatCompletionFunctions: - type: object - deprecated: true - properties: - description: - type: string - description: 'A description of what the function does, used by the model to choose when and how to call the function.' - name: - type: string - description: 'The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.' - parameters: - $ref: '#/components/schemas/FunctionParameters' - required: - - name - ChatCompletionResponseMessage: - type: object - description: A chat completion message generated by the model. - properties: - content: - type: string - description: The contents of the message. - nullable: true - refusal: - type: string - description: The refusal message generated by the model. - nullable: true - tool_calls: - $ref: '#/components/schemas/ChatCompletionMessageToolCalls' - role: - type: string - enum: - - assistant - description: The role of the author of this message. - function_call: - type: object - deprecated: true - description: 'Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.' - properties: - arguments: - type: string - description: 'The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.' - name: - type: string - description: The name of the function to call. - required: - - name - - arguments - audio: - type: object - nullable: true - description: | - If the audio output modality is requested, this object contains data - about the audio response from the model. [Learn more](/docs/guides/audio). - x-oaiExpandable: true - required: - - id - - expires_at - - data - - transcript - properties: - id: - type: string - description: Unique identifier for this audio response. - expires_at: - type: integer - description: | - The Unix timestamp (in seconds) for when this audio response will - no longer be accessible on the server for use in multi-turn - conversations. - data: - type: string - description: | - Base64 encoded audio bytes generated by the model, in the format - specified in the request. - transcript: - type: string - description: Transcript of the audio generated by the model. - required: - - role - - content - - refusal - ChatCompletionTokenLogprob: - type: object - properties: - token: - description: The token. - type: string - logprob: - description: 'The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.' - type: number - bytes: - description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. - type: array - items: - type: integer - nullable: true - top_logprobs: - description: 'List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned.' - type: array - items: - type: object - properties: - token: - description: The token. - type: string - logprob: - description: 'The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.' - type: number - bytes: - description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. - type: array - items: - type: integer - nullable: true - required: - - token - - logprob - - bytes - required: - - token - - logprob - - bytes - - top_logprobs - CompletionUsage: - type: object - description: Usage statistics for the completion request. - properties: - completion_tokens: - type: integer - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - description: Number of tokens in the prompt. - total_tokens: - type: integer - description: Total number of tokens used in the request (prompt + completion). - completion_tokens_details: - type: object - description: Breakdown of tokens used in a completion. - properties: - audio_tokens: - type: integer - description: Audio input tokens generated by the model. - reasoning_tokens: - type: integer - description: Tokens generated by the model for reasoning. - prompt_tokens_details: - type: object - description: Breakdown of tokens used in the prompt. - properties: - audio_tokens: - type: integer - description: Audio input tokens present in the prompt. - cached_tokens: - type: integer - description: Cached tokens present in the prompt. - required: - - prompt_tokens - - completion_tokens - - total_tokens - ChatCompletionRequestSystemMessage: - type: object - title: System message - properties: - content: - description: The contents of the system message. - oneOf: - - type: string - description: The contents of the system message. - title: Text content - - type: array - description: 'An array of content parts with a defined type. For system messages, only type `text` is supported.' - title: Array of content parts - items: - $ref: '#/components/schemas/ChatCompletionRequestSystemMessageContentPart' - minItems: 1 - role: - type: string - enum: - - system - description: 'The role of the messages author, in this case `system`.' - name: - type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - required: - - content - - role - ChatCompletionRequestUserMessage: - type: object - title: User message - properties: - content: - description: | - The contents of the user message. - oneOf: - - type: string - description: The text contents of the message. - title: Text content - - type: array - description: 'An array of content parts with a defined type. Supported options differ based on the [model](/docs/models) being used to generate the response. Can contain text, image, or audio inputs.' - title: Array of content parts - items: - $ref: '#/components/schemas/ChatCompletionRequestUserMessageContentPart' - minItems: 1 - x-oaiExpandable: true - role: - type: string - enum: - - user - description: 'The role of the messages author, in this case `user`.' - name: - type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - required: - - content - - role - ChatCompletionRequestAssistantMessage: - type: object - title: Assistant message - properties: - content: - x-oaiExpandable: true - nullable: true - oneOf: - - type: string - description: The contents of the assistant message. - title: Text content - - type: array - description: 'An array of content parts with a defined type. Can be one or more of type `text`, or exactly one of type `refusal`.' - title: Array of content parts - items: - $ref: '#/components/schemas/ChatCompletionRequestAssistantMessageContentPart' - minItems: 1 - description: | - The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified. - refusal: - nullable: true - type: string - description: The refusal message by the assistant. - role: - type: string - enum: - - assistant - description: 'The role of the messages author, in this case `assistant`.' - name: - type: string - description: An optional name for the participant. Provides the model information to differentiate between participants of the same role. - audio: - type: object - nullable: true - x-oaiExpandable: true - description: | - Data about a previous audio response from the model. - [Learn more](/docs/guides/audio). - required: - - id - properties: - id: - type: string - description: | - Unique identifier for a previous audio response from the model. - tool_calls: - $ref: '#/components/schemas/ChatCompletionMessageToolCalls' - function_call: - type: object - deprecated: true - description: 'Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.' - nullable: true - properties: - arguments: - type: string - description: 'The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.' - name: - type: string - description: The name of the function to call. - required: - - arguments - - name - required: - - role - ChatCompletionRequestToolMessage: - type: object - title: Tool message - properties: - role: - type: string - enum: - - tool - description: 'The role of the messages author, in this case `tool`.' - content: - oneOf: - - type: string - description: The contents of the tool message. - title: Text content - - type: array - description: 'An array of content parts with a defined type. For tool messages, only type `text` is supported.' - title: Array of content parts - items: - $ref: '#/components/schemas/ChatCompletionRequestToolMessageContentPart' - minItems: 1 - description: The contents of the tool message. - tool_call_id: - type: string - description: Tool call that this message is responding to. - required: - - role - - content - - tool_call_id - ChatCompletionRequestFunctionMessage: - type: object - title: Function message - deprecated: true - properties: - role: - type: string - enum: - - function - description: 'The role of the messages author, in this case `function`.' - content: - nullable: true - type: string - description: The contents of the function message. - name: - type: string - description: The name of the function to call. - required: - - role - - content - - name - ResponseFormatJsonSchemaSchema: - type: object - description: 'The schema for the response format, described as a JSON Schema object.' - additionalProperties: true - FunctionObject: - type: object - properties: - description: - type: string - description: 'A description of what the function does, used by the model to choose when and how to call the function.' - name: - type: string - description: 'The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.' - parameters: - $ref: '#/components/schemas/FunctionParameters' - strict: - type: boolean - nullable: true - default: false - description: 'Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](docs/guides/function-calling).' - required: - - name - ChatCompletionNamedToolChoice: - type: object - description: Specifies a tool the model should use. Use to force the model to call a specific function. - properties: - type: - type: string - enum: - - function - description: 'The type of the tool. Currently, only `function` is supported.' - function: - type: object - properties: - name: - type: string - description: The name of the function to call. - required: - - name - required: - - type - - function - FunctionParameters: - type: object - description: |- - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. - - Omitting `parameters` defines a function with an empty parameter list. - additionalProperties: true - ChatCompletionMessageToolCalls: - type: array - description: 'The tool calls generated by the model, such as function calls.' - items: - $ref: '#/components/schemas/ChatCompletionMessageToolCall' - ChatCompletionRequestSystemMessageContentPart: - oneOf: - - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartText' - x-oaiExpandable: true - ChatCompletionRequestUserMessageContentPart: - oneOf: - - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartText' - - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartImage' - - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartAudio' - x-oaiExpandable: true - ChatCompletionRequestAssistantMessageContentPart: - oneOf: - - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartText' - - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartRefusal' - x-oaiExpandable: true - ChatCompletionRequestToolMessageContentPart: - oneOf: - - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartText' - x-oaiExpandable: true - ChatCompletionMessageToolCall: - type: object - properties: - id: - type: string - description: The ID of the tool call. - type: - type: string - enum: - - function - description: 'The type of the tool. Currently, only `function` is supported.' - function: - type: object - description: The function that the model called. - properties: - name: - type: string - description: The name of the function to call. - arguments: - type: string - description: 'The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.' - required: - - name - - arguments - required: - - id - - type - - function - ChatCompletionRequestMessageContentPartText: - type: object - title: Text content part - description: | - Learn about [text inputs](/docs/guides/text-generation). - properties: - type: - type: string - enum: - - text - description: The type of the content part. - text: - type: string - description: The text content. - required: - - type - - text - ChatCompletionRequestMessageContentPartImage: - type: object - title: Image content part - description: | - Learn about [image inputs](/docs/guides/vision). - properties: - type: - type: string - enum: - - image_url - description: The type of the content part. - image_url: - type: object - properties: - url: - type: string - description: Either a URL of the image or the base64 encoded image data. - format: uri - detail: - type: string - description: 'Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding).' - enum: - - auto - - low - - high - default: auto - required: - - url - required: - - type - - image_url - ChatCompletionRequestMessageContentPartAudio: - type: object - title: Audio content part - description: | - Learn about [audio inputs](/docs/guides/audio). - properties: - type: - type: string - enum: - - input_audio - description: The type of the content part. Always `input_audio`. - input_audio: - type: object - properties: - data: - type: string - description: Base64 encoded audio data. - format: - type: string - enum: - - wav - - mp3 - description: | - The format of the encoded audio data. Currently supports "wav" and "mp3". - required: - - data - - format - required: - - type - - input_audio - ChatCompletionRequestMessageContentPartRefusal: - type: object - title: Refusal content part - properties: - type: - type: string - enum: - - refusal - description: The type of the content part. - refusal: - type: string - description: The refusal message generated by the model. - required: - - type - - refusal - responses: {} - securitySchemes: - ApiKeyAuth: - type: http - scheme: bearer - x-stackQL-resources: - completions: - id: openai.chat.completions - name: completions - title: Completions - methods: - create_chat_completion: - operation: - $ref: '#/paths/~1chat~1completions/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/CreateChatCompletionResponse' - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/completions/methods/create_chat_completion' - insert: [] - update: [] - replace: [] - delete: [] -paths: - /chat/completions: - post: - operationId: createChatCompletion - tags: - - Chat - summary: | - Creates a model response for the given chat conversation. Learn more in the - [text generation](/docs/guides/text-generation), [vision](/docs/guides/vision), - and [audio](/docs/guides/audio) guides. - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CreateChatCompletionRequest' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/CreateChatCompletionResponse' - x-oaiMeta: - name: Create chat completion - group: chat - returns: | - Returns a [chat completion](/docs/api-reference/chat/object) object, or a streamed sequence of [chat completion chunk](/docs/api-reference/chat/streaming) objects if the request is streamed. - path: create - examples: - - title: Default - request: - curl: | - curl https://api.openai.com/v1/chat/completions \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "model": "VAR_model_id", - "messages": [ - { - "role": "system", - "content": "You are a helpful assistant." - }, - { - "role": "user", - "content": "Hello!" - } - ] - }' - python: | - from openai import OpenAI - client = OpenAI() - - completion = client.chat.completions.create( - model="VAR_model_id", - messages=[ - {"role": "system", "content": "You are a helpful assistant."}, - {"role": "user", "content": "Hello!"} - ] - ) - - print(completion.choices[0].message) - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const completion = await openai.chat.completions.create({ - messages: [{ role: "system", content: "You are a helpful assistant." }], - model: "VAR_model_id", - }); - - console.log(completion.choices[0]); - } - - main(); - response: | - { - "id": "chatcmpl-123", - "object": "chat.completion", - "created": 1677652288, - "model": "gpt-4o-mini", - "system_fingerprint": "fp_44709d6fcb", - "choices": [{ - "index": 0, - "message": { - "role": "assistant", - "content": "\n\nHello there, how may I assist you today?", - }, - "logprobs": null, - "finish_reason": "stop" - }], - "usage": { - "prompt_tokens": 9, - "completion_tokens": 12, - "total_tokens": 21, - "completion_tokens_details": { - "reasoning_tokens": 0 - } - } - } - - title: Image input - request: - curl: | - curl https://api.openai.com/v1/chat/completions \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "model": "gpt-4o", - "messages": [ - { - "role": "user", - "content": [ - { - "type": "text", - "text": "What'\''s in this image?" - }, - { - "type": "image_url", - "image_url": { - "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" - } - } - ] - } - ], - "max_tokens": 300 - }' - python: | - from openai import OpenAI - - client = OpenAI() - - response = client.chat.completions.create( - model="gpt-4o", - messages=[ - { - "role": "user", - "content": [ - {"type": "text", "text": "What's in this image?"}, - { - "type": "image_url", - "image_url": { - "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", - } - }, - ], - } - ], - max_tokens=300, - ) - - print(response.choices[0]) - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const response = await openai.chat.completions.create({ - model: "gpt-4o", - messages: [ - { - role: "user", - content: [ - { type: "text", text: "What's in this image?" }, - { - type: "image_url", - image_url: { - "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", - }, - } - ], - }, - ], - }); - console.log(response.choices[0]); - } - main(); - response: | - { - "id": "chatcmpl-123", - "object": "chat.completion", - "created": 1677652288, - "model": "gpt-4o-mini", - "system_fingerprint": "fp_44709d6fcb", - "choices": [{ - "index": 0, - "message": { - "role": "assistant", - "content": "\n\nThis image shows a wooden boardwalk extending through a lush green marshland.", - }, - "logprobs": null, - "finish_reason": "stop" - }], - "usage": { - "prompt_tokens": 9, - "completion_tokens": 12, - "total_tokens": 21, - "completion_tokens_details": { - "reasoning_tokens": 0 - } - } - } - - title: Streaming - request: - curl: | - curl https://api.openai.com/v1/chat/completions \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "model": "VAR_model_id", - "messages": [ - { - "role": "system", - "content": "You are a helpful assistant." - }, - { - "role": "user", - "content": "Hello!" - } - ], - "stream": true - }' - python: | - from openai import OpenAI - client = OpenAI() - - completion = client.chat.completions.create( - model="VAR_model_id", - messages=[ - {"role": "system", "content": "You are a helpful assistant."}, - {"role": "user", "content": "Hello!"} - ], - stream=True - ) - - for chunk in completion: - print(chunk.choices[0].delta) - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const completion = await openai.chat.completions.create({ - model: "VAR_model_id", - messages: [ - {"role": "system", "content": "You are a helpful assistant."}, - {"role": "user", "content": "Hello!"} - ], - stream: true, - }); - - for await (const chunk of completion) { - console.log(chunk.choices[0].delta.content); - } - } - - main(); - 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}]} - - {"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}]} - - .... - - {"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"}]} - - title: Functions - request: - curl: | - curl https://api.openai.com/v1/chat/completions \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "model": "gpt-4o", - "messages": [ - { - "role": "user", - "content": "What'\''s the weather like in Boston today?" - } - ], - "tools": [ - { - "type": "function", - "function": { - "name": "get_current_weather", - "description": "Get the current weather in a given location", - "parameters": { - "type": "object", - "properties": { - "location": { - "type": "string", - "description": "The city and state, e.g. San Francisco, CA" - }, - "unit": { - "type": "string", - "enum": ["celsius", "fahrenheit"] - } - }, - "required": ["location"] - } - } - } - ], - "tool_choice": "auto" - }' - python: | - from openai import OpenAI - client = OpenAI() - - tools = [ - { - "type": "function", - "function": { - "name": "get_current_weather", - "description": "Get the current weather in a given location", - "parameters": { - "type": "object", - "properties": { - "location": { - "type": "string", - "description": "The city and state, e.g. San Francisco, CA", - }, - "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}, - }, - "required": ["location"], - }, - } - } - ] - messages = [{"role": "user", "content": "What's the weather like in Boston today?"}] - completion = client.chat.completions.create( - model="VAR_model_id", - messages=messages, - tools=tools, - tool_choice="auto" - ) - - print(completion) - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const messages = [{"role": "user", "content": "What's the weather like in Boston today?"}]; - const tools = [ - { - "type": "function", - "function": { - "name": "get_current_weather", - "description": "Get the current weather in a given location", - "parameters": { - "type": "object", - "properties": { - "location": { - "type": "string", - "description": "The city and state, e.g. San Francisco, CA", - }, - "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}, - }, - "required": ["location"], - }, - } - } - ]; - - const response = await openai.chat.completions.create({ - model: "gpt-4o", - messages: messages, - tools: tools, - tool_choice: "auto", - }); - - console.log(response); - } - - main(); - response: | - { - "id": "chatcmpl-abc123", - "object": "chat.completion", - "created": 1699896916, - "model": "gpt-4o-mini", - "choices": [ - { - "index": 0, - "message": { - "role": "assistant", - "content": null, - "tool_calls": [ - { - "id": "call_abc123", - "type": "function", - "function": { - "name": "get_current_weather", - "arguments": "{\n\"location\": \"Boston, MA\"\n}" - } - } - ] - }, - "logprobs": null, - "finish_reason": "tool_calls" - } - ], - "usage": { - "prompt_tokens": 82, - "completion_tokens": 17, - "total_tokens": 99, - "completion_tokens_details": { - "reasoning_tokens": 0 - } - } - } - - title: Logprobs - request: - curl: | - curl https://api.openai.com/v1/chat/completions \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "model": "VAR_model_id", - "messages": [ - { - "role": "user", - "content": "Hello!" - } - ], - "logprobs": true, - "top_logprobs": 2 - }' - python: | - from openai import OpenAI - client = OpenAI() - - completion = client.chat.completions.create( - model="VAR_model_id", - messages=[ - {"role": "user", "content": "Hello!"} - ], - logprobs=True, - top_logprobs=2 - ) - - print(completion.choices[0].message) - print(completion.choices[0].logprobs) - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const completion = await openai.chat.completions.create({ - messages: [{ role: "user", content: "Hello!" }], - model: "VAR_model_id", - logprobs: true, - top_logprobs: 2, - }); - - console.log(completion.choices[0]); - } - - main(); - response: | - { - "id": "chatcmpl-123", - "object": "chat.completion", - "created": 1702685778, - "model": "gpt-4o-mini", - "choices": [ - { - "index": 0, - "message": { - "role": "assistant", - "content": "Hello! How can I assist you today?" - }, - "logprobs": { - "content": [ - { - "token": "Hello", - "logprob": -0.31725305, - "bytes": [72, 101, 108, 108, 111], - "top_logprobs": [ - { - "token": "Hello", - "logprob": -0.31725305, - "bytes": [72, 101, 108, 108, 111] - }, - { - "token": "Hi", - "logprob": -1.3190403, - "bytes": [72, 105] - } - ] - }, - { - "token": "!", - "logprob": -0.02380986, - "bytes": [ - 33 - ], - "top_logprobs": [ - { - "token": "!", - "logprob": -0.02380986, - "bytes": [33] - }, - { - "token": " there", - "logprob": -3.787621, - "bytes": [32, 116, 104, 101, 114, 101] - } - ] - }, - { - "token": " How", - "logprob": -0.000054669687, - "bytes": [32, 72, 111, 119], - "top_logprobs": [ - { - "token": " How", - "logprob": -0.000054669687, - "bytes": [32, 72, 111, 119] - }, - { - "token": "<|end|>", - "logprob": -10.953937, - "bytes": null - } - ] - }, - { - "token": " can", - "logprob": -0.015801601, - "bytes": [32, 99, 97, 110], - "top_logprobs": [ - { - "token": " can", - "logprob": -0.015801601, - "bytes": [32, 99, 97, 110] - }, - { - "token": " may", - "logprob": -4.161023, - "bytes": [32, 109, 97, 121] - } - ] - }, - { - "token": " I", - "logprob": -3.7697225e-6, - "bytes": [ - 32, - 73 - ], - "top_logprobs": [ - { - "token": " I", - "logprob": -3.7697225e-6, - "bytes": [32, 73] - }, - { - "token": " assist", - "logprob": -13.596657, - "bytes": [32, 97, 115, 115, 105, 115, 116] - } - ] - }, - { - "token": " assist", - "logprob": -0.04571125, - "bytes": [32, 97, 115, 115, 105, 115, 116], - "top_logprobs": [ - { - "token": " assist", - "logprob": -0.04571125, - "bytes": [32, 97, 115, 115, 105, 115, 116] - }, - { - "token": " help", - "logprob": -3.1089056, - "bytes": [32, 104, 101, 108, 112] - } - ] - }, - { - "token": " you", - "logprob": -5.4385737e-6, - "bytes": [32, 121, 111, 117], - "top_logprobs": [ - { - "token": " you", - "logprob": -5.4385737e-6, - "bytes": [32, 121, 111, 117] - }, - { - "token": " today", - "logprob": -12.807695, - "bytes": [32, 116, 111, 100, 97, 121] - } - ] - }, - { - "token": " today", - "logprob": -0.0040071653, - "bytes": [32, 116, 111, 100, 97, 121], - "top_logprobs": [ - { - "token": " today", - "logprob": -0.0040071653, - "bytes": [32, 116, 111, 100, 97, 121] - }, - { - "token": "?", - "logprob": -5.5247097, - "bytes": [63] - } - ] - }, - { - "token": "?", - "logprob": -0.0008108172, - "bytes": [63], - "top_logprobs": [ - { - "token": "?", - "logprob": -0.0008108172, - "bytes": [63] - }, - { - "token": "?\n", - "logprob": -7.184561, - "bytes": [63, 10] - } - ] - } - ] - }, - "finish_reason": "stop" - } - ], - "usage": { - "prompt_tokens": 9, - "completion_tokens": 9, - "total_tokens": 18, - "completion_tokens_details": { - "reasoning_tokens": 0 - } - }, - "system_fingerprint": null - } diff --git a/providers/src/openai/v00.00.00000/services/completions.yaml b/providers/src/openai/v00.00.00000/services/completions.yaml deleted file mode 100644 index a849cfd4..00000000 --- a/providers/src/openai/v00.00.00000/services/completions.yaml +++ /dev/null @@ -1,563 +0,0 @@ -openapi: 3.0.0 -servers: - - url: 'https://api.openai.com/v1' -info: - version: 2.3.0 - termsOfService: 'https://openai.com/policies/terms-of-use' - contact: - name: OpenAI Support - url: 'https://help.openai.com/' - license: - name: MIT - url: 'https://github.com/openai/openai-openapi/blob/master/LICENSE' - title: OpenAI API - completions - description: 'Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.' -security: - - ApiKeyAuth: [] -tags: - - name: Assistants - description: Build Assistants that can call models and use tools. - - name: Audio - description: Turn audio into text or text into audio. - - name: Chat - description: 'Given a list of messages comprising a conversation, the model will return a response.' - - name: Completions - description: 'Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.' - - name: Embeddings - description: Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. - - name: Fine-tuning - description: Manage fine-tuning jobs to tailor a model to your specific training data. - - name: Batch - description: Create large batches of API requests to run asynchronously. - - name: Files - description: Files are used to upload documents that can be used with features like Assistants and Fine-tuning. - - name: Uploads - description: Use Uploads to upload large files in multiple parts. - - name: Images - description: 'Given a prompt and/or an input image, the model will generate a new image.' - - name: Models - description: List and describe the various models available in the API. - - name: Moderations - description: 'Given text and/or image inputs, classifies if those inputs are potentially harmful.' - - name: Audit Logs - description: List user actions and configuration changes within this organization. -components: - schemas: - CreateCompletionRequest: - type: object - properties: - model: - description: | - ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. - anyOf: - - type: string - - type: string - enum: - - gpt-3.5-turbo-instruct - - davinci-002 - - babbage-002 - x-oaiTypeLabel: string - prompt: - description: | - The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays. - - Note that <|endoftext|> is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document. - default: <|endoftext|> - nullable: true - oneOf: - - type: string - default: '' - example: This is a test. - - type: array - items: - type: string - default: '' - example: This is a test. - - type: array - minItems: 1 - items: - type: integer - example: '[1212, 318, 257, 1332, 13]' - - type: array - minItems: 1 - items: - type: array - minItems: 1 - items: - type: integer - example: '[[1212, 318, 257, 1332, 13]]' - best_of: - type: integer - default: 1 - minimum: 0 - maximum: 20 - nullable: true - description: | - Generates `best_of` completions server-side and returns the "best" (the one with the highest log probability per token). Results cannot be streamed. - - When used with `n`, `best_of` controls the number of candidate completions and `n` specifies how many to return – `best_of` must be greater than `n`. - - **Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`. - echo: - type: boolean - default: false - nullable: true - description: | - Echo back the prompt in addition to the completion - frequency_penalty: - type: number - default: 0 - minimum: -2 - maximum: 2 - nullable: true - description: | - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - logit_bias: - type: object - x-oaiTypeLabel: map - default: null - nullable: true - additionalProperties: - type: integer - description: | - Modify the likelihood of specified tokens appearing in the completion. - - Accepts a JSON object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this [tokenizer tool](/tokenizer?view=bpe) to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. - - As an example, you can pass `{"50256": -100}` to prevent the <|endoftext|> token from being generated. - logprobs: - type: integer - minimum: 0 - maximum: 5 - default: null - nullable: true - description: | - Include the log probabilities on the `logprobs` most likely output tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response. - - The maximum value for `logprobs` is 5. - max_tokens: - type: integer - minimum: 0 - default: 16 - example: 16 - nullable: true - description: | - The maximum number of [tokens](/tokenizer) that can be generated in the completion. - - The token count of your prompt plus `max_tokens` cannot exceed the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. - 'n': - type: integer - minimum: 1 - maximum: 128 - default: 1 - example: 1 - nullable: true - description: | - How many completions to generate for each prompt. - - **Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`. - presence_penalty: - type: number - default: 0 - minimum: -2 - maximum: 2 - nullable: true - description: | - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - - [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - seed: - type: integer - minimum: -9223372036854776000 - maximum: 9223372036854776000 - nullable: true - description: | - If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. - - Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. - stop: - description: | - Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence. - default: null - nullable: true - oneOf: - - type: string - default: <|endoftext|> - example: |+ - - nullable: true - - type: array - minItems: 1 - maxItems: 4 - items: - type: string - example: '["\n"]' - stream: - description: | - Whether to stream back partial progress. If set, tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions). - type: boolean - nullable: true - default: false - stream_options: - $ref: '#/components/schemas/ChatCompletionStreamOptions' - suffix: - description: | - The suffix that comes after a completion of inserted text. - - This parameter is only supported for `gpt-3.5-turbo-instruct`. - default: null - nullable: true - type: string - example: test. - temperature: - type: number - minimum: 0 - maximum: 2 - default: 1 - example: 1 - nullable: true - description: | - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - - We generally recommend altering this or `top_p` but not both. - top_p: - type: number - minimum: 0 - maximum: 1 - default: 1 - example: 1 - nullable: true - description: | - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or `temperature` but not both. - user: - type: string - example: user-1234 - description: | - A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - required: - - model - - prompt - CreateCompletionResponse: - type: object - description: | - Represents a completion response from the API. Note: both the streamed and non-streamed response objects share the same shape (unlike the chat endpoint). - properties: - id: - type: string - description: A unique identifier for the completion. - choices: - type: array - description: The list of completion choices the model generated for the input prompt. - items: - type: object - required: - - finish_reason - - index - - logprobs - - text - properties: - finish_reason: - type: string - description: | - The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - `length` if the maximum number of tokens specified in the request was reached, - or `content_filter` if content was omitted due to a flag from our content filters. - enum: - - stop - - length - - content_filter - index: - type: integer - logprobs: - type: object - nullable: true - properties: - text_offset: - type: array - items: - type: integer - token_logprobs: - type: array - items: - type: number - tokens: - type: array - items: - type: string - top_logprobs: - type: array - items: - type: object - additionalProperties: - type: number - text: - type: string - created: - type: integer - description: The Unix timestamp (in seconds) of when the completion was created. - model: - type: string - description: The model used for completion. - system_fingerprint: - type: string - description: | - This fingerprint represents the backend configuration that the model runs with. - - Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - object: - type: string - description: 'The object type, which is always "text_completion"' - enum: - - text_completion - usage: - $ref: '#/components/schemas/CompletionUsage' - required: - - id - - object - - created - - model - - choices - x-oaiMeta: - name: The completion object - legacy: true - example: | - { - "id": "cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7", - "object": "text_completion", - "created": 1589478378, - "model": "gpt-4-turbo", - "choices": [ - { - "text": "\n\nThis is indeed a test", - "index": 0, - "logprobs": null, - "finish_reason": "length" - } - ], - "usage": { - "prompt_tokens": 5, - "completion_tokens": 7, - "total_tokens": 12 - } - } - ChatCompletionStreamOptions: - description: | - Options for streaming response. Only set this when you set `stream: true`. - type: object - nullable: true - default: null - properties: - include_usage: - type: boolean - description: | - If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value. - CompletionUsage: - type: object - description: Usage statistics for the completion request. - properties: - completion_tokens: - type: integer - description: Number of tokens in the generated completion. - prompt_tokens: - type: integer - description: Number of tokens in the prompt. - total_tokens: - type: integer - description: Total number of tokens used in the request (prompt + completion). - completion_tokens_details: - type: object - description: Breakdown of tokens used in a completion. - properties: - audio_tokens: - type: integer - description: Audio input tokens generated by the model. - reasoning_tokens: - type: integer - description: Tokens generated by the model for reasoning. - prompt_tokens_details: - type: object - description: Breakdown of tokens used in the prompt. - properties: - audio_tokens: - type: integer - description: Audio input tokens present in the prompt. - cached_tokens: - type: integer - description: Cached tokens present in the prompt. - required: - - prompt_tokens - - completion_tokens - - total_tokens - responses: {} - securitySchemes: - ApiKeyAuth: - type: http - scheme: bearer - x-stackQL-resources: - completions: - id: openai.completions.completions - name: completions - title: Completions - methods: - create_completion: - operation: - $ref: '#/paths/~1completions/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/CreateCompletionResponse' - sqlVerbs: - select: [] - insert: - - $ref: '#/components/x-stackQL-resources/completions/methods/create_completion' - update: [] - replace: [] - delete: [] -paths: - /completions: - post: - operationId: createCompletion - tags: - - Completions - summary: Creates a completion for the provided prompt and parameters. - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CreateCompletionRequest' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/CreateCompletionResponse' - x-oaiMeta: - name: Create completion - group: completions - returns: | - Returns a [completion](/docs/api-reference/completions/object) object, or a sequence of completion objects if the request is streamed. - legacy: true - examples: - - title: No streaming - request: - curl: | - curl https://api.openai.com/v1/completions \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "model": "VAR_model_id", - "prompt": "Say this is a test", - "max_tokens": 7, - "temperature": 0 - }' - python: | - from openai import OpenAI - client = OpenAI() - - client.completions.create( - model="VAR_model_id", - prompt="Say this is a test", - max_tokens=7, - temperature=0 - ) - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const completion = await openai.completions.create({ - model: "VAR_model_id", - prompt: "Say this is a test.", - max_tokens: 7, - temperature: 0, - }); - - console.log(completion); - } - main(); - response: | - { - "id": "cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7", - "object": "text_completion", - "created": 1589478378, - "model": "VAR_model_id", - "system_fingerprint": "fp_44709d6fcb", - "choices": [ - { - "text": "\n\nThis is indeed a test", - "index": 0, - "logprobs": null, - "finish_reason": "length" - } - ], - "usage": { - "prompt_tokens": 5, - "completion_tokens": 7, - "total_tokens": 12 - } - } - - title: Streaming - request: - curl: | - curl https://api.openai.com/v1/completions \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "model": "VAR_model_id", - "prompt": "Say this is a test", - "max_tokens": 7, - "temperature": 0, - "stream": true - }' - python: | - from openai import OpenAI - client = OpenAI() - - for chunk in client.completions.create( - model="VAR_model_id", - prompt="Say this is a test", - max_tokens=7, - temperature=0, - stream=True - ): - print(chunk.choices[0].text) - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const stream = await openai.completions.create({ - model: "VAR_model_id", - prompt: "Say this is a test.", - stream: true, - }); - - for await (const chunk of stream) { - console.log(chunk.choices[0].text) - } - } - main(); - response: | - { - "id": "cmpl-7iA7iJjj8V2zOkCGvWF2hAkDWBQZe", - "object": "text_completion", - "created": 1690759702, - "choices": [ - { - "text": "This", - "index": 0, - "logprobs": null, - "finish_reason": null - } - ], - "model": "gpt-3.5-turbo-instruct" - "system_fingerprint": "fp_44709d6fcb", - } diff --git a/providers/src/openai/v00.00.00000/services/containers.yaml b/providers/src/openai/v00.00.00000/services/containers.yaml new file mode 100644 index 00000000..dfbb5cef --- /dev/null +++ b/providers/src/openai/v00.00.00000/services/containers.yaml @@ -0,0 +1,1533 @@ +openapi: 3.1.0 +info: + title: containers API + description: openai API + version: 2.3.0 +paths: + /containers: + get: + summary: List Containers + description: Lists containers. + operationId: ListContainers + parameters: + - name: limit + in: query + description: >- + A limit on the number of objects to be returned. Limit can range + between 1 and 100, and the default is 20. + + + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: > + Sort order by the `created_at` timestamp of the objects. `asc` for + ascending order and `desc` for descending order. + schema: + type: string + default: desc + enum: + - asc + - desc + - name: after + in: query + 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 + - name: name + in: query + description: Filter results by container name. + required: false + schema: + type: string + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/ContainerListResource' + x-oaiMeta: + name: List containers + group: containers + path: get + examples: + request: + curl: | + curl https://api.openai.com/v1/containers \ + -H "Authorization: Bearer $OPENAI_API_KEY" + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + // Automatically fetches more pages as needed. + + for await (const containerListResponse of + client.containers.list()) { + console.log(containerListResponse.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.containers.list() + page = page.data[0] + print(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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.containers.ContainerListPage; + import com.openai.models.containers.ContainerListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ContainerListPage page = client.containers().list(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + page = openai.containers.list + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "id": "cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863", + "object": "container", + "created_at": 1747844794, + "status": "running", + "expires_after": { + "anchor": "last_active_at", + "minutes": 20 + }, + "last_active_at": 1747844794, + "memory_limit": "4g", + "name": "My Container" + } + ], + "first_id": "container_123", + "last_id": "container_123", + "has_more": false + } + tags: + - Containers + post: + summary: Create Container + description: Creates a container. + operationId: CreateContainer + parameters: + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateContainerBody' + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/ContainerResource' + x-oaiMeta: + name: Create container + group: containers + path: post + examples: + request: + curl: | + curl https://api.openai.com/v1/containers \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "My Container", + "memory_limit": "4g", + "skills": [ + { + "type": "skill_reference", + "skill_id": "skill_4db6f1a2c9e73508b41f9da06e2c7b5f" + }, + { + "type": "skill_reference", + "skill_id": "openai-spreadsheets", + "version": "latest" + } + ], + "network_policy": { + "type": "allowlist", + "allowed_domains": ["api.buildkite.com"] + } + }' + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const container = await client.containers.create({ name: 'name' + }); + + + console.log(container.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + container = client.containers.create( + name="name", + ) + print(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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.containers.ContainerCreateParams; + import com.openai.models.containers.ContainerCreateResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ContainerCreateParams params = ContainerCreateParams.builder() + .name("name") + .build(); + ContainerCreateResponse container = client.containers().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + container = openai.containers.create(name: "name") + + puts(container) + response: | + { + "id": "cntr_682e30645a488191b6363a0cbefc0f0a025ec61b66250591", + "object": "container", + "created_at": 1747857508, + "status": "running", + "expires_after": { + "anchor": "last_active_at", + "minutes": 20 + }, + "last_active_at": 1747857508, + "network_policy": { + "type": "allowlist", + "allowed_domains": ["api.buildkite.com"] + }, + "memory_limit": "4g", + "name": "My Container" + } + tags: + - Containers + /containers/{container_id}: + get: + summary: Retrieve Container + description: Retrieves a container. + operationId: RetrieveContainer + parameters: + - name: container_id + in: path + required: true + schema: + type: string + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/ContainerResource' + x-oaiMeta: + name: Retrieve container + group: containers + path: get + examples: + request: + curl: > + curl + https://api.openai.com/v1/containers/cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863 + \ + -H "Authorization: Bearer $OPENAI_API_KEY" + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const container = await + client.containers.retrieve('container_id'); + + + console.log(container.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + container = client.containers.retrieve( + "container_id", + ) + print(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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.containers.ContainerRetrieveParams; + import com.openai.models.containers.ContainerRetrieveResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ContainerRetrieveResponse container = client.containers().retrieve("container_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + container = openai.containers.retrieve("container_id") + + puts(container) + response: | + { + "id": "cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863", + "object": "container", + "created_at": 1747844794, + "status": "running", + "expires_after": { + "anchor": "last_active_at", + "minutes": 20 + }, + "last_active_at": 1747844794, + "memory_limit": "4g", + "name": "My Container" + } + tags: + - Containers + delete: + operationId: DeleteContainer + summary: Delete Container + description: Delete a container. + parameters: + - name: container_id + in: path + description: The ID of the container to delete. + required: true + schema: + type: string + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + x-oaiMeta: + name: Delete a container + group: containers + path: delete + examples: + request: + curl: > + curl -X DELETE + https://api.openai.com/v1/containers/cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863 + \ + -H "Authorization: Bearer $OPENAI_API_KEY" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + await client.containers.delete('container_id'); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + client.containers.delete( + "container_id", + ) + 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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.containers.ContainerDeleteParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + client.containers().delete("container_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + result = openai.containers.delete("container_id") + + puts(result) + response: | + { + "id": "cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863", + "object": "container.deleted", + "deleted": true + } + tags: + - Containers + /containers/{container_id}/files: + post: + summary: > + Create a Container File + + + You can send either a multipart/form-data request with the raw file + content, or a JSON request with a file ID. + description: | + Creates a container file. + operationId: CreateContainerFile + parameters: + - name: container_id + in: path + required: true + schema: + type: string + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateContainerFileBody' + multipart/form-data: + schema: + $ref: '#/components/schemas/CreateContainerFileBody' + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/ContainerFileResource' + x-oaiMeta: + name: Create container file + group: containers + path: post + examples: + request: + curl: > + curl + https://api.openai.com/v1/containers/cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04/files + \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -F file="@example.txt" + node.js: |- + import fs from 'fs'; + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const file = await client.containers.files.create('container_id'); + + console.log(file.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + file = client.containers.files.create( + container_id="container_id", + ) + print(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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.containers.files.FileCreateParams; + import com.openai.models.containers.files.FileCreateResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + FileCreateResponse file = client.containers().files().create("container_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + file = openai.containers.files.create("container_id") + + puts(file) + response: | + { + "id": "cfile_682e0e8a43c88191a7978f477a09bdf5", + "object": "container.file", + "created_at": 1747848842, + "bytes": 880, + "container_id": "cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04", + "path": "/mnt/data/88e12fa445d32636f190a0b33daed6cb-tsconfig.json", + "source": "user" + } + tags: + - Containers + get: + summary: List Container files + description: Lists container files. + operationId: ListContainerFiles + parameters: + - name: container_id + in: path + required: true + schema: + type: string + - name: limit + in: query + description: >- + A limit on the number of objects to be returned. Limit can range + between 1 and 100, and the default is 20. + + + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: > + Sort order by the `created_at` timestamp of the objects. `asc` for + ascending order and `desc` for descending order. + schema: + type: string + default: desc + enum: + - asc + - desc + - name: after + in: query + 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 + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/ContainerFileListResource' + x-oaiMeta: + name: List container files + group: containers + path: get + examples: + request: + curl: > + curl + https://api.openai.com/v1/containers/cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04/files + \ + -H "Authorization: Bearer $OPENAI_API_KEY" + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + // Automatically fetches more pages as needed. + + for await (const fileListResponse of + client.containers.files.list('container_id')) { + console.log(fileListResponse.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.containers.files.list( + container_id="container_id", + ) + page = page.data[0] + print(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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.containers.files.FileListPage; + import com.openai.models.containers.files.FileListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + FileListPage page = client.containers().files().list("container_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + page = openai.containers.files.list("container_id") + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "id": "cfile_682e0e8a43c88191a7978f477a09bdf5", + "object": "container.file", + "created_at": 1747848842, + "bytes": 880, + "container_id": "cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04", + "path": "/mnt/data/88e12fa445d32636f190a0b33daed6cb-tsconfig.json", + "source": "user" + } + ], + "first_id": "cfile_682e0e8a43c88191a7978f477a09bdf5", + "has_more": false, + "last_id": "cfile_682e0e8a43c88191a7978f477a09bdf5" + } + tags: + - Containers + /containers/{container_id}/files/{file_id}: + get: + summary: Retrieve Container File + description: Retrieves a container file. + operationId: RetrieveContainerFile + parameters: + - name: container_id + in: path + required: true + schema: + type: string + - name: file_id + in: path + required: true + schema: + type: string + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/ContainerFileResource' + 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 + \ + -H "Authorization: Bearer $OPENAI_API_KEY" + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const file = await client.containers.files.retrieve('file_id', { + container_id: 'container_id' }); + + + console.log(file.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + file = client.containers.files.retrieve( + file_id="file_id", + container_id="container_id", + ) + print(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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.containers.files.FileRetrieveParams; + import com.openai.models.containers.files.FileRetrieveResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + FileRetrieveParams params = FileRetrieveParams.builder() + .containerId("container_id") + .fileId("file_id") + .build(); + FileRetrieveResponse file = client.containers().files().retrieve(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + file = openai.containers.files.retrieve("file_id", container_id: + "container_id") + + + puts(file) + response: | + { + "id": "cfile_682e0e8a43c88191a7978f477a09bdf5", + "object": "container.file", + "created_at": 1747848842, + "bytes": 880, + "container_id": "cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04", + "path": "/mnt/data/88e12fa445d32636f190a0b33daed6cb-tsconfig.json", + "source": "user" + } + tags: + - Containers + delete: + operationId: DeleteContainerFile + summary: Delete Container File + description: Delete a container file. + parameters: + - name: container_id + in: path + required: true + schema: + type: string + - name: file_id + in: path + required: true + schema: + type: string + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + 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 + \ + -H "Authorization: Bearer $OPENAI_API_KEY" + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + await client.containers.files.delete('file_id', { container_id: + 'container_id' }); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + client.containers.files.delete( + file_id="file_id", + container_id="container_id", + ) + 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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.containers.files.FileDeleteParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + FileDeleteParams params = FileDeleteParams.builder() + .containerId("container_id") + .fileId("file_id") + .build(); + client.containers().files().delete(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + result = openai.containers.files.delete("file_id", container_id: + "container_id") + + + puts(result) + response: | + { + "id": "cfile_682e0e8a43c88191a7978f477a09bdf5", + "object": "container.file.deleted", + "deleted": true + } + tags: + - Containers +components: + schemas: + ContainerListResource: + type: object + properties: + object: + type: string + enum: + - list + description: The type of object returned, must be 'list'. + data: + type: array + description: A list of containers. + items: + $ref: '#/components/schemas/ContainerResource' + first_id: + type: string + description: The ID of the first container in the list. + last_id: + type: string + description: The ID of the last container in the list. + has_more: + type: boolean + description: Whether there are more containers available. + required: + - object + - data + - first_id + - last_id + - has_more + CreateContainerBody: + type: object + properties: + name: + type: string + description: Name of the container to create. + file_ids: + type: array + description: IDs of files to copy to the container. + items: + type: string + expires_after: + type: object + description: Container expiration time in seconds relative to the 'anchor' time. + properties: + anchor: + type: string + enum: + - last_active_at + description: >- + Time anchor for the expiration time. Currently only + 'last_active_at' is supported. + minutes: + type: integer + required: + - anchor + - minutes + skills: + type: array + description: An optional list of skills referenced by id or inline data. + items: + oneOf: + - $ref: '#/components/schemas/SkillReferenceParam' + - $ref: '#/components/schemas/InlineSkillParam' + discriminator: + propertyName: type + memory_limit: + type: string + enum: + - 1g + - 4g + - 16g + - 64g + description: Optional memory limit for the container. Defaults to "1g". + network_policy: + description: Network access policy for the container. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - disabled + description: Disable outbound network access. Always `disabled`. + default: disabled + x-stainless-const: true + allowed_domains: + items: + type: string + type: array + minItems: 1 + description: A list of allowed domains when type is `allowlist`. + domain_secrets: + items: + $ref: '#/components/schemas/ContainerNetworkPolicyDomainSecretParam' + type: array + minItems: 1 + description: Optional domain-scoped secrets for allowlisted domains. + type: object + required: + - type + - allowed_domains + required: + - name + ContainerResource: + type: object + title: The container object + properties: + id: + type: string + description: Unique identifier for the container. + object: + type: string + description: The type of this object. + name: + type: string + description: Name of the container. + created_at: + type: integer + format: unixtime + description: Unix timestamp (in seconds) when the container was created. + status: + type: string + description: Status of the container (e.g., active, deleted). + last_active_at: + type: integer + format: unixtime + description: Unix timestamp (in seconds) when the container was last active. + expires_after: + type: object + description: > + The container will expire after this time period. + + The anchor is the reference point for the expiration. + + The minutes is the number of minutes after the anchor before the + container expires. + properties: + anchor: + type: string + description: The reference point for the expiration. + enum: + - last_active_at + minutes: + type: integer + description: >- + The number of minutes after the anchor before the container + expires. + memory_limit: + type: string + description: The memory limit configured for the container. + enum: + - 1g + - 4g + - 16g + - 64g + network_policy: + description: Network access policy for the container. + type: object + properties: + type: + type: string + description: The network policy mode. + enum: + - allowlist + - disabled + allowed_domains: + type: array + description: Allowed outbound domains when `type` is `allowlist`. + items: + type: string + required: + - type + required: + - id + - object + - name + - created_at + - status + - id + - name + - created_at + - status + x-oaiMeta: + name: The container object + example: | + { + "id": "cntr_682dfebaacac8198bbfe9c2474fb6f4a085685cbe3cb5863", + "object": "container", + "created_at": 1747844794, + "status": "running", + "expires_after": { + "anchor": "last_active_at", + "minutes": 20 + }, + "last_active_at": 1747844794, + "memory_limit": "1g", + "name": "My Container" + } + CreateContainerFileBody: + type: object + properties: + file_id: + type: string + description: Name of the file to create. + required: [] + ContainerFileResource: + type: object + title: The container file object + properties: + id: + type: string + description: Unique identifier for the file. + object: + type: string + description: The type of this object (`container.file`). + container_id: + type: string + description: The container this file belongs to. + created_at: + type: integer + format: unixtime + description: Unix timestamp (in seconds) when the file was created. + bytes: + type: integer + description: Size of the file in bytes. + path: + type: string + description: Path of the file in the container. + source: + type: string + description: Source of the file (e.g., `user`, `assistant`). + required: + - id + - object + - created_at + - bytes + - container_id + - path + - source + x-oaiMeta: + name: The container file object + example: | + { + "id": "cfile_682e0e8a43c88191a7978f477a09bdf5", + "object": "container.file", + "created_at": 1747848842, + "bytes": 880, + "container_id": "cntr_682e0e7318108198aa783fd921ff305e08e78805b9fdbb04", + "path": "/mnt/data/88e12fa445d32636f190a0b33daed6cb-tsconfig.json", + "source": "user" + } + ContainerFileListResource: + type: object + properties: + object: + type: string + enum: + - list + description: The type of object returned, must be 'list'. + data: + type: array + description: A list of container files. + items: + $ref: '#/components/schemas/ContainerFileResource' + first_id: + type: string + description: The ID of the first file in the list. + last_id: + type: string + description: The ID of the last file in the list. + has_more: + type: boolean + description: Whether there are more files available. + required: + - object + - data + - first_id + - last_id + - has_more + SkillReferenceParam: + properties: + type: + type: string + enum: + - skill_reference + description: References a skill created with the /v1/skills endpoint. + default: skill_reference + x-stainless-const: true + skill_id: + type: string + maxLength: 64 + minLength: 1 + description: The ID of the referenced skill. + version: + type: string + description: >- + Optional skill version. Use a positive integer or 'latest'. Omit for + default. + type: object + required: + - type + - skill_id + InlineSkillParam: + properties: + type: + type: string + enum: + - inline + description: Defines an inline skill for this request. + default: inline + x-stainless-const: true + name: + type: string + description: The name of the skill. + description: + type: string + description: The description of the skill. + source: + $ref: '#/components/schemas/InlineSkillSourceParam' + description: Inline skill payload + type: object + required: + - type + - name + - description + - source + ContainerNetworkPolicyDisabledParam: + properties: + type: + type: string + enum: + - disabled + description: Disable outbound network access. Always `disabled`. + default: disabled + x-stainless-const: true + type: object + required: + - type + ContainerNetworkPolicyAllowlistParam: + properties: + type: + type: string + enum: + - allowlist + description: >- + Allow outbound network access only to specified domains. Always + `allowlist`. + default: allowlist + x-stainless-const: true + allowed_domains: + items: + type: string + type: array + minItems: 1 + description: A list of allowed domains when type is `allowlist`. + domain_secrets: + items: + $ref: '#/components/schemas/ContainerNetworkPolicyDomainSecretParam' + type: array + minItems: 1 + description: Optional domain-scoped secrets for allowlisted domains. + type: object + required: + - type + - allowed_domains + InlineSkillSourceParam: + properties: + type: + type: string + enum: + - base64 + description: The type of the inline skill source. Must be `base64`. + default: base64 + x-stainless-const: true + media_type: + type: string + enum: + - application/zip + description: >- + The media type of the inline skill payload. Must be + `application/zip`. + default: application/zip + x-stainless-const: true + data: + type: string + maxLength: 70254592 + minLength: 1 + description: Base64-encoded skill zip bundle. + type: object + required: + - type + - media_type + - data + description: Inline skill payload + ContainerNetworkPolicyDomainSecretParam: + properties: + domain: + type: string + minLength: 1 + description: The domain associated with the secret. + name: + type: string + minLength: 1 + description: The name of the secret to inject for the domain. + value: + type: string + maxLength: 10485760 + minLength: 1 + description: The secret value to inject for the domain. + type: object + required: + - domain + - name + - value + x-stackQL-resources: + containers: + id: openai.containers.containers + name: containers + title: Containers + methods: + list: + operation: + $ref: '#/paths/~1containers/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1containers/post' + response: + mediaType: application/json + openAPIDocKey: '200' + get: + operation: + $ref: '#/paths/~1containers~1{container_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1containers~1{container_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/containers/methods/get' + - $ref: '#/components/x-stackQL-resources/containers/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/containers/methods/create' + update: [] + delete: + - $ref: '#/components/x-stackQL-resources/containers/methods/delete' + replace: [] + files: + id: openai.containers.files + name: files + title: Files + methods: + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1containers~1{container_id}~1files/post' + response: + mediaType: application/json + openAPIDocKey: '200' + list: + operation: + $ref: '#/paths/~1containers~1{container_id}~1files/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + get: + operation: + $ref: '#/paths/~1containers~1{container_id}~1files~1{file_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1containers~1{container_id}~1files~1{file_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/files/methods/get' + - $ref: '#/components/x-stackQL-resources/files/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/files/methods/create' + update: [] + delete: + - $ref: '#/components/x-stackQL-resources/files/methods/delete' + replace: [] +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.last_id + location: body + queryParamPushdown: + top: + paramName: limit + maxValue: 100 diff --git a/providers/src/openai/v00.00.00000/services/conversations.yaml b/providers/src/openai/v00.00.00000/services/conversations.yaml new file mode 100644 index 00000000..be4fab07 --- /dev/null +++ b/providers/src/openai/v00.00.00000/services/conversations.yaml @@ -0,0 +1,8173 @@ +openapi: 3.1.0 +info: + title: conversations API + description: openai API + version: 2.3.0 +paths: + /conversations/{conversation_id}/items: + post: + operationId: createConversationItems + tags: + - Conversations + summary: Create items in a conversation with the given ID. + parameters: + - in: path + name: conversation_id + required: true + schema: + type: string + example: conv_123 + description: The ID of the conversation to add the item to. + - name: include + in: query + required: false + schema: + type: array + items: + $ref: '#/components/schemas/IncludeEnum' + description: > + Additional fields to include in the response. See the `include` + + parameter for [listing Conversation items + above](/docs/api-reference/conversations/list-items#conversations_list_items-include) + for more information. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + properties: + items: + type: array + description: > + The items to add to the conversation. You may add up to 20 + items at a time. + items: + $ref: '#/components/schemas/InputItem' + maxItems: 20 + required: + - items + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ConversationItemList' + x-oaiMeta: + name: Create items + group: conversations + path: create-item + examples: + request: + curl: | + curl https://api.openai.com/v1/conversations/conv_123/items \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "items": [ + { + "type": "message", + "role": "user", + "content": [ + {"type": "input_text", "text": "Hello!"} + ] + }, + { + "type": "message", + "role": "user", + "content": [ + {"type": "input_text", "text": "How are you?"} + ] + } + ] + }' + javascript: | + import OpenAI from "openai"; + const client = new OpenAI(); + + const items = await client.conversations.items.create( + "conv_123", + { + items: [ + { + type: "message", + role: "user", + content: [{ type: "input_text", text: "Hello!" }], + }, + { + type: "message", + role: "user", + content: [{ type: "input_text", text: "How are you?" }], + }, + ], + } + ); + console.log(items.data); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + conversation_item_list = client.conversations.items.create( + conversation_id="conv_123", + items=[{ + "content": "string", + "role": "user", + "type": "message", + }], + ) + print(conversation_item_list.first_id) + csharp: | + using System; + using System.Collections.Generic; + using OpenAI.Conversations; + + OpenAIConversationClient client = new( + apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY") + ); + + ConversationItemList created = client.ConversationItems.Create( + conversationId: "conv_123", + new CreateConversationItemsOptions + { + Items = new List + { + new ConversationMessage + { + Role = "user", + Content = + { + new ConversationInputText { Text = "Hello!" } + } + }, + new ConversationMessage + { + Role = "user", + Content = + { + new ConversationInputText { Text = "How are you?" } + } + } + } + } + ); + Console.WriteLine(created.Data.Count); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const conversationItemList = await + client.conversations.items.create('conv_123', { + items: [ + { + content: 'string', + role: 'user', + type: 'message', + }, + ], + }); + + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.conversations.items.ConversationItemList; + import com.openai.models.conversations.items.ItemCreateParams; + import com.openai.models.responses.EasyInputMessage; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ItemCreateParams params = ItemCreateParams.builder() + .conversationId("conv_123") + .addItem(EasyInputMessage.builder() + .content("string") + .role(EasyInputMessage.Role.USER) + .type(EasyInputMessage.Type.MESSAGE) + .build()) + .build(); + ConversationItemList conversationItemList = client.conversations().items().create(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + conversation_item_list = + openai.conversations.items.create("conv_123", items: [{content: + "string", role: :user, type: :message}]) + + + puts(conversation_item_list) + response: | + { + "object": "list", + "data": [ + { + "type": "message", + "id": "msg_abc", + "status": "completed", + "role": "user", + "content": [ + {"type": "input_text", "text": "Hello!"} + ] + }, + { + "type": "message", + "id": "msg_def", + "status": "completed", + "role": "user", + "content": [ + {"type": "input_text", "text": "How are you?"} + ] + } + ], + "first_id": "msg_abc", + "last_id": "msg_def", + "has_more": false + } + get: + operationId: listConversationItems + tags: + - Conversations + summary: List all items for a conversation with the given ID. + parameters: + - in: path + name: conversation_id + required: true + schema: + type: string + example: conv_123 + description: The ID of the conversation to list items for. + - name: limit + in: query + description: >- + A limit on the number of objects to be returned. Limit can range + between + + 1 and 100, and the default is 20. + + + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. + required: false + schema: + type: integer + default: 20 + - in: query + name: order + schema: + type: string + enum: + - asc + - desc + description: | + The order to return the input items in. Default is `desc`. + - `asc`: Return the input items in ascending order. + - `desc`: Return the input items in descending order. + - in: query + name: after + schema: + type: string + description: | + An item ID to list items after, used in pagination. + - name: include + in: query + required: false + schema: + type: array + items: + $ref: '#/components/schemas/IncludeEnum' + description: >- + Specify additional output data to include in the model response. + Currently supported values are: + + - `web_search_call.action.sources`: Include the sources of the web + search tool call. + + - `code_interpreter_call.outputs`: Includes the outputs of python + code execution in code interpreter tool call items. + + - `computer_call_output.output.image_url`: Include image urls from + the computer call output. + + - `file_search_call.results`: Include the search results of the file + search tool call. + + - `message.input_image.image_url`: Include image urls from the input + message. + + - `message.output_text.logprobs`: Include logprobs with assistant + messages. + + - `reasoning.encrypted_content`: Includes an encrypted version of + reasoning tokens in reasoning item outputs. This enables reasoning + items to be used in multi-turn conversations when using the + Responses API statelessly (like when the `store` parameter is set to + `false`, or when an organization is enrolled in the zero data + retention program). + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ConversationItemList' + 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" + \ + -H "Authorization: Bearer $OPENAI_API_KEY" + javascript: > + import OpenAI from "openai"; + + const client = new OpenAI(); + + + const items = await client.conversations.items.list("conv_123", { + limit: 10 }); + + console.log(items.data); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.conversations.items.list( + conversation_id="conv_123", + ) + page = page.data[0] + print(page) + csharp: | + using System; + using OpenAI.Conversations; + + OpenAIConversationClient client = new( + apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY") + ); + + ConversationItemList items = client.ConversationItems.List( + conversationId: "conv_123", + new ListConversationItemsOptions { Limit = 10 } + ); + Console.WriteLine(items.Data.Count); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + // Automatically fetches more pages as needed. + + for await (const conversationItem of + client.conversations.items.list('conv_123')) { + console.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\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.conversations.items.ItemListPage; + import com.openai.models.conversations.items.ItemListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ItemListPage page = client.conversations().items().list("conv_123"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + page = openai.conversations.items.list("conv_123") + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "type": "message", + "id": "msg_abc", + "status": "completed", + "role": "user", + "content": [ + {"type": "input_text", "text": "Hello!"} + ] + } + ], + "first_id": "msg_abc", + "last_id": "msg_abc", + "has_more": false + } + /conversations/{conversation_id}/items/{item_id}: + get: + operationId: getConversationItem + tags: + - Conversations + summary: Get a single item from a conversation with the given IDs. + parameters: + - in: path + name: conversation_id + required: true + schema: + type: string + example: conv_123 + description: The ID of the conversation that contains the item. + - in: path + name: item_id + required: true + schema: + type: string + example: msg_abc + description: The ID of the item to retrieve. + - name: include + in: query + required: false + schema: + type: array + items: + $ref: '#/components/schemas/IncludeEnum' + description: > + Additional fields to include in the response. See the `include` + + parameter for [listing Conversation items + above](/docs/api-reference/conversations/list-items#conversations_list_items-include) + for more information. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ConversationItem' + 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 \ + -H "Authorization: Bearer $OPENAI_API_KEY" + javascript: | + import OpenAI from "openai"; + const client = new OpenAI(); + + const item = await client.conversations.items.retrieve( + "conv_123", + "msg_abc" + ); + console.log(item); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + conversation_item = client.conversations.items.retrieve( + item_id="msg_abc", + conversation_id="conv_123", + ) + print(conversation_item) + csharp: | + using System; + using OpenAI.Conversations; + + OpenAIConversationClient client = new( + apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY") + ); + + ConversationItem item = client.ConversationItems.Get( + conversationId: "conv_123", + itemId: "msg_abc" + ); + Console.WriteLine(item.Id); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const conversationItem = await + client.conversations.items.retrieve('msg_abc', { + conversation_id: 'conv_123', + }); + + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.conversations.items.ConversationItem; + import com.openai.models.conversations.items.ItemRetrieveParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ItemRetrieveParams params = ItemRetrieveParams.builder() + .conversationId("conv_123") + .itemId("msg_abc") + .build(); + ConversationItem conversationItem = client.conversations().items().retrieve(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + conversation_item = openai.conversations.items.retrieve("msg_abc", + conversation_id: "conv_123") + + + puts(conversation_item) + response: | + { + "type": "message", + "id": "msg_abc", + "status": "completed", + "role": "user", + "content": [ + {"type": "input_text", "text": "Hello!"} + ] + } + delete: + operationId: deleteConversationItem + tags: + - Conversations + summary: Delete an item from a conversation with the given IDs. + parameters: + - in: path + name: conversation_id + required: true + schema: + type: string + example: conv_123 + description: The ID of the conversation that contains the item. + - in: path + name: item_id + required: true + schema: + type: string + example: msg_abc + description: The ID of the item to delete. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ConversationResource' + 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 \ + -H "Authorization: Bearer $OPENAI_API_KEY" + javascript: | + import OpenAI from "openai"; + const client = new OpenAI(); + + const conversation = await client.conversations.items.delete( + "conv_123", + "msg_abc" + ); + console.log(conversation); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + conversation = client.conversations.items.delete( + item_id="msg_abc", + conversation_id="conv_123", + ) + print(conversation.id) + csharp: | + using System; + using OpenAI.Conversations; + + OpenAIConversationClient client = new( + apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY") + ); + + Conversation conversation = client.ConversationItems.Delete( + conversationId: "conv_123", + itemId: "msg_abc" + ); + Console.WriteLine(conversation.Id); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const conversation = await + client.conversations.items.delete('msg_abc', { + conversation_id: 'conv_123', + }); + + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.conversations.Conversation; + import com.openai.models.conversations.items.ItemDeleteParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ItemDeleteParams params = ItemDeleteParams.builder() + .conversationId("conv_123") + .itemId("msg_abc") + .build(); + Conversation conversation = client.conversations().items().delete(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + conversation = openai.conversations.items.delete("msg_abc", + conversation_id: "conv_123") + + + puts(conversation) + response: | + { + "id": "conv_123", + "object": "conversation", + "created_at": 1741900000, + "metadata": {"topic": "demo"} + } + /conversations: + post: + tags: + - Conversations + summary: Create a conversation. + operationId: createConversation + parameters: + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateConversationBody' + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/ConversationResource' + x-oaiMeta: + name: Create a conversation + group: conversations + path: create + examples: + request: + curl: | + curl https://api.openai.com/v1/conversations \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "metadata": {"topic": "demo"}, + "items": [ + { + "type": "message", + "role": "user", + "content": "Hello!" + } + ] + }' + javascript: | + import OpenAI from "openai"; + const client = new OpenAI(); + + const conversation = await client.conversations.create({ + metadata: { topic: "demo" }, + items: [ + { type: "message", role: "user", content: "Hello!" } + ], + }); + console.log(conversation); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + conversation = client.conversations.create() + print(conversation.id) + csharp: | + using System; + using System.Collections.Generic; + using OpenAI.Conversations; + + OpenAIConversationClient client = new( + apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY") + ); + + Conversation conversation = client.CreateConversation( + new CreateConversationOptions + { + Metadata = new Dictionary + { + { "topic", "demo" } + }, + Items = + { + new ConversationMessageInput + { + Role = "user", + Content = "Hello!", + } + } + } + ); + Console.WriteLine(conversation.Id); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const conversation = await client.conversations.create(); + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.conversations.Conversation; + import com.openai.models.conversations.ConversationCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Conversation conversation = client.conversations().create(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + conversation = openai.conversations.create + + puts(conversation) + response: | + { + "id": "conv_123", + "object": "conversation", + "created_at": 1741900000, + "metadata": {"topic": "demo"} + } + /conversations/{conversation_id}: + get: + tags: + - Conversations + summary: Get a conversation + operationId: getConversation + parameters: + - name: conversation_id + in: path + description: The ID of the conversation to retrieve. + required: true + schema: + example: conv_123 + type: string + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/ConversationResource' + x-oaiMeta: + name: Retrieve a conversation + group: conversations + path: retrieve + examples: + request: + curl: | + curl https://api.openai.com/v1/conversations/conv_123 \ + -H "Authorization: Bearer $OPENAI_API_KEY" + javascript: > + import OpenAI from "openai"; + + const client = new OpenAI(); + + + const conversation = await + client.conversations.retrieve("conv_123"); + + console.log(conversation); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + conversation = client.conversations.retrieve( + "conv_123", + ) + print(conversation.id) + csharp: | + using System; + using OpenAI.Conversations; + + OpenAIConversationClient client = new( + apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY") + ); + + Conversation conversation = client.GetConversation("conv_123"); + Console.WriteLine(conversation.Id); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const conversation = await + client.conversations.retrieve('conv_123'); + + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.conversations.Conversation; + import com.openai.models.conversations.ConversationRetrieveParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Conversation conversation = client.conversations().retrieve("conv_123"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + conversation = openai.conversations.retrieve("conv_123") + + puts(conversation) + response: | + { + "id": "conv_123", + "object": "conversation", + "created_at": 1741900000, + "metadata": {"topic": "demo"} + } + delete: + tags: + - Conversations + summary: Delete a conversation. Items in the conversation will not be deleted. + operationId: deleteConversation + parameters: + - name: conversation_id + in: path + description: The ID of the conversation to delete. + required: true + schema: + example: conv_123 + type: string + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/DeletedConversationResource' + x-oaiMeta: + name: Delete a conversation + group: conversations + path: delete + examples: + request: + curl: | + curl -X DELETE https://api.openai.com/v1/conversations/conv_123 \ + -H "Authorization: Bearer $OPENAI_API_KEY" + javascript: | + import OpenAI from "openai"; + const client = new OpenAI(); + + const deleted = await client.conversations.delete("conv_123"); + console.log(deleted); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + conversation_deleted_resource = client.conversations.delete( + "conv_123", + ) + print(conversation_deleted_resource.id) + csharp: > + using System; + + using OpenAI.Conversations; + + + OpenAIConversationClient client = new( + apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY") + ); + + + DeletedConversation deleted = + client.DeleteConversation("conv_123"); + + Console.WriteLine(deleted.Id); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const conversationDeletedResource = await + client.conversations.delete('conv_123'); + + + console.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; + + + import com.openai.client.OpenAIClient; + + import com.openai.client.okhttp.OpenAIOkHttpClient; + + import com.openai.models.conversations.ConversationDeleteParams; + + import + com.openai.models.conversations.ConversationDeletedResource; + + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ConversationDeletedResource conversationDeletedResource = client.conversations().delete("conv_123"); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + conversation_deleted_resource = + openai.conversations.delete("conv_123") + + + puts(conversation_deleted_resource) + response: | + { + "id": "conv_123", + "object": "conversation.deleted", + "deleted": true + } + post: + tags: + - Conversations + summary: Update a conversation + operationId: updateConversation + parameters: + - name: conversation_id + in: path + description: The ID of the conversation to update. + required: true + schema: + example: conv_123 + type: string + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateConversationBody' + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/ConversationResource' + x-oaiMeta: + name: Update a conversation + group: conversations + path: update + examples: + request: + curl: | + curl https://api.openai.com/v1/conversations/conv_123 \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "metadata": {"topic": "project-x"} + }' + javascript: | + import OpenAI from "openai"; + const client = new OpenAI(); + + const updated = await client.conversations.update( + "conv_123", + { metadata: { topic: "project-x" } } + ); + console.log(updated); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + conversation = client.conversations.update( + conversation_id="conv_123", + metadata={ + "foo": "string" + }, + ) + print(conversation.id) + csharp: | + using System; + using System.Collections.Generic; + using OpenAI.Conversations; + + OpenAIConversationClient client = new( + apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY") + ); + + Conversation updated = client.UpdateConversation( + conversationId: "conv_123", + new UpdateConversationOptions + { + Metadata = new Dictionary + { + { "topic", "project-x" } + } + } + ); + Console.WriteLine(updated.Id); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const conversation = await client.conversations.update('conv_123', + { metadata: { foo: 'string' } }); + + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.core.JsonValue; + import com.openai.models.conversations.Conversation; + import com.openai.models.conversations.ConversationUpdateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ConversationUpdateParams params = ConversationUpdateParams.builder() + .conversationId("conv_123") + .metadata(ConversationUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build()) + .build(); + Conversation conversation = client.conversations().update(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + conversation = openai.conversations.update("conv_123", metadata: + {foo: "string"}) + + + puts(conversation) + response: | + { + "id": "conv_123", + "object": "conversation", + "created_at": 1741900000, + "metadata": {"topic": "project-x"} + } +components: + schemas: + IncludeEnum: + type: string + enum: + - file_search_call.results + - web_search_call.results + - web_search_call.action.sources + - message.input_image.image_url + - computer_call_output.output.image_url + - code_interpreter_call.outputs + - reasoning.encrypted_content + - message.output_text.logprobs + description: >- + Specify additional output data to include in the model response. + Currently supported values are: + + - `web_search_call.results`: Include the search results of the web + search tool call. + + - `web_search_call.action.sources`: Include the sources of the web + search tool call. + + - `code_interpreter_call.outputs`: Includes the outputs of python code + execution in code interpreter tool call items. + + - `computer_call_output.output.image_url`: Include image urls from the + computer call output. + + - `file_search_call.results`: Include the search results of the file + search tool call. + + - `message.input_image.image_url`: Include image urls from the input + message. + + - `message.output_text.logprobs`: Include logprobs with assistant + messages. + + - `reasoning.encrypted_content`: Includes an encrypted version of + reasoning tokens in reasoning item outputs. This enables reasoning items + to be used in multi-turn conversations when using the Responses API + statelessly (like when the `store` parameter is set to `false`, or when + an organization is enrolled in the zero data retention program). + InputItem: + discriminator: + propertyName: type + type: object + title: Input message + description: > + A message input to the model with a role indicating instruction + following + + hierarchy. Instructions given with the `developer` or `system` role take + + precedence over instructions given with the `user` role. Messages with + the + + `assistant` role are presumed to have been generated by the model in + previous + + interactions. + properties: + role: + type: string + description: > + The role of the message input. One of `user`, `assistant`, `system`, + or + + `developer`. + enum: + - user + - assistant + - system + - developer + content: + description: > + Text, image, or audio input to the model, used to generate a + response. + + Can also contain previous assistant responses. + type: string + title: Text input + items: + $ref: '#/components/schemas/InputContent' + phase: + type: string + description: > + Labels an `assistant` message as intermediate commentary + (`commentary`) or the final answer (`final_answer`). + + For models like `gpt-5.3-codex` and beyond, when sending follow-up + requests, preserve and resend + + phase on all assistant messages — dropping it can degrade + performance. Not used for user messages. + enum: + - commentary + - final_answer + type: + type: string + description: | + The type of the message input. Always `message`. + enum: + - message + x-stainless-const: true + status: + type: string + description: | + The status of item. One of `in_progress`, `completed`, or + `incomplete`. Populated when items are returned via API. + enum: + - in_progress + - completed + - incomplete + id: + type: string + description: | + The unique ID of the output message. + queries: + type: array + items: + type: string + description: | + The queries used to search for files. + results: + type: array + description: | + The results of the file search tool call. + items: + type: object + properties: + file_id: + type: string + description: | + The unique ID of the file. + text: + type: string + description: | + The text that was retrieved from the file. + filename: + type: string + description: | + The name of the file. + attributes: + $ref: '#/components/schemas/VectorStoreFileAttributes' + score: + type: number + format: float + description: | + The relevance score of the file - a value between 0 and 1. + call_id: + type: string + description: | + An identifier used when responding to the tool call with output. + action: + $ref: '#/components/schemas/ComputerAction' + actions: + $ref: '#/components/schemas/ComputerActionList' + pending_safety_checks: + type: array + items: + $ref: '#/components/schemas/ComputerCallSafetyCheckParam' + description: | + The pending safety checks for the computer call. + output: + $ref: '#/components/schemas/ComputerScreenshotImage' + acknowledged_safety_checks: + items: + $ref: '#/components/schemas/ComputerCallSafetyCheckParam' + type: array + description: >- + The safety checks reported by the API that have been acknowledged by + the developer. + namespace: + type: string + description: | + The namespace of the function to run. + name: + type: string + description: | + The name of the function to run. + arguments: + type: string + description: | + A JSON string of the arguments to pass to the function. + execution: + $ref: '#/components/schemas/ToolSearchExecutionType' + description: Whether tool search was executed by the server or by the client. + tools: + items: + $ref: '#/components/schemas/Tool' + type: array + description: The loaded tool definitions returned by the tool search output. + encrypted_content: + type: string + description: > + The encrypted content of the reasoning item - populated when a + response is + + generated with `reasoning.encrypted_content` in the `include` + parameter. + summary: + type: array + description: | + Reasoning summary content. + items: + $ref: '#/components/schemas/SummaryTextContent' + result: + type: string + description: | + The generated image encoded in base64. + container_id: + type: string + description: | + The ID of the container used to run the code. + code: + type: string + description: | + The code to run, or null if not available. + outputs: + type: array + items: + oneOf: + - $ref: '#/components/schemas/CodeInterpreterOutputLogs' + - $ref: '#/components/schemas/CodeInterpreterOutputImage' + discriminator: + propertyName: type + discriminator: + propertyName: type + description: > + The outputs generated by the code interpreter, such as logs or + images. + + Can be null if no outputs are available. + environment: + oneOf: + - $ref: '#/components/schemas/LocalEnvironmentParam' + - $ref: '#/components/schemas/ContainerReferenceParam' + description: The environment to execute the shell commands in. + discriminator: + propertyName: type + type: 'null' + max_output_length: + type: integer + description: >- + The maximum number of UTF-8 characters captured for this shell + call's combined output. + operation: + $ref: '#/components/schemas/ApplyPatchOperationParam' + description: >- + The specific create, delete, or update instruction for the + apply_patch tool call. + server_label: + type: string + description: | + The label of the MCP server. + error: + type: string + description: | + Error message if the server could not list tools. + approval_request_id: + type: string + description: | + The ID of the approval request being answered. + approve: + type: boolean + description: | + Whether the request was approved. + reason: + type: string + description: | + Optional reason for the decision. + input: + type: string + description: | + The input for the custom tool call generated by the model. + required: + - role + - content + - id + - type + - status + - queries + - call_id + - pending_safety_checks + - output + - action + - name + - arguments + - tools + - summary + - encrypted_content + - result + - container_id + - code + - outputs + - operation + - server_label + - request_id + - approve + - approval_request_id + - input + ConversationItemList: + type: object + title: The conversation item list + description: A list of Conversation items. + properties: + object: + type: string + description: The type of object returned, must be `list`. + enum: + - list + x-stainless-const: true + data: + type: array + description: A list of conversation items. + items: + $ref: '#/components/schemas/ConversationItem' + has_more: + type: boolean + description: Whether there are more items available. + first_id: + type: string + description: The ID of the first item in the list. + last_id: + type: string + description: The ID of the last item in the list. + required: + - object + - data + - has_more + - first_id + - last_id + x-oaiMeta: + name: The item list + group: conversations + ConversationItem: + title: Conversation item + description: >- + A single item within a conversation. The set of possible types are the + same as the `output` type of a [Response + object](/docs/api-reference/responses/object#responses/object-output). + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - message + description: The type of the message. Always set to `message`. + default: message + x-stainless-const: true + id: + type: string + description: The unique ID of the message. + status: + $ref: '#/components/schemas/MessageStatus' + description: >- + The status of item. One of `in_progress`, `completed`, or + `incomplete`. Populated when items are returned via API. + role: + $ref: '#/components/schemas/MessageRole' + description: >- + The role of the message. One of `unknown`, `user`, `assistant`, + `system`, `critic`, `discriminator`, `developer`, or `tool`. + content: + items: + oneOf: + - $ref: '#/components/schemas/InputTextContent' + - $ref: '#/components/schemas/OutputTextContent' + - $ref: '#/components/schemas/TextContent' + - $ref: '#/components/schemas/SummaryTextContent' + - $ref: '#/components/schemas/ReasoningTextContent' + - $ref: '#/components/schemas/RefusalContent' + - $ref: '#/components/schemas/InputImageContent' + - $ref: '#/components/schemas/ComputerScreenshotContent' + - $ref: '#/components/schemas/InputFileContent' + description: A content part that makes up an input or output item. + discriminator: + propertyName: type + type: array + description: The content of the message + phase: + type: string + enum: + - commentary + - final_answer + call_id: + type: string + description: | + The unique ID of the function tool call generated by the model. + namespace: + type: string + description: | + The namespace of the function to run. + name: + type: string + description: | + The name of the function to run. + arguments: + type: string + description: | + A JSON string of the arguments to pass to the function. + created_by: + type: string + description: | + The identifier of the actor that created the item. + output: + description: | + The output from the function call generated by your code. + Can be a string or an list of output content. + type: string + title: string output + items: + $ref: '#/components/schemas/FunctionAndCustomToolCallOutput' + queries: + type: array + items: + type: string + description: | + The queries used to search for files. + results: + type: array + description: | + The results of the file search tool call. + items: + type: object + properties: + file_id: + type: string + description: | + The unique ID of the file. + text: + type: string + description: | + The text that was retrieved from the file. + filename: + type: string + description: | + The name of the file. + attributes: + $ref: '#/components/schemas/VectorStoreFileAttributes' + score: + type: number + format: float + description: | + The relevance score of the file - a value between 0 and 1. + action: + type: object + description: > + An object describing the specific action taken in this web search + call. + + Includes details on how the model used the web (search, open_page, + find_in_page). + discriminator: + propertyName: type + title: Search action + properties: + type: + type: string + enum: + - search + description: | + The action type. + x-stainless-const: true + query: + type: string + description: | + [DEPRECATED] The search query. + queries: + type: array + title: Search queries + description: | + The search queries. + items: + type: string + description: | + A search query. + sources: + type: array + title: Web search sources + description: | + The sources used in the search. + items: + type: object + title: Web search source + description: | + A source used in the search. + properties: + type: + type: string + enum: + - url + description: | + The type of source. Always `url`. + x-stainless-const: true + url: + type: string + format: uri + description: | + The URL of the source. + required: + - type + - url + url: + description: | + The URL opened by the model. + type: string + format: uri + pattern: + type: string + description: | + The pattern or text to search for within the page. + required: + - type + - query + - url + - pattern + result: + type: string + description: | + The generated image encoded in base64. + actions: + $ref: '#/components/schemas/ComputerActionList' + pending_safety_checks: + type: array + items: + $ref: '#/components/schemas/ComputerCallSafetyCheckParam' + description: | + The pending safety checks for the computer call. + acknowledged_safety_checks: + type: array + description: > + The safety checks reported by the API that have been acknowledged by + the + + developer. + items: + $ref: '#/components/schemas/ComputerCallSafetyCheckParam' + execution: + $ref: '#/components/schemas/ToolSearchExecutionType' + description: Whether tool search was executed by the server or by the client. + tools: + items: + $ref: '#/components/schemas/Tool' + type: array + description: The loaded tool definitions returned by tool search. + encrypted_content: + type: string + description: > + The encrypted content of the reasoning item - populated when a + response is + + generated with `reasoning.encrypted_content` in the `include` + parameter. + summary: + type: array + description: | + Reasoning summary content. + items: + $ref: '#/components/schemas/SummaryTextContent' + container_id: + type: string + description: | + The ID of the container used to run the code. + code: + type: string + description: | + The code to run, or null if not available. + outputs: + type: array + items: + oneOf: + - $ref: '#/components/schemas/CodeInterpreterOutputLogs' + - $ref: '#/components/schemas/CodeInterpreterOutputImage' + discriminator: + propertyName: type + discriminator: + propertyName: type + description: > + The outputs generated by the code interpreter, such as logs or + images. + + Can be null if no outputs are available. + environment: + type: string + format: json + max_output_length: + type: integer + description: >- + The maximum length of the shell command output. This is generated by + the model and should be passed back with the raw output. + operation: + title: Apply patch operation + description: >- + One of the create_file, delete_file, or update_file operations + applied via apply_patch. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - create_file + description: Create a new file with the provided diff. + default: create_file + x-stainless-const: true + path: + type: string + description: Path of the file to create. + diff: + type: string + description: Diff to apply. + type: object + required: + - type + - path + - diff + server_label: + type: string + description: | + The label of the MCP server. + error: + type: string + description: | + Error message if the server could not list tools. + approval_request_id: + type: string + description: | + The ID of the approval request being answered. + approve: + type: boolean + description: | + Whether the request was approved. + reason: + type: string + description: | + Optional reason for the decision. + input: + type: string + description: | + The input for the custom tool call generated by the model. + type: object + required: + - type + - id + - status + - role + - content + - call_id + - name + - arguments + - output + - queries + - action + - result + - pending_safety_checks + - execution + - tools + - summary + - encrypted_content + - container_id + - code + - outputs + - environment + - max_output_length + - operation + - server_label + - request_id + - approve + - approval_request_id + - input + ConversationResource: + properties: + id: + type: string + description: The unique ID of the conversation. + object: + type: string + enum: + - conversation + description: The object type, which is always `conversation`. + default: conversation + x-stainless-const: true + metadata: + description: >- + Set of 16 key-value pairs that can be attached to an object. This + can be useful for storing additional information about the + object in a structured format, and querying for objects via + API or the dashboard. + Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters. + created_at: + type: integer + format: unixtime + description: >- + The time at which the conversation was created, measured in seconds + since the Unix epoch. + type: object + required: + - id + - object + - metadata + - created_at + CreateConversationBody: + properties: + metadata: + type: object + description: > + Set of 16 key-value pairs that can be attached to an object. This + can be + + useful for storing additional information about the object in a + structured + + format, and querying for objects via API or the dashboard. + + + Keys are strings with a maximum length of 64 characters. Values are + strings + + with a maximum length of 512 characters. + additionalProperties: + type: string + x-oaiTypeLabel: map + items: + items: + $ref: '#/components/schemas/InputItem' + type: array + maxItems: 20 + description: >- + Initial items to include in the conversation context. You may add up + to 20 items at a time. + type: object + required: [] + DeletedConversationResource: + properties: + object: + type: string + enum: + - conversation.deleted + default: conversation.deleted + x-stainless-const: true + deleted: + type: boolean + id: + type: string + type: object + required: + - object + - deleted + - id + UpdateConversationBody: + properties: + metadata: + $ref: '#/components/schemas/Metadata' + description: >- + Set of 16 key-value pairs that can be attached to an object. This + can be useful for storing additional information about the + object in a structured format, and querying for objects via + API or the dashboard. + Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters. + type: object + required: + - metadata + EasyInputMessage: + type: object + title: Input message + description: > + A message input to the model with a role indicating instruction + following + + hierarchy. Instructions given with the `developer` or `system` role take + + precedence over instructions given with the `user` role. Messages with + the + + `assistant` role are presumed to have been generated by the model in + previous + + interactions. + properties: + role: + type: string + description: > + The role of the message input. One of `user`, `assistant`, `system`, + or + + `developer`. + enum: + - user + - assistant + - system + - developer + content: + description: > + Text, image, or audio input to the model, used to generate a + response. + + Can also contain previous assistant responses. + type: string + title: Text input + items: + $ref: '#/components/schemas/InputContent' + phase: + type: string + description: > + Labels an `assistant` message as intermediate commentary + (`commentary`) or the final answer (`final_answer`). + + For models like `gpt-5.3-codex` and beyond, when sending follow-up + requests, preserve and resend + + phase on all assistant messages — dropping it can degrade + performance. Not used for user messages. + enum: + - commentary + - final_answer + type: + type: string + description: | + The type of the message input. Always `message`. + enum: + - message + x-stainless-const: true + required: + - role + - content + Item: + type: object + description: | + Content item used to generate a response. + discriminator: + propertyName: type + title: Input message + properties: + type: + type: string + description: | + The type of the message input. Always set to `message`. + enum: + - message + x-stainless-const: true + role: + type: string + description: > + The role of the message input. One of `user`, `system`, or + `developer`. + enum: + - user + - system + - developer + status: + type: string + description: | + The status of item. One of `in_progress`, `completed`, or + `incomplete`. Populated when items are returned via API. + enum: + - in_progress + - completed + - incomplete + content: + $ref: '#/components/schemas/InputMessageContentList' + id: + type: string + description: | + The unique ID of the output message. + phase: + type: string + description: > + Labels an `assistant` message as intermediate commentary + (`commentary`) or the final answer (`final_answer`). + + For models like `gpt-5.3-codex` and beyond, when sending follow-up + requests, preserve and resend + + phase on all assistant messages — dropping it can degrade + performance. Not used for user messages. + enum: + - commentary + - final_answer + queries: + type: array + items: + type: string + description: | + The queries used to search for files. + results: + type: array + description: | + The results of the file search tool call. + items: + type: object + properties: + file_id: + type: string + description: | + The unique ID of the file. + text: + type: string + description: | + The text that was retrieved from the file. + filename: + type: string + description: | + The name of the file. + attributes: + $ref: '#/components/schemas/VectorStoreFileAttributes' + score: + type: number + format: float + description: | + The relevance score of the file - a value between 0 and 1. + call_id: + type: string + description: | + An identifier used when responding to the tool call with output. + action: + $ref: '#/components/schemas/ComputerAction' + actions: + $ref: '#/components/schemas/ComputerActionList' + pending_safety_checks: + type: array + items: + $ref: '#/components/schemas/ComputerCallSafetyCheckParam' + description: | + The pending safety checks for the computer call. + output: + $ref: '#/components/schemas/ComputerScreenshotImage' + acknowledged_safety_checks: + items: + $ref: '#/components/schemas/ComputerCallSafetyCheckParam' + type: array + description: >- + The safety checks reported by the API that have been acknowledged by + the developer. + namespace: + type: string + description: | + The namespace of the function to run. + name: + type: string + description: | + The name of the function to run. + arguments: + type: string + description: | + A JSON string of the arguments to pass to the function. + execution: + $ref: '#/components/schemas/ToolSearchExecutionType' + description: Whether tool search was executed by the server or by the client. + tools: + items: + $ref: '#/components/schemas/Tool' + type: array + description: The loaded tool definitions returned by the tool search output. + encrypted_content: + type: string + description: > + The encrypted content of the reasoning item - populated when a + response is + + generated with `reasoning.encrypted_content` in the `include` + parameter. + summary: + type: array + description: | + Reasoning summary content. + items: + $ref: '#/components/schemas/SummaryTextContent' + result: + type: string + description: | + The generated image encoded in base64. + container_id: + type: string + description: | + The ID of the container used to run the code. + code: + type: string + description: | + The code to run, or null if not available. + outputs: + type: array + items: + oneOf: + - $ref: '#/components/schemas/CodeInterpreterOutputLogs' + - $ref: '#/components/schemas/CodeInterpreterOutputImage' + discriminator: + propertyName: type + discriminator: + propertyName: type + description: > + The outputs generated by the code interpreter, such as logs or + images. + + Can be null if no outputs are available. + environment: + oneOf: + - $ref: '#/components/schemas/LocalEnvironmentParam' + - $ref: '#/components/schemas/ContainerReferenceParam' + description: The environment to execute the shell commands in. + discriminator: + propertyName: type + type: 'null' + max_output_length: + type: integer + description: >- + The maximum number of UTF-8 characters captured for this shell + call's combined output. + operation: + $ref: '#/components/schemas/ApplyPatchOperationParam' + description: >- + The specific create, delete, or update instruction for the + apply_patch tool call. + server_label: + type: string + description: | + The label of the MCP server. + error: + type: string + description: | + Error message if the server could not list tools. + approval_request_id: + type: string + description: | + The ID of the approval request being answered. + approve: + type: boolean + description: | + Whether the request was approved. + reason: + type: string + description: | + Optional reason for the decision. + input: + type: string + description: | + The input for the custom tool call generated by the model. + required: + - role + - content + - id + - type + - status + - queries + - call_id + - pending_safety_checks + - output + - action + - name + - arguments + - tools + - summary + - encrypted_content + - result + - container_id + - code + - outputs + - operation + - server_label + - request_id + - approve + - approval_request_id + - input + ItemReferenceParam: + properties: + type: + type: string + enum: + - item_reference + description: The type of item to reference. Always `item_reference`. + default: item_reference + x-stainless-const: true + id: + type: string + description: The ID of the item to reference. + type: object + required: + - id + title: Item reference + description: An internal identifier for an item to reference. + Message: + properties: + type: + type: string + enum: + - message + description: The type of the message. Always set to `message`. + default: message + x-stainless-const: true + id: + type: string + description: The unique ID of the message. + status: + $ref: '#/components/schemas/MessageStatus' + description: >- + The status of item. One of `in_progress`, `completed`, or + `incomplete`. Populated when items are returned via API. + role: + $ref: '#/components/schemas/MessageRole' + description: >- + The role of the message. One of `unknown`, `user`, `assistant`, + `system`, `critic`, `discriminator`, `developer`, or `tool`. + content: + items: + oneOf: + - $ref: '#/components/schemas/InputTextContent' + - $ref: '#/components/schemas/OutputTextContent' + - $ref: '#/components/schemas/TextContent' + - $ref: '#/components/schemas/SummaryTextContent' + - $ref: '#/components/schemas/ReasoningTextContent' + - $ref: '#/components/schemas/RefusalContent' + - $ref: '#/components/schemas/InputImageContent' + - $ref: '#/components/schemas/ComputerScreenshotContent' + - $ref: '#/components/schemas/InputFileContent' + description: A content part that makes up an input or output item. + discriminator: + propertyName: type + type: array + description: The content of the message + phase: + type: string + enum: + - commentary + - final_answer + type: object + required: + - type + - id + - status + - role + - content + title: Message + description: A message to or from the model. + FunctionToolCallResource: + type: object + title: Function tool call + description: > + A tool call to run a function. See the + + [function calling guide](/docs/guides/function-calling) for more + information. + properties: + id: + type: string + description: | + The unique ID of the function tool call. + type: + type: string + enum: + - function_call + description: | + The type of the function tool call. Always `function_call`. + x-stainless-const: true + call_id: + type: string + description: | + The unique ID of the function tool call generated by the model. + namespace: + type: string + description: | + The namespace of the function to run. + name: + type: string + description: | + The name of the function to run. + arguments: + type: string + description: | + A JSON string of the arguments to pass to the function. + status: + type: string + description: | + The status of the item. One of `in_progress`, `completed`, or + `incomplete`. Populated when items are returned via API. + enum: + - in_progress + - completed + - incomplete + created_by: + type: string + description: | + The identifier of the actor that created the item. + required: + - type + - call_id + - name + - arguments + - id + - status + FunctionToolCallOutputResource: + type: object + title: Function tool call output + description: | + The output of a function tool call. + properties: + id: + type: string + description: > + The unique ID of the function tool call output. Populated when this + item + + is returned via API. + type: + type: string + enum: + - function_call_output + description: > + The type of the function tool call output. Always + `function_call_output`. + x-stainless-const: true + call_id: + type: string + description: | + The unique ID of the function tool call generated by the model. + output: + description: | + The output from the function call generated by your code. + Can be a string or an list of output content. + type: string + title: string output + items: + $ref: '#/components/schemas/FunctionAndCustomToolCallOutput' + status: + type: string + description: | + The status of the item. One of `in_progress`, `completed`, or + `incomplete`. Populated when items are returned via API. + enum: + - in_progress + - completed + - incomplete + created_by: + type: string + description: | + The identifier of the actor that created the item. + required: + - type + - call_id + - output + - id + - status + FileSearchToolCall: + type: object + title: File search tool call + description: > + The results of a file search tool call. See the + + [file search guide](/docs/guides/tools-file-search) for more + information. + properties: + id: + type: string + description: | + The unique ID of the file search tool call. + type: + type: string + enum: + - file_search_call + description: | + The type of the file search tool call. Always `file_search_call`. + x-stainless-const: true + status: + type: string + description: | + The status of the file search tool call. One of `in_progress`, + `searching`, `incomplete` or `failed`, + enum: + - in_progress + - searching + - completed + - incomplete + - failed + queries: + type: array + items: + type: string + description: | + The queries used to search for files. + results: + type: array + description: | + The results of the file search tool call. + items: + type: object + properties: + file_id: + type: string + description: | + The unique ID of the file. + text: + type: string + description: | + The text that was retrieved from the file. + filename: + type: string + description: | + The name of the file. + attributes: + $ref: '#/components/schemas/VectorStoreFileAttributes' + score: + type: number + format: float + description: | + The relevance score of the file - a value between 0 and 1. + required: + - id + - type + - status + - queries + WebSearchToolCall: + type: object + title: Web search tool call + description: | + The results of a web search tool call. See the + [web search guide](/docs/guides/tools-web-search) for more information. + properties: + id: + type: string + description: | + The unique ID of the web search tool call. + type: + type: string + enum: + - web_search_call + description: | + The type of the web search tool call. Always `web_search_call`. + x-stainless-const: true + status: + type: string + description: | + The status of the web search tool call. + enum: + - in_progress + - searching + - completed + - failed + action: + type: object + description: > + An object describing the specific action taken in this web search + call. + + Includes details on how the model used the web (search, open_page, + find_in_page). + discriminator: + propertyName: type + title: Search action + properties: + type: + type: string + enum: + - search + description: | + The action type. + x-stainless-const: true + query: + type: string + description: | + [DEPRECATED] The search query. + queries: + type: array + title: Search queries + description: | + The search queries. + items: + type: string + description: | + A search query. + sources: + type: array + title: Web search sources + description: | + The sources used in the search. + items: + type: object + title: Web search source + description: | + A source used in the search. + properties: + type: + type: string + enum: + - url + description: | + The type of source. Always `url`. + x-stainless-const: true + url: + type: string + format: uri + description: | + The URL of the source. + required: + - type + - url + url: + description: | + The URL opened by the model. + type: string + format: uri + pattern: + type: string + description: | + The pattern or text to search for within the page. + required: + - type + - query + - url + - pattern + required: + - id + - type + - status + - action + ImageGenToolCall: + type: object + title: Image generation call + description: | + An image generation request made by the model. + properties: + type: + type: string + enum: + - image_generation_call + description: > + The type of the image generation call. Always + `image_generation_call`. + x-stainless-const: true + id: + type: string + description: | + The unique ID of the image generation call. + status: + type: string + enum: + - in_progress + - completed + - generating + - failed + description: | + The status of the image generation call. + result: + type: string + description: | + The generated image encoded in base64. + required: + - type + - id + - status + - result + ComputerToolCall: + type: object + title: Computer tool call + description: > + A tool call to a computer use tool. See the + + [computer use guide](/docs/guides/tools-computer-use) for more + information. + properties: + type: + type: string + description: The type of the computer call. Always `computer_call`. + enum: + - computer_call + default: computer_call + id: + type: string + description: The unique ID of the computer call. + call_id: + type: string + description: | + An identifier used when responding to the tool call with output. + action: + $ref: '#/components/schemas/ComputerAction' + actions: + $ref: '#/components/schemas/ComputerActionList' + pending_safety_checks: + type: array + items: + $ref: '#/components/schemas/ComputerCallSafetyCheckParam' + description: | + The pending safety checks for the computer call. + status: + type: string + description: | + The status of the item. One of `in_progress`, `completed`, or + `incomplete`. Populated when items are returned via API. + enum: + - in_progress + - completed + - incomplete + required: + - type + - id + - call_id + - pending_safety_checks + - status + ComputerToolCallOutputResource: + type: object + title: Computer tool call output + description: | + The output of a computer tool call. + properties: + type: + type: string + description: > + The type of the computer tool call output. Always + `computer_call_output`. + enum: + - computer_call_output + default: computer_call_output + x-stainless-const: true + id: + type: string + description: | + The ID of the computer tool call output. + call_id: + type: string + description: | + The ID of the computer tool call that produced the output. + acknowledged_safety_checks: + type: array + description: > + The safety checks reported by the API that have been acknowledged by + the + + developer. + items: + $ref: '#/components/schemas/ComputerCallSafetyCheckParam' + output: + $ref: '#/components/schemas/ComputerScreenshotImage' + status: + type: string + description: > + The status of the message input. One of `in_progress`, `completed`, + or + + `incomplete`. Populated when input items are returned via API. + enum: + - in_progress + - completed + - incomplete + created_by: + type: string + description: | + The identifier of the actor that created the item. + required: + - type + - call_id + - output + - id + - status + ToolSearchCall: + properties: + type: + type: string + enum: + - tool_search_call + description: The type of the item. Always `tool_search_call`. + default: tool_search_call + x-stainless-const: true + id: + type: string + description: The unique ID of the tool search call item. + call_id: + type: string + description: The unique ID of the tool search call generated by the model. + execution: + $ref: '#/components/schemas/ToolSearchExecutionType' + description: Whether tool search was executed by the server or by the client. + arguments: + description: Arguments used for the tool search call. + status: + $ref: '#/components/schemas/FunctionCallStatus' + description: The status of the tool search call item that was recorded. + created_by: + type: string + description: The identifier of the actor that created the item. + type: object + required: + - type + - id + - call_id + - execution + - arguments + - status + ToolSearchOutput: + properties: + type: + type: string + enum: + - tool_search_output + description: The type of the item. Always `tool_search_output`. + default: tool_search_output + x-stainless-const: true + id: + type: string + description: The unique ID of the tool search output item. + call_id: + type: string + description: The unique ID of the tool search call generated by the model. + execution: + $ref: '#/components/schemas/ToolSearchExecutionType' + description: Whether tool search was executed by the server or by the client. + tools: + items: + $ref: '#/components/schemas/Tool' + type: array + description: The loaded tool definitions returned by tool search. + status: + $ref: '#/components/schemas/FunctionCallOutputStatusEnum' + description: The status of the tool search output item that was recorded. + created_by: + type: string + description: The identifier of the actor that created the item. + type: object + required: + - type + - id + - call_id + - execution + - tools + - status + ReasoningItem: + type: object + description: > + A description of the chain of thought used by a reasoning model while + generating + + a response. Be sure to include these items in your `input` to the + Responses API + + for subsequent turns of a conversation if you are manually + + [managing context](/docs/guides/conversation-state). + title: Reasoning + properties: + type: + type: string + description: | + The type of the object. Always `reasoning`. + enum: + - reasoning + x-stainless-const: true + id: + type: string + description: | + The unique identifier of the reasoning content. + encrypted_content: + type: string + description: > + The encrypted content of the reasoning item - populated when a + response is + + generated with `reasoning.encrypted_content` in the `include` + parameter. + summary: + type: array + description: | + Reasoning summary content. + items: + $ref: '#/components/schemas/SummaryTextContent' + content: + type: array + description: | + Reasoning text content. + items: + $ref: '#/components/schemas/ReasoningTextContent' + status: + type: string + description: | + The status of the item. One of `in_progress`, `completed`, or + `incomplete`. Populated when items are returned via API. + enum: + - in_progress + - completed + - incomplete + required: + - id + - summary + - type + CompactionBody: + properties: + type: + type: string + enum: + - compaction + description: The type of the item. Always `compaction`. + default: compaction + x-stainless-const: true + id: + type: string + description: The unique ID of the compaction item. + encrypted_content: + type: string + description: The encrypted content that was produced by compaction. + created_by: + type: string + description: The identifier of the actor that created the item. + type: object + required: + - type + - id + - encrypted_content + title: Compaction item + description: >- + A compaction item generated by the [`v1/responses/compact` + API](/docs/api-reference/responses/compact). + CodeInterpreterToolCall: + type: object + title: Code interpreter tool call + description: | + A tool call to run code. + properties: + type: + type: string + enum: + - code_interpreter_call + default: code_interpreter_call + x-stainless-const: true + description: > + The type of the code interpreter tool call. Always + `code_interpreter_call`. + id: + type: string + description: | + The unique ID of the code interpreter tool call. + status: + type: string + enum: + - in_progress + - completed + - incomplete + - interpreting + - failed + description: > + The status of the code interpreter tool call. Valid values are + `in_progress`, `completed`, `incomplete`, `interpreting`, and + `failed`. + container_id: + type: string + description: | + The ID of the container used to run the code. + code: + type: string + description: | + The code to run, or null if not available. + outputs: + type: array + items: + oneOf: + - $ref: '#/components/schemas/CodeInterpreterOutputLogs' + - $ref: '#/components/schemas/CodeInterpreterOutputImage' + discriminator: + propertyName: type + discriminator: + propertyName: type + description: > + The outputs generated by the code interpreter, such as logs or + images. + + Can be null if no outputs are available. + required: + - type + - id + - status + - container_id + - code + - outputs + LocalShellToolCall: + type: object + title: Local shell call + description: | + A tool call to run a command on the local shell. + properties: + type: + type: string + enum: + - local_shell_call + description: | + The type of the local shell call. Always `local_shell_call`. + x-stainless-const: true + id: + type: string + description: | + The unique ID of the local shell call. + call_id: + type: string + description: | + The unique ID of the local shell tool call generated by the model. + action: + $ref: '#/components/schemas/LocalShellExecAction' + status: + type: string + enum: + - in_progress + - completed + - incomplete + description: | + The status of the local shell call. + required: + - type + - id + - call_id + - action + - status + LocalShellToolCallOutput: + type: object + title: Local shell call output + description: | + The output of a local shell tool call. + properties: + type: + type: string + enum: + - local_shell_call_output + description: > + The type of the local shell tool call output. Always + `local_shell_call_output`. + x-stainless-const: true + id: + type: string + description: | + The unique ID of the local shell tool call generated by the model. + output: + type: string + description: | + A JSON string of the output of the local shell tool call. + status: + type: string + enum: + - in_progress + - completed + - incomplete + description: > + The status of the item. One of `in_progress`, `completed`, or + `incomplete`. + required: + - id + - type + - call_id + - output + FunctionShellCall: + properties: + type: + type: string + enum: + - shell_call + description: The type of the item. Always `shell_call`. + default: shell_call + x-stainless-const: true + id: + type: string + description: >- + The unique ID of the shell tool call. Populated when this item is + returned via API. + call_id: + type: string + description: The unique ID of the shell tool call generated by the model. + action: + $ref: '#/components/schemas/FunctionShellAction' + description: >- + The shell commands and limits that describe how to run the tool + call. + status: + $ref: '#/components/schemas/FunctionShellCallStatus' + description: >- + The status of the shell call. One of `in_progress`, `completed`, or + `incomplete`. + environment: + oneOf: + - $ref: '#/components/schemas/LocalEnvironmentResource' + - $ref: '#/components/schemas/ContainerReferenceResource' + discriminator: + propertyName: type + type: 'null' + created_by: + type: string + description: The ID of the entity that created this tool call. + type: object + required: + - type + - id + - call_id + - action + - status + - environment + title: Shell tool call + description: >- + A tool call that executes one or more shell commands in a managed + environment. + FunctionShellCallOutput: + properties: + type: + type: string + enum: + - shell_call_output + description: The type of the shell call output. Always `shell_call_output`. + default: shell_call_output + x-stainless-const: true + id: + type: string + description: >- + The unique ID of the shell call output. Populated when this item is + returned via API. + call_id: + type: string + description: The unique ID of the shell tool call generated by the model. + status: + $ref: '#/components/schemas/FunctionShellCallOutputStatusEnum' + description: >- + The status of the shell call output. One of `in_progress`, + `completed`, or `incomplete`. + output: + items: + $ref: '#/components/schemas/FunctionShellCallOutputContent' + type: array + description: An array of shell call output contents + max_output_length: + type: integer + description: >- + The maximum length of the shell command output. This is generated by + the model and should be passed back with the raw output. + created_by: + type: string + description: The identifier of the actor that created the item. + type: object + required: + - type + - id + - call_id + - status + - output + - max_output_length + title: Shell call output + description: The output of a shell tool call that was emitted. + ApplyPatchToolCall: + properties: + type: + type: string + enum: + - apply_patch_call + description: The type of the item. Always `apply_patch_call`. + default: apply_patch_call + x-stainless-const: true + id: + type: string + description: >- + The unique ID of the apply patch tool call. Populated when this item + is returned via API. + call_id: + type: string + description: The unique ID of the apply patch tool call generated by the model. + status: + $ref: '#/components/schemas/ApplyPatchCallStatus' + description: >- + The status of the apply patch tool call. One of `in_progress` or + `completed`. + operation: + title: Apply patch operation + description: >- + One of the create_file, delete_file, or update_file operations + applied via apply_patch. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - create_file + description: Create a new file with the provided diff. + default: create_file + x-stainless-const: true + path: + type: string + description: Path of the file to create. + diff: + type: string + description: Diff to apply. + type: object + required: + - type + - path + - diff + created_by: + type: string + description: The ID of the entity that created this tool call. + type: object + required: + - type + - id + - call_id + - status + - operation + title: Apply patch tool call + description: >- + A tool call that applies file diffs by creating, deleting, or updating + files. + ApplyPatchToolCallOutput: + properties: + type: + type: string + enum: + - apply_patch_call_output + description: The type of the item. Always `apply_patch_call_output`. + default: apply_patch_call_output + x-stainless-const: true + id: + type: string + description: >- + The unique ID of the apply patch tool call output. Populated when + this item is returned via API. + call_id: + type: string + description: The unique ID of the apply patch tool call generated by the model. + status: + $ref: '#/components/schemas/ApplyPatchCallOutputStatus' + description: >- + The status of the apply patch tool call output. One of `completed` + or `failed`. + output: + type: string + description: Optional textual output returned by the apply patch tool. + created_by: + type: string + description: The ID of the entity that created this tool call output. + type: object + required: + - type + - id + - call_id + - status + title: Apply patch tool call output + description: The output emitted by an apply patch tool call. + MCPListTools: + type: object + title: MCP list tools + description: | + A list of tools available on an MCP server. + properties: + type: + type: string + enum: + - mcp_list_tools + description: | + The type of the item. Always `mcp_list_tools`. + x-stainless-const: true + id: + type: string + description: | + The unique ID of the list. + server_label: + type: string + description: | + The label of the MCP server. + tools: + type: array + items: + $ref: '#/components/schemas/MCPListToolsTool' + description: | + The tools available on the server. + error: + type: string + description: | + Error message if the server could not list tools. + required: + - type + - id + - server_label + - tools + MCPApprovalRequest: + type: object + title: MCP approval request + description: | + A request for human approval of a tool invocation. + properties: + type: + type: string + enum: + - mcp_approval_request + description: | + The type of the item. Always `mcp_approval_request`. + x-stainless-const: true + id: + type: string + description: | + The unique ID of the approval request. + server_label: + type: string + description: | + The label of the MCP server making the request. + name: + type: string + description: | + The name of the tool to run. + arguments: + type: string + description: | + A JSON string of arguments for the tool. + required: + - type + - id + - server_label + - name + - arguments + MCPApprovalResponseResource: + type: object + title: MCP approval response + description: | + A response to an MCP approval request. + properties: + type: + type: string + enum: + - mcp_approval_response + description: | + The type of the item. Always `mcp_approval_response`. + x-stainless-const: true + id: + type: string + description: | + The unique ID of the approval response + approval_request_id: + type: string + description: | + The ID of the approval request being answered. + approve: + type: boolean + description: | + Whether the request was approved. + reason: + type: string + description: | + Optional reason for the decision. + required: + - type + - id + - request_id + - approve + - approval_request_id + MCPToolCall: + type: object + title: MCP tool call + description: | + An invocation of a tool on an MCP server. + properties: + type: + type: string + enum: + - mcp_call + description: | + The type of the item. Always `mcp_call`. + x-stainless-const: true + id: + type: string + description: | + The unique ID of the tool call. + server_label: + type: string + description: | + The label of the MCP server running the tool. + name: + type: string + description: | + The name of the tool that was run. + arguments: + type: string + description: | + A JSON string of the arguments passed to the tool. + output: + type: string + description: | + The output from the tool call. + error: + type: string + description: | + The error from the tool call, if any. + status: + $ref: '#/components/schemas/MCPToolCallStatus' + description: > + The status of the tool call. One of `in_progress`, `completed`, + `incomplete`, `calling`, or `failed`. + approval_request_id: + type: string + description: > + Unique identifier for the MCP tool call approval request. + + Include this value in a subsequent `mcp_approval_response` input to + approve or reject the corresponding tool call. + required: + - type + - id + - server_label + - name + - arguments + CustomToolCall: + type: object + title: Custom tool call + description: | + A call to a custom tool created by the model. + properties: + type: + type: string + enum: + - custom_tool_call + x-stainless-const: true + description: | + The type of the custom tool call. Always `custom_tool_call`. + id: + type: string + description: | + The unique ID of the custom tool call in the OpenAI platform. + call_id: + type: string + description: > + An identifier used to map this custom tool call to a tool call + output. + namespace: + type: string + description: | + The namespace of the custom tool being called. + name: + type: string + description: | + The name of the custom tool being called. + input: + type: string + description: | + The input for the custom tool call generated by the model. + required: + - type + - call_id + - name + - input + CustomToolCallOutput: + type: object + title: Custom tool call output + description: > + The output of a custom tool call from your code, being sent back to the + model. + properties: + type: + type: string + enum: + - custom_tool_call_output + x-stainless-const: true + description: > + The type of the custom tool call output. Always + `custom_tool_call_output`. + id: + type: string + description: | + The unique ID of the custom tool call output in the OpenAI platform. + call_id: + type: string + description: > + The call ID, used to map this custom tool call output to a custom + tool call. + output: + description: | + The output from the custom tool call generated by your code. + Can be a string or an list of output content. + type: string + title: string output + items: + $ref: '#/components/schemas/FunctionAndCustomToolCallOutput' + required: + - type + - call_id + - output + Metadata: + type: object + description: > + Set of 16 key-value pairs that can be attached to an object. This can be + + useful for storing additional information about the object in a + structured + + format, and querying for objects via API or the dashboard. + + + Keys are strings with a maximum length of 64 characters. Values are + strings + + with a maximum length of 512 characters. + additionalProperties: + type: string + x-oaiTypeLabel: map + InputMessageContentList: + type: array + title: Input item content list + description: > + A list of one or many input items to the model, containing different + content + + types. + items: + $ref: '#/components/schemas/InputContent' + MessagePhase: + type: string + description: > + Labels an `assistant` message as intermediate commentary (`commentary`) + or the final answer (`final_answer`). + + For models like `gpt-5.3-codex` and beyond, when sending follow-up + requests, preserve and resend + + phase on all assistant messages — dropping it can degrade performance. + Not used for user messages. + enum: + - commentary + - final_answer + InputMessage: + type: object + title: Input message + description: > + A message input to the model with a role indicating instruction + following + + hierarchy. Instructions given with the `developer` or `system` role take + + precedence over instructions given with the `user` role. + properties: + type: + type: string + description: | + The type of the message input. Always set to `message`. + enum: + - message + x-stainless-const: true + role: + type: string + description: > + The role of the message input. One of `user`, `system`, or + `developer`. + enum: + - user + - system + - developer + status: + type: string + description: | + The status of item. One of `in_progress`, `completed`, or + `incomplete`. Populated when items are returned via API. + enum: + - in_progress + - completed + - incomplete + content: + $ref: '#/components/schemas/InputMessageContentList' + required: + - role + - content + OutputMessage: + type: object + title: Output message + description: | + An output message from the model. + properties: + id: + type: string + description: | + The unique ID of the output message. + type: + type: string + description: | + The type of the output message. Always `message`. + enum: + - message + x-stainless-const: true + role: + type: string + description: | + The role of the output message. Always `assistant`. + enum: + - assistant + x-stainless-const: true + content: + type: array + description: | + The content of the output message. + items: + $ref: '#/components/schemas/OutputMessageContent' + phase: + type: string + description: > + Labels an `assistant` message as intermediate commentary + (`commentary`) or the final answer (`final_answer`). + + For models like `gpt-5.3-codex` and beyond, when sending follow-up + requests, preserve and resend + + phase on all assistant messages — dropping it can degrade + performance. Not used for user messages. + enum: + - commentary + - final_answer + status: + type: string + description: > + The status of the message input. One of `in_progress`, `completed`, + or + + `incomplete`. Populated when input items are returned via API. + enum: + - in_progress + - completed + - incomplete + required: + - id + - type + - role + - content + - status + ComputerCallOutputItemParam: + properties: + id: + type: string + description: The ID of the computer tool call output. + example: cuo_123 + call_id: + type: string + maxLength: 64 + minLength: 1 + description: The ID of the computer tool call that produced the output. + type: + type: string + enum: + - computer_call_output + description: >- + The type of the computer tool call output. Always + `computer_call_output`. + default: computer_call_output + x-stainless-const: true + output: + $ref: '#/components/schemas/ComputerScreenshotImage' + acknowledged_safety_checks: + items: + $ref: '#/components/schemas/ComputerCallSafetyCheckParam' + type: array + description: >- + The safety checks reported by the API that have been acknowledged by + the developer. + status: + type: string + enum: + - in_progress + - completed + - incomplete + type: object + required: + - call_id + - type + - output + title: Computer tool call output + description: The output of a computer tool call. + FunctionToolCall: + type: object + title: Function tool call + description: > + A tool call to run a function. See the + + [function calling guide](/docs/guides/function-calling) for more + information. + properties: + id: + type: string + description: | + The unique ID of the function tool call. + type: + type: string + enum: + - function_call + description: | + The type of the function tool call. Always `function_call`. + x-stainless-const: true + call_id: + type: string + description: | + The unique ID of the function tool call generated by the model. + namespace: + type: string + description: | + The namespace of the function to run. + name: + type: string + description: | + The name of the function to run. + arguments: + type: string + description: | + A JSON string of the arguments to pass to the function. + status: + type: string + description: | + The status of the item. One of `in_progress`, `completed`, or + `incomplete`. Populated when items are returned via API. + enum: + - in_progress + - completed + - incomplete + required: + - type + - call_id + - name + - arguments + FunctionCallOutputItemParam: + properties: + id: + type: string + description: >- + The unique ID of the function tool call output. Populated when this + item is returned via API. + example: fc_123 + call_id: + type: string + maxLength: 64 + minLength: 1 + description: The unique ID of the function tool call generated by the model. + type: + type: string + enum: + - function_call_output + description: >- + The type of the function tool call output. Always + `function_call_output`. + default: function_call_output + x-stainless-const: true + output: + description: Text, image, or file output of the function tool call. + type: string + maxLength: 10485760 + items: + oneOf: + - $ref: '#/components/schemas/InputTextContentParam' + - $ref: '#/components/schemas/InputImageContentParamAutoParam' + - $ref: '#/components/schemas/InputFileContentParam' + description: A piece of message content, such as text, an image, or a file. + discriminator: + propertyName: type + status: + type: string + enum: + - in_progress + - completed + - incomplete + type: object + required: + - call_id + - type + - output + title: Function tool call output + description: The output of a function tool call. + ToolSearchCallItemParam: + properties: + id: + type: string + description: The unique ID of this tool search call. + example: tsc_123 + call_id: + type: string + maxLength: 64 + minLength: 1 + description: The unique ID of the tool search call generated by the model. + type: + type: string + enum: + - tool_search_call + description: The item type. Always `tool_search_call`. + default: tool_search_call + x-stainless-const: true + execution: + $ref: '#/components/schemas/ToolSearchExecutionType' + description: Whether tool search was executed by the server or by the client. + arguments: + $ref: '#/components/schemas/EmptyModelParam' + description: The arguments supplied to the tool search call. + status: + type: string + enum: + - in_progress + - completed + - incomplete + type: object + required: + - type + - arguments + ToolSearchOutputItemParam: + properties: + id: + type: string + description: The unique ID of this tool search output. + example: tso_123 + call_id: + type: string + maxLength: 64 + minLength: 1 + description: The unique ID of the tool search call generated by the model. + type: + type: string + enum: + - tool_search_output + description: The item type. Always `tool_search_output`. + default: tool_search_output + x-stainless-const: true + execution: + $ref: '#/components/schemas/ToolSearchExecutionType' + description: Whether tool search was executed by the server or by the client. + tools: + items: + $ref: '#/components/schemas/Tool' + type: array + description: The loaded tool definitions returned by the tool search output. + status: + type: string + enum: + - in_progress + - completed + - incomplete + type: object + required: + - type + - tools + CompactionSummaryItemParam: + properties: + id: + type: string + description: The ID of the compaction item. + example: cmp_123 + type: + type: string + enum: + - compaction + description: The type of the item. Always `compaction`. + default: compaction + x-stainless-const: true + encrypted_content: + type: string + maxLength: 10485760 + description: The encrypted content of the compaction summary. + type: object + required: + - type + - encrypted_content + title: Compaction item + description: >- + A compaction item generated by the [`v1/responses/compact` + API](/docs/api-reference/responses/compact). + FunctionShellCallItemParam: + properties: + id: + type: string + description: >- + The unique ID of the shell tool call. Populated when this item is + returned via API. + example: sh_123 + call_id: + type: string + maxLength: 64 + minLength: 1 + description: The unique ID of the shell tool call generated by the model. + type: + type: string + enum: + - shell_call + description: The type of the item. Always `shell_call`. + default: shell_call + x-stainless-const: true + action: + $ref: '#/components/schemas/FunctionShellActionParam' + description: >- + The shell commands and limits that describe how to run the tool + call. + status: + type: string + enum: + - in_progress + - completed + - incomplete + title: Shell call status + description: Status values reported for shell tool calls. + environment: + oneOf: + - $ref: '#/components/schemas/LocalEnvironmentParam' + - $ref: '#/components/schemas/ContainerReferenceParam' + description: The environment to execute the shell commands in. + discriminator: + propertyName: type + type: 'null' + type: object + required: + - call_id + - type + - action + title: Shell tool call + description: A tool representing a request to execute one or more shell commands. + FunctionShellCallOutputItemParam: + properties: + id: + type: string + description: >- + The unique ID of the shell tool call output. Populated when this + item is returned via API. + example: sho_123 + call_id: + type: string + maxLength: 64 + minLength: 1 + description: The unique ID of the shell tool call generated by the model. + type: + type: string + enum: + - shell_call_output + description: The type of the item. Always `shell_call_output`. + default: shell_call_output + x-stainless-const: true + output: + items: + $ref: '#/components/schemas/FunctionShellCallOutputContentParam' + type: array + description: >- + Captured chunks of stdout and stderr output, along with their + associated outcomes. + status: + type: string + enum: + - in_progress + - completed + - incomplete + title: Shell call status + description: Status values reported for shell tool calls. + max_output_length: + type: integer + description: >- + The maximum number of UTF-8 characters captured for this shell + call's combined output. + type: object + required: + - call_id + - type + - output + title: Shell tool call output + description: The streamed output items emitted by a shell tool call. + ApplyPatchToolCallItemParam: + properties: + type: + type: string + enum: + - apply_patch_call + description: The type of the item. Always `apply_patch_call`. + default: apply_patch_call + x-stainless-const: true + id: + type: string + description: >- + The unique ID of the apply patch tool call. Populated when this item + is returned via API. + example: apc_123 + call_id: + type: string + maxLength: 64 + minLength: 1 + description: The unique ID of the apply patch tool call generated by the model. + status: + $ref: '#/components/schemas/ApplyPatchCallStatusParam' + description: >- + The status of the apply patch tool call. One of `in_progress` or + `completed`. + operation: + $ref: '#/components/schemas/ApplyPatchOperationParam' + description: >- + The specific create, delete, or update instruction for the + apply_patch tool call. + type: object + required: + - type + - call_id + - status + - operation + title: Apply patch tool call + description: >- + A tool call representing a request to create, delete, or update files + using diff patches. + ApplyPatchToolCallOutputItemParam: + properties: + type: + type: string + enum: + - apply_patch_call_output + description: The type of the item. Always `apply_patch_call_output`. + default: apply_patch_call_output + x-stainless-const: true + id: + type: string + description: >- + The unique ID of the apply patch tool call output. Populated when + this item is returned via API. + example: apco_123 + call_id: + type: string + maxLength: 64 + minLength: 1 + description: The unique ID of the apply patch tool call generated by the model. + status: + $ref: '#/components/schemas/ApplyPatchCallOutputStatusParam' + description: >- + The status of the apply patch tool call output. One of `completed` + or `failed`. + output: + type: string + maxLength: 10485760 + description: >- + Optional human-readable log text from the apply patch tool (e.g., + patch results or errors). + type: object + required: + - type + - call_id + - status + title: Apply patch tool call output + description: The streamed output emitted by an apply patch tool call. + MCPApprovalResponse: + type: object + title: MCP approval response + description: | + A response to an MCP approval request. + properties: + type: + type: string + enum: + - mcp_approval_response + description: | + The type of the item. Always `mcp_approval_response`. + x-stainless-const: true + id: + type: string + description: | + The unique ID of the approval response + approval_request_id: + type: string + description: | + The ID of the approval request being answered. + approve: + type: boolean + description: | + Whether the request was approved. + reason: + type: string + description: | + Optional reason for the decision. + required: + - type + - request_id + - approve + - approval_request_id + MessageStatus: + type: string + enum: + - in_progress + - completed + - incomplete + MessageRole: + type: string + enum: + - unknown + - user + - assistant + - system + - critic + - discriminator + - developer + - tool + InputTextContent: + properties: + type: + type: string + enum: + - input_text + description: The type of the input item. Always `input_text`. + default: input_text + x-stainless-const: true + text: + type: string + description: The text input to the model. + type: object + required: + - type + - text + title: Input text + description: A text input to the model. + OutputTextContent: + properties: + type: + type: string + enum: + - output_text + description: The type of the output text. Always `output_text`. + default: output_text + x-stainless-const: true + text: + type: string + description: The text output from the model. + annotations: + items: + $ref: '#/components/schemas/Annotation' + type: array + description: The annotations of the text output. + logprobs: + items: + $ref: '#/components/schemas/LogProb' + type: array + type: object + required: + - type + - text + - annotations + - logprobs + title: Output text + description: A text output from the model. + TextContent: + properties: + type: + type: string + enum: + - text + default: text + x-stainless-const: true + text: + type: string + type: object + required: + - type + - text + title: Text Content + description: A text content. + SummaryTextContent: + properties: + type: + type: string + enum: + - summary_text + description: The type of the object. Always `summary_text`. + default: summary_text + x-stainless-const: true + text: + type: string + description: A summary of the reasoning output from the model so far. + type: object + required: + - type + - text + title: Summary text + description: A summary text from the model. + ReasoningTextContent: + properties: + type: + type: string + enum: + - reasoning_text + description: The type of the reasoning text. Always `reasoning_text`. + default: reasoning_text + x-stainless-const: true + text: + type: string + description: The reasoning text from the model. + type: object + required: + - type + - text + title: Reasoning text + description: Reasoning text from the model. + RefusalContent: + properties: + type: + type: string + enum: + - refusal + description: The type of the refusal. Always `refusal`. + default: refusal + x-stainless-const: true + refusal: + type: string + description: The refusal explanation from the model. + type: object + required: + - type + - refusal + title: Refusal + description: A refusal from the model. + InputImageContent: + properties: + type: + type: string + enum: + - input_image + description: The type of the input item. Always `input_image`. + default: input_image + x-stainless-const: true + image_url: + type: string + format: uri + description: >- + The URL of the image to be sent to the model. A fully qualified URL + or base64 encoded image in a data URL. + file_id: + type: string + description: The ID of the file to be sent to the model. + detail: + $ref: '#/components/schemas/ImageDetail' + description: >- + The detail level of the image to be sent to the model. One of + `high`, `low`, `auto`, or `original`. Defaults to `auto`. + type: object + required: + - type + - detail + title: Input image + description: >- + An image input to the model. Learn about [image + inputs](/docs/guides/vision). + ComputerScreenshotContent: + properties: + type: + type: string + enum: + - computer_screenshot + description: >- + Specifies the event type. For a computer screenshot, this property + is always set to `computer_screenshot`. + default: computer_screenshot + x-stainless-const: true + image_url: + type: string + format: uri + description: The URL of the screenshot image. + file_id: + type: string + description: The identifier of an uploaded file that contains the screenshot. + detail: + $ref: '#/components/schemas/ImageDetail' + description: >- + The detail level of the screenshot image to be sent to the model. + One of `high`, `low`, `auto`, or `original`. Defaults to `auto`. + type: object + required: + - type + - image_url + - file_id + - detail + title: Computer screenshot + description: A screenshot of a computer. + InputFileContent: + properties: + type: + type: string + enum: + - input_file + description: The type of the input item. Always `input_file`. + default: input_file + x-stainless-const: true + file_id: + type: string + description: The ID of the file to be sent to the model. + filename: + type: string + description: The name of the file to be sent to the model. + file_data: + type: string + description: | + The content of the file to be sent to the model. + file_url: + type: string + format: uri + description: The URL of the file to be sent to the model. + detail: + $ref: '#/components/schemas/FileInputDetail' + description: >- + The detail level of the file to be sent to the model. Use `low` for + the default rendering behavior, or `high` to render the file at + higher quality. Defaults to `low`. + type: object + required: + - type + title: Input file + description: A file input to the model. + MessagePhase-2: + type: string + enum: + - commentary + - final_answer + FunctionCallStatus: + type: string + enum: + - in_progress + - completed + - incomplete + FunctionToolCallOutput: + type: object + title: Function tool call output + description: | + The output of a function tool call. + properties: + id: + type: string + description: > + The unique ID of the function tool call output. Populated when this + item + + is returned via API. + type: + type: string + enum: + - function_call_output + description: > + The type of the function tool call output. Always + `function_call_output`. + x-stainless-const: true + call_id: + type: string + description: | + The unique ID of the function tool call generated by the model. + output: + description: | + The output from the function call generated by your code. + Can be a string or an list of output content. + type: string + title: string output + items: + $ref: '#/components/schemas/FunctionAndCustomToolCallOutput' + status: + type: string + description: | + The status of the item. One of `in_progress`, `completed`, or + `incomplete`. Populated when items are returned via API. + enum: + - in_progress + - completed + - incomplete + required: + - type + - call_id + - output + FunctionCallOutputStatusEnum: + type: string + enum: + - in_progress + - completed + - incomplete + VectorStoreFileAttributes: + type: object + description: > + Set of 16 key-value pairs that can be attached to an object. This can be + + useful for storing additional information about the object in a + structured + + format, and querying for objects via API or the dashboard. Keys are + strings + + with a maximum length of 64 characters. Values are strings with a + maximum + + length of 512 characters, booleans, or numbers. + maxProperties: 16 + propertyNames: + type: string + maxLength: 64 + additionalProperties: + oneOf: + - type: string + maxLength: 512 + - type: number + - type: boolean + x-oaiTypeLabel: map + WebSearchActionSearch: + type: object + title: Search action + description: | + Action type "search" - Performs a web search query. + properties: + type: + type: string + enum: + - search + description: | + The action type. + x-stainless-const: true + query: + type: string + description: | + [DEPRECATED] The search query. + queries: + type: array + title: Search queries + description: | + The search queries. + items: + type: string + description: | + A search query. + sources: + type: array + title: Web search sources + description: | + The sources used in the search. + items: + type: object + title: Web search source + description: | + A source used in the search. + properties: + type: + type: string + enum: + - url + description: | + The type of source. Always `url`. + x-stainless-const: true + url: + type: string + format: uri + description: | + The URL of the source. + required: + - type + - url + required: + - type + - query + WebSearchActionOpenPage: + type: object + title: Open page action + description: | + Action type "open_page" - Opens a specific URL from search results. + properties: + type: + type: string + enum: + - open_page + description: | + The action type. + x-stainless-const: true + url: + description: | + The URL opened by the model. + type: string + format: uri + required: + - type + WebSearchActionFind: + type: object + title: Find action + description: | + Action type "find_in_page": Searches for a pattern within a loaded page. + properties: + type: + type: string + enum: + - find_in_page + description: | + The action type. + x-stainless-const: true + url: + type: string + format: uri + description: | + The URL of the page searched for the pattern. + pattern: + type: string + description: | + The pattern or text to search for within the page. + required: + - type + - url + - pattern + ComputerAction: + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - click + description: >- + Specifies the event type. For a click action, this property is + always `click`. + default: click + x-stainless-const: true + button: + $ref: '#/components/schemas/ClickButtonType' + description: >- + Indicates which mouse button was pressed during the click. One of + `left`, `right`, `wheel`, `back`, or `forward`. + x: + type: integer + description: The x-coordinate where the click occurred. + 'y': + type: integer + description: The y-coordinate where the click occurred. + keys: + items: + type: string + type: array + description: The keys being held while clicking. + path: + items: + $ref: '#/components/schemas/CoordParam' + type: array + description: >- + An array of coordinates representing the path of the drag action. + Coordinates will appear as an array of objects, eg + + ``` + + [ + { x: 100, y: 200 }, + { x: 200, y: 300 } + ] + + ``` + scroll_x: + type: integer + description: The horizontal scroll distance. + scroll_y: + type: integer + description: The vertical scroll distance. + text: + type: string + description: The text to type. + type: object + required: + - type + - button + - x + - 'y' + - keys + - path + - scroll_x + - scroll_y + - text + title: Click + description: A click action. + ComputerActionList: + title: Computer Action List + type: array + description: | + Flattened batched actions for `computer_use`. Each action includes an + `type` discriminator and action-specific fields. + items: + $ref: '#/components/schemas/ComputerAction' + ComputerCallSafetyCheckParam: + properties: + id: + type: string + description: The ID of the pending safety check. + code: + type: string + description: The type of the pending safety check. + message: + type: string + description: Details about the pending safety check. + type: object + required: + - id + description: A pending safety check for the computer call. + ComputerToolCallOutput: + type: object + title: Computer tool call output + description: | + The output of a computer tool call. + properties: + type: + type: string + description: > + The type of the computer tool call output. Always + `computer_call_output`. + enum: + - computer_call_output + default: computer_call_output + x-stainless-const: true + id: + type: string + description: | + The ID of the computer tool call output. + call_id: + type: string + description: | + The ID of the computer tool call that produced the output. + acknowledged_safety_checks: + type: array + description: > + The safety checks reported by the API that have been acknowledged by + the + + developer. + items: + $ref: '#/components/schemas/ComputerCallSafetyCheckParam' + output: + $ref: '#/components/schemas/ComputerScreenshotImage' + status: + type: string + description: > + The status of the message input. One of `in_progress`, `completed`, + or + + `incomplete`. Populated when input items are returned via API. + enum: + - in_progress + - completed + - incomplete + required: + - type + - call_id + - output + ComputerCallOutputStatus: + type: string + enum: + - completed + - incomplete + - failed + ToolSearchExecutionType: + type: string + enum: + - server + - client + Tool: + description: | + A tool that can be used to generate a response. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - function + description: The type of the function tool. Always `function`. + default: function + x-stainless-const: true + name: + type: string + description: The name of the function to call. + description: + type: string + description: >- + A description of the function. Used by the model to determine + whether or not to call the function. + parameters: + additionalProperties: {} + type: object + description: A JSON schema object describing the parameters of the function. + x-oaiTypeLabel: map + strict: + type: boolean + description: Whether to enforce strict parameter validation. Default `true`. + defer_loading: + type: boolean + description: Whether this function is deferred and loaded via tool search. + vector_store_ids: + items: + type: string + type: array + description: The IDs of the vector stores to search. + max_num_results: + type: integer + description: >- + The maximum number of results to return. This number should be + between 1 and 50 inclusive. + ranking_options: + $ref: '#/components/schemas/RankingOptions' + description: Ranking options for search. + filters: + type: object + additionalProperties: false + title: Comparison Filter + description: > + A filter used to compare a specified attribute key to a given value + using a defined comparison operation. + properties: + type: + type: string + default: eq + enum: + - eq + - ne + - gt + - gte + - lt + - lte + - in + - nin + description: > + Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, + `lt`, `lte`, `in`, `nin`. + + - `eq`: equals + + - `ne`: not equal + + - `gt`: greater than + + - `gte`: greater than or equal + + - `lt`: less than + + - `lte`: less than or equal + + - `in`: in + + - `nin`: not in + key: + type: string + description: The key to compare against the value. + value: + description: >- + The value to compare against the attribute key; supports string, + number, or boolean types. + type: string + items: + oneOf: + - type: string + - type: number + filters: + type: array + description: >- + Array of filters to combine. Items can be `ComparisonFilter` or + `CompoundFilter`. + items: + oneOf: + - $ref: '#/components/schemas/ComparisonFilter' + - $recursiveRef: '#' + discriminator: + propertyName: type + required: + - type + - key + - value + - filters + x-oaiMeta: + name: ComparisonFilter + $recursiveAnchor: true + environment: + $ref: '#/components/schemas/ComputerEnvironment' + description: The type of computer environment to control. + display_width: + type: integer + description: The width of the computer display. + display_height: + type: integer + description: The height of the computer display. + user_location: + $ref: '#/components/schemas/WebSearchApproximateLocation' + search_context_size: + type: string + enum: + - low + - medium + - high + default: medium + description: >- + High level guidance for the amount of context window space to use + for the search. One of `low`, `medium`, or `high`. `medium` is the + default. + server_label: + type: string + description: | + A label for this MCP server, used to identify it in tool calls. + server_url: + type: string + format: uri + description: > + The URL for the MCP server. One of `server_url` or `connector_id` + must be + + provided. + connector_id: + type: string + enum: + - connector_dropbox + - connector_gmail + - connector_googlecalendar + - connector_googledrive + - connector_microsoftteams + - connector_outlookcalendar + - connector_outlookemail + - connector_sharepoint + description: > + Identifier for service connectors, like those available in ChatGPT. + One of + + `server_url` or `connector_id` must be provided. Learn more about + service + + connectors [here](/docs/guides/tools-remote-mcp#connectors). + + + Currently supported `connector_id` values are: + + + - Dropbox: `connector_dropbox` + + - Gmail: `connector_gmail` + + - Google Calendar: `connector_googlecalendar` + + - Google Drive: `connector_googledrive` + + - Microsoft Teams: `connector_microsoftteams` + + - Outlook Calendar: `connector_outlookcalendar` + + - Outlook Email: `connector_outlookemail` + + - SharePoint: `connector_sharepoint` + authorization: + type: string + description: > + An OAuth access token that can be used with a remote MCP server, + either + + with a custom MCP server URL or a service connector. Your + application + + must handle the OAuth authorization flow and provide the token here. + server_description: + type: string + description: > + Optional description of the MCP server, used to provide more + context. + headers: + type: object + additionalProperties: + type: string + description: > + Optional HTTP headers to send to the MCP server. Use for + authentication + + or other purposes. + allowed_tools: + description: | + List of allowed tool names or a filter object. + oneOf: + - type: array + title: MCP allowed tools + description: A string array of allowed tool names + items: + type: string + - $ref: '#/components/schemas/MCPToolFilter' + type: 'null' + require_approval: + description: Specify which of the MCP server's tools require approval. + oneOf: + - type: object + title: MCP tool approval filter + description: | + Specify which of the MCP server's tools require approval. Can be + `always`, `never`, or a filter object associated with tools + that require approval. + properties: + always: + $ref: '#/components/schemas/MCPToolFilter' + never: + $ref: '#/components/schemas/MCPToolFilter' + additionalProperties: false + - type: string + title: MCP tool approval setting + description: > + Specify a single approval policy for all tools. One of `always` + or + + `never`. When set to `always`, all tools will require approval. + When + + set to `never`, all tools will not require approval. + enum: + - always + - never + default: always + type: 'null' + container: + description: > + The code interpreter container. Can be a container ID or an object + that + + specifies uploaded file IDs to make available to your code, along + with an + + optional `memory_limit` setting. + type: string + properties: + type: + type: string + enum: + - auto + description: Always `auto`. + default: auto + x-stainless-const: true + file_ids: + items: + type: string + example: file-123 + type: array + maxItems: 50 + description: >- + An optional list of uploaded files to make available to your + code. + memory_limit: + type: string + enum: + - 1g + - 4g + - 16g + - 64g + network_policy: + description: Network access policy for the container. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - disabled + description: Disable outbound network access. Always `disabled`. + default: disabled + x-stainless-const: true + allowed_domains: + items: + type: string + type: array + minItems: 1 + description: A list of allowed domains when type is `allowlist`. + domain_secrets: + items: + $ref: >- + #/components/schemas/ContainerNetworkPolicyDomainSecretParam + type: array + minItems: 1 + description: Optional domain-scoped secrets for allowlisted domains. + type: object + required: + - type + - allowed_domains + required: + - type + title: CodeInterpreterToolAuto + model: + type: string + enum: + - gpt-image-1 + - gpt-image-1-mini + - gpt-image-1.5 + description: | + The image generation model to use. Default: `gpt-image-1`. + default: gpt-image-1 + quality: + type: string + enum: + - low + - medium + - high + - auto + description: | + The quality of the generated image. One of `low`, `medium`, `high`, + or `auto`. Default: `auto`. + default: auto + size: + description: >- + The size of the generated images. For `gpt-image-2` and + `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as + `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height + must both be divisible by 16 and the requested aspect ratio must be + between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, + and the maximum supported resolution is `3840x2160`. The requested + size must also satisfy the model's current pixel and edge limits. + The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are + supported by the GPT image models; `auto` is supported for models + that allow automatic sizing. For `dall-e-2`, use one of `256x256`, + `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, + `1792x1024`, or `1024x1792`. + default: auto + type: string + enum: + - 1024x1024 + - 1024x1536 + - 1536x1024 + - auto + output_format: + type: string + enum: + - png + - webp + - jpeg + description: | + The output format of the generated image. One of `png`, `webp`, or + `jpeg`. Default: `png`. + default: png + output_compression: + type: integer + minimum: 0 + maximum: 100 + description: | + Compression level for the output image. Default: 100. + default: 100 + moderation: + type: string + enum: + - auto + - low + description: | + Moderation level for the generated image. Default: `auto`. + default: auto + background: + type: string + enum: + - transparent + - opaque + - auto + description: | + Background type for the generated image. One of `transparent`, + `opaque`, or `auto`. Default: `auto`. + default: auto + input_fidelity: + type: string + enum: + - high + - low + description: >- + Control how much effort the model will exert to match the style and + features, especially facial features, of input images. This + parameter is only supported for `gpt-image-1` and `gpt-image-1.5` + and later models, unsupported for `gpt-image-1-mini`. Supports + `high` and `low`. Defaults to `low`. + input_image_mask: + type: object + description: | + Optional mask for inpainting. Contains `image_url` + (string, optional) and `file_id` (string, optional). + properties: + image_url: + type: string + description: | + Base64-encoded mask image. + file_id: + type: string + description: | + File ID for the mask image. + required: [] + additionalProperties: false + partial_images: + type: integer + minimum: 0 + maximum: 3 + description: > + Number of partial images to generate in streaming mode, from 0 + (default value) to 3. + default: 0 + action: + description: > + Whether to generate a new image or edit an existing image. Default: + `auto`. + $ref: '#/components/schemas/ImageGenActionEnum' + format: + description: The input format for the custom tool. Default is unconstrained text. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - text + description: Unconstrained text format. Always `text`. + default: text + x-stainless-const: true + syntax: + $ref: '#/components/schemas/GrammarSyntax1' + description: The syntax of the grammar definition. One of `lark` or `regex`. + definition: + type: string + description: The grammar definition. + type: object + required: + - type + - syntax + - definition + title: Text format + tools: + items: + oneOf: + - $ref: '#/components/schemas/FunctionToolParam' + - $ref: '#/components/schemas/CustomToolParam' + description: A function or custom tool that belongs to a namespace. + discriminator: + propertyName: type + type: array + minItems: 1 + description: The function/custom tools available inside this namespace. + execution: + $ref: '#/components/schemas/ToolSearchExecutionType' + description: Whether tool search is executed by the server or by the client. + search_content_types: + items: + $ref: '#/components/schemas/SearchContentType' + type: array + type: object + required: + - type + - name + - strict + - parameters + - vector_store_ids + - environment + - display_width + - display_height + - server_label + - container + - description + - tools + title: Function + CodeInterpreterOutputLogs: + properties: + type: + type: string + enum: + - logs + description: The type of the output. Always `logs`. + default: logs + x-stainless-const: true + logs: + type: string + description: The logs output from the code interpreter. + type: object + required: + - type + - logs + title: Code interpreter output logs + description: The logs output from the code interpreter. + CodeInterpreterOutputImage: + properties: + type: + type: string + enum: + - image + description: The type of the output. Always `image`. + default: image + x-stainless-const: true + url: + type: string + format: uri + description: The URL of the image output from the code interpreter. + type: object + required: + - type + - url + title: Code interpreter output image + description: The image output from the code interpreter. + LocalShellExecAction: + properties: + type: + type: string + enum: + - exec + description: The type of the local shell action. Always `exec`. + default: exec + x-stainless-const: true + command: + items: + type: string + type: array + description: The command to run. + timeout_ms: + type: integer + description: Optional timeout in milliseconds for the command. + working_directory: + type: string + description: Optional working directory to run the command in. + env: + additionalProperties: + type: string + type: object + description: Environment variables to set for the command. + x-oaiTypeLabel: map + user: + type: string + description: Optional user to run the command as. + type: object + required: + - type + - command + - env + title: Local shell exec action + description: Execute a shell command on the server. + FunctionShellAction: + properties: + commands: + items: + type: string + description: A list of commands to run. + type: array + timeout_ms: + type: integer + description: Optional timeout in milliseconds for the commands. + max_output_length: + type: integer + description: Optional maximum number of characters to return from each command. + type: object + required: + - commands + - timeout_ms + - max_output_length + title: Shell exec action + description: Execute a shell command. + FunctionShellCallStatus: + type: string + enum: + - in_progress + - completed + - incomplete + LocalEnvironmentResource: + properties: + type: + type: string + enum: + - local + description: The environment type. Always `local`. + default: local + x-stainless-const: true + type: object + required: + - type + title: Local Environment + description: Represents the use of a local environment to perform shell actions. + ContainerReferenceResource: + properties: + type: + type: string + enum: + - container_reference + description: The environment type. Always `container_reference`. + default: container_reference + x-stainless-const: true + container_id: + type: string + type: object + required: + - type + - container_id + title: Container Reference + description: Represents a container created with /v1/containers. + FunctionShellCallOutputStatusEnum: + type: string + enum: + - in_progress + - completed + - incomplete + FunctionShellCallOutputContent: + properties: + stdout: + type: string + description: The standard output that was captured. + stderr: + type: string + description: The standard error output that was captured. + outcome: + title: Shell call outcome + description: >- + Represents either an exit outcome (with an exit code) or a timeout + outcome for a shell call output chunk. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - timeout + description: The outcome type. Always `timeout`. + default: timeout + x-stainless-const: true + exit_code: + type: integer + description: Exit code from the shell process. + type: object + required: + - type + - exit_code + created_by: + type: string + description: The identifier of the actor that created the item. + type: object + required: + - stdout + - stderr + - outcome + title: Shell call output content + description: The content of a shell tool call output that was emitted. + ApplyPatchCallStatus: + type: string + enum: + - in_progress + - completed + ApplyPatchCreateFileOperation: + properties: + type: + type: string + enum: + - create_file + description: Create a new file with the provided diff. + default: create_file + x-stainless-const: true + path: + type: string + description: Path of the file to create. + diff: + type: string + description: Diff to apply. + type: object + required: + - type + - path + - diff + title: Apply patch create file operation + description: Instruction describing how to create a file via the apply_patch tool. + ApplyPatchDeleteFileOperation: + properties: + type: + type: string + enum: + - delete_file + description: Delete the specified file. + default: delete_file + x-stainless-const: true + path: + type: string + description: Path of the file to delete. + type: object + required: + - type + - path + title: Apply patch delete file operation + description: Instruction describing how to delete a file via the apply_patch tool. + ApplyPatchUpdateFileOperation: + properties: + type: + type: string + enum: + - update_file + description: Update an existing file with the provided diff. + default: update_file + x-stainless-const: true + path: + type: string + description: Path of the file to update. + diff: + type: string + description: Diff to apply. + type: object + required: + - type + - path + - diff + title: Apply patch update file operation + description: Instruction describing how to update a file via the apply_patch tool. + ApplyPatchCallOutputStatus: + type: string + enum: + - completed + - failed + MCPListToolsTool: + type: object + title: MCP list tools tool + description: | + A tool available on an MCP server. + properties: + name: + type: string + description: | + The name of the tool. + description: + type: string + description: | + The description of the tool. + input_schema: + type: string + description: |- + The JSON schema describing the tool's input. + (opaque JSON object) + annotations: + type: string + description: |- + Additional annotations about the tool. + (opaque JSON object) + required: + - name + - input_schema + MCPToolCallStatus: + type: string + enum: + - in_progress + - completed + - incomplete + - calling + - failed + FunctionAndCustomToolCallOutput: + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - input_text + description: The type of the input item. Always `input_text`. + default: input_text + x-stainless-const: true + text: + type: string + description: The text input to the model. + image_url: + type: string + format: uri + description: >- + The URL of the image to be sent to the model. A fully qualified URL + or base64 encoded image in a data URL. + file_id: + type: string + description: The ID of the file to be sent to the model. + detail: + $ref: '#/components/schemas/ImageDetail' + description: >- + The detail level of the image to be sent to the model. One of + `high`, `low`, `auto`, or `original`. Defaults to `auto`. + filename: + type: string + description: The name of the file to be sent to the model. + file_data: + type: string + description: | + The content of the file to be sent to the model. + file_url: + type: string + format: uri + description: The URL of the file to be sent to the model. + type: object + required: + - type + - text + - detail + title: Input text + description: A text input to the model. + InputContent: + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - input_text + description: The type of the input item. Always `input_text`. + default: input_text + x-stainless-const: true + text: + type: string + description: The text input to the model. + image_url: + type: string + format: uri + description: >- + The URL of the image to be sent to the model. A fully qualified URL + or base64 encoded image in a data URL. + file_id: + type: string + description: The ID of the file to be sent to the model. + detail: + $ref: '#/components/schemas/ImageDetail' + description: >- + The detail level of the image to be sent to the model. One of + `high`, `low`, `auto`, or `original`. Defaults to `auto`. + filename: + type: string + description: The name of the file to be sent to the model. + file_data: + type: string + description: | + The content of the file to be sent to the model. + file_url: + type: string + format: uri + description: The URL of the file to be sent to the model. + type: object + required: + - type + - text + - detail + title: Input text + description: A text input to the model. + OutputMessageContent: + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - output_text + description: The type of the output text. Always `output_text`. + default: output_text + x-stainless-const: true + text: + type: string + description: The text output from the model. + annotations: + items: + $ref: '#/components/schemas/Annotation' + type: array + description: The annotations of the text output. + logprobs: + items: + $ref: '#/components/schemas/LogProb' + type: array + refusal: + type: string + description: The refusal explanation from the model. + type: object + required: + - type + - text + - annotations + - logprobs + - refusal + title: Output text + description: A text output from the model. + ComputerScreenshotImage: + type: object + description: | + A computer screenshot image used with the computer use tool. + properties: + type: + type: string + enum: + - computer_screenshot + default: computer_screenshot + description: > + Specifies the event type. For a computer screenshot, this property + is + + always set to `computer_screenshot`. + x-stainless-const: true + image_url: + type: string + format: uri + description: The URL of the screenshot image. + file_id: + type: string + description: The identifier of an uploaded file that contains the screenshot. + required: + - type + FunctionCallItemStatus: + type: string + enum: + - in_progress + - completed + - incomplete + InputTextContentParam: + properties: + type: + type: string + enum: + - input_text + description: The type of the input item. Always `input_text`. + default: input_text + x-stainless-const: true + text: + type: string + maxLength: 10485760 + description: The text input to the model. + type: object + required: + - type + - text + title: Input text + description: A text input to the model. + InputImageContentParamAutoParam: + properties: + type: + type: string + enum: + - input_image + description: The type of the input item. Always `input_image`. + default: input_image + x-stainless-const: true + image_url: + type: string + maxLength: 20971520 + format: uri + description: >- + The URL of the image to be sent to the model. A fully qualified URL + or base64 encoded image in a data URL. + file_id: + type: string + description: The ID of the file to be sent to the model. + example: file-123 + detail: + type: string + enum: + - low + - high + - auto + - original + type: object + required: + - type + title: Input image + description: >- + An image input to the model. Learn about [image + inputs](/docs/guides/vision) + InputFileContentParam: + properties: + type: + type: string + enum: + - input_file + description: The type of the input item. Always `input_file`. + default: input_file + x-stainless-const: true + file_id: + type: string + description: The ID of the file to be sent to the model. + example: file-123 + filename: + type: string + description: The name of the file to be sent to the model. + file_data: + type: string + maxLength: 73400320 + description: The base64-encoded data of the file to be sent to the model. + file_url: + type: string + format: uri + description: The URL of the file to be sent to the model. + detail: + $ref: '#/components/schemas/FileDetailEnum' + description: >- + The detail level of the file to be sent to the model. Use `low` for + the default rendering behavior, or `high` to render the file at + higher quality. Defaults to `low`. + type: object + required: + - type + title: Input file + description: A file input to the model. + EmptyModelParam: + properties: {} + type: object + required: [] + FunctionShellActionParam: + properties: + commands: + items: + type: string + type: array + description: Ordered shell commands for the execution environment to run. + timeout_ms: + type: integer + description: >- + Maximum wall-clock time in milliseconds to allow the shell commands + to run. + max_output_length: + type: integer + description: >- + Maximum number of UTF-8 characters to capture from combined stdout + and stderr output. + type: object + required: + - commands + title: Shell action + description: Commands and limits describing how to run the shell tool call. + FunctionShellCallItemStatus: + type: string + enum: + - in_progress + - completed + - incomplete + title: Shell call status + description: Status values reported for shell tool calls. + LocalEnvironmentParam: + properties: + type: + type: string + enum: + - local + description: Use a local computer environment. + default: local + x-stainless-const: true + skills: + items: + $ref: '#/components/schemas/LocalSkillParam' + type: array + maxItems: 200 + description: An optional list of skills. + type: object + required: + - type + ContainerReferenceParam: + properties: + type: + type: string + enum: + - container_reference + description: References a container created with the /v1/containers endpoint + default: container_reference + x-stainless-const: true + container_id: + type: string + description: The ID of the referenced container. + example: cntr_123 + type: object + required: + - type + - container_id + FunctionShellCallOutputContentParam: + properties: + stdout: + type: string + maxLength: 10485760 + description: Captured stdout output for the shell call. + stderr: + type: string + maxLength: 10485760 + description: Captured stderr output for the shell call. + outcome: + $ref: '#/components/schemas/FunctionShellCallOutputOutcomeParam' + description: The exit or timeout outcome associated with this shell call. + type: object + required: + - stdout + - stderr + - outcome + title: Shell output content + description: Captured stdout and stderr for a portion of a shell tool call output. + ApplyPatchCallStatusParam: + type: string + enum: + - in_progress + - completed + title: Apply patch call status + description: Status values reported for apply_patch tool calls. + ApplyPatchOperationParam: + title: Apply patch operation + description: >- + One of the create_file, delete_file, or update_file operations supplied + to the apply_patch tool. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - create_file + description: The operation type. Always `create_file`. + default: create_file + x-stainless-const: true + path: + type: string + minLength: 1 + description: Path of the file to create relative to the workspace root. + diff: + type: string + maxLength: 10485760 + description: Unified diff content to apply when creating the file. + type: object + required: + - type + - path + - diff + ApplyPatchCallOutputStatusParam: + type: string + enum: + - completed + - failed + title: Apply patch call output status + description: Outcome values reported for apply_patch tool call outputs. + Annotation: + description: An annotation that applies to a span of output text. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - file_citation + description: The type of the file citation. Always `file_citation`. + default: file_citation + x-stainless-const: true + file_id: + type: string + description: The ID of the file. + index: + type: integer + description: The index of the file in the list of files. + filename: + type: string + description: The filename of the file cited. + url: + type: string + format: uri + description: The URL of the web resource. + start_index: + type: integer + description: The index of the first character of the URL citation in the message. + end_index: + type: integer + description: The index of the last character of the URL citation in the message. + title: + type: string + description: The title of the web resource. + container_id: + type: string + description: The ID of the container file. + type: object + required: + - type + - file_id + - index + - filename + - url + - start_index + - end_index + - title + - container_id + title: File citation + LogProb: + properties: + token: + type: string + logprob: + type: number + bytes: + items: + type: integer + type: array + top_logprobs: + items: + $ref: '#/components/schemas/TopLogProb' + type: array + type: object + required: + - token + - logprob + - bytes + - top_logprobs + title: Log probability + description: The log probability of a token. + ImageDetail: + type: string + enum: + - low + - high + - auto + - original + FileInputDetail: + type: string + enum: + - low + - high + ClickParam: + properties: + type: + type: string + enum: + - click + description: >- + Specifies the event type. For a click action, this property is + always `click`. + default: click + x-stainless-const: true + button: + $ref: '#/components/schemas/ClickButtonType' + description: >- + Indicates which mouse button was pressed during the click. One of + `left`, `right`, `wheel`, `back`, or `forward`. + x: + type: integer + description: The x-coordinate where the click occurred. + 'y': + type: integer + description: The y-coordinate where the click occurred. + keys: + items: + type: string + type: array + description: The keys being held while clicking. + type: object + required: + - type + - button + - x + - 'y' + title: Click + description: A click action. + DoubleClickAction: + properties: + type: + type: string + enum: + - double_click + description: >- + Specifies the event type. For a double click action, this property + is always set to `double_click`. + default: double_click + x-stainless-const: true + x: + type: integer + description: The x-coordinate where the double click occurred. + 'y': + type: integer + description: The y-coordinate where the double click occurred. + keys: + items: + type: string + type: array + description: The keys being held while double-clicking. + type: object + required: + - type + - x + - 'y' + - keys + title: DoubleClick + description: A double click action. + DragParam: + properties: + type: + type: string + enum: + - drag + description: >- + Specifies the event type. For a drag action, this property is always + set to `drag`. + default: drag + x-stainless-const: true + path: + items: + $ref: '#/components/schemas/CoordParam' + type: array + description: >- + An array of coordinates representing the path of the drag action. + Coordinates will appear as an array of objects, eg + + ``` + + [ + { x: 100, y: 200 }, + { x: 200, y: 300 } + ] + + ``` + keys: + items: + type: string + type: array + description: The keys being held while dragging the mouse. + type: object + required: + - type + - path + title: Drag + description: A drag action. + KeyPressAction: + properties: + type: + type: string + enum: + - keypress + description: >- + Specifies the event type. For a keypress action, this property is + always set to `keypress`. + default: keypress + x-stainless-const: true + keys: + items: + type: string + description: One of the keys the model is requesting to be pressed. + type: array + description: >- + The combination of keys the model is requesting to be pressed. This + is an array of strings, each representing a key. + type: object + required: + - type + - keys + title: KeyPress + description: A collection of keypresses the model would like to perform. + MoveParam: + properties: + type: + type: string + enum: + - move + description: >- + Specifies the event type. For a move action, this property is always + set to `move`. + default: move + x-stainless-const: true + x: + type: integer + description: The x-coordinate to move to. + 'y': + type: integer + description: The y-coordinate to move to. + keys: + items: + type: string + type: array + description: The keys being held while moving the mouse. + type: object + required: + - type + - x + - 'y' + title: Move + description: A mouse move action. + ScreenshotParam: + properties: + type: + type: string + enum: + - screenshot + description: >- + Specifies the event type. For a screenshot action, this property is + always set to `screenshot`. + default: screenshot + x-stainless-const: true + type: object + required: + - type + title: Screenshot + description: A screenshot action. + ScrollParam: + properties: + type: + type: string + enum: + - scroll + description: >- + Specifies the event type. For a scroll action, this property is + always set to `scroll`. + default: scroll + x-stainless-const: true + x: + type: integer + description: The x-coordinate where the scroll occurred. + 'y': + type: integer + description: The y-coordinate where the scroll occurred. + scroll_x: + type: integer + description: The horizontal scroll distance. + scroll_y: + type: integer + description: The vertical scroll distance. + keys: + items: + type: string + type: array + description: The keys being held while scrolling. + type: object + required: + - type + - x + - 'y' + - scroll_x + - scroll_y + title: Scroll + description: A scroll action. + TypeParam: + properties: + type: + type: string + enum: + - type + description: >- + Specifies the event type. For a type action, this property is always + set to `type`. + default: type + x-stainless-const: true + text: + type: string + description: The text to type. + type: object + required: + - type + - text + title: Type + description: An action to type in text. + WaitParam: + properties: + type: + type: string + enum: + - wait + description: >- + Specifies the event type. For a wait action, this property is always + set to `wait`. + default: wait + x-stainless-const: true + type: object + required: + - type + title: Wait + description: A wait action. + FunctionTool: + properties: + type: + type: string + enum: + - function + description: The type of the function tool. Always `function`. + default: function + x-stainless-const: true + name: + type: string + description: The name of the function to call. + description: + type: string + description: >- + A description of the function. Used by the model to determine + whether or not to call the function. + parameters: + additionalProperties: {} + type: object + description: A JSON schema object describing the parameters of the function. + x-oaiTypeLabel: map + strict: + type: boolean + description: Whether to enforce strict parameter validation. Default `true`. + defer_loading: + type: boolean + description: Whether this function is deferred and loaded via tool search. + type: object + required: + - type + - name + - strict + - parameters + title: Function + description: >- + Defines a function in your own code the model can choose to call. Learn + more about [function + calling](https://platform.openai.com/docs/guides/function-calling). + FileSearchTool: + properties: + type: + type: string + enum: + - file_search + description: The type of the file search tool. Always `file_search`. + default: file_search + x-stainless-const: true + vector_store_ids: + items: + type: string + type: array + description: The IDs of the vector stores to search. + max_num_results: + type: integer + description: >- + The maximum number of results to return. This number should be + between 1 and 50 inclusive. + ranking_options: + $ref: '#/components/schemas/RankingOptions' + description: Ranking options for search. + filters: + type: object + additionalProperties: false + title: Comparison Filter + description: > + A filter used to compare a specified attribute key to a given value + using a defined comparison operation. + properties: + type: + type: string + default: eq + enum: + - eq + - ne + - gt + - gte + - lt + - lte + - in + - nin + description: > + Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, + `lt`, `lte`, `in`, `nin`. + + - `eq`: equals + + - `ne`: not equal + + - `gt`: greater than + + - `gte`: greater than or equal + + - `lt`: less than + + - `lte`: less than or equal + + - `in`: in + + - `nin`: not in + key: + type: string + description: The key to compare against the value. + value: + description: >- + The value to compare against the attribute key; supports string, + number, or boolean types. + type: string + items: + oneOf: + - type: string + - type: number + filters: + type: array + description: >- + Array of filters to combine. Items can be `ComparisonFilter` or + `CompoundFilter`. + items: + oneOf: + - $ref: '#/components/schemas/ComparisonFilter' + - $recursiveRef: '#' + discriminator: + propertyName: type + required: + - type + - key + - value + - filters + x-oaiMeta: + name: ComparisonFilter + $recursiveAnchor: true + type: object + required: + - type + - vector_store_ids + title: File search + description: >- + A tool that searches for relevant content from uploaded files. Learn + more about the [file search + tool](https://platform.openai.com/docs/guides/tools-file-search). + ComputerTool: + properties: + type: + type: string + enum: + - computer + description: The type of the computer tool. Always `computer`. + default: computer + x-stainless-const: true + type: object + required: + - type + title: Computer + description: >- + A tool that controls a virtual computer. Learn more about the [computer + tool](https://platform.openai.com/docs/guides/tools-computer-use). + ComputerUsePreviewTool: + properties: + type: + type: string + enum: + - computer_use_preview + description: The type of the computer use tool. Always `computer_use_preview`. + default: computer_use_preview + x-stainless-const: true + environment: + $ref: '#/components/schemas/ComputerEnvironment' + description: The type of computer environment to control. + display_width: + type: integer + description: The width of the computer display. + display_height: + type: integer + description: The height of the computer display. + type: object + required: + - type + - environment + - display_width + - display_height + title: Computer use preview + description: >- + A tool that controls a virtual computer. Learn more about the [computer + tool](https://platform.openai.com/docs/guides/tools-computer-use). + WebSearchTool: + type: object + title: Web search + description: > + Search the Internet for sources related to the prompt. Learn more about + the + + [web search tool](/docs/guides/tools-web-search). + properties: + type: + type: string + enum: + - web_search + - web_search_2025_08_26 + description: >- + The type of the web search tool. One of `web_search` or + `web_search_2025_08_26`. + default: web_search + filters: + type: object + description: | + Filters for the search. + properties: + allowed_domains: + anyOf: + - type: array + title: Allowed domains for the search. + description: > + Allowed domains for the search. If not provided, all domains + are allowed. + + Subdomains of the provided domains are allowed as well. + + + Example: `["pubmed.ncbi.nlm.nih.gov"]` + items: + type: string + description: Allowed domain for the search. + default: [] + - type: 'null' + user_location: + $ref: '#/components/schemas/WebSearchApproximateLocation' + search_context_size: + type: string + enum: + - low + - medium + - high + default: medium + description: >- + High level guidance for the amount of context window space to use + for the search. One of `low`, `medium`, or `high`. `medium` is the + default. + required: + - type + MCPTool: + type: object + title: MCP tool + description: > + Give the model access to additional tools via remote Model Context + Protocol + + (MCP) servers. [Learn more about MCP](/docs/guides/tools-remote-mcp). + properties: + type: + type: string + enum: + - mcp + description: The type of the MCP tool. Always `mcp`. + x-stainless-const: true + server_label: + type: string + description: | + A label for this MCP server, used to identify it in tool calls. + server_url: + type: string + format: uri + description: > + The URL for the MCP server. One of `server_url` or `connector_id` + must be + + provided. + connector_id: + type: string + enum: + - connector_dropbox + - connector_gmail + - connector_googlecalendar + - connector_googledrive + - connector_microsoftteams + - connector_outlookcalendar + - connector_outlookemail + - connector_sharepoint + description: > + Identifier for service connectors, like those available in ChatGPT. + One of + + `server_url` or `connector_id` must be provided. Learn more about + service + + connectors [here](/docs/guides/tools-remote-mcp#connectors). + + + Currently supported `connector_id` values are: + + + - Dropbox: `connector_dropbox` + + - Gmail: `connector_gmail` + + - Google Calendar: `connector_googlecalendar` + + - Google Drive: `connector_googledrive` + + - Microsoft Teams: `connector_microsoftteams` + + - Outlook Calendar: `connector_outlookcalendar` + + - Outlook Email: `connector_outlookemail` + + - SharePoint: `connector_sharepoint` + authorization: + type: string + description: > + An OAuth access token that can be used with a remote MCP server, + either + + with a custom MCP server URL or a service connector. Your + application + + must handle the OAuth authorization flow and provide the token here. + server_description: + type: string + description: > + Optional description of the MCP server, used to provide more + context. + headers: + type: object + additionalProperties: + type: string + description: > + Optional HTTP headers to send to the MCP server. Use for + authentication + + or other purposes. + allowed_tools: + description: | + List of allowed tool names or a filter object. + oneOf: + - type: array + title: MCP allowed tools + description: A string array of allowed tool names + items: + type: string + - $ref: '#/components/schemas/MCPToolFilter' + type: 'null' + require_approval: + description: Specify which of the MCP server's tools require approval. + oneOf: + - type: object + title: MCP tool approval filter + description: | + Specify which of the MCP server's tools require approval. Can be + `always`, `never`, or a filter object associated with tools + that require approval. + properties: + always: + $ref: '#/components/schemas/MCPToolFilter' + never: + $ref: '#/components/schemas/MCPToolFilter' + additionalProperties: false + - type: string + title: MCP tool approval setting + description: > + Specify a single approval policy for all tools. One of `always` + or + + `never`. When set to `always`, all tools will require approval. + When + + set to `never`, all tools will not require approval. + enum: + - always + - never + default: always + type: 'null' + defer_loading: + type: boolean + description: | + Whether this MCP tool is deferred and discovered via tool search. + required: + - type + - server_label + CodeInterpreterTool: + type: object + title: Code interpreter + description: | + A tool that runs Python code to help generate a response to a prompt. + properties: + type: + type: string + enum: + - code_interpreter + description: | + The type of the code interpreter tool. Always `code_interpreter`. + x-stainless-const: true + container: + description: > + The code interpreter container. Can be a container ID or an object + that + + specifies uploaded file IDs to make available to your code, along + with an + + optional `memory_limit` setting. + type: string + properties: + type: + type: string + enum: + - auto + description: Always `auto`. + default: auto + x-stainless-const: true + file_ids: + items: + type: string + example: file-123 + type: array + maxItems: 50 + description: >- + An optional list of uploaded files to make available to your + code. + memory_limit: + type: string + enum: + - 1g + - 4g + - 16g + - 64g + network_policy: + description: Network access policy for the container. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - disabled + description: Disable outbound network access. Always `disabled`. + default: disabled + x-stainless-const: true + allowed_domains: + items: + type: string + type: array + minItems: 1 + description: A list of allowed domains when type is `allowlist`. + domain_secrets: + items: + $ref: >- + #/components/schemas/ContainerNetworkPolicyDomainSecretParam + type: array + minItems: 1 + description: Optional domain-scoped secrets for allowlisted domains. + type: object + required: + - type + - allowed_domains + required: + - type + title: CodeInterpreterToolAuto + required: + - type + - container + ImageGenTool: + type: object + title: Image generation tool + description: | + A tool that generates images using the GPT image models. + properties: + type: + type: string + enum: + - image_generation + description: | + The type of the image generation tool. Always `image_generation`. + x-stainless-const: true + model: + type: string + enum: + - gpt-image-1 + - gpt-image-1-mini + - gpt-image-1.5 + description: | + The image generation model to use. Default: `gpt-image-1`. + default: gpt-image-1 + quality: + type: string + enum: + - low + - medium + - high + - auto + description: | + The quality of the generated image. One of `low`, `medium`, `high`, + or `auto`. Default: `auto`. + default: auto + size: + description: >- + The size of the generated images. For `gpt-image-2` and + `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as + `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height + must both be divisible by 16 and the requested aspect ratio must be + between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, + and the maximum supported resolution is `3840x2160`. The requested + size must also satisfy the model's current pixel and edge limits. + The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are + supported by the GPT image models; `auto` is supported for models + that allow automatic sizing. For `dall-e-2`, use one of `256x256`, + `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, + `1792x1024`, or `1024x1792`. + default: auto + type: string + enum: + - 1024x1024 + - 1024x1536 + - 1536x1024 + - auto + output_format: + type: string + enum: + - png + - webp + - jpeg + description: | + The output format of the generated image. One of `png`, `webp`, or + `jpeg`. Default: `png`. + default: png + output_compression: + type: integer + minimum: 0 + maximum: 100 + description: | + Compression level for the output image. Default: 100. + default: 100 + moderation: + type: string + enum: + - auto + - low + description: | + Moderation level for the generated image. Default: `auto`. + default: auto + background: + type: string + enum: + - transparent + - opaque + - auto + description: | + Background type for the generated image. One of `transparent`, + `opaque`, or `auto`. Default: `auto`. + default: auto + input_fidelity: + type: string + enum: + - high + - low + description: >- + Control how much effort the model will exert to match the style and + features, especially facial features, of input images. This + parameter is only supported for `gpt-image-1` and `gpt-image-1.5` + and later models, unsupported for `gpt-image-1-mini`. Supports + `high` and `low`. Defaults to `low`. + input_image_mask: + type: object + description: | + Optional mask for inpainting. Contains `image_url` + (string, optional) and `file_id` (string, optional). + properties: + image_url: + type: string + description: | + Base64-encoded mask image. + file_id: + type: string + description: | + File ID for the mask image. + required: [] + additionalProperties: false + partial_images: + type: integer + minimum: 0 + maximum: 3 + description: > + Number of partial images to generate in streaming mode, from 0 + (default value) to 3. + default: 0 + action: + description: > + Whether to generate a new image or edit an existing image. Default: + `auto`. + $ref: '#/components/schemas/ImageGenActionEnum' + required: + - type + LocalShellToolParam: + properties: + type: + type: string + enum: + - local_shell + description: The type of the local shell tool. Always `local_shell`. + default: local_shell + x-stainless-const: true + type: object + required: + - type + title: Local shell tool + description: >- + A tool that allows the model to execute shell commands in a local + environment. + FunctionShellToolParam: + properties: + type: + type: string + enum: + - shell + description: The type of the shell tool. Always `shell`. + default: shell + x-stainless-const: true + environment: + oneOf: + - $ref: '#/components/schemas/ContainerAutoParam' + - $ref: '#/components/schemas/LocalEnvironmentParam' + - $ref: '#/components/schemas/ContainerReferenceParam' + discriminator: + propertyName: type + type: 'null' + type: object + required: + - type + title: Shell tool + description: A tool that allows the model to execute shell commands. + CustomToolParam: + properties: + type: + type: string + enum: + - custom + description: The type of the custom tool. Always `custom`. + default: custom + x-stainless-const: true + name: + type: string + description: The name of the custom tool, used to identify it in tool calls. + description: + type: string + description: >- + Optional description of the custom tool, used to provide more + context. + format: + description: The input format for the custom tool. Default is unconstrained text. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - text + description: Unconstrained text format. Always `text`. + default: text + x-stainless-const: true + syntax: + $ref: '#/components/schemas/GrammarSyntax1' + description: The syntax of the grammar definition. One of `lark` or `regex`. + definition: + type: string + description: The grammar definition. + type: object + required: + - type + - syntax + - definition + title: Text format + defer_loading: + type: boolean + description: Whether this tool should be deferred and discovered via tool search. + type: object + required: + - type + - name + title: Custom tool + description: >- + A custom tool that processes input using a specified format. Learn more + about [custom tools](/docs/guides/function-calling#custom-tools) + NamespaceToolParam: + properties: + type: + type: string + enum: + - namespace + description: The type of the tool. Always `namespace`. + default: namespace + x-stainless-const: true + name: + type: string + minLength: 1 + description: The namespace name used in tool calls (for example, `crm`). + description: + type: string + minLength: 1 + description: A description of the namespace shown to the model. + tools: + items: + oneOf: + - $ref: '#/components/schemas/FunctionToolParam' + - $ref: '#/components/schemas/CustomToolParam' + description: A function or custom tool that belongs to a namespace. + discriminator: + propertyName: type + type: array + minItems: 1 + description: The function/custom tools available inside this namespace. + type: object + required: + - type + - name + - description + - tools + title: Namespace + description: Groups function/custom tools under a shared namespace. + ToolSearchToolParam: + properties: + type: + type: string + enum: + - tool_search + description: The type of the tool. Always `tool_search`. + default: tool_search + x-stainless-const: true + execution: + $ref: '#/components/schemas/ToolSearchExecutionType' + description: Whether tool search is executed by the server or by the client. + description: + type: string + description: >- + Description shown to the model for a client-executed tool search + tool. + parameters: + properties: {} + type: object + required: [] + type: object + required: + - type + title: Tool search tool + description: Hosted or BYOT tool search configuration for deferred tools. + WebSearchPreviewTool: + properties: + type: + type: string + enum: + - web_search_preview + - web_search_preview_2025_03_11 + description: >- + The type of the web search tool. One of `web_search_preview` or + `web_search_preview_2025_03_11`. + default: web_search_preview + x-stainless-const: true + user_location: + properties: + type: + type: string + enum: + - approximate + description: The type of location approximation. Always `approximate`. + default: approximate + x-stainless-const: true + country: + type: string + description: >- + The two-letter [ISO country + code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user, + e.g. `US`. + region: + type: string + description: Free text input for the region of the user, e.g. `California`. + city: + type: string + description: Free text input for the city of the user, e.g. `San Francisco`. + timezone: + type: string + description: >- + The [IANA + timezone](https://timeapi.io/documentation/iana-timezones) of + the user, e.g. `America/Los_Angeles`. + type: object + required: + - type + search_context_size: + $ref: '#/components/schemas/SearchContextSize' + description: >- + High level guidance for the amount of context window space to use + for the search. One of `low`, `medium`, or `high`. `medium` is the + default. + search_content_types: + items: + $ref: '#/components/schemas/SearchContentType' + type: array + type: object + required: + - type + title: Web search preview + description: >- + This tool searches the web for relevant results to use in a response. + Learn more about the [web search + tool](https://platform.openai.com/docs/guides/tools-web-search). + ApplyPatchToolParam: + properties: + type: + type: string + enum: + - apply_patch + description: The type of the tool. Always `apply_patch`. + default: apply_patch + x-stainless-const: true + type: object + required: + - type + title: Apply patch tool + description: >- + Allows the assistant to create, delete, or update files using unified + diffs. + FunctionShellCallOutputTimeoutOutcome: + properties: + type: + type: string + enum: + - timeout + description: The outcome type. Always `timeout`. + default: timeout + x-stainless-const: true + type: object + required: + - type + title: Shell call timeout outcome + description: Indicates that the shell call exceeded its configured time limit. + FunctionShellCallOutputExitOutcome: + properties: + type: + type: string + enum: + - exit + description: The outcome type. Always `exit`. + default: exit + x-stainless-const: true + exit_code: + type: integer + description: Exit code from the shell process. + type: object + required: + - type + - exit_code + title: Shell call exit outcome + description: Indicates that the shell commands finished and returned an exit code. + DetailEnum: + type: string + enum: + - low + - high + - auto + - original + FileDetailEnum: + type: string + enum: + - low + - high + LocalSkillParam: + properties: + name: + type: string + description: The name of the skill. + description: + type: string + description: The description of the skill. + path: + type: string + description: The path to the directory containing the skill. + type: object + required: + - name + - description + - path + FunctionShellCallOutputOutcomeParam: + title: Shell call outcome + description: The exit or timeout outcome associated with this shell call. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - timeout + description: The outcome type. Always `timeout`. + default: timeout + x-stainless-const: true + exit_code: + type: integer + description: The exit code returned by the shell process. + type: object + required: + - type + - exit_code + ApplyPatchCreateFileOperationParam: + properties: + type: + type: string + enum: + - create_file + description: The operation type. Always `create_file`. + default: create_file + x-stainless-const: true + path: + type: string + minLength: 1 + description: Path of the file to create relative to the workspace root. + diff: + type: string + maxLength: 10485760 + description: Unified diff content to apply when creating the file. + type: object + required: + - type + - path + - diff + title: Apply patch create file operation + description: Instruction for creating a new file via the apply_patch tool. + ApplyPatchDeleteFileOperationParam: + properties: + type: + type: string + enum: + - delete_file + description: The operation type. Always `delete_file`. + default: delete_file + x-stainless-const: true + path: + type: string + minLength: 1 + description: Path of the file to delete relative to the workspace root. + type: object + required: + - type + - path + title: Apply patch delete file operation + description: Instruction for deleting an existing file via the apply_patch tool. + ApplyPatchUpdateFileOperationParam: + properties: + type: + type: string + enum: + - update_file + description: The operation type. Always `update_file`. + default: update_file + x-stainless-const: true + path: + type: string + minLength: 1 + description: Path of the file to update relative to the workspace root. + diff: + type: string + maxLength: 10485760 + description: Unified diff content to apply to the existing file. + type: object + required: + - type + - path + - diff + title: Apply patch update file operation + description: Instruction for updating an existing file via the apply_patch tool. + FileCitationBody: + properties: + type: + type: string + enum: + - file_citation + description: The type of the file citation. Always `file_citation`. + default: file_citation + x-stainless-const: true + file_id: + type: string + description: The ID of the file. + index: + type: integer + description: The index of the file in the list of files. + filename: + type: string + description: The filename of the file cited. + type: object + required: + - type + - file_id + - index + - filename + title: File citation + description: A citation to a file. + UrlCitationBody: + properties: + type: + type: string + enum: + - url_citation + description: The type of the URL citation. Always `url_citation`. + default: url_citation + x-stainless-const: true + url: + type: string + format: uri + description: The URL of the web resource. + start_index: + type: integer + description: The index of the first character of the URL citation in the message. + end_index: + type: integer + description: The index of the last character of the URL citation in the message. + title: + type: string + description: The title of the web resource. + type: object + required: + - type + - url + - start_index + - end_index + - title + title: URL citation + description: A citation for a web resource used to generate a model response. + ContainerFileCitationBody: + properties: + type: + type: string + enum: + - container_file_citation + description: >- + The type of the container file citation. Always + `container_file_citation`. + default: container_file_citation + x-stainless-const: true + container_id: + type: string + description: The ID of the container file. + file_id: + type: string + description: The ID of the file. + start_index: + type: integer + description: >- + The index of the first character of the container file citation in + the message. + end_index: + type: integer + description: >- + The index of the last character of the container file citation in + the message. + filename: + type: string + description: The filename of the container file cited. + type: object + required: + - type + - container_id + - file_id + - start_index + - end_index + - filename + title: Container file citation + description: A citation for a container file used to generate a model response. + FilePath: + type: object + title: File path + description: | + A path to a file. + properties: + type: + type: string + description: | + The type of the file path. Always `file_path`. + enum: + - file_path + x-stainless-const: true + file_id: + type: string + description: | + The ID of the file. + index: + type: integer + description: | + The index of the file in the list of files. + required: + - type + - file_id + - index + TopLogProb: + properties: + token: + type: string + logprob: + type: number + bytes: + items: + type: integer + type: array + type: object + required: + - token + - logprob + - bytes + title: Top log probability + description: The top log probability of a token. + ClickButtonType: + type: string + enum: + - left + - right + - wheel + - back + - forward + CoordParam: + properties: + x: + type: integer + description: The x-coordinate. + 'y': + type: integer + description: The y-coordinate. + type: object + required: + - x + - 'y' + title: Coordinate + description: 'An x/y coordinate pair, e.g. `{ x: 100, y: 200 }`.' + RankingOptions: + properties: + ranker: + $ref: '#/components/schemas/RankerVersionType' + description: The ranker to use for the file search. + score_threshold: + type: number + description: >- + The score threshold for the file search, a number between 0 and 1. + Numbers closer to 1 will attempt to return only the most relevant + results, but may return fewer results. + hybrid_search: + $ref: '#/components/schemas/HybridSearchOptions' + description: >- + Weights that control how reciprocal rank fusion balances semantic + embedding matches versus sparse keyword matches when hybrid search + is enabled. + type: object + required: [] + Filters: + type: object + additionalProperties: false + title: Comparison Filter + description: > + A filter used to compare a specified attribute key to a given value + using a defined comparison operation. + properties: + type: + type: string + default: eq + enum: + - eq + - ne + - gt + - gte + - lt + - lte + - in + - nin + description: > + Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, + `lte`, `in`, `nin`. + + - `eq`: equals + + - `ne`: not equal + + - `gt`: greater than + + - `gte`: greater than or equal + + - `lt`: less than + + - `lte`: less than or equal + + - `in`: in + + - `nin`: not in + key: + type: string + description: The key to compare against the value. + value: + description: >- + The value to compare against the attribute key; supports string, + number, or boolean types. + type: string + items: + oneOf: + - type: string + - type: number + filters: + type: array + description: >- + Array of filters to combine. Items can be `ComparisonFilter` or + `CompoundFilter`. + items: + oneOf: + - $ref: '#/components/schemas/ComparisonFilter' + - $recursiveRef: '#' + discriminator: + propertyName: type + required: + - type + - key + - value + - filters + x-oaiMeta: + name: ComparisonFilter + $recursiveAnchor: true + ComputerEnvironment: + type: string + enum: + - windows + - mac + - linux + - ubuntu + - browser + WebSearchApproximateLocation: + type: object + title: Web search approximate location + description: | + The approximate location of the user. + properties: + type: + type: string + enum: + - approximate + description: The type of location approximation. Always `approximate`. + default: approximate + x-stainless-const: true + country: + anyOf: + - type: string + description: >- + The two-letter [ISO country + code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user, + e.g. `US`. + - type: 'null' + region: + anyOf: + - type: string + description: Free text input for the region of the user, e.g. `California`. + - type: 'null' + city: + anyOf: + - type: string + description: Free text input for the city of the user, e.g. `San Francisco`. + - type: 'null' + timezone: + anyOf: + - type: string + description: >- + The [IANA + timezone](https://timeapi.io/documentation/iana-timezones) of + the user, e.g. `America/Los_Angeles`. + - type: 'null' + MCPToolFilter: + type: object + title: MCP tool filter + description: | + A filter object to specify which tools are allowed. + properties: + tool_names: + type: array + title: MCP allowed tools + items: + type: string + description: List of allowed tool names. + read_only: + type: boolean + description: > + Indicates whether or not a tool modifies data or is read-only. If an + + MCP server is [annotated with + `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint), + + it will match this filter. + required: [] + additionalProperties: false + AutoCodeInterpreterToolParam: + properties: + type: + type: string + enum: + - auto + description: Always `auto`. + default: auto + x-stainless-const: true + file_ids: + items: + type: string + example: file-123 + type: array + maxItems: 50 + description: An optional list of uploaded files to make available to your code. + memory_limit: + type: string + enum: + - 1g + - 4g + - 16g + - 64g + network_policy: + description: Network access policy for the container. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - disabled + description: Disable outbound network access. Always `disabled`. + default: disabled + x-stainless-const: true + allowed_domains: + items: + type: string + type: array + minItems: 1 + description: A list of allowed domains when type is `allowlist`. + domain_secrets: + items: + $ref: '#/components/schemas/ContainerNetworkPolicyDomainSecretParam' + type: array + minItems: 1 + description: Optional domain-scoped secrets for allowlisted domains. + type: object + required: + - type + - allowed_domains + type: object + required: + - type + title: CodeInterpreterToolAuto + description: >- + Configuration for a code interpreter container. Optionally specify the + IDs of the files to run the code on. + InputFidelity: + type: string + enum: + - high + - low + description: >- + Control how much effort the model will exert to match the style and + features, especially facial features, of input images. This parameter is + only supported for `gpt-image-1` and `gpt-image-1.5` and later models, + unsupported for `gpt-image-1-mini`. Supports `high` and `low`. Defaults + to `low`. + ImageGenActionEnum: + type: string + enum: + - generate + - edit + - auto + ContainerAutoParam: + properties: + type: + type: string + enum: + - container_auto + description: Automatically creates a container for this request + default: container_auto + x-stainless-const: true + file_ids: + items: + type: string + example: file-123 + type: array + maxItems: 50 + description: An optional list of uploaded files to make available to your code. + memory_limit: + type: string + enum: + - 1g + - 4g + - 16g + - 64g + network_policy: + description: Network access policy for the container. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - disabled + description: Disable outbound network access. Always `disabled`. + default: disabled + x-stainless-const: true + allowed_domains: + items: + type: string + type: array + minItems: 1 + description: A list of allowed domains when type is `allowlist`. + domain_secrets: + items: + $ref: '#/components/schemas/ContainerNetworkPolicyDomainSecretParam' + type: array + minItems: 1 + description: Optional domain-scoped secrets for allowlisted domains. + type: object + required: + - type + - allowed_domains + skills: + items: + oneOf: + - $ref: '#/components/schemas/SkillReferenceParam' + - $ref: '#/components/schemas/InlineSkillParam' + discriminator: + propertyName: type + type: array + maxItems: 200 + description: An optional list of skills referenced by id or inline data. + type: object + required: + - type + CustomTextFormatParam: + properties: + type: + type: string + enum: + - text + description: Unconstrained text format. Always `text`. + default: text + x-stainless-const: true + type: object + required: + - type + title: Text format + description: Unconstrained free-form text. + CustomGrammarFormatParam: + properties: + type: + type: string + enum: + - grammar + description: Grammar format. Always `grammar`. + default: grammar + x-stainless-const: true + syntax: + $ref: '#/components/schemas/GrammarSyntax1' + description: The syntax of the grammar definition. One of `lark` or `regex`. + definition: + type: string + description: The grammar definition. + type: object + required: + - type + - syntax + - definition + title: Grammar format + description: A grammar defined by the user. + FunctionToolParam: + properties: + name: + type: string + maxLength: 128 + minLength: 1 + pattern: ^[a-zA-Z0-9_-]+$ + description: + type: string + parameters: + properties: {} + type: object + required: [] + strict: + type: boolean + type: + type: string + enum: + - function + default: function + x-stainless-const: true + defer_loading: + type: boolean + description: >- + Whether this function should be deferred and discovered via tool + search. + type: object + required: + - name + - type + ApproximateLocation: + properties: + type: + type: string + enum: + - approximate + description: The type of location approximation. Always `approximate`. + default: approximate + x-stainless-const: true + country: + type: string + description: >- + The two-letter [ISO country + code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user, e.g. + `US`. + region: + type: string + description: Free text input for the region of the user, e.g. `California`. + city: + type: string + description: Free text input for the city of the user, e.g. `San Francisco`. + timezone: + type: string + description: >- + The [IANA timezone](https://timeapi.io/documentation/iana-timezones) + of the user, e.g. `America/Los_Angeles`. + type: object + required: + - type + SearchContextSize: + type: string + enum: + - low + - medium + - high + SearchContentType: + type: string + enum: + - text + - image + FunctionShellCallOutputTimeoutOutcomeParam: + properties: + type: + type: string + enum: + - timeout + description: The outcome type. Always `timeout`. + default: timeout + x-stainless-const: true + type: object + required: + - type + title: Shell call timeout outcome + description: Indicates that the shell call exceeded its configured time limit. + FunctionShellCallOutputExitOutcomeParam: + properties: + type: + type: string + enum: + - exit + description: The outcome type. Always `exit`. + default: exit + x-stainless-const: true + exit_code: + type: integer + description: The exit code returned by the shell process. + type: object + required: + - type + - exit_code + title: Shell call exit outcome + description: Indicates that the shell commands finished and returned an exit code. + RankerVersionType: + type: string + enum: + - auto + - default-2024-11-15 + HybridSearchOptions: + properties: + embedding_weight: + type: number + description: The weight of the embedding in the reciprocal ranking fusion. + text_weight: + type: number + description: The weight of the text in the reciprocal ranking fusion. + type: object + required: + - embedding_weight + - text_weight + ComparisonFilter: + type: object + additionalProperties: false + title: Comparison Filter + description: > + A filter used to compare a specified attribute key to a given value + using a defined comparison operation. + properties: + type: + type: string + default: eq + enum: + - eq + - ne + - gt + - gte + - lt + - lte + - in + - nin + description: > + Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, + `lte`, `in`, `nin`. + + - `eq`: equals + + - `ne`: not equal + + - `gt`: greater than + + - `gte`: greater than or equal + + - `lt`: less than + + - `lte`: less than or equal + + - `in`: in + + - `nin`: not in + key: + type: string + description: The key to compare against the value. + value: + description: >- + The value to compare against the attribute key; supports string, + number, or boolean types. + type: string + items: + oneOf: + - type: string + - type: number + required: + - type + - key + - value + x-oaiMeta: + name: ComparisonFilter + CompoundFilter: + $recursiveAnchor: true + type: object + additionalProperties: false + title: Compound Filter + description: Combine multiple filters using `and` or `or`. + properties: + type: + type: string + description: 'Type of operation: `and` or `or`.' + enum: + - and + - or + filters: + type: array + description: >- + Array of filters to combine. Items can be `ComparisonFilter` or + `CompoundFilter`. + items: + oneOf: + - $ref: '#/components/schemas/ComparisonFilter' + - $recursiveRef: '#' + discriminator: + propertyName: type + required: + - type + - filters + x-oaiMeta: + name: CompoundFilter + ContainerMemoryLimit: + type: string + enum: + - 1g + - 4g + - 16g + - 64g + ContainerNetworkPolicyDisabledParam: + properties: + type: + type: string + enum: + - disabled + description: Disable outbound network access. Always `disabled`. + default: disabled + x-stainless-const: true + type: object + required: + - type + ContainerNetworkPolicyAllowlistParam: + properties: + type: + type: string + enum: + - allowlist + description: >- + Allow outbound network access only to specified domains. Always + `allowlist`. + default: allowlist + x-stainless-const: true + allowed_domains: + items: + type: string + type: array + minItems: 1 + description: A list of allowed domains when type is `allowlist`. + domain_secrets: + items: + $ref: '#/components/schemas/ContainerNetworkPolicyDomainSecretParam' + type: array + minItems: 1 + description: Optional domain-scoped secrets for allowlisted domains. + type: object + required: + - type + - allowed_domains + SkillReferenceParam: + properties: + type: + type: string + enum: + - skill_reference + description: References a skill created with the /v1/skills endpoint. + default: skill_reference + x-stainless-const: true + skill_id: + type: string + maxLength: 64 + minLength: 1 + description: The ID of the referenced skill. + version: + type: string + description: >- + Optional skill version. Use a positive integer or 'latest'. Omit for + default. + type: object + required: + - type + - skill_id + InlineSkillParam: + properties: + type: + type: string + enum: + - inline + description: Defines an inline skill for this request. + default: inline + x-stainless-const: true + name: + type: string + description: The name of the skill. + description: + type: string + description: The description of the skill. + source: + $ref: '#/components/schemas/InlineSkillSourceParam' + description: Inline skill payload + type: object + required: + - type + - name + - description + - source + GrammarSyntax1: + type: string + enum: + - lark + - regex + ContainerNetworkPolicyDomainSecretParam: + properties: + domain: + type: string + minLength: 1 + description: The domain associated with the secret. + name: + type: string + minLength: 1 + description: The name of the secret to inject for the domain. + value: + type: string + maxLength: 10485760 + minLength: 1 + description: The secret value to inject for the domain. + type: object + required: + - domain + - name + - value + InlineSkillSourceParam: + properties: + type: + type: string + enum: + - base64 + description: The type of the inline skill source. Must be `base64`. + default: base64 + x-stainless-const: true + media_type: + type: string + enum: + - application/zip + description: >- + The media type of the inline skill payload. Must be + `application/zip`. + default: application/zip + x-stainless-const: true + data: + type: string + maxLength: 70254592 + minLength: 1 + description: Base64-encoded skill zip bundle. + type: object + required: + - type + - media_type + - data + description: Inline skill payload + x-stackQL-resources: + items: + id: openai.conversations.items + name: items + title: Items + methods: + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1conversations~1{conversation_id}~1items/post' + response: + mediaType: application/json + openAPIDocKey: '200' + list: + operation: + $ref: '#/paths/~1conversations~1{conversation_id}~1items/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + get: + operation: + $ref: '#/paths/~1conversations~1{conversation_id}~1items~1{item_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: >- + #/paths/~1conversations~1{conversation_id}~1items~1{item_id}/delete + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/items/methods/get' + - $ref: '#/components/x-stackQL-resources/items/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/items/methods/create' + update: [] + delete: + - $ref: '#/components/x-stackQL-resources/items/methods/delete' + replace: [] + conversations: + id: openai.conversations.conversations + name: conversations + title: Conversations + methods: + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1conversations/post' + response: + mediaType: application/json + openAPIDocKey: '200' + get: + operation: + $ref: '#/paths/~1conversations~1{conversation_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1conversations~1{conversation_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + update: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1conversations~1{conversation_id}/post' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/conversations/methods/get' + insert: + - $ref: '#/components/x-stackQL-resources/conversations/methods/create' + update: + - $ref: '#/components/x-stackQL-resources/conversations/methods/update' + delete: + - $ref: '#/components/x-stackQL-resources/conversations/methods/delete' + replace: [] +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.last_id + location: body + queryParamPushdown: + top: + paramName: limit + maxValue: 100 diff --git a/providers/src/openai/v00.00.00000/services/embeddings.yaml b/providers/src/openai/v00.00.00000/services/embeddings.yaml deleted file mode 100644 index b65104d9..00000000 --- a/providers/src/openai/v00.00.00000/services/embeddings.yaml +++ /dev/null @@ -1,297 +0,0 @@ -openapi: 3.0.0 -servers: - - url: 'https://api.openai.com/v1' -info: - version: 2.3.0 - termsOfService: 'https://openai.com/policies/terms-of-use' - contact: - name: OpenAI Support - url: 'https://help.openai.com/' - license: - name: MIT - url: 'https://github.com/openai/openai-openapi/blob/master/LICENSE' - title: OpenAI API - embeddings - description: Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. -security: - - ApiKeyAuth: [] -tags: - - name: Assistants - description: Build Assistants that can call models and use tools. - - name: Audio - description: Turn audio into text or text into audio. - - name: Chat - description: 'Given a list of messages comprising a conversation, the model will return a response.' - - name: Completions - description: 'Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.' - - name: Embeddings - description: Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. - - name: Fine-tuning - description: Manage fine-tuning jobs to tailor a model to your specific training data. - - name: Batch - description: Create large batches of API requests to run asynchronously. - - name: Files - description: Files are used to upload documents that can be used with features like Assistants and Fine-tuning. - - name: Uploads - description: Use Uploads to upload large files in multiple parts. - - name: Images - description: 'Given a prompt and/or an input image, the model will generate a new image.' - - name: Models - description: List and describe the various models available in the API. - - name: Moderations - description: 'Given text and/or image inputs, classifies if those inputs are potentially harmful.' - - name: Audit Logs - description: List user actions and configuration changes within this organization. -components: - schemas: - CreateEmbeddingRequest: - type: object - additionalProperties: false - properties: - input: - description: | - Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model (8192 tokens for `text-embedding-ada-002`), cannot be an empty string, and any array must be 2048 dimensions or less. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. - example: The quick brown fox jumped over the lazy dog - oneOf: - - type: string - title: string - description: The string that will be turned into an embedding. - default: '' - example: This is a test. - - type: array - title: array - description: The array of strings that will be turned into an embedding. - minItems: 1 - maxItems: 2048 - items: - type: string - default: '' - example: '[''This is a test.'']' - - type: array - title: array - description: The array of integers that will be turned into an embedding. - minItems: 1 - maxItems: 2048 - items: - type: integer - example: '[1212, 318, 257, 1332, 13]' - - type: array - title: array - description: The array of arrays containing integers that will be turned into an embedding. - minItems: 1 - maxItems: 2048 - items: - type: array - minItems: 1 - items: - type: integer - example: '[[1212, 318, 257, 1332, 13]]' - x-oaiExpandable: true - model: - description: | - ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. - example: text-embedding-3-small - anyOf: - - type: string - - type: string - enum: - - text-embedding-ada-002 - - text-embedding-3-small - - text-embedding-3-large - x-oaiTypeLabel: string - encoding_format: - description: 'The format to return the embeddings in. Can be either `float` or [`base64`](https://pypi.org/project/pybase64/).' - example: float - default: float - type: string - enum: - - float - - base64 - dimensions: - description: | - The number of dimensions the resulting output embeddings should have. Only supported in `text-embedding-3` and later models. - type: integer - minimum: 1 - user: - type: string - example: user-1234 - description: | - A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - required: - - model - - input - CreateEmbeddingResponse: - type: object - properties: - data: - type: array - description: The list of embeddings generated by the model. - items: - $ref: '#/components/schemas/Embedding' - model: - type: string - description: The name of the model used to generate the embedding. - object: - type: string - description: 'The object type, which is always "list".' - enum: - - list - usage: - type: object - description: The usage information for the request. - properties: - prompt_tokens: - type: integer - description: The number of tokens used by the prompt. - total_tokens: - type: integer - description: The total number of tokens used by the request. - required: - - prompt_tokens - - total_tokens - required: - - object - - model - - data - - usage - Embedding: - type: object - description: | - Represents an embedding vector returned by embedding endpoint. - properties: - index: - type: integer - description: The index of the embedding in the list of embeddings. - embedding: - type: array - description: | - The embedding vector, which is a list of floats. The length of vector depends on the model as listed in the [embedding guide](/docs/guides/embeddings). - items: - type: number - object: - type: string - description: 'The object type, which is always "embedding".' - enum: - - embedding - required: - - index - - object - - embedding - x-oaiMeta: - name: The embedding object - example: | - { - "object": "embedding", - "embedding": [ - 0.0023064255, - -0.009327292, - .... (1536 floats total for ada-002) - -0.0028842222, - ], - "index": 0 - } - responses: {} - securitySchemes: - ApiKeyAuth: - type: http - scheme: bearer - x-stackQL-resources: - embeddings: - id: openai.embeddings.embeddings - name: embeddings - title: Embeddings - methods: - create_embedding: - operation: - $ref: '#/paths/~1embeddings/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/CreateEmbeddingResponse' - sqlVerbs: - select: [] - insert: - - $ref: '#/components/x-stackQL-resources/embeddings/methods/create_embedding' - update: [] - replace: [] - delete: [] -paths: - /embeddings: - post: - operationId: createEmbedding - tags: - - Embeddings - summary: Creates an embedding vector representing the input text. - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CreateEmbeddingRequest' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/CreateEmbeddingResponse' - x-oaiMeta: - name: Create embeddings - group: embeddings - returns: 'A list of [embedding](/docs/api-reference/embeddings/object) objects.' - examples: - request: - curl: | - curl https://api.openai.com/v1/embeddings \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -d '{ - "input": "The food was delicious and the waiter...", - "model": "text-embedding-ada-002", - "encoding_format": "float" - }' - python: | - from openai import OpenAI - client = OpenAI() - - client.embeddings.create( - model="text-embedding-ada-002", - input="The food was delicious and the waiter...", - encoding_format="float" - ) - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const embedding = await openai.embeddings.create({ - model: "text-embedding-ada-002", - input: "The quick brown fox jumped over the lazy dog", - encoding_format: "float", - }); - - console.log(embedding); - } - - main(); - response: | - { - "object": "list", - "data": [ - { - "object": "embedding", - "embedding": [ - 0.0023064255, - -0.009327292, - .... (1536 floats total for ada-002) - -0.0028842222, - ], - "index": 0 - } - ], - "model": "text-embedding-ada-002", - "usage": { - "prompt_tokens": 8, - "total_tokens": 8 - } - } diff --git a/providers/src/openai/v00.00.00000/services/evals.yaml b/providers/src/openai/v00.00.00000/services/evals.yaml new file mode 100644 index 00000000..8e03ad31 --- /dev/null +++ b/providers/src/openai/v00.00.00000/services/evals.yaml @@ -0,0 +1,8779 @@ +openapi: 3.1.0 +info: + title: evals API + description: openai API + version: 2.3.0 +paths: + /evals: + get: + operationId: listEvals + tags: + - Evals + summary: | + List evaluations for a project. + parameters: + - name: after + in: query + description: Identifier for the last eval from the previous pagination request. + required: false + schema: + type: string + - name: limit + in: query + description: >- + Number of evals to retrieve. + + + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: >- + Sort order for evals by timestamp. Use `asc` for ascending order or + `desc` for descending order. + required: false + schema: + type: string + enum: + - asc + - desc + default: asc + - name: order_by + in: query + description: > + Evals can be ordered by creation time or last updated time. Use + + `created_at` for creation time or `updated_at` for last updated + time. + required: false + schema: + type: string + enum: + - created_at + - updated_at + default: created_at + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: A list of evals + content: + application/json: + schema: + $ref: '#/components/schemas/EvalList' + x-oaiMeta: + name: List evals + group: evals + path: list + examples: + request: + curl: | + curl https://api.openai.com/v1/evals?limit=1 \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.evals.list() + page = page.data[0] + print(page.id) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + const evals = await openai.evals.list({ limit: 1 }); + console.log(evals); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const evalListResponse of client.evals.list()) { + console.log(evalListResponse.id); + } + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.evals.EvalListPage; + import com.openai.models.evals.EvalListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + EvalListPage page = client.evals().list(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + page = openai.evals.list + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "id": "eval_67abd54d9b0081909a86353f6fb9317a", + "object": "eval", + "data_source_config": { + "type": "stored_completions", + "metadata": { + "usecase": "push_notifications_summarizer" + }, + "schema": { + "type": "object", + "properties": { + "item": { + "type": "object" + }, + "sample": { + "type": "object" + } + }, + "required": [ + "item", + "sample" + ] + } + }, + "testing_criteria": [ + { + "name": "Push Notification Summary Grader", + "id": "Push Notification Summary Grader-9b876f24-4762-4be9-aff4-db7a9b31c673", + "type": "label_model", + "model": "o3-mini", + "input": [ + { + "type": "message", + "role": "developer", + "content": { + "type": "input_text", + "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" + } + }, + { + "type": "message", + "role": "user", + "content": { + "type": "input_text", + "text": "\nPush notifications: {{item.input}}\nSummary: {{sample.output_text}}\n" + } + } + ], + "passing_labels": [ + "correct" + ], + "labels": [ + "correct", + "incorrect" + ], + "sampling_params": null + } + ], + "name": "Push Notification Summary Grader", + "created_at": 1739314509, + "metadata": { + "description": "A stored completions eval for push notification summaries" + } + } + ], + "first_id": "eval_67abd54d9b0081909a86353f6fb9317a", + "last_id": "eval_67aa884cf6688190b58f657d4441c8b7", + "has_more": true + } + post: + operationId: createEval + tags: + - Evals + summary: > + Create the structure of an evaluation that can be used to test a model's + performance. + + An 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. + + For more information, see the [Evals guide](/docs/guides/evals). + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateEvalRequest' + responses: + '201': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Eval' + x-oaiMeta: + name: Create eval + group: evals + path: post + examples: + request: + curl: | + curl https://api.openai.com/v1/evals \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "Sentiment", + "data_source_config": { + "type": "stored_completions", + "metadata": { + "usecase": "chatbot" + } + }, + "testing_criteria": [ + { + "type": "label_model", + "model": "o3-mini", + "input": [ + { + "role": "developer", + "content": "Classify the sentiment of the following statement as one of 'positive', 'neutral', or 'negative'" + }, + { + "role": "user", + "content": "Statement: {{item.input}}" + } + ], + "passing_labels": [ + "positive" + ], + "labels": [ + "positive", + "neutral", + "negative" + ], + "name": "Example label grader" + } + ] + }' + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + eval = client.evals.create( + data_source_config={ + "item_schema": { + "foo": "bar" + }, + "type": "custom", + }, + testing_criteria=[{ + "input": [{ + "content": "content", + "role": "role", + }], + "labels": ["string"], + "model": "model", + "name": "name", + "passing_labels": ["string"], + "type": "label_model", + }], + ) + print(eval.id) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + const evalObj = await openai.evals.create({ + name: "Sentiment", + data_source_config: { + type: "stored_completions", + metadata: { usecase: "chatbot" } + }, + testing_criteria: [ + { + type: "label_model", + model: "o3-mini", + input: [ + { role: "developer", content: "Classify the sentiment of the following statement as one of 'positive', 'neutral', or 'negative'" }, + { role: "user", content: "Statement: {{item.input}}" } + ], + passing_labels: ["positive"], + labels: ["positive", "neutral", "negative"], + name: "Example label grader" + } + ] + }); + console.log(evalObj); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const _eval = await client.evals.create({ + data_source_config: { + item_schema: { foo: 'bar' }, + type: 'custom', + }, + testing_criteria: [ + { + input: [{ content: 'content', role: 'role' }], + labels: ['string'], + model: 'model', + name: 'name', + passing_labels: ['string'], + type: 'label_model', + }, + ], + }); + + console.log(_eval.id); + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.core.JsonValue; + import com.openai.models.evals.EvalCreateParams; + import com.openai.models.evals.EvalCreateResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + EvalCreateParams params = EvalCreateParams.builder() + .customDataSourceConfig(EvalCreateParams.DataSourceConfig.Custom.ItemSchema.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .addTestingCriterion(EvalCreateParams.TestingCriterion.LabelModel.builder() + .addInput(EvalCreateParams.TestingCriterion.LabelModel.Input.SimpleInputMessage.builder() + .content("content") + .role("role") + .build()) + .addLabel("string") + .model("model") + .name("name") + .addPassingLabel("string") + .build()) + .build(); + EvalCreateResponse eval = client.evals().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + eval_ = openai.evals.create( + data_source_config: {item_schema: {foo: "bar"}, type: :custom}, + testing_criteria: [ + { + input: [{content: "content", role: "role"}], + labels: ["string"], + model: "model", + name: "name", + passing_labels: ["string"], + type: :label_model + } + ] + ) + + puts(eval_) + response: | + { + "object": "eval", + "id": "eval_67b7fa9a81a88190ab4aa417e397ea21", + "data_source_config": { + "type": "stored_completions", + "metadata": { + "usecase": "chatbot" + }, + "schema": { + "type": "object", + "properties": { + "item": { + "type": "object" + }, + "sample": { + "type": "object" + } + }, + "required": [ + "item", + "sample" + ] + }, + "testing_criteria": [ + { + "name": "Example label grader", + "type": "label_model", + "model": "o3-mini", + "input": [ + { + "type": "message", + "role": "developer", + "content": { + "type": "input_text", + "text": "Classify the sentiment of the following statement as one of positive, neutral, or negative" + } + }, + { + "type": "message", + "role": "user", + "content": { + "type": "input_text", + "text": "Statement: {{item.input}}" + } + } + ], + "passing_labels": [ + "positive" + ], + "labels": [ + "positive", + "neutral", + "negative" + ] + } + ], + "name": "Sentiment", + "created_at": 1740110490, + "metadata": { + "description": "An eval for sentiment analysis" + } + } + parameters: + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + /evals/{eval_id}: + get: + operationId: getEval + tags: + - Evals + summary: | + Get an evaluation by ID. + parameters: + - name: eval_id + in: path + required: true + schema: + type: string + description: The ID of the evaluation to retrieve. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: The evaluation + content: + application/json: + schema: + $ref: '#/components/schemas/Eval' + x-oaiMeta: + name: Get an eval + group: evals + path: get + examples: + request: + curl: > + curl + https://api.openai.com/v1/evals/eval_67abd54d9b0081909a86353f6fb9317a + \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + eval = client.evals.retrieve( + "eval_id", + ) + print(eval.id) + javascript: > + import OpenAI from "openai"; + + + const openai = new OpenAI(); + + + const evalObj = await + openai.evals.retrieve("eval_67abd54d9b0081909a86353f6fb9317a"); + + console.log(evalObj); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const _eval = await client.evals.retrieve('eval_id'); + + console.log(_eval.id); + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.evals.EvalRetrieveParams; + import com.openai.models.evals.EvalRetrieveResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + EvalRetrieveResponse eval = client.evals().retrieve("eval_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + eval_ = openai.evals.retrieve("eval_id") + + puts(eval_) + response: | + { + "object": "eval", + "id": "eval_67abd54d9b0081909a86353f6fb9317a", + "data_source_config": { + "type": "custom", + "schema": { + "type": "object", + "properties": { + "item": { + "type": "object", + "properties": { + "input": { + "type": "string" + }, + "ground_truth": { + "type": "string" + } + }, + "required": [ + "input", + "ground_truth" + ] + } + }, + "required": [ + "item" + ] + } + }, + "testing_criteria": [ + { + "name": "String check", + "id": "String check-2eaf2d8d-d649-4335-8148-9535a7ca73c2", + "type": "string_check", + "input": "{{item.input}}", + "reference": "{{item.ground_truth}}", + "operation": "eq" + } + ], + "name": "External Data Eval", + "created_at": 1739314509, + "metadata": {}, + } + post: + operationId: updateEval + tags: + - Evals + summary: | + Update certain properties of an evaluation. + parameters: + - name: eval_id + in: path + required: true + schema: + type: string + description: The ID of the evaluation to update. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + requestBody: + description: Request to update an evaluation + required: true + content: + application/json: + schema: + type: object + properties: + name: + type: string + description: Rename the evaluation. + metadata: + $ref: '#/components/schemas/Metadata' + responses: + '200': + description: The updated evaluation + content: + application/json: + schema: + $ref: '#/components/schemas/Eval' + x-oaiMeta: + name: Update an eval + group: evals + path: update + examples: + request: + curl: > + curl + https://api.openai.com/v1/evals/eval_67abd54d9b0081909a86353f6fb9317a + \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"name": "Updated Eval", "metadata": {"description": "Updated description"}}' + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + eval = client.evals.update( + eval_id="eval_id", + ) + print(eval.id) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + const updatedEval = await openai.evals.update( + "eval_67abd54d9b0081909a86353f6fb9317a", + { + name: "Updated Eval", + metadata: { description: "Updated description" } + } + ); + console.log(updatedEval); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const _eval = await client.evals.update('eval_id'); + + console.log(_eval.id); + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.evals.EvalUpdateParams; + import com.openai.models.evals.EvalUpdateResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + EvalUpdateResponse eval = client.evals().update("eval_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + eval_ = openai.evals.update("eval_id") + + puts(eval_) + response: | + { + "object": "eval", + "id": "eval_67abd54d9b0081909a86353f6fb9317a", + "data_source_config": { + "type": "custom", + "schema": { + "type": "object", + "properties": { + "item": { + "type": "object", + "properties": { + "input": { + "type": "string" + }, + "ground_truth": { + "type": "string" + } + }, + "required": [ + "input", + "ground_truth" + ] + } + }, + "required": [ + "item" + ] + } + }, + "testing_criteria": [ + { + "name": "String check", + "id": "String check-2eaf2d8d-d649-4335-8148-9535a7ca73c2", + "type": "string_check", + "input": "{{item.input}}", + "reference": "{{item.ground_truth}}", + "operation": "eq" + } + ], + "name": "Updated Eval", + "created_at": 1739314509, + "metadata": {"description": "Updated description"}, + } + delete: + operationId: deleteEval + tags: + - Evals + summary: | + Delete an evaluation. + parameters: + - name: eval_id + in: path + required: true + schema: + type: string + description: The ID of the evaluation to delete. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: Successfully deleted the evaluation. + content: + application/json: + schema: + type: object + properties: + object: + type: string + example: eval.deleted + deleted: + type: boolean + example: true + eval_id: + type: string + example: eval_abc123 + required: + - object + - deleted + - eval_id + '404': + description: Evaluation not found. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + x-oaiMeta: + name: Delete an eval + group: evals + examples: + request: + curl: | + curl https://api.openai.com/v1/evals/eval_abc123 \ + -X DELETE \ + -H "Authorization: Bearer $OPENAI_API_KEY" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + eval = client.evals.delete( + "eval_id", + ) + print(eval.eval_id) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + const deleted = await openai.evals.delete("eval_abc123"); + console.log(deleted); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const _eval = await client.evals.delete('eval_id'); + + console.log(_eval.eval_id); + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.evals.EvalDeleteParams; + import com.openai.models.evals.EvalDeleteResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + EvalDeleteResponse eval = client.evals().delete("eval_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + eval_ = openai.evals.delete("eval_id") + + puts(eval_) + response: | + { + "object": "eval.deleted", + "deleted": true, + "eval_id": "eval_abc123" + } + /evals/{eval_id}/runs: + get: + operationId: getEvalRuns + tags: + - Evals + summary: | + Get a list of runs for an evaluation. + parameters: + - name: eval_id + in: path + required: true + schema: + type: string + description: The ID of the evaluation to retrieve runs for. + - name: after + in: query + description: Identifier for the last run from the previous pagination request. + required: false + schema: + type: string + - name: limit + in: query + description: >- + Number of runs to retrieve. + + + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: >- + Sort order for runs by timestamp. Use `asc` for ascending order or + `desc` for descending order. Defaults to `asc`. + required: false + schema: + type: string + enum: + - asc + - desc + default: asc + - name: status + in: query + description: >- + Filter runs by status. One of `queued` | `in_progress` | `failed` | + `completed` | `canceled`. + required: false + schema: + type: string + enum: + - queued + - in_progress + - completed + - canceled + - failed + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: A list of runs for the evaluation + content: + application/json: + schema: + $ref: '#/components/schemas/EvalRunList' + x-oaiMeta: + name: Get eval runs + group: evals + path: get-runs + examples: + request: + curl: > + curl + https://api.openai.com/v1/evals/egroup_67abd54d9b0081909a86353f6fb9317a/runs + \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.evals.runs.list( + eval_id="eval_id", + ) + page = page.data[0] + print(page.id) + javascript: > + import OpenAI from "openai"; + + + const openai = new OpenAI(); + + + const runs = await + openai.evals.runs.list("egroup_67abd54d9b0081909a86353f6fb9317a"); + + console.log(runs); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + // Automatically fetches more pages as needed. + + for await (const runListResponse of + client.evals.runs.list('eval_id')) { + console.log(runListResponse.id); + } + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.evals.runs.RunListPage; + import com.openai.models.evals.runs.RunListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RunListPage page = client.evals().runs().list("eval_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + page = openai.evals.runs.list("eval_id") + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "object": "eval.run", + "id": "evalrun_67e0c7d31560819090d60c0780591042", + "eval_id": "eval_67e0c726d560819083f19a957c4c640b", + "report_url": "https://platform.openai.com/evaluations/eval_67e0c726d560819083f19a957c4c640b", + "status": "completed", + "model": "o3-mini", + "name": "bulk_with_negative_examples_o3-mini", + "created_at": 1742784467, + "result_counts": { + "total": 1, + "errored": 0, + "failed": 0, + "passed": 1 + }, + "per_model_usage": [ + { + "model_name": "o3-mini", + "invocation_count": 1, + "prompt_tokens": 563, + "completion_tokens": 874, + "total_tokens": 1437, + "cached_tokens": 0 + } + ], + "per_testing_criteria_results": [ + { + "testing_criteria": "Push Notification Summary Grader-1808cd0b-eeec-4e0b-a519-337e79f4f5d1", + "passed": 1, + "failed": 0 + } + ], + "data_source": { + "type": "completions", + "source": { + "type": "file_content", + "content": [ + { + "item": { + "notifications": "\n- New message from Sarah: \"Can you call me later?\"\n- Your package has been delivered!\n- Flash sale: 20% off electronics for the next 2 hours!\n" + } + } + ] + }, + "input_messages": { + "type": "template", + "template": [ + { + "type": "message", + "role": "developer", + "content": { + "type": "input_text", + "text": "\n\n\n\nYou are a helpful assistant that takes in an array of push notifications and returns a collapsed summary of them.\nThe push notification will be provided as follows:\n\n...notificationlist...\n\n\nYou should return just the summary and nothing else.\n\n\nYou should return a summary that is concise and snappy.\n\n\nHere is an example of a good summary:\n\n- Traffic alert: Accident reported on Main Street.- Package out for delivery: Expected by 5 PM.- New friend suggestion: Connect with Emma.\n\n\nTraffic alert, package expected by 5pm, suggestion for new friend (Emily).\n\n\n\nHere is an example of a bad summary:\n\n- Traffic alert: Accident reported on Main Street.- Package out for delivery: Expected by 5 PM.- New friend suggestion: Connect with Emma.\n\n\nTraffic alert reported on main street. You have a package that will arrive by 5pm, Emily is a new friend suggested for you.\n\n" + } + }, + { + "type": "message", + "role": "user", + "content": { + "type": "input_text", + "text": "{{item.notifications}}" + } + } + ] + }, + "model": "o3-mini", + "sampling_params": null + }, + "error": null, + "metadata": {} + } + ], + "first_id": "evalrun_67e0c7d31560819090d60c0780591042", + "last_id": "evalrun_67e0c7d31560819090d60c0780591042", + "has_more": true + } + post: + operationId: createEvalRun + tags: + - Evals + summary: > + Kicks off a new run for a given evaluation, specifying the data source, + and what model configuration to use to test. The datasource will be + validated against the schema specified in the config of the evaluation. + parameters: + - in: path + name: eval_id + required: true + schema: + type: string + description: The ID of the evaluation to create a run for. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateEvalRunRequest' + responses: + '201': + description: Successfully created a run for the evaluation + content: + application/json: + schema: + $ref: '#/components/schemas/EvalRun' + '400': + description: Bad request (for example, missing eval object) + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + x-oaiMeta: + name: Create eval run + group: evals + examples: + request: + curl: > + curl + https://api.openai.com/v1/evals/eval_67e579652b548190aaa83ada4b125f47/runs + \ + -X POST \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -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"}}]}}' + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + run = client.evals.runs.create( + eval_id="eval_id", + data_source={ + "source": { + "content": [{ + "item": { + "foo": "bar" + } + }], + "type": "file_content", + }, + "type": "jsonl", + }, + ) + print(run.id) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + const run = await openai.evals.runs.create( + "eval_67e579652b548190aaa83ada4b125f47", + { + 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" + } + } + ] + } + } + } + ); + console.log(run); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const run = await client.evals.runs.create('eval_id', { + data_source: { + source: { content: [{ item: { foo: 'bar' } }], type: 'file_content' }, + type: 'jsonl', + }, + }); + + console.log(run.id); + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.core.JsonValue; + import com.openai.models.evals.runs.CreateEvalJsonlRunDataSource; + import com.openai.models.evals.runs.RunCreateParams; + import com.openai.models.evals.runs.RunCreateResponse; + import java.util.List; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RunCreateParams params = RunCreateParams.builder() + .evalId("eval_id") + .dataSource(CreateEvalJsonlRunDataSource.builder() + .fileContentSource(List.of(CreateEvalJsonlRunDataSource.Source.FileContent.Content.builder() + .item(CreateEvalJsonlRunDataSource.Source.FileContent.Content.Item.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .build())) + .build()) + .build(); + RunCreateResponse run = client.evals().runs().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + run = openai.evals.runs.create( + "eval_id", + data_source: {source: {content: [{item: {foo: "bar"}}], type: :file_content}, type: :jsonl} + ) + + puts(run) + response: | + { + "object": "eval.run", + "id": "evalrun_67e57965b480819094274e3a32235e4c", + "eval_id": "eval_67e579652b548190aaa83ada4b125f47", + "report_url": "https://platform.openai.com/evaluations/eval_67e579652b548190aaa83ada4b125f47&run_id=evalrun_67e57965b480819094274e3a32235e4c", + "status": "queued", + "model": "gpt-4o-mini", + "name": "gpt-4o-mini", + "created_at": 1743092069, + "result_counts": { + "total": 0, + "errored": 0, + "failed": 0, + "passed": 0 + }, + "per_model_usage": null, + "per_testing_criteria_results": null, + "data_source": { + "type": "completions", + "source": { + "type": "file_content", + "content": [ + { + "item": { + "input": "Tech Company Launches Advanced Artificial Intelligence Platform", + "ground_truth": "Technology" + } + } + ] + }, + "input_messages": { + "type": "template", + "template": [ + { + "type": "message", + "role": "developer", + "content": { + "type": "input_text", + "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" + } + }, + { + "type": "message", + "role": "user", + "content": { + "type": "input_text", + "text": "{{item.input}}" + } + } + ] + }, + "model": "gpt-4o-mini", + "sampling_params": { + "seed": 42, + "temperature": 1.0, + "top_p": 1.0, + "max_completions_tokens": 2048 + } + }, + "error": null, + "metadata": {} + } + /evals/{eval_id}/runs/{run_id}: + get: + operationId: getEvalRun + tags: + - Evals + summary: | + Get an evaluation run by ID. + parameters: + - name: eval_id + in: path + required: true + schema: + type: string + description: The ID of the evaluation to retrieve runs for. + - name: run_id + in: path + required: true + schema: + type: string + description: The ID of the run to retrieve. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: The evaluation run + content: + application/json: + schema: + $ref: '#/components/schemas/EvalRun' + 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 + \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + run = client.evals.runs.retrieve( + run_id="run_id", + eval_id="eval_id", + ) + print(run.id) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + const run = await openai.evals.runs.retrieve( + "evalrun_67abd54d60ec8190832b46859da808f7", + { eval_id: "eval_67abd54d9b0081909a86353f6fb9317a" } + ); + console.log(run); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const run = await client.evals.runs.retrieve('run_id', { eval_id: + 'eval_id' }); + + + console.log(run.id); + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.evals.runs.RunRetrieveParams; + import com.openai.models.evals.runs.RunRetrieveResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RunRetrieveParams params = RunRetrieveParams.builder() + .evalId("eval_id") + .runId("run_id") + .build(); + RunRetrieveResponse run = client.evals().runs().retrieve(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + run = openai.evals.runs.retrieve("run_id", eval_id: "eval_id") + + puts(run) + response: | + { + "object": "eval.run", + "id": "evalrun_67abd54d60ec8190832b46859da808f7", + "eval_id": "eval_67abd54d9b0081909a86353f6fb9317a", + "report_url": "https://platform.openai.com/evaluations/eval_67abd54d9b0081909a86353f6fb9317a?run_id=evalrun_67abd54d60ec8190832b46859da808f7", + "status": "queued", + "model": "gpt-4o-mini", + "name": "gpt-4o-mini", + "created_at": 1743092069, + "result_counts": { + "total": 0, + "errored": 0, + "failed": 0, + "passed": 0 + }, + "per_model_usage": null, + "per_testing_criteria_results": null, + "data_source": { + "type": "completions", + "source": { + "type": "file_content", + "content": [ + { + "item": { + "input": "Tech Company Launches Advanced Artificial Intelligence Platform", + "ground_truth": "Technology" + } + }, + { + "item": { + "input": "Central Bank Increases Interest Rates Amid Inflation Concerns", + "ground_truth": "Markets" + } + }, + { + "item": { + "input": "International Summit Addresses Climate Change Strategies", + "ground_truth": "World" + } + }, + { + "item": { + "input": "Major Retailer Reports Record-Breaking Holiday Sales", + "ground_truth": "Business" + } + }, + { + "item": { + "input": "National Team Qualifies for World Championship Finals", + "ground_truth": "Sports" + } + }, + { + "item": { + "input": "Stock Markets Rally After Positive Economic Data Released", + "ground_truth": "Markets" + } + }, + { + "item": { + "input": "Global Manufacturer Announces Merger with Competitor", + "ground_truth": "Business" + } + }, + { + "item": { + "input": "Breakthrough in Renewable Energy Technology Unveiled", + "ground_truth": "Technology" + } + }, + { + "item": { + "input": "World Leaders Sign Historic Climate Agreement", + "ground_truth": "World" + } + }, + { + "item": { + "input": "Professional Athlete Sets New Record in Championship Event", + "ground_truth": "Sports" + } + }, + { + "item": { + "input": "Financial Institutions Adapt to New Regulatory Requirements", + "ground_truth": "Business" + } + }, + { + "item": { + "input": "Tech Conference Showcases Advances in Artificial Intelligence", + "ground_truth": "Technology" + } + }, + { + "item": { + "input": "Global Markets Respond to Oil Price Fluctuations", + "ground_truth": "Markets" + } + }, + { + "item": { + "input": "International Cooperation Strengthened Through New Treaty", + "ground_truth": "World" + } + }, + { + "item": { + "input": "Sports League Announces Revised Schedule for Upcoming Season", + "ground_truth": "Sports" + } + } + ] + }, + "input_messages": { + "type": "template", + "template": [ + { + "type": "message", + "role": "developer", + "content": { + "type": "input_text", + "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" + } + }, + { + "type": "message", + "role": "user", + "content": { + "type": "input_text", + "text": "{{item.input}}" + } + } + ] + }, + "model": "gpt-4o-mini", + "sampling_params": { + "seed": 42, + "temperature": 1.0, + "top_p": 1.0, + "max_completions_tokens": 2048 + } + }, + "error": null, + "metadata": {} + } + post: + operationId: cancelEvalRun + tags: + - Evals + summary: | + Cancel an ongoing evaluation run. + parameters: + - name: eval_id + in: path + required: true + schema: + type: string + description: The ID of the evaluation whose run you want to cancel. + - name: run_id + in: path + required: true + schema: + type: string + description: The ID of the run to cancel. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: The canceled eval run object + content: + application/json: + schema: + $ref: '#/components/schemas/EvalRun' + 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 + \ + -X POST \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + response = client.evals.runs.cancel( + run_id="run_id", + eval_id="eval_id", + ) + print(response.id) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + const canceledRun = await openai.evals.runs.cancel( + "evalrun_67abd54d60ec8190832b46859da808f7", + { eval_id: "eval_67abd54d9b0081909a86353f6fb9317a" } + ); + console.log(canceledRun); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const response = await client.evals.runs.cancel('run_id', { + eval_id: 'eval_id' }); + + + console.log(response.id); + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.evals.runs.RunCancelParams; + import com.openai.models.evals.runs.RunCancelResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RunCancelParams params = RunCancelParams.builder() + .evalId("eval_id") + .runId("run_id") + .build(); + RunCancelResponse response = client.evals().runs().cancel(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + response = openai.evals.runs.cancel("run_id", eval_id: "eval_id") + + puts(response) + response: | + { + "object": "eval.run", + "id": "evalrun_67abd54d60ec8190832b46859da808f7", + "eval_id": "eval_67abd54d9b0081909a86353f6fb9317a", + "report_url": "https://platform.openai.com/evaluations/eval_67abd54d9b0081909a86353f6fb9317a?run_id=evalrun_67abd54d60ec8190832b46859da808f7", + "status": "canceled", + "model": "gpt-4o-mini", + "name": "gpt-4o-mini", + "created_at": 1743092069, + "result_counts": { + "total": 0, + "errored": 0, + "failed": 0, + "passed": 0 + }, + "per_model_usage": null, + "per_testing_criteria_results": null, + "data_source": { + "type": "completions", + "source": { + "type": "file_content", + "content": [ + { + "item": { + "input": "Tech Company Launches Advanced Artificial Intelligence Platform", + "ground_truth": "Technology" + } + }, + { + "item": { + "input": "Central Bank Increases Interest Rates Amid Inflation Concerns", + "ground_truth": "Markets" + } + }, + { + "item": { + "input": "International Summit Addresses Climate Change Strategies", + "ground_truth": "World" + } + }, + { + "item": { + "input": "Major Retailer Reports Record-Breaking Holiday Sales", + "ground_truth": "Business" + } + }, + { + "item": { + "input": "National Team Qualifies for World Championship Finals", + "ground_truth": "Sports" + } + }, + { + "item": { + "input": "Stock Markets Rally After Positive Economic Data Released", + "ground_truth": "Markets" + } + }, + { + "item": { + "input": "Global Manufacturer Announces Merger with Competitor", + "ground_truth": "Business" + } + }, + { + "item": { + "input": "Breakthrough in Renewable Energy Technology Unveiled", + "ground_truth": "Technology" + } + }, + { + "item": { + "input": "World Leaders Sign Historic Climate Agreement", + "ground_truth": "World" + } + }, + { + "item": { + "input": "Professional Athlete Sets New Record in Championship Event", + "ground_truth": "Sports" + } + }, + { + "item": { + "input": "Financial Institutions Adapt to New Regulatory Requirements", + "ground_truth": "Business" + } + }, + { + "item": { + "input": "Tech Conference Showcases Advances in Artificial Intelligence", + "ground_truth": "Technology" + } + }, + { + "item": { + "input": "Global Markets Respond to Oil Price Fluctuations", + "ground_truth": "Markets" + } + }, + { + "item": { + "input": "International Cooperation Strengthened Through New Treaty", + "ground_truth": "World" + } + }, + { + "item": { + "input": "Sports League Announces Revised Schedule for Upcoming Season", + "ground_truth": "Sports" + } + } + ] + }, + "input_messages": { + "type": "template", + "template": [ + { + "type": "message", + "role": "developer", + "content": { + "type": "input_text", + "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" + } + }, + { + "type": "message", + "role": "user", + "content": { + "type": "input_text", + "text": "{{item.input}}" + } + } + ] + }, + "model": "gpt-4o-mini", + "sampling_params": { + "seed": 42, + "temperature": 1.0, + "top_p": 1.0, + "max_completions_tokens": 2048 + } + }, + "error": null, + "metadata": {} + } + delete: + operationId: deleteEvalRun + tags: + - Evals + summary: | + Delete an eval run. + parameters: + - name: eval_id + in: path + required: true + schema: + type: string + description: The ID of the evaluation to delete the run from. + - name: run_id + in: path + required: true + schema: + type: string + description: The ID of the run to delete. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: Successfully deleted the eval run + content: + application/json: + schema: + type: object + properties: + object: + type: string + example: eval.run.deleted + deleted: + type: boolean + example: true + run_id: + type: string + example: evalrun_677469f564d48190807532a852da3afb + '404': + description: Run not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 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 \ + -X DELETE \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + run = client.evals.runs.delete( + run_id="run_id", + eval_id="eval_id", + ) + print(run.run_id) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + const deleted = await openai.evals.runs.delete( + "eval_123abc", + "evalrun_abc456" + ); + console.log(deleted); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const run = await client.evals.runs.delete('run_id', { eval_id: + 'eval_id' }); + + + console.log(run.run_id); + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.evals.runs.RunDeleteParams; + import com.openai.models.evals.runs.RunDeleteResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RunDeleteParams params = RunDeleteParams.builder() + .evalId("eval_id") + .runId("run_id") + .build(); + RunDeleteResponse run = client.evals().runs().delete(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + run = openai.evals.runs.delete("run_id", eval_id: "eval_id") + + puts(run) + response: | + { + "object": "eval.run.deleted", + "deleted": true, + "run_id": "evalrun_abc456" + } + /evals/{eval_id}/runs/{run_id}/output_items: + get: + operationId: getEvalRunOutputItems + tags: + - Evals + summary: | + Get a list of output items for an evaluation run. + parameters: + - name: eval_id + in: path + required: true + schema: + type: string + description: The ID of the evaluation to retrieve runs for. + - name: run_id + in: path + required: true + schema: + type: string + description: The ID of the run to retrieve output items for. + - name: after + in: query + description: >- + Identifier for the last output item from the previous pagination + request. + required: false + schema: + type: string + - name: limit + in: query + description: >- + Number of output items to retrieve. + + + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. + required: false + schema: + type: integer + default: 20 + - name: status + in: query + description: > + Filter output items by status. Use `failed` to filter by failed + output + + items or `pass` to filter by passed output items. + required: false + schema: + type: string + enum: + - fail + - pass + - name: order + in: query + description: >- + Sort order for output items by timestamp. Use `asc` for ascending + order or `desc` for descending order. Defaults to `asc`. + required: false + schema: + type: string + enum: + - asc + - desc + default: asc + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: A list of output items for the evaluation run + content: + application/json: + schema: + $ref: '#/components/schemas/EvalRunOutputItemList' + 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 + \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.evals.runs.output_items.list( + run_id="run_id", + eval_id="eval_id", + ) + page = page.data[0] + print(page.id) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + const outputItems = await openai.evals.runs.outputItems.list( + "egroup_67abd54d9b0081909a86353f6fb9317a", + "erun_67abd54d60ec8190832b46859da808f7" + ); + console.log(outputItems); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + // Automatically fetches more pages as needed. + + for await (const outputItemListResponse of + client.evals.runs.outputItems.list('run_id', { + eval_id: 'eval_id', + })) { + console.log(outputItemListResponse.id); + } + java: >- + package com.openai.example; + + + import com.openai.client.OpenAIClient; + + import com.openai.client.okhttp.OpenAIOkHttpClient; + + import + com.openai.models.evals.runs.outputitems.OutputItemListPage; + + import + com.openai.models.evals.runs.outputitems.OutputItemListParams; + + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + OutputItemListParams params = OutputItemListParams.builder() + .evalId("eval_id") + .runId("run_id") + .build(); + OutputItemListPage page = client.evals().runs().outputItems().list(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + page = openai.evals.runs.output_items.list("run_id", eval_id: + "eval_id") + + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "object": "eval.run.output_item", + "id": "outputitem_67e5796c28e081909917bf79f6e6214d", + "created_at": 1743092076, + "run_id": "evalrun_67abd54d60ec8190832b46859da808f7", + "eval_id": "eval_67abd54d9b0081909a86353f6fb9317a", + "status": "pass", + "datasource_item_id": 5, + "datasource_item": { + "input": "Stock Markets Rally After Positive Economic Data Released", + "ground_truth": "Markets" + }, + "results": [ + { + "name": "String check-a2486074-d803-4445-b431-ad2262e85d47", + "sample": null, + "passed": true, + "score": 1.0 + } + ], + "sample": { + "input": [ + { + "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", + "tool_call_id": null, + "tool_calls": null, + "function_call": null + }, + { + "role": "user", + "content": "Stock Markets Rally After Positive Economic Data Released", + "tool_call_id": null, + "tool_calls": null, + "function_call": null + } + ], + "output": [ + { + "role": "assistant", + "content": "Markets", + "tool_call_id": null, + "tool_calls": null, + "function_call": null + } + ], + "finish_reason": "stop", + "model": "gpt-4o-mini-2024-07-18", + "usage": { + "total_tokens": 325, + "completion_tokens": 2, + "prompt_tokens": 323, + "cached_tokens": 0 + }, + "error": null, + "temperature": 1.0, + "max_completion_tokens": 2048, + "top_p": 1.0, + "seed": 42 + } + } + ], + "first_id": "outputitem_67e5796c28e081909917bf79f6e6214d", + "last_id": "outputitem_67e5796c28e081909917bf79f6e6214d", + "has_more": true + } + /evals/{eval_id}/runs/{run_id}/output_items/{output_item_id}: + get: + operationId: getEvalRunOutputItem + tags: + - Evals + summary: | + Get an evaluation run output item by ID. + parameters: + - name: eval_id + in: path + required: true + schema: + type: string + description: The ID of the evaluation to retrieve runs for. + - name: run_id + in: path + required: true + schema: + type: string + description: The ID of the run to retrieve. + - name: output_item_id + in: path + required: true + schema: + type: string + description: The ID of the output item to retrieve. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: The evaluation run output item + content: + application/json: + schema: + $ref: '#/components/schemas/EvalRunOutputItem' + 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 + \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + output_item = client.evals.runs.output_items.retrieve( + output_item_id="output_item_id", + eval_id="eval_id", + run_id="run_id", + ) + print(output_item.id) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + const outputItem = await openai.evals.runs.outputItems.retrieve( + "outputitem_67abd55eb6548190bb580745d5644a33", + { + eval_id: "eval_67abd54d9b0081909a86353f6fb9317a", + run_id: "evalrun_67abd54d60ec8190832b46859da808f7", + } + ); + console.log(outputItem); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const outputItem = await + client.evals.runs.outputItems.retrieve('output_item_id', { + eval_id: 'eval_id', + run_id: 'run_id', + }); + + + console.log(outputItem.id); + java: >- + package com.openai.example; + + + import com.openai.client.OpenAIClient; + + import com.openai.client.okhttp.OpenAIOkHttpClient; + + import + com.openai.models.evals.runs.outputitems.OutputItemRetrieveParams; + + import + com.openai.models.evals.runs.outputitems.OutputItemRetrieveResponse; + + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + OutputItemRetrieveParams params = OutputItemRetrieveParams.builder() + .evalId("eval_id") + .runId("run_id") + .outputItemId("output_item_id") + .build(); + OutputItemRetrieveResponse outputItem = client.evals().runs().outputItems().retrieve(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + output_item = + openai.evals.runs.output_items.retrieve("output_item_id", eval_id: + "eval_id", run_id: "run_id") + + + puts(output_item) + response: | + { + "object": "eval.run.output_item", + "id": "outputitem_67e5796c28e081909917bf79f6e6214d", + "created_at": 1743092076, + "run_id": "evalrun_67abd54d60ec8190832b46859da808f7", + "eval_id": "eval_67abd54d9b0081909a86353f6fb9317a", + "status": "pass", + "datasource_item_id": 5, + "datasource_item": { + "input": "Stock Markets Rally After Positive Economic Data Released", + "ground_truth": "Markets" + }, + "results": [ + { + "name": "String check-a2486074-d803-4445-b431-ad2262e85d47", + "sample": null, + "passed": true, + "score": 1.0 + } + ], + "sample": { + "input": [ + { + "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", + "tool_call_id": null, + "tool_calls": null, + "function_call": null + }, + { + "role": "user", + "content": "Stock Markets Rally After Positive Economic Data Released", + "tool_call_id": null, + "tool_calls": null, + "function_call": null + } + ], + "output": [ + { + "role": "assistant", + "content": "Markets", + "tool_call_id": null, + "tool_calls": null, + "function_call": null + } + ], + "finish_reason": "stop", + "model": "gpt-4o-mini-2024-07-18", + "usage": { + "total_tokens": 325, + "completion_tokens": 2, + "prompt_tokens": 323, + "cached_tokens": 0 + }, + "error": null, + "temperature": 1.0, + "max_completion_tokens": 2048, + "top_p": 1.0, + "seed": 42 + } + } +components: + schemas: + EvalList: + type: object + title: EvalList + description: | + An object representing a list of evals. + properties: + object: + type: string + enum: + - list + default: list + description: | + The type of this object. It is always set to "list". + x-stainless-const: true + data: + type: array + description: | + An array of eval objects. + items: + $ref: '#/components/schemas/Eval' + first_id: + type: string + description: The identifier of the first eval in the data array. + last_id: + type: string + description: The identifier of the last eval in the data array. + has_more: + type: boolean + description: Indicates whether there are more evals available. + required: + - object + - data + - first_id + - last_id + - has_more + x-oaiMeta: + name: The eval list object + group: evals + example: | + { + "object": "list", + "data": [ + { + "object": "eval", + "id": "eval_67abd54d9b0081909a86353f6fb9317a", + "data_source_config": { + "type": "custom", + "schema": { + "type": "object", + "properties": { + "item": { + "type": "object", + "properties": { + "input": { + "type": "string" + }, + "ground_truth": { + "type": "string" + } + }, + "required": [ + "input", + "ground_truth" + ] + } + }, + "required": [ + "item" + ] + } + }, + "testing_criteria": [ + { + "name": "String check", + "id": "String check-2eaf2d8d-d649-4335-8148-9535a7ca73c2", + "type": "string_check", + "input": "{{item.input}}", + "reference": "{{item.ground_truth}}", + "operation": "eq" + } + ], + "name": "External Data Eval", + "created_at": 1739314509, + "metadata": {}, + } + ], + "first_id": "eval_67abd54d9b0081909a86353f6fb9317a", + "last_id": "eval_67abd54d9b0081909a86353f6fb9317a", + "has_more": true + } + CreateEvalRequest: + type: object + title: CreateEvalRequest + properties: + name: + type: string + description: The name of the evaluation. + metadata: + $ref: '#/components/schemas/Metadata' + data_source_config: + type: object + description: >- + The configuration for the data source used for the evaluation runs. + Dictates the schema of the data used in the evaluation. + title: CustomDataSourceConfig + properties: + type: + type: string + enum: + - custom + default: custom + description: The type of data source. Always `custom`. + x-stainless-const: true + item_schema: + type: object + description: The json schema for each row in the data source. + additionalProperties: true + example: | + { + "type": "object", + "properties": { + "name": {"type": "string"}, + "age": {"type": "integer"} + }, + "required": ["name", "age"] + } + include_sample_schema: + type: boolean + default: false + description: >- + Whether the eval should expect you to populate the sample + namespace (ie, by generating responses off of your data source) + metadata: + type: object + description: Metadata filters for the logs data source. + additionalProperties: true + example: | + { + "use_case": "customer_support_agent" + } + required: + - item_schema + - type + x-oaiMeta: + name: The eval file data source config object + group: evals + example: | + { + "type": "custom", + "item_schema": { + "type": "object", + "properties": { + "name": {"type": "string"}, + "age": {"type": "integer"} + }, + "required": ["name", "age"] + }, + "include_sample_schema": true + } + deprecated: true + testing_criteria: + type: array + description: >- + A list of graders for all eval runs in this group. Graders can + reference variables in the data source using double curly braces + notation, like `{{item.variable_name}}`. To reference the model's + output, use the `sample` namespace (ie, `{{sample.output_text}}`). + items: + oneOf: + - $ref: '#/components/schemas/CreateEvalLabelModelGrader' + - $ref: '#/components/schemas/EvalGraderStringCheck' + - $ref: '#/components/schemas/EvalGraderTextSimilarity' + - $ref: '#/components/schemas/EvalGraderPython' + - $ref: '#/components/schemas/EvalGraderScoreModel' + required: + - data_source_config + - testing_criteria + Eval: + type: object + title: Eval + description: | + An Eval object with a data source config and testing criteria. + An Eval represents a task to be done for your LLM integration. + Like: + - Improve the quality of my chatbot + - See how well my chatbot handles customer support + - Check if o4-mini is better at my usecase than gpt-4o + properties: + object: + type: string + enum: + - eval + default: eval + description: The object type. + x-stainless-const: true + id: + type: string + description: Unique identifier for the evaluation. + name: + type: string + description: The name of the evaluation. + example: Chatbot effectiveness Evaluation + data_source_config: + type: object + description: Configuration of data sources used in runs of the evaluation. + title: CustomDataSourceConfig + properties: + type: + type: string + enum: + - custom + default: custom + description: The type of data source. Always `custom`. + x-stainless-const: true + schema: + type: object + description: > + The json schema for the run data source items. + + Learn how to build JSON schemas + [here](https://json-schema.org/). + additionalProperties: true + example: | + { + "type": "object", + "properties": { + "item": { + "type": "object", + "properties": { + "label": {"type": "string"}, + }, + "required": ["label"] + } + }, + "required": ["item"] + } + metadata: + $ref: '#/components/schemas/Metadata' + required: + - type + - schema + x-oaiMeta: + name: The eval custom data source config object + group: evals + example: | + { + "type": "custom", + "schema": { + "type": "object", + "properties": { + "item": { + "type": "object", + "properties": { + "label": {"type": "string"}, + }, + "required": ["label"] + } + }, + "required": ["item"] + } + } + deprecated: true + testing_criteria: + default: eval + description: A list of testing criteria. + type: array + items: + oneOf: + - $ref: '#/components/schemas/EvalGraderLabelModel' + - $ref: '#/components/schemas/EvalGraderStringCheck' + - $ref: '#/components/schemas/EvalGraderTextSimilarity' + - $ref: '#/components/schemas/EvalGraderPython' + - $ref: '#/components/schemas/EvalGraderScoreModel' + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the eval was created. + metadata: + $ref: '#/components/schemas/Metadata' + required: + - id + - data_source_config + - object + - testing_criteria + - name + - created_at + - metadata + x-oaiMeta: + name: The eval object + group: evals + example: | + { + "object": "eval", + "id": "eval_67abd54d9b0081909a86353f6fb9317a", + "data_source_config": { + "type": "custom", + "item_schema": { + "type": "object", + "properties": { + "label": {"type": "string"}, + }, + "required": ["label"] + }, + "include_sample_schema": true + }, + "testing_criteria": [ + { + "name": "My string check grader", + "type": "string_check", + "input": "{{sample.output_text}}", + "reference": "{{item.label}}", + "operation": "eq", + } + ], + "name": "External Data Eval", + "created_at": 1739314509, + "metadata": { + "test": "synthetics", + } + } + Metadata: + type: object + description: > + Set of 16 key-value pairs that can be attached to an object. This can be + + useful for storing additional information about the object in a + structured + + format, and querying for objects via API or the dashboard. + + + Keys are strings with a maximum length of 64 characters. Values are + strings + + with a maximum length of 512 characters. + additionalProperties: + type: string + x-oaiTypeLabel: map + Error: + type: object + properties: + code: + type: string + message: + type: string + param: + type: string + type: + type: string + required: + - type + - message + - param + - code + EvalRunList: + type: object + title: EvalRunList + description: | + An object representing a list of runs for an evaluation. + properties: + object: + type: string + enum: + - list + default: list + description: | + The type of this object. It is always set to "list". + x-stainless-const: true + data: + type: array + description: | + An array of eval run objects. + items: + $ref: '#/components/schemas/EvalRun' + first_id: + type: string + description: The identifier of the first eval run in the data array. + last_id: + type: string + description: The identifier of the last eval run in the data array. + has_more: + type: boolean + description: Indicates whether there are more evals available. + required: + - object + - data + - first_id + - last_id + - has_more + x-oaiMeta: + name: The eval run list object + group: evals + example: | + { + "object": "list", + "data": [ + { + "object": "eval.run", + "id": "evalrun_67b7fbdad46c819092f6fe7a14189620", + "eval_id": "eval_67b7fa9a81a88190ab4aa417e397ea21", + "report_url": "https://platform.openai.com/evaluations/eval_67b7fa9a81a88190ab4aa417e397ea21?run_id=evalrun_67b7fbdad46c819092f6fe7a14189620", + "status": "completed", + "model": "o3-mini", + "name": "Academic Assistant", + "created_at": 1740110812, + "result_counts": { + "total": 171, + "errored": 0, + "failed": 80, + "passed": 91 + }, + "per_model_usage": null, + "per_testing_criteria_results": [ + { + "testing_criteria": "String check grader", + "passed": 91, + "failed": 80 + } + ], + "run_data_source": { + "type": "completions", + "template_messages": [ + { + "type": "message", + "role": "system", + "content": { + "type": "input_text", + "text": "You are a helpful assistant." + } + }, + { + "type": "message", + "role": "user", + "content": { + "type": "input_text", + "text": "Hello, can you help me with my homework?" + } + } + ], + "datasource_reference": null, + "model": "o3-mini", + "max_completion_tokens": null, + "seed": null, + "temperature": null, + "top_p": null + }, + "error": null, + "metadata": {"test": "synthetics"} + } + ], + "first_id": "evalrun_67abd54d60ec8190832b46859da808f7", + "last_id": "evalrun_67abd54d60ec8190832b46859da808f7", + "has_more": false + } + CreateEvalRunRequest: + type: object + title: CreateEvalRunRequest + properties: + name: + type: string + description: The name of the run. + metadata: + $ref: '#/components/schemas/Metadata' + data_source: + type: object + description: Details about the run's data source. + title: JsonlRunDataSource + properties: + type: + type: string + enum: + - jsonl + default: jsonl + description: The type of data source. Always `jsonl`. + x-stainless-const: true + source: + description: >- + Determines what populates the `item` namespace in the data + source. + type: object + title: EvalJsonlFileContentSource + properties: + type: + type: string + enum: + - file_content + default: file_content + description: The type of jsonl source. Always `file_content`. + x-stainless-const: true + content: + type: array + items: + type: object + properties: + item: + type: object + additionalProperties: true + sample: + type: object + additionalProperties: true + required: + - item + description: The content of the jsonl file. + id: + type: string + description: The identifier of the file. + required: + - type + - content + - id + input_messages: + description: >- + Used when sampling from a model. Dictates the structure of the + messages passed into the model. Can either be a reference to a + prebuilt trajectory (ie, `item.input_trajectory`), or a template + with variable references to the `item` namespace. + type: object + title: TemplateInputMessages + properties: + type: + type: string + enum: + - template + description: The type of input messages. Always `template`. + template: + type: array + description: >- + A list of chat messages forming the prompt or context. May + include variable references to the `item` namespace, ie + {{item.name}}. + items: + oneOf: + - $ref: '#/components/schemas/EasyInputMessage' + - $ref: '#/components/schemas/EvalItem' + item_reference: + type: string + description: >- + A reference to a variable in the `item` namespace. Ie, + "item.input_trajectory" + required: + - type + - template + - item_reference + sampling_params: + type: object + properties: + reasoning_effort: + $ref: '#/components/schemas/ReasoningEffort' + temperature: + type: number + description: A higher temperature increases randomness in the outputs. + default: 1 + max_completion_tokens: + type: integer + description: The maximum number of tokens in the generated output. + top_p: + type: number + description: >- + An alternative to temperature for nucleus sampling; 1.0 + includes all tokens. + default: 1 + seed: + type: integer + description: A seed value to initialize the randomness, during sampling. + default: 42 + response_format: + description: > + An object specifying the format that the model must output. + + + Setting to `{ "type": "json_schema", "json_schema": {...} }` + enables + + Structured Outputs which ensures the model will match your + supplied JSON + + schema. Learn more in the [Structured Outputs + + guide](/docs/guides/structured-outputs). + + + Setting to `{ "type": "json_object" }` enables the older + JSON mode, which + + ensures the message the model generates is valid JSON. Using + `json_schema` + + is preferred for models that support it. + oneOf: + - $ref: '#/components/schemas/ResponseFormatText' + - $ref: '#/components/schemas/ResponseFormatJsonSchema' + - $ref: '#/components/schemas/ResponseFormatJsonObject' + tools: + type: array + description: > + A list of tools the model may call. Currently, only + functions are supported as a tool. Use this to provide a + list of functions the model may generate JSON inputs for. A + max of 128 functions are supported. + items: + $ref: '#/components/schemas/ChatCompletionTool' + model: + type: string + description: >- + The name of the model to use for generating completions (e.g. + "o3-mini"). + required: + - type + - source + x-oaiMeta: + name: The file data source object for the eval run configuration + group: evals + example: | + { + "type": "jsonl", + "source": { + "type": "file_id", + "id": "file-9GYS6xbkWgWhmE7VoLUWFg" + } + } + required: + - data_source + EvalRun: + type: object + title: EvalRun + description: | + A schema representing an evaluation run. + properties: + object: + type: string + enum: + - eval.run + default: eval.run + description: The type of the object. Always "eval.run". + x-stainless-const: true + id: + type: string + description: Unique identifier for the evaluation run. + eval_id: + type: string + description: The identifier of the associated evaluation. + status: + type: string + description: The status of the evaluation run. + model: + type: string + description: The model that is evaluated, if applicable. + name: + type: string + description: The name of the evaluation run. + created_at: + type: integer + format: unixtime + description: Unix timestamp (in seconds) when the evaluation run was created. + report_url: + type: string + format: uri + description: The URL to the rendered evaluation run report on the UI dashboard. + result_counts: + type: object + description: Counters summarizing the outcomes of the evaluation run. + properties: + total: + type: integer + description: Total number of executed output items. + errored: + type: integer + description: Number of output items that resulted in an error. + failed: + type: integer + description: Number of output items that failed to pass the evaluation. + passed: + type: integer + description: Number of output items that passed the evaluation. + required: + - total + - errored + - failed + - passed + per_model_usage: + type: array + description: Usage statistics for each model during the evaluation run. + items: + type: object + properties: + model_name: + type: string + description: The name of the model. + invocation_count: + type: integer + description: The number of invocations. + prompt_tokens: + type: integer + description: The number of prompt tokens used. + completion_tokens: + type: integer + description: The number of completion tokens generated. + total_tokens: + type: integer + description: The total number of tokens used. + cached_tokens: + type: integer + description: The number of tokens retrieved from cache. + required: + - model_name + - invocation_count + - prompt_tokens + - completion_tokens + - total_tokens + - cached_tokens + per_testing_criteria_results: + type: array + description: Results per testing criteria applied during the evaluation run. + items: + type: object + properties: + testing_criteria: + type: string + description: A description of the testing criteria. + passed: + type: integer + description: Number of tests passed for this criteria. + failed: + type: integer + description: Number of tests failed for this criteria. + required: + - testing_criteria + - passed + - failed + data_source: + type: object + description: Information about the run's data source. + title: JsonlRunDataSource + properties: + type: + type: string + enum: + - jsonl + default: jsonl + description: The type of data source. Always `jsonl`. + x-stainless-const: true + source: + description: >- + Determines what populates the `item` namespace in the data + source. + type: object + title: EvalJsonlFileContentSource + properties: + type: + type: string + enum: + - file_content + default: file_content + description: The type of jsonl source. Always `file_content`. + x-stainless-const: true + content: + type: array + items: + type: object + properties: + item: + type: object + additionalProperties: true + sample: + type: object + additionalProperties: true + required: + - item + description: The content of the jsonl file. + id: + type: string + description: The identifier of the file. + required: + - type + - content + - id + input_messages: + description: >- + Used when sampling from a model. Dictates the structure of the + messages passed into the model. Can either be a reference to a + prebuilt trajectory (ie, `item.input_trajectory`), or a template + with variable references to the `item` namespace. + type: object + title: TemplateInputMessages + properties: + type: + type: string + enum: + - template + description: The type of input messages. Always `template`. + template: + type: array + description: >- + A list of chat messages forming the prompt or context. May + include variable references to the `item` namespace, ie + {{item.name}}. + items: + oneOf: + - $ref: '#/components/schemas/EasyInputMessage' + - $ref: '#/components/schemas/EvalItem' + item_reference: + type: string + description: >- + A reference to a variable in the `item` namespace. Ie, + "item.input_trajectory" + required: + - type + - template + - item_reference + sampling_params: + type: object + properties: + reasoning_effort: + $ref: '#/components/schemas/ReasoningEffort' + temperature: + type: number + description: A higher temperature increases randomness in the outputs. + default: 1 + max_completion_tokens: + type: integer + description: The maximum number of tokens in the generated output. + top_p: + type: number + description: >- + An alternative to temperature for nucleus sampling; 1.0 + includes all tokens. + default: 1 + seed: + type: integer + description: A seed value to initialize the randomness, during sampling. + default: 42 + response_format: + description: > + An object specifying the format that the model must output. + + + Setting to `{ "type": "json_schema", "json_schema": {...} }` + enables + + Structured Outputs which ensures the model will match your + supplied JSON + + schema. Learn more in the [Structured Outputs + + guide](/docs/guides/structured-outputs). + + + Setting to `{ "type": "json_object" }` enables the older + JSON mode, which + + ensures the message the model generates is valid JSON. Using + `json_schema` + + is preferred for models that support it. + oneOf: + - $ref: '#/components/schemas/ResponseFormatText' + - $ref: '#/components/schemas/ResponseFormatJsonSchema' + - $ref: '#/components/schemas/ResponseFormatJsonObject' + tools: + type: array + description: > + A list of tools the model may call. Currently, only + functions are supported as a tool. Use this to provide a + list of functions the model may generate JSON inputs for. A + max of 128 functions are supported. + items: + $ref: '#/components/schemas/ChatCompletionTool' + model: + type: string + description: >- + The name of the model to use for generating completions (e.g. + "o3-mini"). + required: + - type + - source + x-oaiMeta: + name: The file data source object for the eval run configuration + group: evals + example: | + { + "type": "jsonl", + "source": { + "type": "file_id", + "id": "file-9GYS6xbkWgWhmE7VoLUWFg" + } + } + metadata: + $ref: '#/components/schemas/Metadata' + error: + $ref: '#/components/schemas/EvalApiError' + required: + - object + - id + - eval_id + - status + - model + - name + - created_at + - report_url + - result_counts + - per_model_usage + - per_testing_criteria_results + - data_source + - metadata + - error + x-oaiMeta: + name: The eval run object + group: evals + example: | + { + "object": "eval.run", + "id": "evalrun_67e57965b480819094274e3a32235e4c", + "eval_id": "eval_67e579652b548190aaa83ada4b125f47", + "report_url": "https://platform.openai.com/evaluations/eval_67e579652b548190aaa83ada4b125f47?run_id=evalrun_67e57965b480819094274e3a32235e4c", + "status": "queued", + "model": "gpt-4o-mini", + "name": "gpt-4o-mini", + "created_at": 1743092069, + "result_counts": { + "total": 0, + "errored": 0, + "failed": 0, + "passed": 0 + }, + "per_model_usage": null, + "per_testing_criteria_results": null, + "data_source": { + "type": "completions", + "source": { + "type": "file_content", + "content": [ + { + "item": { + "input": "Tech Company Launches Advanced Artificial Intelligence Platform", + "ground_truth": "Technology" + } + }, + { + "item": { + "input": "Central Bank Increases Interest Rates Amid Inflation Concerns", + "ground_truth": "Markets" + } + }, + { + "item": { + "input": "International Summit Addresses Climate Change Strategies", + "ground_truth": "World" + } + }, + { + "item": { + "input": "Major Retailer Reports Record-Breaking Holiday Sales", + "ground_truth": "Business" + } + }, + { + "item": { + "input": "National Team Qualifies for World Championship Finals", + "ground_truth": "Sports" + } + }, + { + "item": { + "input": "Stock Markets Rally After Positive Economic Data Released", + "ground_truth": "Markets" + } + }, + { + "item": { + "input": "Global Manufacturer Announces Merger with Competitor", + "ground_truth": "Business" + } + }, + { + "item": { + "input": "Breakthrough in Renewable Energy Technology Unveiled", + "ground_truth": "Technology" + } + }, + { + "item": { + "input": "World Leaders Sign Historic Climate Agreement", + "ground_truth": "World" + } + }, + { + "item": { + "input": "Professional Athlete Sets New Record in Championship Event", + "ground_truth": "Sports" + } + }, + { + "item": { + "input": "Financial Institutions Adapt to New Regulatory Requirements", + "ground_truth": "Business" + } + }, + { + "item": { + "input": "Tech Conference Showcases Advances in Artificial Intelligence", + "ground_truth": "Technology" + } + }, + { + "item": { + "input": "Global Markets Respond to Oil Price Fluctuations", + "ground_truth": "Markets" + } + }, + { + "item": { + "input": "International Cooperation Strengthened Through New Treaty", + "ground_truth": "World" + } + }, + { + "item": { + "input": "Sports League Announces Revised Schedule for Upcoming Season", + "ground_truth": "Sports" + } + } + ] + }, + "input_messages": { + "type": "template", + "template": [ + { + "type": "message", + "role": "developer", + "content": { + "type": "input_text", + "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" + } + }, + { + "type": "message", + "role": "user", + "content": { + "type": "input_text", + "text": "{{item.input}}" + } + } + ] + }, + "model": "gpt-4o-mini", + "sampling_params": { + "seed": 42, + "temperature": 1.0, + "top_p": 1.0, + "max_completions_tokens": 2048 + } + }, + "error": null, + "metadata": {} + } + EvalRunOutputItemList: + type: object + title: EvalRunOutputItemList + description: | + An object representing a list of output items for an evaluation run. + properties: + object: + type: string + enum: + - list + default: list + description: | + The type of this object. It is always set to "list". + x-stainless-const: true + data: + type: array + description: | + An array of eval run output item objects. + items: + $ref: '#/components/schemas/EvalRunOutputItem' + first_id: + type: string + description: The identifier of the first eval run output item in the data array. + last_id: + type: string + description: The identifier of the last eval run output item in the data array. + has_more: + type: boolean + description: Indicates whether there are more eval run output items available. + required: + - object + - data + - first_id + - last_id + - has_more + x-oaiMeta: + name: The eval run output item list object + group: evals + example: | + { + "object": "list", + "data": [ + { + "object": "eval.run.output_item", + "id": "outputitem_67abd55eb6548190bb580745d5644a33", + "run_id": "evalrun_67abd54d60ec8190832b46859da808f7", + "eval_id": "eval_67abd54d9b0081909a86353f6fb9317a", + "created_at": 1739314509, + "status": "pass", + "datasource_item_id": 137, + "datasource_item": { + "teacher": "To grade essays, I only check for style, content, and grammar.", + "student": "I am a student who is trying to write the best essay." + }, + "results": [ + { + "name": "String Check Grader", + "type": "string-check-grader", + "score": 1.0, + "passed": true, + } + ], + "sample": { + "input": [ + { + "role": "system", + "content": "You are an evaluator bot..." + }, + { + "role": "user", + "content": "You are assessing..." + } + ], + "output": [ + { + "role": "assistant", + "content": "The rubric is not clear nor concise." + } + ], + "finish_reason": "stop", + "model": "gpt-4o-2024-08-06", + "usage": { + "total_tokens": 521, + "completion_tokens": 2, + "prompt_tokens": 519, + "cached_tokens": 0 + }, + "error": null, + "temperature": 1.0, + "max_completion_tokens": 2048, + "top_p": 1.0, + "seed": 42 + } + }, + ], + "first_id": "outputitem_67abd55eb6548190bb580745d5644a33", + "last_id": "outputitem_67abd55eb6548190bb580745d5644a33", + "has_more": false + } + EvalRunOutputItem: + type: object + title: EvalRunOutputItem + description: | + A schema representing an evaluation run output item. + properties: + object: + type: string + enum: + - eval.run.output_item + default: eval.run.output_item + description: The type of the object. Always "eval.run.output_item". + x-stainless-const: true + id: + type: string + description: Unique identifier for the evaluation run output item. + run_id: + type: string + description: >- + The identifier of the evaluation run associated with this output + item. + eval_id: + type: string + description: The identifier of the evaluation group. + created_at: + type: integer + format: unixtime + description: Unix timestamp (in seconds) when the evaluation run was created. + status: + type: string + description: The status of the evaluation run. + datasource_item_id: + type: integer + description: The identifier for the data source item. + datasource_item: + type: object + description: Details of the input data source item. + additionalProperties: true + results: + type: array + description: A list of grader results for this output item. + items: + $ref: '#/components/schemas/EvalRunOutputItemResult' + sample: + type: object + description: A sample containing the input and output of the evaluation run. + properties: + input: + type: array + description: An array of input messages. + items: + type: object + description: An input message. + properties: + role: + type: string + description: >- + The role of the message sender (e.g., system, user, + developer). + content: + type: string + description: The content of the message. + required: + - role + - content + output: + type: array + description: An array of output messages. + items: + type: object + properties: + role: + type: string + description: >- + The role of the message (e.g. "system", "assistant", + "user"). + content: + type: string + description: The content of the message. + finish_reason: + type: string + description: The reason why the sample generation was finished. + model: + type: string + description: The model used for generating the sample. + usage: + type: object + description: Token usage details for the sample. + properties: + total_tokens: + type: integer + description: The total number of tokens used. + completion_tokens: + type: integer + description: The number of completion tokens generated. + prompt_tokens: + type: integer + description: The number of prompt tokens used. + cached_tokens: + type: integer + description: The number of tokens retrieved from cache. + required: + - total_tokens + - completion_tokens + - prompt_tokens + - cached_tokens + error: + $ref: '#/components/schemas/EvalApiError' + temperature: + type: number + description: The sampling temperature used. + max_completion_tokens: + type: integer + description: The maximum number of tokens allowed for completion. + top_p: + type: number + description: The top_p value used for sampling. + seed: + type: integer + description: The seed used for generating the sample. + required: + - input + - output + - finish_reason + - model + - usage + - error + - temperature + - max_completion_tokens + - top_p + - seed + required: + - object + - id + - run_id + - eval_id + - created_at + - status + - datasource_item_id + - datasource_item + - results + - sample + x-oaiMeta: + name: The eval run output item object + group: evals + example: | + { + "object": "eval.run.output_item", + "id": "outputitem_67abd55eb6548190bb580745d5644a33", + "run_id": "evalrun_67abd54d60ec8190832b46859da808f7", + "eval_id": "eval_67abd54d9b0081909a86353f6fb9317a", + "created_at": 1739314509, + "status": "pass", + "datasource_item_id": 137, + "datasource_item": { + "teacher": "To grade essays, I only check for style, content, and grammar.", + "student": "I am a student who is trying to write the best essay." + }, + "results": [ + { + "name": "String Check Grader", + "type": "string-check-grader", + "score": 1.0, + "passed": true, + } + ], + "sample": { + "input": [ + { + "role": "system", + "content": "You are an evaluator bot..." + }, + { + "role": "user", + "content": "You are assessing..." + } + ], + "output": [ + { + "role": "assistant", + "content": "The rubric is not clear nor concise." + } + ], + "finish_reason": "stop", + "model": "gpt-4o-2024-08-06", + "usage": { + "total_tokens": 521, + "completion_tokens": 2, + "prompt_tokens": 519, + "cached_tokens": 0 + }, + "error": null, + "temperature": 1.0, + "max_completion_tokens": 2048, + "top_p": 1.0, + "seed": 42 + } + } + CreateEvalCustomDataSourceConfig: + type: object + title: CustomDataSourceConfig + description: > + A CustomDataSourceConfig object that defines the schema for the data + source used for the evaluation runs. + + This schema is used to define the shape of the data that will be: + + - Used to define your testing criteria and + + - What data is required when creating a run + properties: + type: + type: string + enum: + - custom + default: custom + description: The type of data source. Always `custom`. + x-stainless-const: true + item_schema: + type: object + description: The json schema for each row in the data source. + additionalProperties: true + example: | + { + "type": "object", + "properties": { + "name": {"type": "string"}, + "age": {"type": "integer"} + }, + "required": ["name", "age"] + } + include_sample_schema: + type: boolean + default: false + description: >- + Whether the eval should expect you to populate the sample namespace + (ie, by generating responses off of your data source) + required: + - item_schema + - type + x-oaiMeta: + name: The eval file data source config object + group: evals + example: | + { + "type": "custom", + "item_schema": { + "type": "object", + "properties": { + "name": {"type": "string"}, + "age": {"type": "integer"} + }, + "required": ["name", "age"] + }, + "include_sample_schema": true + } + CreateEvalLogsDataSourceConfig: + type: object + title: LogsDataSourceConfig + description: > + A data source config which specifies the metadata property of your logs + query. + + This is usually metadata like `usecase=chatbot` or `prompt-version=v2`, + etc. + properties: + type: + type: string + enum: + - logs + default: logs + description: The type of data source. Always `logs`. + x-stainless-const: true + metadata: + type: object + description: Metadata filters for the logs data source. + additionalProperties: true + example: | + { + "use_case": "customer_support_agent" + } + required: + - type + x-oaiMeta: + name: The logs data source object for evals + group: evals + example: | + { + "type": "logs", + "metadata": { + "use_case": "customer_support_agent" + } + } + CreateEvalStoredCompletionsDataSourceConfig: + type: object + title: StoredCompletionsDataSourceConfig + description: | + Deprecated in favor of LogsDataSourceConfig. + properties: + type: + type: string + enum: + - stored_completions + default: stored_completions + description: The type of data source. Always `stored_completions`. + x-stainless-const: true + metadata: + type: object + description: Metadata filters for the stored completions data source. + additionalProperties: true + example: | + { + "use_case": "customer_support_agent" + } + required: + - type + deprecated: true + x-oaiMeta: + name: The stored completions data source object for evals + group: evals + example: | + { + "type": "stored_completions", + "metadata": { + "use_case": "customer_support_agent" + } + } + CreateEvalLabelModelGrader: + type: object + title: LabelModelGrader + description: > + A LabelModelGrader object which uses a model to assign labels to each + item + + in the evaluation. + properties: + type: + description: The object type, which is always `label_model`. + type: string + enum: + - label_model + x-stainless-const: true + name: + type: string + description: The name of the grader. + model: + type: string + description: >- + The model to use for the evaluation. Must support structured + outputs. + input: + type: array + description: >- + A list of chat messages forming the prompt or context. May include + variable references to the `item` namespace, ie {{item.name}}. + items: + $ref: '#/components/schemas/CreateEvalItem' + labels: + type: array + items: + type: string + description: The labels to classify to each item in the evaluation. + passing_labels: + type: array + items: + type: string + description: >- + The labels that indicate a passing result. Must be a subset of + labels. + required: + - type + - model + - input + - passing_labels + - labels + - name + x-oaiMeta: + name: The eval label model grader object + group: evals + example: | + { + "type": "label_model", + "model": "gpt-4o-2024-08-06", + "input": [ + { + "role": "system", + "content": "Classify the sentiment of the following statement as one of 'positive', 'neutral', or 'negative'" + }, + { + "role": "user", + "content": "Statement: {{item.response}}" + } + ], + "passing_labels": ["positive"], + "labels": ["positive", "neutral", "negative"], + "name": "Sentiment label grader" + } + EvalGraderStringCheck: + type: object + title: StringCheckGrader + description: > + A StringCheckGrader object that performs a string comparison between + input and reference using a specified operation. + properties: + type: + type: string + enum: + - string_check + description: The object type, which is always `string_check`. + x-stainless-const: true + name: + type: string + description: The name of the grader. + input: + type: string + description: The input text. This may include template strings. + reference: + type: string + description: The reference text. This may include template strings. + operation: + type: string + enum: + - eq + - ne + - like + - ilike + description: >- + The string check operation to perform. One of `eq`, `ne`, `like`, or + `ilike`. + required: + - type + - name + - input + - reference + - operation + x-oaiMeta: + name: String Check Grader + group: graders + example: | + { + "type": "string_check", + "name": "Example string check grader", + "input": "{{sample.output_text}}", + "reference": "{{item.label}}", + "operation": "eq" + } + EvalGraderTextSimilarity: + type: object + title: TextSimilarityGrader + description: > + A TextSimilarityGrader object which grades text based on similarity + metrics. + properties: + type: + type: string + enum: + - text_similarity + default: text_similarity + description: The type of grader. + x-stainless-const: true + name: + type: string + description: The name of the grader. + input: + type: string + description: The text being graded. + reference: + type: string + description: The text being graded against. + evaluation_metric: + type: string + enum: + - cosine + - fuzzy_match + - bleu + - gleu + - meteor + - rouge_1 + - rouge_2 + - rouge_3 + - rouge_4 + - rouge_5 + - rouge_l + description: > + The evaluation metric to use. One of `cosine`, `fuzzy_match`, + `bleu`, + + `gleu`, `meteor`, `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, + `rouge_5`, + + or `rouge_l`. + pass_threshold: + type: number + description: The threshold for the score. + required: + - type + - name + - input + - reference + - evaluation_metric + - pass_threshold + x-oaiMeta: + name: Text Similarity Grader + group: graders + example: | + { + "type": "text_similarity", + "name": "Example text similarity grader", + "input": "{{sample.output_text}}", + "reference": "{{item.label}}", + "evaluation_metric": "fuzzy_match" + } + EvalGraderPython: + type: object + title: PythonGrader + description: | + A PythonGrader object that runs a python script on the input. + properties: + type: + type: string + enum: + - python + description: The object type, which is always `python`. + x-stainless-const: true + name: + type: string + description: The name of the grader. + source: + type: string + description: The source code of the python script. + image_tag: + type: string + description: The image tag to use for the python script. + pass_threshold: + type: number + description: The threshold for the score. + required: + - type + - name + - source + x-oaiMeta: + name: Python Grader + group: graders + example: | + { + "type": "python", + "name": "Example python grader", + "image_tag": "2025-05-08", + "source": """ + def grade(sample: dict, item: dict) -> float: + \""" + Returns 1.0 if `output_text` equals `label`, otherwise 0.0. + \""" + output = sample.get("output_text") + label = item.get("label") + return 1.0 if output == label else 0.0 + """, + } + EvalGraderScoreModel: + type: object + title: ScoreModelGrader + description: > + A ScoreModelGrader object that uses a model to assign a score to the + input. + properties: + type: + type: string + enum: + - score_model + description: The object type, which is always `score_model`. + x-stainless-const: true + name: + type: string + description: The name of the grader. + model: + type: string + description: The model to use for the evaluation. + sampling_params: + type: object + description: The sampling parameters for the model. + properties: + seed: + anyOf: + - type: integer + description: | + A seed value to initialize the randomness, during sampling. + - type: 'null' + top_p: + anyOf: + - type: number + default: 1 + example: 1 + description: > + An alternative to temperature for nucleus sampling; 1.0 + includes all tokens. + - type: 'null' + temperature: + anyOf: + - type: number + description: | + A higher temperature increases randomness in the outputs. + - type: 'null' + max_completions_tokens: + anyOf: + - type: integer + minimum: 1 + description: > + The maximum number of tokens the grader model may generate + in its response. + - type: 'null' + reasoning_effort: + $ref: '#/components/schemas/ReasoningEffort' + input: + type: array + items: + $ref: '#/components/schemas/EvalItem' + description: > + The input messages evaluated by the grader. Supports text, output + text, input image, and input audio content blocks, and may include + template strings. + range: + type: array + items: + type: number + min_items: 2 + max_items: 2 + description: The range of the score. Defaults to `[0, 1]`. + pass_threshold: + type: number + description: The threshold for the score. + required: + - type + - name + - input + - model + x-oaiMeta: + name: Score Model Grader + group: graders + example: | + { + "type": "score_model", + "name": "Example score model grader", + "input": [ + { + "role": "user", + "content": [ + { + "type": "input_text", + "text": ( + "Score how close the reference answer is to the model answer. Score 1.0 if they are the same and 0.0 if they are different." + " Return just a floating point score\n\n" + " Reference answer: {{item.label}}\n\n" + " Model answer: {{sample.output_text}}" + ) + }, + { + "type": "input_image", + "image_url": "https://example.com/reference.png", + "file_id": null, + "detail": "auto" + } + ], + } + ], + "model": "gpt-5-mini", + "sampling_params": { + "temperature": 1, + "top_p": 1, + "seed": 42, + "max_completions_tokens": 32768, + "reasoning_effort": "medium" + }, + } + EvalCustomDataSourceConfig: + type: object + title: CustomDataSourceConfig + description: > + A CustomDataSourceConfig which specifies the schema of your `item` and + optionally `sample` namespaces. + + The response schema defines the shape of the data that will be: + + - Used to define your testing criteria and + + - What data is required when creating a run + properties: + type: + type: string + enum: + - custom + default: custom + description: The type of data source. Always `custom`. + x-stainless-const: true + schema: + type: object + description: | + The json schema for the run data source items. + Learn how to build JSON schemas [here](https://json-schema.org/). + additionalProperties: true + example: | + { + "type": "object", + "properties": { + "item": { + "type": "object", + "properties": { + "label": {"type": "string"}, + }, + "required": ["label"] + } + }, + "required": ["item"] + } + required: + - type + - schema + x-oaiMeta: + name: The eval custom data source config object + group: evals + example: | + { + "type": "custom", + "schema": { + "type": "object", + "properties": { + "item": { + "type": "object", + "properties": { + "label": {"type": "string"}, + }, + "required": ["label"] + } + }, + "required": ["item"] + } + } + EvalLogsDataSourceConfig: + type: object + title: LogsDataSourceConfig + description: > + A LogsDataSourceConfig which specifies the metadata property of your + logs query. + + This is usually metadata like `usecase=chatbot` or `prompt-version=v2`, + etc. + + The schema returned by this data source config is used to defined what + variables are available in your evals. + + `item` and `sample` are both defined when using this data source config. + properties: + type: + type: string + enum: + - logs + default: logs + description: The type of data source. Always `logs`. + x-stainless-const: true + metadata: + $ref: '#/components/schemas/Metadata' + schema: + type: object + description: | + The json schema for the run data source items. + Learn how to build JSON schemas [here](https://json-schema.org/). + additionalProperties: true + required: + - type + - schema + x-oaiMeta: + name: The logs data source object for evals + group: evals + example: | + { + "type": "logs", + "metadata": { + "language": "english" + }, + "schema": { + "type": "object", + "properties": { + "item": { + "type": "object" + }, + "sample": { + "type": "object" + } + }, + "required": [ + "item", + "sample" + } + } + EvalStoredCompletionsDataSourceConfig: + type: object + title: StoredCompletionsDataSourceConfig + description: | + Deprecated in favor of LogsDataSourceConfig. + properties: + type: + type: string + enum: + - stored_completions + default: stored_completions + description: The type of data source. Always `stored_completions`. + x-stainless-const: true + metadata: + $ref: '#/components/schemas/Metadata' + schema: + type: object + description: | + The json schema for the run data source items. + Learn how to build JSON schemas [here](https://json-schema.org/). + additionalProperties: true + required: + - type + - schema + deprecated: true + x-oaiMeta: + name: The stored completions data source object for evals + group: evals + example: | + { + "type": "stored_completions", + "metadata": { + "language": "english" + }, + "schema": { + "type": "object", + "properties": { + "item": { + "type": "object" + }, + "sample": { + "type": "object" + } + }, + "required": [ + "item", + "sample" + } + } + EvalGraderLabelModel: + type: object + title: LabelModelGrader + description: > + A LabelModelGrader object which uses a model to assign labels to each + item + + in the evaluation. + properties: + type: + description: The object type, which is always `label_model`. + type: string + enum: + - label_model + x-stainless-const: true + name: + type: string + description: The name of the grader. + model: + type: string + description: >- + The model to use for the evaluation. Must support structured + outputs. + input: + type: array + items: + $ref: '#/components/schemas/EvalItem' + labels: + type: array + items: + type: string + description: The labels to assign to each item in the evaluation. + passing_labels: + type: array + items: + type: string + description: >- + The labels that indicate a passing result. Must be a subset of + labels. + required: + - type + - model + - input + - passing_labels + - labels + - name + x-oaiMeta: + name: Label Model Grader + group: graders + example: | + { + "name": "First label grader", + "type": "label_model", + "model": "gpt-4o-2024-08-06", + "input": [ + { + "type": "message", + "role": "system", + "content": { + "type": "input_text", + "text": "Classify the sentiment of the following statement as one of positive, neutral, or negative" + } + }, + { + "type": "message", + "role": "user", + "content": { + "type": "input_text", + "text": "Statement: {{item.response}}" + } + } + ], + "passing_labels": [ + "positive" + ], + "labels": [ + "positive", + "neutral", + "negative" + ] + } + CreateEvalJsonlRunDataSource: + type: object + title: JsonlRunDataSource + description: > + A JsonlRunDataSource object with that specifies a JSONL file that + matches the eval + properties: + type: + type: string + enum: + - jsonl + default: jsonl + description: The type of data source. Always `jsonl`. + x-stainless-const: true + source: + description: Determines what populates the `item` namespace in the data source. + type: object + title: EvalJsonlFileContentSource + properties: + type: + type: string + enum: + - file_content + default: file_content + description: The type of jsonl source. Always `file_content`. + x-stainless-const: true + content: + type: array + items: + type: object + properties: + item: + type: object + additionalProperties: true + sample: + type: object + additionalProperties: true + required: + - item + description: The content of the jsonl file. + id: + type: string + description: The identifier of the file. + required: + - type + - content + - id + required: + - type + - source + x-oaiMeta: + name: The file data source object for the eval run configuration + group: evals + example: | + { + "type": "jsonl", + "source": { + "type": "file_id", + "id": "file-9GYS6xbkWgWhmE7VoLUWFg" + } + } + CreateEvalCompletionsRunDataSource: + type: object + title: CompletionsRunDataSource + description: > + A CompletionsRunDataSource object describing a model sampling + configuration. + properties: + type: + type: string + enum: + - completions + default: completions + description: The type of run data source. Always `completions`. + input_messages: + description: >- + Used when sampling from a model. Dictates the structure of the + messages passed into the model. Can either be a reference to a + prebuilt trajectory (ie, `item.input_trajectory`), or a template + with variable references to the `item` namespace. + type: object + title: TemplateInputMessages + properties: + type: + type: string + enum: + - template + description: The type of input messages. Always `template`. + template: + type: array + description: >- + A list of chat messages forming the prompt or context. May + include variable references to the `item` namespace, ie + {{item.name}}. + items: + oneOf: + - $ref: '#/components/schemas/EasyInputMessage' + - $ref: '#/components/schemas/EvalItem' + item_reference: + type: string + description: >- + A reference to a variable in the `item` namespace. Ie, + "item.input_trajectory" + required: + - type + - template + - item_reference + sampling_params: + type: object + properties: + reasoning_effort: + $ref: '#/components/schemas/ReasoningEffort' + temperature: + type: number + description: A higher temperature increases randomness in the outputs. + default: 1 + max_completion_tokens: + type: integer + description: The maximum number of tokens in the generated output. + top_p: + type: number + description: >- + An alternative to temperature for nucleus sampling; 1.0 includes + all tokens. + default: 1 + seed: + type: integer + description: A seed value to initialize the randomness, during sampling. + default: 42 + response_format: + description: > + An object specifying the format that the model must output. + + + Setting to `{ "type": "json_schema", "json_schema": {...} }` + enables + + Structured Outputs which ensures the model will match your + supplied JSON + + schema. Learn more in the [Structured Outputs + + guide](/docs/guides/structured-outputs). + + + Setting to `{ "type": "json_object" }` enables the older JSON + mode, which + + ensures the message the model generates is valid JSON. Using + `json_schema` + + is preferred for models that support it. + oneOf: + - $ref: '#/components/schemas/ResponseFormatText' + - $ref: '#/components/schemas/ResponseFormatJsonSchema' + - $ref: '#/components/schemas/ResponseFormatJsonObject' + tools: + type: array + description: > + A list of tools the model may call. Currently, only functions + are supported as a tool. Use this to provide a list of functions + the model may generate JSON inputs for. A max of 128 functions + are supported. + items: + $ref: '#/components/schemas/ChatCompletionTool' + model: + type: string + description: >- + The name of the model to use for generating completions (e.g. + "o3-mini"). + source: + description: >- + Determines what populates the `item` namespace in this run's data + source. + type: object + title: EvalJsonlFileContentSource + properties: + type: + type: string + enum: + - file_content + default: file_content + description: The type of jsonl source. Always `file_content`. + x-stainless-const: true + content: + type: array + items: + type: object + properties: + item: + type: object + additionalProperties: true + sample: + type: object + additionalProperties: true + required: + - item + description: The content of the jsonl file. + id: + type: string + description: The identifier of the file. + metadata: + $ref: '#/components/schemas/Metadata' + model: + type: string + description: An optional model to filter by (e.g., 'gpt-4o'). + created_after: + type: integer + description: >- + An optional Unix timestamp to filter items created after this + time. + created_before: + type: integer + description: >- + An optional Unix timestamp to filter items created before this + time. + limit: + type: integer + description: An optional maximum number of items to return. + required: + - type + - content + - id + x-oaiMeta: + name: >- + The stored completions data source object used to configure an + individual run + group: eval runs + example: | + { + "type": "stored_completions", + "model": "gpt-4o", + "created_after": 1668124800, + "created_before": 1668124900, + "limit": 100, + "metadata": {} + } + required: + - type + - source + x-oaiMeta: + name: The completions data source object used to configure an individual run + group: eval runs + example: | + { + "name": "gpt-4o-mini-2024-07-18", + "data_source": { + "type": "completions", + "input_messages": { + "type": "item_reference", + "item_reference": "item.input" + }, + "model": "gpt-4o-mini-2024-07-18", + "source": { + "type": "stored_completions", + "model": "gpt-4o-mini-2024-07-18" + } + } + } + CreateEvalResponsesRunDataSource: + type: object + title: ResponsesRunDataSource + description: > + A ResponsesRunDataSource object describing a model sampling + configuration. + properties: + type: + type: string + enum: + - responses + default: responses + description: The type of run data source. Always `responses`. + input_messages: + description: >- + Used when sampling from a model. Dictates the structure of the + messages passed into the model. Can either be a reference to a + prebuilt trajectory (ie, `item.input_trajectory`), or a template + with variable references to the `item` namespace. + type: object + title: InputMessagesTemplate + properties: + type: + type: string + enum: + - template + description: The type of input messages. Always `template`. + template: + type: array + description: >- + A list of chat messages forming the prompt or context. May + include variable references to the `item` namespace, ie + {{item.name}}. + items: + oneOf: + - type: object + title: ChatMessage + properties: + role: + type: string + description: >- + The role of the message (e.g. "system", "assistant", + "user"). + content: + type: string + description: The content of the message. + required: + - role + - content + - $ref: '#/components/schemas/EvalItem' + item_reference: + type: string + description: >- + A reference to a variable in the `item` namespace. Ie, + "item.name" + required: + - type + - template + - item_reference + sampling_params: + type: object + properties: + reasoning_effort: + $ref: '#/components/schemas/ReasoningEffort' + temperature: + type: number + description: A higher temperature increases randomness in the outputs. + default: 1 + max_completion_tokens: + type: integer + description: The maximum number of tokens in the generated output. + top_p: + type: number + description: >- + An alternative to temperature for nucleus sampling; 1.0 includes + all tokens. + default: 1 + seed: + type: integer + description: A seed value to initialize the randomness, during sampling. + default: 42 + tools: + type: array + description: > + An array of tools the model may call while generating a + response. You + + can specify which tool to use by setting the `tool_choice` + parameter. + + + The two categories of tools you can provide the model are: + + + - **Built-in tools**: Tools that are provided by OpenAI that + extend the + model's capabilities, like [web search](/docs/guides/tools-web-search) + or [file search](/docs/guides/tools-file-search). Learn more about + [built-in tools](/docs/guides/tools). + - **Function calls (custom tools)**: Functions that are defined + by you, + enabling the model to call your own code. Learn more about + [function calling](/docs/guides/function-calling). + items: + $ref: '#/components/schemas/Tool' + text: + type: object + description: > + Configuration options for a text response from the model. Can be + plain + + text or structured JSON data. Learn more: + + - [Text inputs and outputs](/docs/guides/text) + + - [Structured Outputs](/docs/guides/structured-outputs) + properties: + format: + $ref: '#/components/schemas/TextResponseFormatConfiguration' + model: + type: string + description: >- + The name of the model to use for generating completions (e.g. + "o3-mini"). + source: + description: >- + Determines what populates the `item` namespace in this run's data + source. + type: object + title: EvalJsonlFileContentSource + properties: + type: + type: string + enum: + - file_content + default: file_content + description: The type of jsonl source. Always `file_content`. + x-stainless-const: true + content: + type: array + items: + type: object + properties: + item: + type: object + additionalProperties: true + sample: + type: object + additionalProperties: true + required: + - item + description: The content of the jsonl file. + id: + type: string + description: The identifier of the file. + metadata: + type: string + description: >- + Metadata filter for the responses. This is a query parameter + used to select responses. (opaque JSON object) + model: + type: string + description: >- + The name of the model to find responses for. This is a query + parameter used to select responses. + instructions_search: + type: string + description: >- + Optional string to search the 'instructions' field. This is a + query parameter used to select responses. + created_after: + type: integer + minimum: 0 + description: >- + Only include items created after this timestamp (inclusive). + This is a query parameter used to select responses. + created_before: + type: integer + minimum: 0 + description: >- + Only include items created before this timestamp (inclusive). + This is a query parameter used to select responses. + reasoning_effort: + type: string + enum: + - none + - minimal + - low + - medium + - high + - xhigh + default: medium + description: > + Constrains effort on reasoning for + + [reasoning + models](https://platform.openai.com/docs/guides/reasoning). + + Currently supported values are `none`, `minimal`, `low`, + `medium`, `high`, and `xhigh`. Reducing + + reasoning effort can result in faster responses and fewer tokens + used + + on reasoning in a response. + + + - `gpt-5.1` defaults to `none`, which does not perform + reasoning. The supported reasoning values for `gpt-5.1` are + `none`, `low`, `medium`, and `high`. Tool calls are supported + for all reasoning values in gpt-5.1. + + - All models before `gpt-5.1` default to `medium` reasoning + effort, and do not support `none`. + + - The `gpt-5-pro` model defaults to (and only supports) `high` + reasoning effort. + + - `xhigh` is supported for all models after `gpt-5.1-codex-max`. + temperature: + type: number + description: >- + Sampling temperature. This is a query parameter used to select + responses. + top_p: + type: number + description: >- + Nucleus sampling parameter. This is a query parameter used to + select responses. + users: + type: array + items: + type: string + description: >- + List of user identifiers. This is a query parameter used to + select responses. + tools: + type: array + items: + type: string + description: >- + List of tool names. This is a query parameter used to select + responses. + required: + - type + - content + - id + x-oaiMeta: + name: The run data source object used to configure an individual run + group: eval runs + example: | + { + "type": "responses", + "model": "gpt-4o-mini-2024-07-18", + "temperature": 0.7, + "top_p": 1.0, + "users": ["user1", "user2"], + "tools": ["tool1", "tool2"], + "instructions_search": "You are a coding assistant" + } + required: + - type + - source + x-oaiMeta: + name: The completions data source object used to configure an individual run + group: eval runs + example: | + { + "name": "gpt-4o-mini-2024-07-18", + "data_source": { + "type": "responses", + "input_messages": { + "type": "item_reference", + "item_reference": "item.input" + }, + "model": "gpt-4o-mini-2024-07-18", + "source": { + "type": "responses", + "model": "gpt-4o-mini-2024-07-18" + } + } + } + EvalApiError: + type: object + title: EvalApiError + description: | + An object representing an error response from the Eval API. + properties: + code: + type: string + description: The error code. + message: + type: string + description: The error message. + required: + - code + - message + x-oaiMeta: + name: The API error object + group: evals + example: | + { + "code": "internal_error", + "message": "The eval run failed due to an internal error." + } + EvalRunOutputItemResult: + type: object + title: EvalRunOutputItemResult + description: | + A single grader result for an evaluation run output item. + properties: + name: + type: string + description: The name of the grader. + type: + type: string + description: The grader type (for example, "string-check-grader"). + score: + type: number + description: The numeric score produced by the grader. + passed: + type: boolean + description: Whether the grader considered the output a pass. + sample: + description: Optional sample or intermediate data produced by the grader. + type: object + additionalProperties: true + additionalProperties: true + required: + - name + - score + - passed + CreateEvalItem: + title: CreateEvalItem + description: >- + A chat message that makes up the prompt or context. May include variable + references to the `item` namespace, ie {{item.name}}. + type: object + x-oaiMeta: + name: The chat message object used to configure an individual run + properties: + role: + type: string + description: The role of the message (e.g. "system", "assistant", "user"). + content: + type: string + description: The content of the message. + type: + type: string + description: | + The type of the message input. Always `message`. + enum: + - message + x-stainless-const: true + required: + - role + - content + GraderStringCheck: + type: object + title: StringCheckGrader + description: > + A StringCheckGrader object that performs a string comparison between + input and reference using a specified operation. + properties: + type: + type: string + enum: + - string_check + description: The object type, which is always `string_check`. + x-stainless-const: true + name: + type: string + description: The name of the grader. + input: + type: string + description: The input text. This may include template strings. + reference: + type: string + description: The reference text. This may include template strings. + operation: + type: string + enum: + - eq + - ne + - like + - ilike + description: >- + The string check operation to perform. One of `eq`, `ne`, `like`, or + `ilike`. + required: + - type + - name + - input + - reference + - operation + x-oaiMeta: + name: String Check Grader + group: graders + example: | + { + "type": "string_check", + "name": "Example string check grader", + "input": "{{sample.output_text}}", + "reference": "{{item.label}}", + "operation": "eq" + } + GraderTextSimilarity: + type: object + title: TextSimilarityGrader + description: > + A TextSimilarityGrader object which grades text based on similarity + metrics. + properties: + type: + type: string + enum: + - text_similarity + default: text_similarity + description: The type of grader. + x-stainless-const: true + name: + type: string + description: The name of the grader. + input: + type: string + description: The text being graded. + reference: + type: string + description: The text being graded against. + evaluation_metric: + type: string + enum: + - cosine + - fuzzy_match + - bleu + - gleu + - meteor + - rouge_1 + - rouge_2 + - rouge_3 + - rouge_4 + - rouge_5 + - rouge_l + description: > + The evaluation metric to use. One of `cosine`, `fuzzy_match`, + `bleu`, + + `gleu`, `meteor`, `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, + `rouge_5`, + + or `rouge_l`. + required: + - type + - name + - input + - reference + - evaluation_metric + x-oaiMeta: + name: Text Similarity Grader + group: graders + example: | + { + "type": "text_similarity", + "name": "Example text similarity grader", + "input": "{{sample.output_text}}", + "reference": "{{item.label}}", + "evaluation_metric": "fuzzy_match" + } + GraderPython: + type: object + title: PythonGrader + description: | + A PythonGrader object that runs a python script on the input. + properties: + type: + type: string + enum: + - python + description: The object type, which is always `python`. + x-stainless-const: true + name: + type: string + description: The name of the grader. + source: + type: string + description: The source code of the python script. + image_tag: + type: string + description: The image tag to use for the python script. + required: + - type + - name + - source + x-oaiMeta: + name: Python Grader + group: graders + example: | + { + "type": "python", + "name": "Example python grader", + "image_tag": "2025-05-08", + "source": """ + def grade(sample: dict, item: dict) -> float: + \""" + Returns 1.0 if `output_text` equals `label`, otherwise 0.0. + \""" + output = sample.get("output_text") + label = item.get("label") + return 1.0 if output == label else 0.0 + """, + } + GraderScoreModel: + type: object + title: ScoreModelGrader + description: > + A ScoreModelGrader object that uses a model to assign a score to the + input. + properties: + type: + type: string + enum: + - score_model + description: The object type, which is always `score_model`. + x-stainless-const: true + name: + type: string + description: The name of the grader. + model: + type: string + description: The model to use for the evaluation. + sampling_params: + type: object + description: The sampling parameters for the model. + properties: + seed: + anyOf: + - type: integer + description: | + A seed value to initialize the randomness, during sampling. + - type: 'null' + top_p: + anyOf: + - type: number + default: 1 + example: 1 + description: > + An alternative to temperature for nucleus sampling; 1.0 + includes all tokens. + - type: 'null' + temperature: + anyOf: + - type: number + description: | + A higher temperature increases randomness in the outputs. + - type: 'null' + max_completions_tokens: + anyOf: + - type: integer + minimum: 1 + description: > + The maximum number of tokens the grader model may generate + in its response. + - type: 'null' + reasoning_effort: + $ref: '#/components/schemas/ReasoningEffort' + input: + type: array + items: + $ref: '#/components/schemas/EvalItem' + description: > + The input messages evaluated by the grader. Supports text, output + text, input image, and input audio content blocks, and may include + template strings. + range: + type: array + items: + type: number + min_items: 2 + max_items: 2 + description: The range of the score. Defaults to `[0, 1]`. + required: + - type + - name + - input + - model + x-oaiMeta: + name: Score Model Grader + group: graders + example: | + { + "type": "score_model", + "name": "Example score model grader", + "input": [ + { + "role": "user", + "content": [ + { + "type": "input_text", + "text": ( + "Score how close the reference answer is to the model answer. Score 1.0 if they are the same and 0.0 if they are different." + " Return just a floating point score\n\n" + " Reference answer: {{item.label}}\n\n" + " Model answer: {{sample.output_text}}" + ) + }, + { + "type": "input_image", + "image_url": "https://example.com/reference.png", + "file_id": null, + "detail": "auto" + } + ], + } + ], + "model": "gpt-5-mini", + "sampling_params": { + "temperature": 1, + "top_p": 1, + "seed": 42, + "max_completions_tokens": 32768, + "reasoning_effort": "medium" + }, + } + GraderLabelModel: + type: object + title: LabelModelGrader + description: > + A LabelModelGrader object which uses a model to assign labels to each + item + + in the evaluation. + properties: + type: + description: The object type, which is always `label_model`. + type: string + enum: + - label_model + x-stainless-const: true + name: + type: string + description: The name of the grader. + model: + type: string + description: >- + The model to use for the evaluation. Must support structured + outputs. + input: + type: array + items: + $ref: '#/components/schemas/EvalItem' + labels: + type: array + items: + type: string + description: The labels to assign to each item in the evaluation. + passing_labels: + type: array + items: + type: string + description: >- + The labels that indicate a passing result. Must be a subset of + labels. + required: + - type + - model + - input + - passing_labels + - labels + - name + x-oaiMeta: + name: Label Model Grader + group: graders + example: | + { + "name": "First label grader", + "type": "label_model", + "model": "gpt-4o-2024-08-06", + "input": [ + { + "type": "message", + "role": "system", + "content": { + "type": "input_text", + "text": "Classify the sentiment of the following statement as one of positive, neutral, or negative" + } + }, + { + "type": "message", + "role": "user", + "content": { + "type": "input_text", + "text": "Statement: {{item.response}}" + } + } + ], + "passing_labels": [ + "positive" + ], + "labels": [ + "positive", + "neutral", + "negative" + ] + } + EvalJsonlFileContentSource: + type: object + title: EvalJsonlFileContentSource + properties: + type: + type: string + enum: + - file_content + default: file_content + description: The type of jsonl source. Always `file_content`. + x-stainless-const: true + content: + type: array + items: + type: object + properties: + item: + type: object + additionalProperties: true + sample: + type: object + additionalProperties: true + required: + - item + description: The content of the jsonl file. + required: + - type + - content + EvalJsonlFileIdSource: + type: object + title: EvalJsonlFileIdSource + properties: + type: + type: string + enum: + - file_id + default: file_id + description: The type of jsonl source. Always `file_id`. + x-stainless-const: true + id: + type: string + description: The identifier of the file. + required: + - type + - id + EasyInputMessage: + type: object + title: Input message + description: > + A message input to the model with a role indicating instruction + following + + hierarchy. Instructions given with the `developer` or `system` role take + + precedence over instructions given with the `user` role. Messages with + the + + `assistant` role are presumed to have been generated by the model in + previous + + interactions. + properties: + role: + type: string + description: > + The role of the message input. One of `user`, `assistant`, `system`, + or + + `developer`. + enum: + - user + - assistant + - system + - developer + content: + description: > + Text, image, or audio input to the model, used to generate a + response. + + Can also contain previous assistant responses. + type: string + title: Text input + items: + $ref: '#/components/schemas/InputContent' + phase: + type: string + description: > + Labels an `assistant` message as intermediate commentary + (`commentary`) or the final answer (`final_answer`). + + For models like `gpt-5.3-codex` and beyond, when sending follow-up + requests, preserve and resend + + phase on all assistant messages — dropping it can degrade + performance. Not used for user messages. + enum: + - commentary + - final_answer + type: + type: string + description: | + The type of the message input. Always `message`. + enum: + - message + x-stainless-const: true + required: + - role + - content + EvalItem: + type: object + title: Eval message object + description: > + A message input to the model with a role indicating instruction + following + + hierarchy. Instructions given with the `developer` or `system` role take + + precedence over instructions given with the `user` role. Messages with + the + + `assistant` role are presumed to have been generated by the model in + previous + + interactions. + properties: + role: + type: string + description: > + The role of the message input. One of `user`, `assistant`, `system`, + or + + `developer`. + enum: + - user + - assistant + - system + - developer + content: + $ref: '#/components/schemas/EvalItemContent' + type: + type: string + description: | + The type of the message input. Always `message`. + enum: + - message + x-stainless-const: true + required: + - role + - content + ReasoningEffort: + type: string + enum: + - none + - minimal + - low + - medium + - high + - xhigh + default: medium + description: > + Constrains effort on reasoning for + + [reasoning models](https://platform.openai.com/docs/guides/reasoning). + + Currently supported values are `none`, `minimal`, `low`, `medium`, + `high`, and `xhigh`. Reducing + + reasoning effort can result in faster responses and fewer tokens used + + on reasoning in a response. + + + - `gpt-5.1` defaults to `none`, which does not perform reasoning. The + supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, + and `high`. Tool calls are supported for all reasoning values in + gpt-5.1. + + - All models before `gpt-5.1` default to `medium` reasoning effort, and + do not support `none`. + + - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning + effort. + + - `xhigh` is supported for all models after `gpt-5.1-codex-max`. + ResponseFormatText: + type: object + title: Text + description: | + Default response format. Used to generate text responses. + properties: + type: + type: string + description: The type of response format being defined. Always `text`. + enum: + - text + x-stainless-const: true + required: + - type + ResponseFormatJsonSchema: + type: object + title: JSON schema + description: | + JSON Schema response format. Used to generate structured JSON responses. + Learn more about [Structured Outputs](/docs/guides/structured-outputs). + properties: + type: + type: string + description: The type of response format being defined. Always `json_schema`. + enum: + - json_schema + x-stainless-const: true + json_schema: + type: object + title: JSON schema + description: | + Structured Outputs configuration options, including a JSON Schema. + properties: + description: + type: string + description: > + A description of what the response format is for, used by the + model to + + determine how to respond in the format. + name: + type: string + description: > + The name of the response format. Must be a-z, A-Z, 0-9, or + contain + + underscores and dashes, with a maximum length of 64. + schema: + $ref: '#/components/schemas/ResponseFormatJsonSchemaSchema' + strict: + anyOf: + - type: boolean + default: false + description: > + Whether to enable strict schema adherence when generating + the output. + + If set to true, the model will always follow the exact + schema defined + + in the `schema` field. Only a subset of JSON Schema is + supported when + + `strict` is `true`. To learn more, read the [Structured + Outputs + + guide](/docs/guides/structured-outputs). + - type: 'null' + required: + - name + required: + - type + - json_schema + ResponseFormatJsonObject: + type: object + title: JSON object + description: > + JSON object response format. An older method of generating JSON + responses. + + Using `json_schema` is recommended for models that support it. Note that + the + + model will not generate JSON without a system or user message + instructing it + + to do so. + properties: + type: + type: string + description: The type of response format being defined. Always `json_object`. + enum: + - json_object + x-stainless-const: true + required: + - type + ChatCompletionTool: + type: object + title: Function tool + description: | + A function tool that can be used to generate a response. + properties: + type: + type: string + enum: + - function + description: The type of the tool. Currently, only `function` is supported. + x-stainless-const: true + function: + $ref: '#/components/schemas/FunctionObject' + required: + - type + - function + EvalStoredCompletionsSource: + type: object + title: StoredCompletionsRunDataSource + description: > + A StoredCompletionsRunDataSource configuration describing a set of + filters + properties: + type: + type: string + enum: + - stored_completions + default: stored_completions + description: The type of source. Always `stored_completions`. + x-stainless-const: true + metadata: + $ref: '#/components/schemas/Metadata' + model: + type: string + description: An optional model to filter by (e.g., 'gpt-4o'). + created_after: + type: integer + description: An optional Unix timestamp to filter items created after this time. + created_before: + type: integer + description: An optional Unix timestamp to filter items created before this time. + limit: + type: integer + description: An optional maximum number of items to return. + required: + - type + x-oaiMeta: + name: >- + The stored completions data source object used to configure an + individual run + group: eval runs + example: | + { + "type": "stored_completions", + "model": "gpt-4o", + "created_after": 1668124800, + "created_before": 1668124900, + "limit": 100, + "metadata": {} + } + Tool: + description: | + A tool that can be used to generate a response. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - function + description: The type of the function tool. Always `function`. + default: function + x-stainless-const: true + name: + type: string + description: The name of the function to call. + description: + type: string + description: >- + A description of the function. Used by the model to determine + whether or not to call the function. + parameters: + additionalProperties: {} + type: object + description: A JSON schema object describing the parameters of the function. + x-oaiTypeLabel: map + strict: + type: boolean + description: Whether to enforce strict parameter validation. Default `true`. + defer_loading: + type: boolean + description: Whether this function is deferred and loaded via tool search. + vector_store_ids: + items: + type: string + type: array + description: The IDs of the vector stores to search. + max_num_results: + type: integer + description: >- + The maximum number of results to return. This number should be + between 1 and 50 inclusive. + ranking_options: + $ref: '#/components/schemas/RankingOptions' + description: Ranking options for search. + filters: + type: object + additionalProperties: false + title: Comparison Filter + description: > + A filter used to compare a specified attribute key to a given value + using a defined comparison operation. + properties: + type: + type: string + default: eq + enum: + - eq + - ne + - gt + - gte + - lt + - lte + - in + - nin + description: > + Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, + `lt`, `lte`, `in`, `nin`. + + - `eq`: equals + + - `ne`: not equal + + - `gt`: greater than + + - `gte`: greater than or equal + + - `lt`: less than + + - `lte`: less than or equal + + - `in`: in + + - `nin`: not in + key: + type: string + description: The key to compare against the value. + value: + description: >- + The value to compare against the attribute key; supports string, + number, or boolean types. + type: string + items: + oneOf: + - type: string + - type: number + filters: + type: array + description: >- + Array of filters to combine. Items can be `ComparisonFilter` or + `CompoundFilter`. + items: + oneOf: + - $ref: '#/components/schemas/ComparisonFilter' + - $recursiveRef: '#' + discriminator: + propertyName: type + required: + - type + - key + - value + - filters + x-oaiMeta: + name: ComparisonFilter + $recursiveAnchor: true + environment: + $ref: '#/components/schemas/ComputerEnvironment' + description: The type of computer environment to control. + display_width: + type: integer + description: The width of the computer display. + display_height: + type: integer + description: The height of the computer display. + user_location: + $ref: '#/components/schemas/WebSearchApproximateLocation' + search_context_size: + type: string + enum: + - low + - medium + - high + default: medium + description: >- + High level guidance for the amount of context window space to use + for the search. One of `low`, `medium`, or `high`. `medium` is the + default. + server_label: + type: string + description: | + A label for this MCP server, used to identify it in tool calls. + server_url: + type: string + format: uri + description: > + The URL for the MCP server. One of `server_url` or `connector_id` + must be + + provided. + connector_id: + type: string + enum: + - connector_dropbox + - connector_gmail + - connector_googlecalendar + - connector_googledrive + - connector_microsoftteams + - connector_outlookcalendar + - connector_outlookemail + - connector_sharepoint + description: > + Identifier for service connectors, like those available in ChatGPT. + One of + + `server_url` or `connector_id` must be provided. Learn more about + service + + connectors [here](/docs/guides/tools-remote-mcp#connectors). + + + Currently supported `connector_id` values are: + + + - Dropbox: `connector_dropbox` + + - Gmail: `connector_gmail` + + - Google Calendar: `connector_googlecalendar` + + - Google Drive: `connector_googledrive` + + - Microsoft Teams: `connector_microsoftteams` + + - Outlook Calendar: `connector_outlookcalendar` + + - Outlook Email: `connector_outlookemail` + + - SharePoint: `connector_sharepoint` + authorization: + type: string + description: > + An OAuth access token that can be used with a remote MCP server, + either + + with a custom MCP server URL or a service connector. Your + application + + must handle the OAuth authorization flow and provide the token here. + server_description: + type: string + description: > + Optional description of the MCP server, used to provide more + context. + headers: + type: object + additionalProperties: + type: string + description: > + Optional HTTP headers to send to the MCP server. Use for + authentication + + or other purposes. + allowed_tools: + description: | + List of allowed tool names or a filter object. + oneOf: + - type: array + title: MCP allowed tools + description: A string array of allowed tool names + items: + type: string + - $ref: '#/components/schemas/MCPToolFilter' + type: 'null' + require_approval: + description: Specify which of the MCP server's tools require approval. + oneOf: + - type: object + title: MCP tool approval filter + description: | + Specify which of the MCP server's tools require approval. Can be + `always`, `never`, or a filter object associated with tools + that require approval. + properties: + always: + $ref: '#/components/schemas/MCPToolFilter' + never: + $ref: '#/components/schemas/MCPToolFilter' + additionalProperties: false + - type: string + title: MCP tool approval setting + description: > + Specify a single approval policy for all tools. One of `always` + or + + `never`. When set to `always`, all tools will require approval. + When + + set to `never`, all tools will not require approval. + enum: + - always + - never + default: always + type: 'null' + container: + description: > + The code interpreter container. Can be a container ID or an object + that + + specifies uploaded file IDs to make available to your code, along + with an + + optional `memory_limit` setting. + type: string + properties: + type: + type: string + enum: + - auto + description: Always `auto`. + default: auto + x-stainless-const: true + file_ids: + items: + type: string + example: file-123 + type: array + maxItems: 50 + description: >- + An optional list of uploaded files to make available to your + code. + memory_limit: + type: string + enum: + - 1g + - 4g + - 16g + - 64g + network_policy: + description: Network access policy for the container. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - disabled + description: Disable outbound network access. Always `disabled`. + default: disabled + x-stainless-const: true + allowed_domains: + items: + type: string + type: array + minItems: 1 + description: A list of allowed domains when type is `allowlist`. + domain_secrets: + items: + $ref: >- + #/components/schemas/ContainerNetworkPolicyDomainSecretParam + type: array + minItems: 1 + description: Optional domain-scoped secrets for allowlisted domains. + type: object + required: + - type + - allowed_domains + required: + - type + title: CodeInterpreterToolAuto + model: + type: string + enum: + - gpt-image-1 + - gpt-image-1-mini + - gpt-image-1.5 + description: | + The image generation model to use. Default: `gpt-image-1`. + default: gpt-image-1 + quality: + type: string + enum: + - low + - medium + - high + - auto + description: | + The quality of the generated image. One of `low`, `medium`, `high`, + or `auto`. Default: `auto`. + default: auto + size: + description: >- + The size of the generated images. For `gpt-image-2` and + `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as + `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height + must both be divisible by 16 and the requested aspect ratio must be + between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, + and the maximum supported resolution is `3840x2160`. The requested + size must also satisfy the model's current pixel and edge limits. + The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are + supported by the GPT image models; `auto` is supported for models + that allow automatic sizing. For `dall-e-2`, use one of `256x256`, + `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, + `1792x1024`, or `1024x1792`. + default: auto + type: string + enum: + - 1024x1024 + - 1024x1536 + - 1536x1024 + - auto + output_format: + type: string + enum: + - png + - webp + - jpeg + description: | + The output format of the generated image. One of `png`, `webp`, or + `jpeg`. Default: `png`. + default: png + output_compression: + type: integer + minimum: 0 + maximum: 100 + description: | + Compression level for the output image. Default: 100. + default: 100 + moderation: + type: string + enum: + - auto + - low + description: | + Moderation level for the generated image. Default: `auto`. + default: auto + background: + type: string + enum: + - transparent + - opaque + - auto + description: | + Background type for the generated image. One of `transparent`, + `opaque`, or `auto`. Default: `auto`. + default: auto + input_fidelity: + type: string + enum: + - high + - low + description: >- + Control how much effort the model will exert to match the style and + features, especially facial features, of input images. This + parameter is only supported for `gpt-image-1` and `gpt-image-1.5` + and later models, unsupported for `gpt-image-1-mini`. Supports + `high` and `low`. Defaults to `low`. + input_image_mask: + type: object + description: | + Optional mask for inpainting. Contains `image_url` + (string, optional) and `file_id` (string, optional). + properties: + image_url: + type: string + description: | + Base64-encoded mask image. + file_id: + type: string + description: | + File ID for the mask image. + required: [] + additionalProperties: false + partial_images: + type: integer + minimum: 0 + maximum: 3 + description: > + Number of partial images to generate in streaming mode, from 0 + (default value) to 3. + default: 0 + action: + description: > + Whether to generate a new image or edit an existing image. Default: + `auto`. + $ref: '#/components/schemas/ImageGenActionEnum' + format: + description: The input format for the custom tool. Default is unconstrained text. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - text + description: Unconstrained text format. Always `text`. + default: text + x-stainless-const: true + syntax: + $ref: '#/components/schemas/GrammarSyntax1' + description: The syntax of the grammar definition. One of `lark` or `regex`. + definition: + type: string + description: The grammar definition. + type: object + required: + - type + - syntax + - definition + title: Text format + tools: + items: + oneOf: + - $ref: '#/components/schemas/FunctionToolParam' + - $ref: '#/components/schemas/CustomToolParam' + description: A function or custom tool that belongs to a namespace. + discriminator: + propertyName: type + type: array + minItems: 1 + description: The function/custom tools available inside this namespace. + execution: + $ref: '#/components/schemas/ToolSearchExecutionType' + description: Whether tool search is executed by the server or by the client. + search_content_types: + items: + $ref: '#/components/schemas/SearchContentType' + type: array + type: object + required: + - type + - name + - strict + - parameters + - vector_store_ids + - environment + - display_width + - display_height + - server_label + - container + - description + - tools + title: Function + TextResponseFormatConfiguration: + description: > + An object specifying the format that the model must output. + + + Configuring `{ "type": "json_schema" }` enables Structured Outputs, + + which ensures the model will match your supplied JSON schema. Learn more + in the + + [Structured Outputs guide](/docs/guides/structured-outputs). + + + The default format is `{ "type": "text" }` with no additional options. + + + **Not recommended for gpt-4o and newer models:** + + + Setting to `{ "type": "json_object" }` enables the older JSON mode, + which + + ensures the message the model generates is valid JSON. Using + `json_schema` + + is preferred for models that support it. + type: object + title: Text + properties: + type: + type: string + description: The type of response format being defined. Always `text`. + enum: + - text + x-stainless-const: true + description: + type: string + description: > + A description of what the response format is for, used by the model + to + + determine how to respond in the format. + name: + type: string + description: | + The name of the response format. Must be a-z, A-Z, 0-9, or contain + underscores and dashes, with a maximum length of 64. + schema: + $ref: '#/components/schemas/ResponseFormatJsonSchemaSchema' + strict: + type: boolean + default: false + description: > + Whether to enable strict schema adherence when generating the + output. + + If set to true, the model will always follow the exact schema + defined + + in the `schema` field. Only a subset of JSON Schema is supported + when + + `strict` is `true`. To learn more, read the [Structured Outputs + + guide](/docs/guides/structured-outputs). + required: + - type + - schema + - name + EvalResponsesSource: + type: object + title: EvalResponsesSource + description: | + A EvalResponsesSource object describing a run data source configuration. + properties: + type: + type: string + enum: + - responses + description: The type of run data source. Always `responses`. + metadata: + type: string + description: >- + Metadata filter for the responses. This is a query parameter used to + select responses. (opaque JSON object) + model: + type: string + description: >- + The name of the model to find responses for. This is a query + parameter used to select responses. + instructions_search: + type: string + description: >- + Optional string to search the 'instructions' field. This is a query + parameter used to select responses. + created_after: + type: integer + minimum: 0 + description: >- + Only include items created after this timestamp (inclusive). This is + a query parameter used to select responses. + created_before: + type: integer + minimum: 0 + description: >- + Only include items created before this timestamp (inclusive). This + is a query parameter used to select responses. + reasoning_effort: + type: string + enum: + - none + - minimal + - low + - medium + - high + - xhigh + default: medium + description: > + Constrains effort on reasoning for + + [reasoning + models](https://platform.openai.com/docs/guides/reasoning). + + Currently supported values are `none`, `minimal`, `low`, `medium`, + `high`, and `xhigh`. Reducing + + reasoning effort can result in faster responses and fewer tokens + used + + on reasoning in a response. + + + - `gpt-5.1` defaults to `none`, which does not perform reasoning. + The supported reasoning values for `gpt-5.1` are `none`, `low`, + `medium`, and `high`. Tool calls are supported for all reasoning + values in gpt-5.1. + + - All models before `gpt-5.1` default to `medium` reasoning effort, + and do not support `none`. + + - The `gpt-5-pro` model defaults to (and only supports) `high` + reasoning effort. + + - `xhigh` is supported for all models after `gpt-5.1-codex-max`. + temperature: + type: number + description: >- + Sampling temperature. This is a query parameter used to select + responses. + top_p: + type: number + description: >- + Nucleus sampling parameter. This is a query parameter used to select + responses. + users: + type: array + items: + type: string + description: >- + List of user identifiers. This is a query parameter used to select + responses. + tools: + type: array + items: + type: string + description: >- + List of tool names. This is a query parameter used to select + responses. + required: + - type + x-oaiMeta: + name: The run data source object used to configure an individual run + group: eval runs + example: | + { + "type": "responses", + "model": "gpt-4o-mini-2024-07-18", + "temperature": 0.7, + "top_p": 1.0, + "users": ["user1", "user2"], + "tools": ["tool1", "tool2"], + "instructions_search": "You are a coding assistant" + } + InputMessageContentList: + type: array + title: Input item content list + description: > + A list of one or many input items to the model, containing different + content + + types. + items: + $ref: '#/components/schemas/InputContent' + MessagePhase: + type: string + description: > + Labels an `assistant` message as intermediate commentary (`commentary`) + or the final answer (`final_answer`). + + For models like `gpt-5.3-codex` and beyond, when sending follow-up + requests, preserve and resend + + phase on all assistant messages — dropping it can degrade performance. + Not used for user messages. + enum: + - commentary + - final_answer + EvalItemContent: + title: Eval content + description: > + Inputs to the model - can contain template strings. Supports text, + output text, input images, and input audio, either as a single item or + an array of items. + type: string + properties: + type: + type: string + enum: + - input_text + description: The type of the input item. Always `input_text`. + default: input_text + x-stainless-const: true + text: + type: string + description: The text input to the model. + image_url: + type: string + format: uri + description: | + The URL of the image input. + detail: + type: string + description: > + The detail level of the image to be sent to the model. One of + `high`, `low`, or `auto`. Defaults to `auto`. + input_audio: + type: object + properties: + data: + type: string + description: | + Base64-encoded audio data. + format: + type: string + description: > + The format of the audio data. Currently supported formats are + `mp3` and + + `wav`. + enum: + - mp3 + - wav + required: + - data + - format + required: + - type + - text + - image_url + - input_audio + items: + $ref: '#/components/schemas/EvalItemContentItem' + ResponseFormatJsonSchemaSchema: + type: object + title: JSON schema + description: | + The schema for the response format, described as a JSON Schema object. + Learn how to build JSON schemas [here](https://json-schema.org/). + additionalProperties: true + FunctionObject: + type: object + properties: + description: + type: string + description: >- + A description of what the function does, used by the model to choose + when and how to call the function. + name: + type: string + description: >- + The name of the function to be called. Must be a-z, A-Z, 0-9, or + contain underscores and dashes, with a maximum length of 64. + parameters: + $ref: '#/components/schemas/FunctionParameters' + strict: + type: boolean + default: false + description: >- + Whether to enable strict schema adherence when generating the + function call. If set to true, the model will follow the exact + schema defined in the `parameters` field. Only a subset of JSON + Schema is supported when `strict` is `true`. Learn more about + Structured Outputs in the [function calling + guide](/docs/guides/function-calling). + required: + - name + FunctionTool: + properties: + type: + type: string + enum: + - function + description: The type of the function tool. Always `function`. + default: function + x-stainless-const: true + name: + type: string + description: The name of the function to call. + description: + type: string + description: >- + A description of the function. Used by the model to determine + whether or not to call the function. + parameters: + additionalProperties: {} + type: object + description: A JSON schema object describing the parameters of the function. + x-oaiTypeLabel: map + strict: + type: boolean + description: Whether to enforce strict parameter validation. Default `true`. + defer_loading: + type: boolean + description: Whether this function is deferred and loaded via tool search. + type: object + required: + - type + - name + - strict + - parameters + title: Function + description: >- + Defines a function in your own code the model can choose to call. Learn + more about [function + calling](https://platform.openai.com/docs/guides/function-calling). + FileSearchTool: + properties: + type: + type: string + enum: + - file_search + description: The type of the file search tool. Always `file_search`. + default: file_search + x-stainless-const: true + vector_store_ids: + items: + type: string + type: array + description: The IDs of the vector stores to search. + max_num_results: + type: integer + description: >- + The maximum number of results to return. This number should be + between 1 and 50 inclusive. + ranking_options: + $ref: '#/components/schemas/RankingOptions' + description: Ranking options for search. + filters: + type: object + additionalProperties: false + title: Comparison Filter + description: > + A filter used to compare a specified attribute key to a given value + using a defined comparison operation. + properties: + type: + type: string + default: eq + enum: + - eq + - ne + - gt + - gte + - lt + - lte + - in + - nin + description: > + Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, + `lt`, `lte`, `in`, `nin`. + + - `eq`: equals + + - `ne`: not equal + + - `gt`: greater than + + - `gte`: greater than or equal + + - `lt`: less than + + - `lte`: less than or equal + + - `in`: in + + - `nin`: not in + key: + type: string + description: The key to compare against the value. + value: + description: >- + The value to compare against the attribute key; supports string, + number, or boolean types. + type: string + items: + oneOf: + - type: string + - type: number + filters: + type: array + description: >- + Array of filters to combine. Items can be `ComparisonFilter` or + `CompoundFilter`. + items: + oneOf: + - $ref: '#/components/schemas/ComparisonFilter' + - $recursiveRef: '#' + discriminator: + propertyName: type + required: + - type + - key + - value + - filters + x-oaiMeta: + name: ComparisonFilter + $recursiveAnchor: true + type: object + required: + - type + - vector_store_ids + title: File search + description: >- + A tool that searches for relevant content from uploaded files. Learn + more about the [file search + tool](https://platform.openai.com/docs/guides/tools-file-search). + ComputerTool: + properties: + type: + type: string + enum: + - computer + description: The type of the computer tool. Always `computer`. + default: computer + x-stainless-const: true + type: object + required: + - type + title: Computer + description: >- + A tool that controls a virtual computer. Learn more about the [computer + tool](https://platform.openai.com/docs/guides/tools-computer-use). + ComputerUsePreviewTool: + properties: + type: + type: string + enum: + - computer_use_preview + description: The type of the computer use tool. Always `computer_use_preview`. + default: computer_use_preview + x-stainless-const: true + environment: + $ref: '#/components/schemas/ComputerEnvironment' + description: The type of computer environment to control. + display_width: + type: integer + description: The width of the computer display. + display_height: + type: integer + description: The height of the computer display. + type: object + required: + - type + - environment + - display_width + - display_height + title: Computer use preview + description: >- + A tool that controls a virtual computer. Learn more about the [computer + tool](https://platform.openai.com/docs/guides/tools-computer-use). + WebSearchTool: + type: object + title: Web search + description: > + Search the Internet for sources related to the prompt. Learn more about + the + + [web search tool](/docs/guides/tools-web-search). + properties: + type: + type: string + enum: + - web_search + - web_search_2025_08_26 + description: >- + The type of the web search tool. One of `web_search` or + `web_search_2025_08_26`. + default: web_search + filters: + type: object + description: | + Filters for the search. + properties: + allowed_domains: + anyOf: + - type: array + title: Allowed domains for the search. + description: > + Allowed domains for the search. If not provided, all domains + are allowed. + + Subdomains of the provided domains are allowed as well. + + + Example: `["pubmed.ncbi.nlm.nih.gov"]` + items: + type: string + description: Allowed domain for the search. + default: [] + - type: 'null' + user_location: + $ref: '#/components/schemas/WebSearchApproximateLocation' + search_context_size: + type: string + enum: + - low + - medium + - high + default: medium + description: >- + High level guidance for the amount of context window space to use + for the search. One of `low`, `medium`, or `high`. `medium` is the + default. + required: + - type + MCPTool: + type: object + title: MCP tool + description: > + Give the model access to additional tools via remote Model Context + Protocol + + (MCP) servers. [Learn more about MCP](/docs/guides/tools-remote-mcp). + properties: + type: + type: string + enum: + - mcp + description: The type of the MCP tool. Always `mcp`. + x-stainless-const: true + server_label: + type: string + description: | + A label for this MCP server, used to identify it in tool calls. + server_url: + type: string + format: uri + description: > + The URL for the MCP server. One of `server_url` or `connector_id` + must be + + provided. + connector_id: + type: string + enum: + - connector_dropbox + - connector_gmail + - connector_googlecalendar + - connector_googledrive + - connector_microsoftteams + - connector_outlookcalendar + - connector_outlookemail + - connector_sharepoint + description: > + Identifier for service connectors, like those available in ChatGPT. + One of + + `server_url` or `connector_id` must be provided. Learn more about + service + + connectors [here](/docs/guides/tools-remote-mcp#connectors). + + + Currently supported `connector_id` values are: + + + - Dropbox: `connector_dropbox` + + - Gmail: `connector_gmail` + + - Google Calendar: `connector_googlecalendar` + + - Google Drive: `connector_googledrive` + + - Microsoft Teams: `connector_microsoftteams` + + - Outlook Calendar: `connector_outlookcalendar` + + - Outlook Email: `connector_outlookemail` + + - SharePoint: `connector_sharepoint` + authorization: + type: string + description: > + An OAuth access token that can be used with a remote MCP server, + either + + with a custom MCP server URL or a service connector. Your + application + + must handle the OAuth authorization flow and provide the token here. + server_description: + type: string + description: > + Optional description of the MCP server, used to provide more + context. + headers: + type: object + additionalProperties: + type: string + description: > + Optional HTTP headers to send to the MCP server. Use for + authentication + + or other purposes. + allowed_tools: + description: | + List of allowed tool names or a filter object. + oneOf: + - type: array + title: MCP allowed tools + description: A string array of allowed tool names + items: + type: string + - $ref: '#/components/schemas/MCPToolFilter' + type: 'null' + require_approval: + description: Specify which of the MCP server's tools require approval. + oneOf: + - type: object + title: MCP tool approval filter + description: | + Specify which of the MCP server's tools require approval. Can be + `always`, `never`, or a filter object associated with tools + that require approval. + properties: + always: + $ref: '#/components/schemas/MCPToolFilter' + never: + $ref: '#/components/schemas/MCPToolFilter' + additionalProperties: false + - type: string + title: MCP tool approval setting + description: > + Specify a single approval policy for all tools. One of `always` + or + + `never`. When set to `always`, all tools will require approval. + When + + set to `never`, all tools will not require approval. + enum: + - always + - never + default: always + type: 'null' + defer_loading: + type: boolean + description: | + Whether this MCP tool is deferred and discovered via tool search. + required: + - type + - server_label + CodeInterpreterTool: + type: object + title: Code interpreter + description: | + A tool that runs Python code to help generate a response to a prompt. + properties: + type: + type: string + enum: + - code_interpreter + description: | + The type of the code interpreter tool. Always `code_interpreter`. + x-stainless-const: true + container: + description: > + The code interpreter container. Can be a container ID or an object + that + + specifies uploaded file IDs to make available to your code, along + with an + + optional `memory_limit` setting. + type: string + properties: + type: + type: string + enum: + - auto + description: Always `auto`. + default: auto + x-stainless-const: true + file_ids: + items: + type: string + example: file-123 + type: array + maxItems: 50 + description: >- + An optional list of uploaded files to make available to your + code. + memory_limit: + type: string + enum: + - 1g + - 4g + - 16g + - 64g + network_policy: + description: Network access policy for the container. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - disabled + description: Disable outbound network access. Always `disabled`. + default: disabled + x-stainless-const: true + allowed_domains: + items: + type: string + type: array + minItems: 1 + description: A list of allowed domains when type is `allowlist`. + domain_secrets: + items: + $ref: >- + #/components/schemas/ContainerNetworkPolicyDomainSecretParam + type: array + minItems: 1 + description: Optional domain-scoped secrets for allowlisted domains. + type: object + required: + - type + - allowed_domains + required: + - type + title: CodeInterpreterToolAuto + required: + - type + - container + ImageGenTool: + type: object + title: Image generation tool + description: | + A tool that generates images using the GPT image models. + properties: + type: + type: string + enum: + - image_generation + description: | + The type of the image generation tool. Always `image_generation`. + x-stainless-const: true + model: + type: string + enum: + - gpt-image-1 + - gpt-image-1-mini + - gpt-image-1.5 + description: | + The image generation model to use. Default: `gpt-image-1`. + default: gpt-image-1 + quality: + type: string + enum: + - low + - medium + - high + - auto + description: | + The quality of the generated image. One of `low`, `medium`, `high`, + or `auto`. Default: `auto`. + default: auto + size: + description: >- + The size of the generated images. For `gpt-image-2` and + `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as + `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height + must both be divisible by 16 and the requested aspect ratio must be + between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, + and the maximum supported resolution is `3840x2160`. The requested + size must also satisfy the model's current pixel and edge limits. + The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are + supported by the GPT image models; `auto` is supported for models + that allow automatic sizing. For `dall-e-2`, use one of `256x256`, + `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, + `1792x1024`, or `1024x1792`. + default: auto + type: string + enum: + - 1024x1024 + - 1024x1536 + - 1536x1024 + - auto + output_format: + type: string + enum: + - png + - webp + - jpeg + description: | + The output format of the generated image. One of `png`, `webp`, or + `jpeg`. Default: `png`. + default: png + output_compression: + type: integer + minimum: 0 + maximum: 100 + description: | + Compression level for the output image. Default: 100. + default: 100 + moderation: + type: string + enum: + - auto + - low + description: | + Moderation level for the generated image. Default: `auto`. + default: auto + background: + type: string + enum: + - transparent + - opaque + - auto + description: | + Background type for the generated image. One of `transparent`, + `opaque`, or `auto`. Default: `auto`. + default: auto + input_fidelity: + type: string + enum: + - high + - low + description: >- + Control how much effort the model will exert to match the style and + features, especially facial features, of input images. This + parameter is only supported for `gpt-image-1` and `gpt-image-1.5` + and later models, unsupported for `gpt-image-1-mini`. Supports + `high` and `low`. Defaults to `low`. + input_image_mask: + type: object + description: | + Optional mask for inpainting. Contains `image_url` + (string, optional) and `file_id` (string, optional). + properties: + image_url: + type: string + description: | + Base64-encoded mask image. + file_id: + type: string + description: | + File ID for the mask image. + required: [] + additionalProperties: false + partial_images: + type: integer + minimum: 0 + maximum: 3 + description: > + Number of partial images to generate in streaming mode, from 0 + (default value) to 3. + default: 0 + action: + description: > + Whether to generate a new image or edit an existing image. Default: + `auto`. + $ref: '#/components/schemas/ImageGenActionEnum' + required: + - type + LocalShellToolParam: + properties: + type: + type: string + enum: + - local_shell + description: The type of the local shell tool. Always `local_shell`. + default: local_shell + x-stainless-const: true + type: object + required: + - type + title: Local shell tool + description: >- + A tool that allows the model to execute shell commands in a local + environment. + FunctionShellToolParam: + properties: + type: + type: string + enum: + - shell + description: The type of the shell tool. Always `shell`. + default: shell + x-stainless-const: true + environment: + oneOf: + - $ref: '#/components/schemas/ContainerAutoParam' + - $ref: '#/components/schemas/LocalEnvironmentParam' + - $ref: '#/components/schemas/ContainerReferenceParam' + discriminator: + propertyName: type + type: 'null' + type: object + required: + - type + title: Shell tool + description: A tool that allows the model to execute shell commands. + CustomToolParam: + properties: + type: + type: string + enum: + - custom + description: The type of the custom tool. Always `custom`. + default: custom + x-stainless-const: true + name: + type: string + description: The name of the custom tool, used to identify it in tool calls. + description: + type: string + description: >- + Optional description of the custom tool, used to provide more + context. + format: + description: The input format for the custom tool. Default is unconstrained text. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - text + description: Unconstrained text format. Always `text`. + default: text + x-stainless-const: true + syntax: + $ref: '#/components/schemas/GrammarSyntax1' + description: The syntax of the grammar definition. One of `lark` or `regex`. + definition: + type: string + description: The grammar definition. + type: object + required: + - type + - syntax + - definition + title: Text format + defer_loading: + type: boolean + description: Whether this tool should be deferred and discovered via tool search. + type: object + required: + - type + - name + title: Custom tool + description: >- + A custom tool that processes input using a specified format. Learn more + about [custom tools](/docs/guides/function-calling#custom-tools) + NamespaceToolParam: + properties: + type: + type: string + enum: + - namespace + description: The type of the tool. Always `namespace`. + default: namespace + x-stainless-const: true + name: + type: string + minLength: 1 + description: The namespace name used in tool calls (for example, `crm`). + description: + type: string + minLength: 1 + description: A description of the namespace shown to the model. + tools: + items: + oneOf: + - $ref: '#/components/schemas/FunctionToolParam' + - $ref: '#/components/schemas/CustomToolParam' + description: A function or custom tool that belongs to a namespace. + discriminator: + propertyName: type + type: array + minItems: 1 + description: The function/custom tools available inside this namespace. + type: object + required: + - type + - name + - description + - tools + title: Namespace + description: Groups function/custom tools under a shared namespace. + ToolSearchToolParam: + properties: + type: + type: string + enum: + - tool_search + description: The type of the tool. Always `tool_search`. + default: tool_search + x-stainless-const: true + execution: + $ref: '#/components/schemas/ToolSearchExecutionType' + description: Whether tool search is executed by the server or by the client. + description: + type: string + description: >- + Description shown to the model for a client-executed tool search + tool. + parameters: + properties: {} + type: object + required: [] + type: object + required: + - type + title: Tool search tool + description: Hosted or BYOT tool search configuration for deferred tools. + WebSearchPreviewTool: + properties: + type: + type: string + enum: + - web_search_preview + - web_search_preview_2025_03_11 + description: >- + The type of the web search tool. One of `web_search_preview` or + `web_search_preview_2025_03_11`. + default: web_search_preview + x-stainless-const: true + user_location: + properties: + type: + type: string + enum: + - approximate + description: The type of location approximation. Always `approximate`. + default: approximate + x-stainless-const: true + country: + type: string + description: >- + The two-letter [ISO country + code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user, + e.g. `US`. + region: + type: string + description: Free text input for the region of the user, e.g. `California`. + city: + type: string + description: Free text input for the city of the user, e.g. `San Francisco`. + timezone: + type: string + description: >- + The [IANA + timezone](https://timeapi.io/documentation/iana-timezones) of + the user, e.g. `America/Los_Angeles`. + type: object + required: + - type + search_context_size: + $ref: '#/components/schemas/SearchContextSize' + description: >- + High level guidance for the amount of context window space to use + for the search. One of `low`, `medium`, or `high`. `medium` is the + default. + search_content_types: + items: + $ref: '#/components/schemas/SearchContentType' + type: array + type: object + required: + - type + title: Web search preview + description: >- + This tool searches the web for relevant results to use in a response. + Learn more about the [web search + tool](https://platform.openai.com/docs/guides/tools-web-search). + ApplyPatchToolParam: + properties: + type: + type: string + enum: + - apply_patch + description: The type of the tool. Always `apply_patch`. + default: apply_patch + x-stainless-const: true + type: object + required: + - type + title: Apply patch tool + description: >- + Allows the assistant to create, delete, or update files using unified + diffs. + TextResponseFormatJsonSchema: + type: object + title: JSON schema + description: | + JSON Schema response format. Used to generate structured JSON responses. + Learn more about [Structured Outputs](/docs/guides/structured-outputs). + properties: + type: + type: string + description: The type of response format being defined. Always `json_schema`. + enum: + - json_schema + x-stainless-const: true + description: + type: string + description: > + A description of what the response format is for, used by the model + to + + determine how to respond in the format. + name: + type: string + description: | + The name of the response format. Must be a-z, A-Z, 0-9, or contain + underscores and dashes, with a maximum length of 64. + schema: + $ref: '#/components/schemas/ResponseFormatJsonSchemaSchema' + strict: + type: boolean + default: false + description: > + Whether to enable strict schema adherence when generating the + output. + + If set to true, the model will always follow the exact schema + defined + + in the `schema` field. Only a subset of JSON Schema is supported + when + + `strict` is `true`. To learn more, read the [Structured Outputs + + guide](/docs/guides/structured-outputs). + required: + - type + - schema + - name + InputContent: + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - input_text + description: The type of the input item. Always `input_text`. + default: input_text + x-stainless-const: true + text: + type: string + description: The text input to the model. + image_url: + type: string + format: uri + description: >- + The URL of the image to be sent to the model. A fully qualified URL + or base64 encoded image in a data URL. + file_id: + type: string + description: The ID of the file to be sent to the model. + detail: + $ref: '#/components/schemas/ImageDetail' + description: >- + The detail level of the image to be sent to the model. One of + `high`, `low`, `auto`, or `original`. Defaults to `auto`. + filename: + type: string + description: The name of the file to be sent to the model. + file_data: + type: string + description: | + The content of the file to be sent to the model. + file_url: + type: string + format: uri + description: The URL of the file to be sent to the model. + type: object + required: + - type + - text + - detail + title: Input text + description: A text input to the model. + EvalItemContentItem: + title: Eval content item + description: > + A single content item: input text, output text, input image, or input + audio. + type: string + properties: + type: + type: string + enum: + - input_text + description: The type of the input item. Always `input_text`. + default: input_text + x-stainless-const: true + text: + type: string + description: The text input to the model. + image_url: + type: string + format: uri + description: | + The URL of the image input. + detail: + type: string + description: > + The detail level of the image to be sent to the model. One of + `high`, `low`, or `auto`. Defaults to `auto`. + input_audio: + type: object + properties: + data: + type: string + description: | + Base64-encoded audio data. + format: + type: string + description: > + The format of the audio data. Currently supported formats are + `mp3` and + + `wav`. + enum: + - mp3 + - wav + required: + - data + - format + required: + - type + - text + - image_url + - input_audio + EvalItemContentArray: + type: array + title: An array of Input text, Output text, Input image, and Input audio + description: > + A list of inputs, each of which may be either an input text, output + text, input + + image, or input audio object. + items: + $ref: '#/components/schemas/EvalItemContentItem' + FunctionParameters: + type: object + description: >- + The parameters the functions accepts, described as a JSON Schema object. + See the [guide](/docs/guides/function-calling) for examples, and the + [JSON Schema + reference](https://json-schema.org/understanding-json-schema/) for + documentation about the format. + + + Omitting `parameters` defines a function with an empty parameter list. + additionalProperties: true + RankingOptions: + properties: + ranker: + $ref: '#/components/schemas/RankerVersionType' + description: The ranker to use for the file search. + score_threshold: + type: number + description: >- + The score threshold for the file search, a number between 0 and 1. + Numbers closer to 1 will attempt to return only the most relevant + results, but may return fewer results. + hybrid_search: + $ref: '#/components/schemas/HybridSearchOptions' + description: >- + Weights that control how reciprocal rank fusion balances semantic + embedding matches versus sparse keyword matches when hybrid search + is enabled. + type: object + required: [] + Filters: + type: object + additionalProperties: false + title: Comparison Filter + description: > + A filter used to compare a specified attribute key to a given value + using a defined comparison operation. + properties: + type: + type: string + default: eq + enum: + - eq + - ne + - gt + - gte + - lt + - lte + - in + - nin + description: > + Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, + `lte`, `in`, `nin`. + + - `eq`: equals + + - `ne`: not equal + + - `gt`: greater than + + - `gte`: greater than or equal + + - `lt`: less than + + - `lte`: less than or equal + + - `in`: in + + - `nin`: not in + key: + type: string + description: The key to compare against the value. + value: + description: >- + The value to compare against the attribute key; supports string, + number, or boolean types. + type: string + items: + oneOf: + - type: string + - type: number + filters: + type: array + description: >- + Array of filters to combine. Items can be `ComparisonFilter` or + `CompoundFilter`. + items: + oneOf: + - $ref: '#/components/schemas/ComparisonFilter' + - $recursiveRef: '#' + discriminator: + propertyName: type + required: + - type + - key + - value + - filters + x-oaiMeta: + name: ComparisonFilter + $recursiveAnchor: true + ComputerEnvironment: + type: string + enum: + - windows + - mac + - linux + - ubuntu + - browser + WebSearchApproximateLocation: + type: object + title: Web search approximate location + description: | + The approximate location of the user. + properties: + type: + type: string + enum: + - approximate + description: The type of location approximation. Always `approximate`. + default: approximate + x-stainless-const: true + country: + anyOf: + - type: string + description: >- + The two-letter [ISO country + code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user, + e.g. `US`. + - type: 'null' + region: + anyOf: + - type: string + description: Free text input for the region of the user, e.g. `California`. + - type: 'null' + city: + anyOf: + - type: string + description: Free text input for the city of the user, e.g. `San Francisco`. + - type: 'null' + timezone: + anyOf: + - type: string + description: >- + The [IANA + timezone](https://timeapi.io/documentation/iana-timezones) of + the user, e.g. `America/Los_Angeles`. + - type: 'null' + MCPToolFilter: + type: object + title: MCP tool filter + description: | + A filter object to specify which tools are allowed. + properties: + tool_names: + type: array + title: MCP allowed tools + items: + type: string + description: List of allowed tool names. + read_only: + type: boolean + description: > + Indicates whether or not a tool modifies data or is read-only. If an + + MCP server is [annotated with + `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint), + + it will match this filter. + required: [] + additionalProperties: false + AutoCodeInterpreterToolParam: + properties: + type: + type: string + enum: + - auto + description: Always `auto`. + default: auto + x-stainless-const: true + file_ids: + items: + type: string + example: file-123 + type: array + maxItems: 50 + description: An optional list of uploaded files to make available to your code. + memory_limit: + type: string + enum: + - 1g + - 4g + - 16g + - 64g + network_policy: + description: Network access policy for the container. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - disabled + description: Disable outbound network access. Always `disabled`. + default: disabled + x-stainless-const: true + allowed_domains: + items: + type: string + type: array + minItems: 1 + description: A list of allowed domains when type is `allowlist`. + domain_secrets: + items: + $ref: '#/components/schemas/ContainerNetworkPolicyDomainSecretParam' + type: array + minItems: 1 + description: Optional domain-scoped secrets for allowlisted domains. + type: object + required: + - type + - allowed_domains + type: object + required: + - type + title: CodeInterpreterToolAuto + description: >- + Configuration for a code interpreter container. Optionally specify the + IDs of the files to run the code on. + InputFidelity: + type: string + enum: + - high + - low + description: >- + Control how much effort the model will exert to match the style and + features, especially facial features, of input images. This parameter is + only supported for `gpt-image-1` and `gpt-image-1.5` and later models, + unsupported for `gpt-image-1-mini`. Supports `high` and `low`. Defaults + to `low`. + ImageGenActionEnum: + type: string + enum: + - generate + - edit + - auto + ContainerAutoParam: + properties: + type: + type: string + enum: + - container_auto + description: Automatically creates a container for this request + default: container_auto + x-stainless-const: true + file_ids: + items: + type: string + example: file-123 + type: array + maxItems: 50 + description: An optional list of uploaded files to make available to your code. + memory_limit: + type: string + enum: + - 1g + - 4g + - 16g + - 64g + network_policy: + description: Network access policy for the container. + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - disabled + description: Disable outbound network access. Always `disabled`. + default: disabled + x-stainless-const: true + allowed_domains: + items: + type: string + type: array + minItems: 1 + description: A list of allowed domains when type is `allowlist`. + domain_secrets: + items: + $ref: '#/components/schemas/ContainerNetworkPolicyDomainSecretParam' + type: array + minItems: 1 + description: Optional domain-scoped secrets for allowlisted domains. + type: object + required: + - type + - allowed_domains + skills: + items: + oneOf: + - $ref: '#/components/schemas/SkillReferenceParam' + - $ref: '#/components/schemas/InlineSkillParam' + discriminator: + propertyName: type + type: array + maxItems: 200 + description: An optional list of skills referenced by id or inline data. + type: object + required: + - type + LocalEnvironmentParam: + properties: + type: + type: string + enum: + - local + description: Use a local computer environment. + default: local + x-stainless-const: true + skills: + items: + $ref: '#/components/schemas/LocalSkillParam' + type: array + maxItems: 200 + description: An optional list of skills. + type: object + required: + - type + ContainerReferenceParam: + properties: + type: + type: string + enum: + - container_reference + description: References a container created with the /v1/containers endpoint + default: container_reference + x-stainless-const: true + container_id: + type: string + description: The ID of the referenced container. + example: cntr_123 + type: object + required: + - type + - container_id + CustomTextFormatParam: + properties: + type: + type: string + enum: + - text + description: Unconstrained text format. Always `text`. + default: text + x-stainless-const: true + type: object + required: + - type + title: Text format + description: Unconstrained free-form text. + CustomGrammarFormatParam: + properties: + type: + type: string + enum: + - grammar + description: Grammar format. Always `grammar`. + default: grammar + x-stainless-const: true + syntax: + $ref: '#/components/schemas/GrammarSyntax1' + description: The syntax of the grammar definition. One of `lark` or `regex`. + definition: + type: string + description: The grammar definition. + type: object + required: + - type + - syntax + - definition + title: Grammar format + description: A grammar defined by the user. + FunctionToolParam: + properties: + name: + type: string + maxLength: 128 + minLength: 1 + pattern: ^[a-zA-Z0-9_-]+$ + description: + type: string + parameters: + properties: {} + type: object + required: [] + strict: + type: boolean + type: + type: string + enum: + - function + default: function + x-stainless-const: true + defer_loading: + type: boolean + description: >- + Whether this function should be deferred and discovered via tool + search. + type: object + required: + - name + - type + ToolSearchExecutionType: + type: string + enum: + - server + - client + EmptyModelParam: + properties: {} + type: object + required: [] + ApproximateLocation: + properties: + type: + type: string + enum: + - approximate + description: The type of location approximation. Always `approximate`. + default: approximate + x-stainless-const: true + country: + type: string + description: >- + The two-letter [ISO country + code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user, e.g. + `US`. + region: + type: string + description: Free text input for the region of the user, e.g. `California`. + city: + type: string + description: Free text input for the city of the user, e.g. `San Francisco`. + timezone: + type: string + description: >- + The [IANA timezone](https://timeapi.io/documentation/iana-timezones) + of the user, e.g. `America/Los_Angeles`. + type: object + required: + - type + SearchContextSize: + type: string + enum: + - low + - medium + - high + SearchContentType: + type: string + enum: + - text + - image + InputTextContent: + properties: + type: + type: string + enum: + - input_text + description: The type of the input item. Always `input_text`. + default: input_text + x-stainless-const: true + text: + type: string + description: The text input to the model. + type: object + required: + - type + - text + title: Input text + description: A text input to the model. + InputImageContent: + properties: + type: + type: string + enum: + - input_image + description: The type of the input item. Always `input_image`. + default: input_image + x-stainless-const: true + image_url: + type: string + format: uri + description: >- + The URL of the image to be sent to the model. A fully qualified URL + or base64 encoded image in a data URL. + file_id: + type: string + description: The ID of the file to be sent to the model. + detail: + $ref: '#/components/schemas/ImageDetail' + description: >- + The detail level of the image to be sent to the model. One of + `high`, `low`, `auto`, or `original`. Defaults to `auto`. + type: object + required: + - type + - detail + title: Input image + description: >- + An image input to the model. Learn about [image + inputs](/docs/guides/vision). + InputFileContent: + properties: + type: + type: string + enum: + - input_file + description: The type of the input item. Always `input_file`. + default: input_file + x-stainless-const: true + file_id: + type: string + description: The ID of the file to be sent to the model. + filename: + type: string + description: The name of the file to be sent to the model. + file_data: + type: string + description: | + The content of the file to be sent to the model. + file_url: + type: string + format: uri + description: The URL of the file to be sent to the model. + detail: + $ref: '#/components/schemas/FileInputDetail' + description: >- + The detail level of the file to be sent to the model. Use `low` for + the default rendering behavior, or `high` to render the file at + higher quality. Defaults to `low`. + type: object + required: + - type + title: Input file + description: A file input to the model. + EvalItemContentText: + type: string + title: Text input + description: | + A text input to the model. + EvalItemContentOutputText: + type: object + title: Output text + description: | + A text output from the model. + properties: + type: + type: string + description: | + The type of the output text. Always `output_text`. + enum: + - output_text + x-stainless-const: true + text: + type: string + description: | + The text output from the model. + required: + - type + - text + EvalItemInputImage: + title: Input image + description: An image input block used within EvalItem content arrays. + type: object + properties: + type: + type: string + description: | + The type of the image input. Always `input_image`. + enum: + - input_image + x-stainless-const: true + image_url: + type: string + format: uri + description: | + The URL of the image input. + detail: + type: string + description: > + The detail level of the image to be sent to the model. One of + `high`, `low`, or `auto`. Defaults to `auto`. + required: + - type + - image_url + InputAudio: + type: object + title: Input audio + description: | + An audio input to the model. + properties: + type: + type: string + description: | + The type of the input item. Always `input_audio`. + enum: + - input_audio + x-stainless-const: true + input_audio: + type: object + properties: + data: + type: string + description: | + Base64-encoded audio data. + format: + type: string + description: > + The format of the audio data. Currently supported formats are + `mp3` and + + `wav`. + enum: + - mp3 + - wav + required: + - data + - format + required: + - type + - input_audio + RankerVersionType: + type: string + enum: + - auto + - default-2024-11-15 + HybridSearchOptions: + properties: + embedding_weight: + type: number + description: The weight of the embedding in the reciprocal ranking fusion. + text_weight: + type: number + description: The weight of the text in the reciprocal ranking fusion. + type: object + required: + - embedding_weight + - text_weight + ComparisonFilter: + type: object + additionalProperties: false + title: Comparison Filter + description: > + A filter used to compare a specified attribute key to a given value + using a defined comparison operation. + properties: + type: + type: string + default: eq + enum: + - eq + - ne + - gt + - gte + - lt + - lte + - in + - nin + description: > + Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, + `lte`, `in`, `nin`. + + - `eq`: equals + + - `ne`: not equal + + - `gt`: greater than + + - `gte`: greater than or equal + + - `lt`: less than + + - `lte`: less than or equal + + - `in`: in + + - `nin`: not in + key: + type: string + description: The key to compare against the value. + value: + description: >- + The value to compare against the attribute key; supports string, + number, or boolean types. + type: string + items: + oneOf: + - type: string + - type: number + required: + - type + - key + - value + x-oaiMeta: + name: ComparisonFilter + CompoundFilter: + $recursiveAnchor: true + type: object + additionalProperties: false + title: Compound Filter + description: Combine multiple filters using `and` or `or`. + properties: + type: + type: string + description: 'Type of operation: `and` or `or`.' + enum: + - and + - or + filters: + type: array + description: >- + Array of filters to combine. Items can be `ComparisonFilter` or + `CompoundFilter`. + items: + oneOf: + - $ref: '#/components/schemas/ComparisonFilter' + - $recursiveRef: '#' + discriminator: + propertyName: type + required: + - type + - filters + x-oaiMeta: + name: CompoundFilter + ContainerMemoryLimit: + type: string + enum: + - 1g + - 4g + - 16g + - 64g + ContainerNetworkPolicyDisabledParam: + properties: + type: + type: string + enum: + - disabled + description: Disable outbound network access. Always `disabled`. + default: disabled + x-stainless-const: true + type: object + required: + - type + ContainerNetworkPolicyAllowlistParam: + properties: + type: + type: string + enum: + - allowlist + description: >- + Allow outbound network access only to specified domains. Always + `allowlist`. + default: allowlist + x-stainless-const: true + allowed_domains: + items: + type: string + type: array + minItems: 1 + description: A list of allowed domains when type is `allowlist`. + domain_secrets: + items: + $ref: '#/components/schemas/ContainerNetworkPolicyDomainSecretParam' + type: array + minItems: 1 + description: Optional domain-scoped secrets for allowlisted domains. + type: object + required: + - type + - allowed_domains + SkillReferenceParam: + properties: + type: + type: string + enum: + - skill_reference + description: References a skill created with the /v1/skills endpoint. + default: skill_reference + x-stainless-const: true + skill_id: + type: string + maxLength: 64 + minLength: 1 + description: The ID of the referenced skill. + version: + type: string + description: >- + Optional skill version. Use a positive integer or 'latest'. Omit for + default. + type: object + required: + - type + - skill_id + InlineSkillParam: + properties: + type: + type: string + enum: + - inline + description: Defines an inline skill for this request. + default: inline + x-stainless-const: true + name: + type: string + description: The name of the skill. + description: + type: string + description: The description of the skill. + source: + $ref: '#/components/schemas/InlineSkillSourceParam' + description: Inline skill payload + type: object + required: + - type + - name + - description + - source + LocalSkillParam: + properties: + name: + type: string + description: The name of the skill. + description: + type: string + description: The description of the skill. + path: + type: string + description: The path to the directory containing the skill. + type: object + required: + - name + - description + - path + GrammarSyntax1: + type: string + enum: + - lark + - regex + ImageDetail: + type: string + enum: + - low + - high + - auto + - original + FileInputDetail: + type: string + enum: + - low + - high + ContainerNetworkPolicyDomainSecretParam: + properties: + domain: + type: string + minLength: 1 + description: The domain associated with the secret. + name: + type: string + minLength: 1 + description: The name of the secret to inject for the domain. + value: + type: string + maxLength: 10485760 + minLength: 1 + description: The secret value to inject for the domain. + type: object + required: + - domain + - name + - value + InlineSkillSourceParam: + properties: + type: + type: string + enum: + - base64 + description: The type of the inline skill source. Must be `base64`. + default: base64 + x-stainless-const: true + media_type: + type: string + enum: + - application/zip + description: >- + The media type of the inline skill payload. Must be + `application/zip`. + default: application/zip + x-stainless-const: true + data: + type: string + maxLength: 70254592 + minLength: 1 + description: Base64-encoded skill zip bundle. + type: object + required: + - type + - media_type + - data + description: Inline skill payload + x-stackQL-resources: + evals: + id: openai.evals.evals + name: evals + title: Evals + methods: + list: + operation: + $ref: '#/paths/~1evals/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1evals/post' + response: + mediaType: application/json + openAPIDocKey: '201' + get: + operation: + $ref: '#/paths/~1evals~1{eval_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + update: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1evals~1{eval_id}/post' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1evals~1{eval_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/evals/methods/get' + - $ref: '#/components/x-stackQL-resources/evals/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/evals/methods/create' + update: + - $ref: '#/components/x-stackQL-resources/evals/methods/update' + delete: + - $ref: '#/components/x-stackQL-resources/evals/methods/delete' + replace: [] + runs: + id: openai.evals.runs + name: runs + title: Runs + methods: + list: + operation: + $ref: '#/paths/~1evals~1{eval_id}~1runs/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1evals~1{eval_id}~1runs/post' + response: + mediaType: application/json + openAPIDocKey: '201' + get: + operation: + $ref: '#/paths/~1evals~1{eval_id}~1runs~1{run_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + cancel: + operation: + $ref: '#/paths/~1evals~1{eval_id}~1runs~1{run_id}/post' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1evals~1{eval_id}~1runs~1{run_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/runs/methods/get' + - $ref: '#/components/x-stackQL-resources/runs/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/runs/methods/create' + update: [] + delete: + - $ref: '#/components/x-stackQL-resources/runs/methods/delete' + replace: [] + run_output_items: + id: openai.evals.run_output_items + name: run_output_items + title: Run Output Items + methods: + list: + operation: + $ref: '#/paths/~1evals~1{eval_id}~1runs~1{run_id}~1output_items/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + get: + operation: + $ref: >- + #/paths/~1evals~1{eval_id}~1runs~1{run_id}~1output_items~1{output_item_id}/get + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/run_output_items/methods/get' + - $ref: '#/components/x-stackQL-resources/run_output_items/methods/list' + insert: [] + update: [] + delete: [] + replace: [] +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.last_id + location: body + queryParamPushdown: + top: + paramName: limit + maxValue: 100 diff --git a/providers/src/openai/v00.00.00000/services/files.yaml b/providers/src/openai/v00.00.00000/services/files.yaml index 1f552737..ad57ba75 100644 --- a/providers/src/openai/v00.00.00000/services/files.yaml +++ b/providers/src/openai/v00.00.00000/services/files.yaml @@ -1,226 +1,15 @@ -openapi: 3.0.0 -servers: - - url: 'https://api.openai.com/v1' +openapi: 3.1.0 info: + title: files API + description: openai API version: 2.3.0 - termsOfService: 'https://openai.com/policies/terms-of-use' - contact: - name: OpenAI Support - url: 'https://help.openai.com/' - license: - name: MIT - url: 'https://github.com/openai/openai-openapi/blob/master/LICENSE' - title: OpenAI API - files - description: Files are used to upload documents that can be used with features like Assistants and Fine-tuning. -security: - - ApiKeyAuth: [] -tags: - - name: Assistants - description: Build Assistants that can call models and use tools. - - name: Audio - description: Turn audio into text or text into audio. - - name: Chat - description: 'Given a list of messages comprising a conversation, the model will return a response.' - - name: Completions - description: 'Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.' - - name: Embeddings - description: Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. - - name: Fine-tuning - description: Manage fine-tuning jobs to tailor a model to your specific training data. - - name: Batch - description: Create large batches of API requests to run asynchronously. - - name: Files - description: Files are used to upload documents that can be used with features like Assistants and Fine-tuning. - - name: Uploads - description: Use Uploads to upload large files in multiple parts. - - name: Images - description: 'Given a prompt and/or an input image, the model will generate a new image.' - - name: Models - description: List and describe the various models available in the API. - - name: Moderations - description: 'Given text and/or image inputs, classifies if those inputs are potentially harmful.' - - name: Audit Logs - description: List user actions and configuration changes within this organization. -components: - schemas: - ListFilesResponse: - type: object - properties: - data: - type: array - items: - $ref: '#/components/schemas/OpenAIFile' - object: - type: string - enum: - - list - required: - - object - - data - OpenAIFile: - title: OpenAIFile - description: The `File` object represents a document that has been uploaded to OpenAI. - properties: - id: - type: string - description: 'The file identifier, which can be referenced in the API endpoints.' - bytes: - type: integer - description: 'The size of the file, in bytes.' - created_at: - type: integer - description: The Unix timestamp (in seconds) for when the file was created. - filename: - type: string - description: The name of the file. - object: - type: string - description: 'The object type, which is always `file`.' - enum: - - file - purpose: - type: string - description: 'The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`.' - enum: - - assistants - - assistants_output - - batch - - batch_output - - fine-tune - - fine-tune-results - - vision - status: - type: string - deprecated: true - description: 'Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.' - enum: - - uploaded - - processed - - error - status_details: - type: string - deprecated: true - description: 'Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.' - required: - - id - - object - - bytes - - created_at - - filename - - purpose - - status - x-oaiMeta: - name: The file object - example: | - { - "id": "file-abc123", - "object": "file", - "bytes": 120000, - "created_at": 1677610602, - "filename": "salesOverview.pdf", - "purpose": "assistants", - } - CreateFileRequest: - type: object - additionalProperties: false - properties: - file: - description: | - The File object (not file name) to be uploaded. - type: string - format: binary - purpose: - description: | - The intended purpose of the uploaded file. - - Use "assistants" for [Assistants](/docs/api-reference/assistants) and [Message](/docs/api-reference/messages) files, "vision" for Assistants image file inputs, "batch" for [Batch API](/docs/guides/batch), and "fine-tune" for [Fine-tuning](/docs/api-reference/fine-tuning). - type: string - enum: - - assistants - - batch - - fine-tune - - vision - required: - - file - - purpose - DeleteFileResponse: - type: object - properties: - id: - type: string - object: - type: string - enum: - - file - deleted: - type: boolean - required: - - id - - object - - deleted - responses: {} - securitySchemes: - ApiKeyAuth: - type: http - scheme: bearer - x-stackQL-resources: - files: - id: openai.files.files - name: files - title: Files - methods: - list_files: - operation: - $ref: '#/paths/~1files/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ListFilesResponse' - objectKey: $.data - create_file: - operation: - $ref: '#/paths/~1files/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/OpenAIFile' - delete_file: - operation: - $ref: '#/paths/~1files~1{file_id}/delete' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/DeleteFileResponse' - retrieve_file: - operation: - $ref: '#/paths/~1files~1{file_id}/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/OpenAIFile' - download_file: - operation: - $ref: '#/paths/~1files~1{file_id}~1content/get' - response: - mediaType: application/json - openAPIDocKey: '200' - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/files/methods/retrieve_file' - - $ref: '#/components/x-stackQL-resources/files/methods/list_files' - insert: - - $ref: '#/components/x-stackQL-resources/files/methods/create_file' - update: [] - replace: [] - delete: - - $ref: '#/components/x-stackQL-resources/files/methods/delete_file' paths: /files: get: operationId: listFiles tags: - Files - summary: Returns a list of files that belong to the user's organization. + summary: Returns a list of files. parameters: - in: query name: purpose @@ -228,6 +17,58 @@ paths: schema: type: string description: Only return files with the given purpose. + - name: limit + in: query + 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. + + + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. + required: false + schema: + type: integer + default: 10000 + - name: order + in: query + description: > + Sort order by the `created_at` timestamp of the objects. `asc` for + ascending order and `desc` for descending order. + schema: + type: string + default: desc + enum: + - asc + - desc + - name: after + in: query + 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 + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string responses: '200': description: OK @@ -238,18 +79,22 @@ paths: x-oaiMeta: name: List files group: files - returns: 'A list of [File](/docs/api-reference/files/object) objects.' examples: request: curl: | curl https://api.openai.com/v1/files \ -H "Authorization: Bearer $OPENAI_API_KEY" - python: | + python: |- + import os from openai import OpenAI - client = OpenAI() - client.files.list() - node.js: |- + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.files.list() + page = page.data[0] + print(page) + javascript: |- import OpenAI from "openai"; const openai = new OpenAI(); @@ -263,42 +108,110 @@ paths: } main(); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const fileObject of client.files.list()) { + console.log(fileObject); + } + 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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.files.FileListPage; + import com.openai.models.files.FileListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + FileListPage page = client.files().list(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + page = openai.files.list + + puts(page) response: | { + "object": "list", "data": [ { "id": "file-abc123", "object": "file", "bytes": 175, "created_at": 1613677385, + "expires_at": 1677614202, "filename": "salesOverview.pdf", "purpose": "assistants", }, { - "id": "file-abc123", + "id": "file-abc456", "object": "file", "bytes": 140, "created_at": 1613779121, + "expires_at": 1677614202, "filename": "puppy.jsonl", "purpose": "fine-tune", } ], - "object": "list" + "first_id": "file-abc123", + "last_id": "file-abc456", + "has_more": false } post: operationId: createFile tags: - Files - summary: | - Upload a file that can be used across various endpoints. Individual files can be up to 512 MB, and the size of all files uploaded by one organization can be up to 100 GB. + summary: > + Upload a file that can be used across various endpoints. Individual + files + + can be up to 512 MB, and each project can store up to 2.5 TB of files in + + total. There is no organization-wide storage limit. Uploads to this - The Assistants API supports files up to 2 million tokens and of specific file types. See the [Assistants Tools guide](/docs/assistants/tools) for details. + endpoint are rate-limited to 1,000 requests per minute per authenticated - The Fine-tuning API only supports `.jsonl` files. The input also has certain required formats for fine-tuning [chat](/docs/api-reference/fine-tuning/chat-input) or [completions](/docs/api-reference/fine-tuning/completions-input) models. + user. - The Batch API only supports `.jsonl` files up to 100 MB in size. The input also has a specific required [format](/docs/api-reference/batch/request-input). - Please [contact us](https://help.openai.com/) if you need to increase these storage limits. + - The Assistants API supports files up to 2 million tokens and of + specific + file types. See the [Assistants Tools guide](/docs/assistants/tools) for + details. + - The Fine-tuning API only supports `.jsonl` files. The input also has + certain required formats for fine-tuning + [chat](/docs/api-reference/fine-tuning/chat-input) or + [completions](/docs/api-reference/fine-tuning/completions-input) models. + - The Batch API only supports `.jsonl` files up to 200 MB in size. The + input + also has a specific required + [format](/docs/api-reference/batch/request-input). + - 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_stores/{vector_store_id}/file_batches`](/docs/api-reference/vector-stores-file-batches/createBatch) + instead of attaching them one by one. Vector store attachment has separate + limits from file upload, including 2,000 attached files per minute per + organization. + + Please [contact us](https://help.openai.com/) if you need to increase + these + + storage limits. requestBody: required: true content: @@ -315,7 +228,13 @@ paths: x-oaiMeta: name: Upload file group: files - returns: 'The uploaded [File](/docs/api-reference/files/object) object.' + 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. examples: request: curl: | @@ -323,15 +242,21 @@ paths: -H "Authorization: Bearer $OPENAI_API_KEY" \ -F purpose="fine-tune" \ -F file="@mydata.jsonl" - python: | + -F expires_after[anchor]="created_at" + -F expires_after[seconds]=2592000 + python: |- + import os from openai import OpenAI - client = OpenAI() - client.files.create( - file=open("mydata.jsonl", "rb"), - purpose="fine-tune" + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted ) - node.js: |- + file_object = client.files.create( + file=b"Example data", + purpose="assistants", + ) + print(file_object.id) + javascript: |- import fs from "fs"; import OpenAI from "openai"; @@ -341,27 +266,101 @@ paths: const file = await openai.files.create({ file: fs.createReadStream("mydata.jsonl"), purpose: "fine-tune", + expires_after: { + anchor: "created_at", + seconds: 2592000 + } }); console.log(file); } main(); + node.js: |- + import fs from 'fs'; + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const fileObject = await client.files.create({ + file: fs.createReadStream('fine-tune.jsonl'), + purpose: 'assistants', + }); + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.files.FileCreateParams; + import com.openai.models.files.FileObject; + import com.openai.models.files.FilePurpose; + import java.io.ByteArrayInputStream; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + FileCreateParams params = FileCreateParams.builder() + .file(new ByteArrayInputStream("Example data".getBytes())) + .purpose(FilePurpose.ASSISTANTS) + .build(); + FileObject fileObject = client.files().create(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + file_object = openai.files.create(file: StringIO.new("Example + data"), purpose: :assistants) + + + puts(file_object) response: | { "id": "file-abc123", "object": "file", "bytes": 120000, "created_at": 1677610602, + "expires_at": 1677614202, "filename": "mydata.jsonl", "purpose": "fine-tune", } - '/files/{file_id}': + parameters: + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + /files/{file_id}: delete: operationId: deleteFile tags: - Files - summary: Delete a file. + summary: Delete a file and remove it from all vector stores. parameters: - in: path name: file_id @@ -369,6 +368,24 @@ paths: schema: type: string description: The ID of the file to use for this request. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string responses: '200': description: OK @@ -379,30 +396,71 @@ paths: x-oaiMeta: name: Delete file group: files - returns: Deletion status. examples: request: curl: | curl https://api.openai.com/v1/files/file-abc123 \ -X DELETE \ -H "Authorization: Bearer $OPENAI_API_KEY" - python: | + python: |- + import os from openai import OpenAI - client = OpenAI() - client.files.delete("file-abc123") - node.js: |- + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + file_deleted = client.files.delete( + "file_id", + ) + print(file_deleted.id) + javascript: |- import OpenAI from "openai"; const openai = new OpenAI(); async function main() { - const file = await openai.files.del("file-abc123"); + const file = await openai.files.delete("file-abc123"); console.log(file); } main(); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const fileDeleted = await client.files.delete('file_id'); + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.files.FileDeleteParams; + import com.openai.models.files.FileDeleted; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + FileDeleted fileDeleted = client.files().delete("file_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + file_deleted = openai.files.delete("file_id") + + puts(file_deleted) response: | { "id": "file-abc123", @@ -421,6 +479,24 @@ paths: schema: type: string description: The ID of the file to use for this request. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string responses: '200': description: OK @@ -431,18 +507,23 @@ paths: x-oaiMeta: name: Retrieve file group: files - returns: 'The [File](/docs/api-reference/files/object) object matching the specified ID.' examples: request: curl: | curl https://api.openai.com/v1/files/file-abc123 \ -H "Authorization: Bearer $OPENAI_API_KEY" - python: | + python: |- + import os from openai import OpenAI - client = OpenAI() - client.files.retrieve("file-abc123") - node.js: |- + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + file_object = client.files.retrieve( + "file_id", + ) + print(file_object.id) + javascript: |- import OpenAI from "openai"; const openai = new OpenAI(); @@ -454,58 +535,273 @@ paths: } main(); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const fileObject = await client.files.retrieve('file_id'); + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.files.FileObject; + import com.openai.models.files.FileRetrieveParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + FileObject fileObject = client.files().retrieve("file_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + file_object = openai.files.retrieve("file_id") + + puts(file_object) response: | { "id": "file-abc123", "object": "file", "bytes": 120000, "created_at": 1677610602, + "expires_at": 1677614202, "filename": "mydata.jsonl", "purpose": "fine-tune", } - '/files/{file_id}/content': - get: - operationId: downloadFile - tags: - - Files - summary: Returns the contents of the specified file. - parameters: - - in: path - name: file_id - required: true - schema: - type: string - description: The ID of the file to use for this request. - responses: - '200': - description: OK - content: - application/json: - schema: - type: string +components: + schemas: + ListFilesResponse: + type: object + properties: + object: + type: string + example: list + data: + type: array + items: + $ref: '#/components/schemas/OpenAIFile' + first_id: + type: string + example: file-abc123 + last_id: + type: string + example: file-abc456 + has_more: + type: boolean + example: false + required: + - object + - data + - first_id + - last_id + - has_more + CreateFileRequest: + type: object + additionalProperties: false + properties: + purpose: + description: | + The intended purpose of the uploaded file. One of: + - `assistants`: Used in the Assistants API + - `batch`: Used in the Batch API + - `fine-tune`: Used for fine-tuning + - `vision`: Images used for vision fine-tuning + - `user_data`: Flexible file type for any purpose + - `evals`: Used for eval data sets + type: string + enum: + - assistants + - batch + - fine-tune + - vision + - user_data + - evals + expires_after: + $ref: '#/components/schemas/FileExpirationAfter' + required: + - purpose + OpenAIFile: + title: OpenAIFile + description: >- + The `File` object represents a document that has been uploaded to + OpenAI. + properties: + id: + type: string + description: The file identifier, which can be referenced in the API endpoints. + bytes: + type: integer + description: The size of the file, in bytes. + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the file was created. + expires_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the file will expire. + filename: + type: string + description: The name of the file. + object: + type: string + description: The object type, which is always `file`. + enum: + - file + x-stainless-const: true + purpose: + type: string + description: >- + The intended purpose of the file. Supported values are `assistants`, + `assistants_output`, `batch`, `batch_output`, `fine-tune`, + `fine-tune-results`, `vision`, and `user_data`. + enum: + - assistants + - assistants_output + - batch + - batch_output + - fine-tune + - fine-tune-results + - vision + - user_data + status: + type: string + deprecated: true + description: >- + Deprecated. The current status of the file, which can be either + `uploaded`, `processed`, or `error`. + enum: + - uploaded + - processed + - error + status_details: + type: string + deprecated: true + description: >- + Deprecated. For details on why a fine-tuning training file failed + validation, see the `error` field on `fine_tuning.job`. + required: + - id + - object + - bytes + - created_at + - filename + - purpose + - status x-oaiMeta: - name: Retrieve file content - group: files - returns: The file content. - examples: - request: - curl: | - curl https://api.openai.com/v1/files/file-abc123/content \ - -H "Authorization: Bearer $OPENAI_API_KEY" > file.jsonl - python: | - from openai import OpenAI - client = OpenAI() - - content = client.files.content("file-abc123") - node.js: | - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const file = await openai.files.content("file-abc123"); - - console.log(file); - } - - main(); + name: The file object + example: | + { + "id": "file-abc123", + "object": "file", + "bytes": 120000, + "created_at": 1677610602, + "expires_at": 1680202602, + "filename": "salesOverview.pdf", + "purpose": "assistants", + } + type: object + DeleteFileResponse: + type: object + properties: + id: + type: string + object: + type: string + enum: + - file + x-stainless-const: true + deleted: + type: boolean + required: + - id + - object + - deleted + FileExpirationAfter: + type: object + title: File expiration policy + description: >- + The expiration policy for a file. By default, files with `purpose=batch` + expire after 30 days and all other files are persisted until they are + manually deleted. + properties: + anchor: + description: >- + Anchor timestamp after which the expiration policy applies. + Supported anchors: `created_at`. + type: string + enum: + - created_at + x-stainless-const: true + seconds: + description: >- + The number of seconds after the anchor time that the file will + expire. Must be between 3600 (1 hour) and 2592000 (30 days). + type: integer + format: int64 + minimum: 3600 + maximum: 2592000 + required: + - anchor + - seconds + x-stackQL-resources: + files: + id: openai.files.files + name: files + title: Files + methods: + list: + operation: + $ref: '#/paths/~1files/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + delete: + operation: + $ref: '#/paths/~1files~1{file_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + get: + operation: + $ref: '#/paths/~1files~1{file_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/files/methods/get' + - $ref: '#/components/x-stackQL-resources/files/methods/list' + insert: [] + update: [] + delete: + - $ref: '#/components/x-stackQL-resources/files/methods/delete' + replace: [] +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.last_id + location: body + queryParamPushdown: + top: + paramName: limit + maxValue: 100 diff --git a/providers/src/openai/v00.00.00000/services/fine_tuning.yaml b/providers/src/openai/v00.00.00000/services/fine_tuning.yaml index 3c772fac..a89e0b1c 100644 --- a/providers/src/openai/v00.00.00000/services/fine_tuning.yaml +++ b/providers/src/openai/v00.00.00000/services/fine_tuning.yaml @@ -1,221 +1,2590 @@ -openapi: 3.0.0 -servers: - - url: 'https://api.openai.com/v1' +openapi: 3.1.0 info: + title: fine_tuning API + description: openai API version: 2.3.0 - termsOfService: 'https://openai.com/policies/terms-of-use' - contact: - name: OpenAI Support - url: 'https://help.openai.com/' - license: - name: MIT - url: 'https://github.com/openai/openai-openapi/blob/master/LICENSE' - title: OpenAI API - fine_tuning - description: Manage fine-tuning jobs to tailor a model to your specific training data. -security: - - ApiKeyAuth: [] -tags: - - name: Assistants - description: Build Assistants that can call models and use tools. - - name: Audio - description: Turn audio into text or text into audio. - - name: Chat - description: 'Given a list of messages comprising a conversation, the model will return a response.' - - name: Completions - description: 'Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.' - - name: Embeddings - description: Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. - - name: Fine-tuning - description: Manage fine-tuning jobs to tailor a model to your specific training data. - - name: Batch - description: Create large batches of API requests to run asynchronously. - - name: Files - description: Files are used to upload documents that can be used with features like Assistants and Fine-tuning. - - name: Uploads - description: Use Uploads to upload large files in multiple parts. - - name: Images - description: 'Given a prompt and/or an input image, the model will generate a new image.' - - name: Models - description: List and describe the various models available in the API. - - name: Moderations - description: 'Given text and/or image inputs, classifies if those inputs are potentially harmful.' - - name: Audit Logs - description: List user actions and configuration changes within this organization. -components: - schemas: - CreateFineTuningJobRequest: - type: object - properties: - model: - description: | - The name of the model to fine-tune. You can select one of the - [supported models](/docs/guides/fine-tuning/which-models-can-be-fine-tuned). - example: gpt-4o-mini - anyOf: - - type: string - - type: string - enum: - - babbage-002 - - davinci-002 - - gpt-3.5-turbo - - gpt-4o-mini - x-oaiTypeLabel: string - training_file: +paths: + /fine_tuning/checkpoints/{fine_tuned_model_checkpoint}/permissions: + get: + operationId: listFineTuningCheckpointPermissions + tags: + - Fine-tuning + summary: > + **NOTE:** This endpoint requires an [admin API key](../admin-api-keys). + + + Organization owners can use this endpoint to view all permissions for a + fine-tuned model checkpoint. + parameters: + - in: path + name: fine_tuned_model_checkpoint + required: true + schema: + type: string + example: ft-AF1WoRqd3aJAHsqc9NY7iL8F description: | - The ID of an uploaded file that contains training data. + The ID of the fine-tuned model checkpoint to get permissions for. + - name: project_id + in: query + description: The ID of the project to get permissions for. + required: false + schema: + type: string + - name: after + in: query + description: >- + Identifier for the last permission ID from the previous pagination + request. + required: false + schema: + type: string + - name: limit + in: query + description: >- + Number of permissions to retrieve. - See [upload file](/docs/api-reference/files/create) for how to upload a file. - Your dataset must be formatted as a JSONL file. Additionally, you must upload your file with the purpose `fine-tune`. + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. + required: false + schema: + type: integer + default: 10 + - name: order + in: query + description: The order in which to retrieve permissions. + required: false + schema: + type: string + enum: + - ascending + - descending + default: descending + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: >- + #/components/schemas/ListFineTuningCheckpointPermissionResponse + 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 + \ + -H "Authorization: Bearer $OPENAI_API_KEY" + node.js: >- + import OpenAI from 'openai'; - The contents of the file should differ depending on if the model uses the [chat](/docs/api-reference/fine-tuning/chat-input) or [completions](/docs/api-reference/fine-tuning/completions-input) format. - See the [fine-tuning guide](/docs/guides/fine-tuning) for more details. - type: string - example: file-abc123 - hyperparameters: - type: object - description: The hyperparameters used for the fine-tuning job. - properties: - batch_size: - description: | - Number of examples in each batch. A larger batch size means that model parameters - are updated less frequently, but with lower variance. - oneOf: - - type: string - enum: - - auto - - type: integer - minimum: 1 - maximum: 256 - default: auto - learning_rate_multiplier: - description: | - Scaling factor for the learning rate. A smaller learning rate may be useful to avoid - overfitting. - oneOf: - - type: string - enum: - - auto - - type: number - minimum: 0 - exclusiveMinimum: true - default: auto - n_epochs: - description: | - The number of epochs to train the model for. An epoch refers to one full cycle - through the training dataset. - oneOf: - - type: string - enum: - - auto - - type: integer - minimum: 1 - maximum: 50 - default: auto - suffix: - description: | - A string of up to 64 characters that will be added to your fine-tuned model name. + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); - For example, a `suffix` of "custom-model-name" would produce a model name like `ft:gpt-4o-mini:openai:custom-model-name:7p4lURel`. - type: string - minLength: 1 - maxLength: 64 - default: null - nullable: true - validation_file: + + const permission = await + client.fineTuning.checkpoints.permissions.retrieve( + 'ft-AF1WoRqd3aJAHsqc9NY7iL8F', + ); + + + console.log(permission.first_id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + permission = client.fine_tuning.checkpoints.permissions.retrieve( + fine_tuned_model_checkpoint="ft-AF1WoRqd3aJAHsqc9NY7iL8F", + ) + print(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; + + + import com.openai.client.OpenAIClient; + + import com.openai.client.okhttp.OpenAIOkHttpClient; + + import + com.openai.models.finetuning.checkpoints.permissions.PermissionRetrieveParams; + + import + com.openai.models.finetuning.checkpoints.permissions.PermissionRetrieveResponse; + + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + PermissionRetrieveResponse permission = client.fineTuning().checkpoints().permissions().retrieve("ft-AF1WoRqd3aJAHsqc9NY7iL8F"); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + permission = + openai.fine_tuning.checkpoints.permissions.retrieve("ft-AF1WoRqd3aJAHsqc9NY7iL8F") + + + puts(permission) + response: | + { + "object": "list", + "data": [ + { + "object": "checkpoint.permission", + "id": "cp_zc4Q7MP6XxulcVzj4MZdwsAB", + "created_at": 1721764867, + "project_id": "proj_abGMw1llN8IrBb6SvvY5A1iH" + }, + { + "object": "checkpoint.permission", + "id": "cp_enQCFmOTGj3syEpYVhBRLTSy", + "created_at": 1721764800, + "project_id": "proj_iqGMw1llN8IrBb6SvvY5A1oF" + }, + ], + "first_id": "cp_zc4Q7MP6XxulcVzj4MZdwsAB", + "last_id": "cp_enQCFmOTGj3syEpYVhBRLTSy", + "has_more": false + } + post: + operationId: createFineTuningCheckpointPermission + tags: + - Fine-tuning + summary: > + **NOTE:** Calling this endpoint requires an [admin API + key](../admin-api-keys). + + + This enables organization owners to share fine-tuned models with other + projects in their organization. + parameters: + - in: path + name: fine_tuned_model_checkpoint + required: true + schema: + type: string + example: ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd + description: > + The ID of the fine-tuned model checkpoint to create a permission + for. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateFineTuningCheckpointPermissionRequest' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: >- + #/components/schemas/ListFineTuningCheckpointPermissionResponse + 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 + \ + -H "Authorization: Bearer $OPENAI_API_KEY" + -d '{"project_ids": ["proj_abGMw1llN8IrBb6SvvY5A1iH"]}' + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + // Automatically fetches more pages as needed. + + for await (const permissionCreateResponse of + client.fineTuning.checkpoints.permissions.create( + 'ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd', + { project_ids: ['string'] }, + )) { + console.log(permissionCreateResponse.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.fine_tuning.checkpoints.permissions.create( + fine_tuned_model_checkpoint="ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd", + project_ids=["string"], + ) + page = page.data[0] + print(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; + + + import com.openai.client.OpenAIClient; + + import com.openai.client.okhttp.OpenAIOkHttpClient; + + import + com.openai.models.finetuning.checkpoints.permissions.PermissionCreatePage; + + import + com.openai.models.finetuning.checkpoints.permissions.PermissionCreateParams; + + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + PermissionCreateParams params = PermissionCreateParams.builder() + .fineTunedModelCheckpoint("ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd") + .addProjectId("string") + .build(); + PermissionCreatePage page = client.fineTuning().checkpoints().permissions().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + page = openai.fine_tuning.checkpoints.permissions.create( + "ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd", + project_ids: ["string"] + ) + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "object": "checkpoint.permission", + "id": "cp_zc4Q7MP6XxulcVzj4MZdwsAB", + "created_at": 1721764867, + "project_id": "proj_abGMw1llN8IrBb6SvvY5A1iH" + } + ], + "first_id": "cp_zc4Q7MP6XxulcVzj4MZdwsAB", + "last_id": "cp_zc4Q7MP6XxulcVzj4MZdwsAB", + "has_more": false + } + /fine_tuning/checkpoints/{fine_tuned_model_checkpoint}/permissions/{permission_id}: + delete: + operationId: deleteFineTuningCheckpointPermission + tags: + - Fine-tuning + summary: > + **NOTE:** This endpoint requires an [admin API key](../admin-api-keys). + + + Organization owners can use this endpoint to delete a permission for a + fine-tuned model checkpoint. + parameters: + - in: path + name: fine_tuned_model_checkpoint + required: true + schema: + type: string + example: ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd + description: > + The ID of the fine-tuned model checkpoint to delete a permission + for. + - in: path + name: permission_id + required: true + schema: + type: string + example: cp_zc4Q7MP6XxulcVzj4MZdwsAB description: | - The ID of an uploaded file that contains validation data. + The ID of the fine-tuned model checkpoint permission to delete. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: >- + #/components/schemas/DeleteFineTuningCheckpointPermissionResponse + 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 + \ + -H "Authorization: Bearer $OPENAI_API_KEY" + node.js: >- + import OpenAI from 'openai'; - If you provide this file, the data is used to generate validation - metrics periodically during fine-tuning. These metrics can be viewed in - the fine-tuning results file. - The same data should not be present in both train and validation files. - Your dataset must be formatted as a JSONL file. You must upload your file with the purpose `fine-tune`. + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); - See the [fine-tuning guide](/docs/guides/fine-tuning) for more details. - type: string - nullable: true - example: file-abc123 - integrations: - type: array - description: A list of integrations to enable for your fine-tuning job. - nullable: true - items: - type: object - required: - - type - - wandb - properties: + + const permission = await + client.fineTuning.checkpoints.permissions.delete( + 'cp_zc4Q7MP6XxulcVzj4MZdwsAB', + { fine_tuned_model_checkpoint: 'ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd' }, + ); + + + console.log(permission.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + permission = client.fine_tuning.checkpoints.permissions.delete( + permission_id="cp_zc4Q7MP6XxulcVzj4MZdwsAB", + fine_tuned_model_checkpoint="ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd", + ) + print(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; + + + import com.openai.client.OpenAIClient; + + import com.openai.client.okhttp.OpenAIOkHttpClient; + + import + com.openai.models.finetuning.checkpoints.permissions.PermissionDeleteParams; + + import + com.openai.models.finetuning.checkpoints.permissions.PermissionDeleteResponse; + + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + PermissionDeleteParams params = PermissionDeleteParams.builder() + .fineTunedModelCheckpoint("ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd") + .permissionId("cp_zc4Q7MP6XxulcVzj4MZdwsAB") + .build(); + PermissionDeleteResponse permission = client.fineTuning().checkpoints().permissions().delete(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + permission = openai.fine_tuning.checkpoints.permissions.delete( + "cp_zc4Q7MP6XxulcVzj4MZdwsAB", + fine_tuned_model_checkpoint: "ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd" + ) + + puts(permission) + response: | + { + "object": "checkpoint.permission", + "id": "cp_zc4Q7MP6XxulcVzj4MZdwsAB", + "deleted": true + } + /fine_tuning/jobs: + post: + operationId: createFineTuningJob + tags: + - Fine-tuning + summary: > + Creates a fine-tuning job which begins the process of creating a new + model from a given dataset. + + + Response includes details of the enqueued job including job status and + the name of the fine-tuned models once complete. + + + [Learn more about fine-tuning](/docs/guides/model-optimization) + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateFineTuningJobRequest' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/FineTuningJob' + x-oaiMeta: + name: Create fine-tuning job + group: fine-tuning + examples: + - title: Default + request: + curl: | + curl https://api.openai.com/v1/fine_tuning/jobs \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "training_file": "file-BK7bzQj3FfZFXr7DbL6xJwfo", + "model": "gpt-4o-mini" + }' + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + fine_tuning_job = client.fine_tuning.jobs.create( + model="gpt-4o-mini", + training_file="file-abc123", + ) + print(fine_tuning_job.id) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const fineTune = await openai.fineTuning.jobs.create({ + training_file: "file-abc123" + }); + + console.log(fineTune); + } + + main(); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const fineTuningJob = await client.fineTuning.jobs.create({ + model: 'gpt-4o-mini', + training_file: 'file-abc123', + }); + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.finetuning.jobs.FineTuningJob; + import com.openai.models.finetuning.jobs.JobCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + JobCreateParams params = JobCreateParams.builder() + .model(JobCreateParams.Model.GPT_4O_MINI) + .trainingFile("file-abc123") + .build(); + FineTuningJob fineTuningJob = client.fineTuning().jobs().create(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + fine_tuning_job = openai.fine_tuning.jobs.create(model: + :"gpt-4o-mini", training_file: "file-abc123") + + + puts(fine_tuning_job) + response: | + { + "object": "fine_tuning.job", + "id": "ftjob-abc123", + "model": "gpt-4o-mini-2024-07-18", + "created_at": 1721764800, + "fine_tuned_model": null, + "organization_id": "org-123", + "result_files": [], + "status": "queued", + "validation_file": null, + "training_file": "file-abc123", + "method": { + "type": "supervised", + "supervised": { + "hyperparameters": { + "batch_size": "auto", + "learning_rate_multiplier": "auto", + "n_epochs": "auto", + } + } + }, + "metadata": null + } + - title: Epochs + request: + curl: | + curl https://api.openai.com/v1/fine_tuning/jobs \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "training_file": "file-abc123", + "model": "gpt-4o-mini", + "method": { + "type": "supervised", + "supervised": { + "hyperparameters": { + "n_epochs": 2 + } + } + } + }' + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + fine_tuning_job = client.fine_tuning.jobs.create( + model="gpt-4o-mini", + training_file="file-abc123", + ) + print(fine_tuning_job.id) + javascript: > + import OpenAI from "openai"; + + import { SupervisedMethod, SupervisedHyperparameters } from + "openai/resources/fine-tuning/methods"; + + + const openai = new OpenAI(); + + + async function main() { + const fineTune = await openai.fineTuning.jobs.create({ + training_file: "file-abc123", + model: "gpt-4o-mini", + method: { + type: "supervised", + supervised: { + hyperparameters: { + n_epochs: 2 + } + } + } + }); + + console.log(fineTune); + } + + + main(); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const fineTuningJob = await client.fineTuning.jobs.create({ + model: 'gpt-4o-mini', + training_file: 'file-abc123', + }); + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.finetuning.jobs.FineTuningJob; + import com.openai.models.finetuning.jobs.JobCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + JobCreateParams params = JobCreateParams.builder() + .model(JobCreateParams.Model.GPT_4O_MINI) + .trainingFile("file-abc123") + .build(); + FineTuningJob fineTuningJob = client.fineTuning().jobs().create(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + fine_tuning_job = openai.fine_tuning.jobs.create(model: + :"gpt-4o-mini", training_file: "file-abc123") + + + puts(fine_tuning_job) + response: | + { + "object": "fine_tuning.job", + "id": "ftjob-abc123", + "model": "gpt-4o-mini", + "created_at": 1721764800, + "fine_tuned_model": null, + "organization_id": "org-123", + "result_files": [], + "status": "queued", + "validation_file": null, + "training_file": "file-abc123", + "hyperparameters": { + "batch_size": "auto", + "learning_rate_multiplier": "auto", + "n_epochs": 2 + }, + "method": { + "type": "supervised", + "supervised": { + "hyperparameters": { + "batch_size": "auto", + "learning_rate_multiplier": "auto", + "n_epochs": 2 + } + } + }, + "metadata": null, + "error": { + "code": null, + "message": null, + "param": null + }, + "finished_at": null, + "seed": 683058546, + "trained_tokens": null, + "estimated_finish": null, + "integrations": [], + "user_provided_suffix": null, + "usage_metrics": null, + "shared_with_openai": false + } + - title: DPO + request: + curl: | + curl https://api.openai.com/v1/fine_tuning/jobs \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "training_file": "file-abc123", + "validation_file": "file-abc123", + "model": "gpt-4o-mini", + "method": { + "type": "dpo", + "dpo": { + "hyperparameters": { + "beta": 0.1 + } + } + } + }' + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + fine_tuning_job = client.fine_tuning.jobs.create( + model="gpt-4o-mini", + training_file="file-abc123", + ) + print(fine_tuning_job.id) + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const fineTuningJob = await client.fineTuning.jobs.create({ + model: 'gpt-4o-mini', + training_file: 'file-abc123', + }); + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.finetuning.jobs.FineTuningJob; + import com.openai.models.finetuning.jobs.JobCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + JobCreateParams params = JobCreateParams.builder() + .model(JobCreateParams.Model.GPT_4O_MINI) + .trainingFile("file-abc123") + .build(); + FineTuningJob fineTuningJob = client.fineTuning().jobs().create(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + fine_tuning_job = openai.fine_tuning.jobs.create(model: + :"gpt-4o-mini", training_file: "file-abc123") + + + puts(fine_tuning_job) + response: | + { + "object": "fine_tuning.job", + "id": "ftjob-abc", + "model": "gpt-4o-mini", + "created_at": 1746130590, + "fine_tuned_model": null, + "organization_id": "org-abc", + "result_files": [], + "status": "queued", + "validation_file": "file-123", + "training_file": "file-abc", + "method": { + "type": "dpo", + "dpo": { + "hyperparameters": { + "beta": 0.1, + "batch_size": "auto", + "learning_rate_multiplier": "auto", + "n_epochs": "auto" + } + } + }, + "metadata": null, + "error": { + "code": null, + "message": null, + "param": null + }, + "finished_at": null, + "hyperparameters": null, + "seed": 1036326793, + "estimated_finish": null, + "integrations": [], + "user_provided_suffix": null, + "usage_metrics": null, + "shared_with_openai": false + } + - title: Reinforcement + request: + curl: | + curl https://api.openai.com/v1/fine_tuning/jobs \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "training_file": "file-abc", + "validation_file": "file-123", + "model": "o4-mini", + "method": { + "type": "reinforcement", + "reinforcement": { + "grader": { + "type": "string_check", + "name": "Example string check grader", + "input": "{{sample.output_text}}", + "reference": "{{item.label}}", + "operation": "eq" + }, + "hyperparameters": { + "reasoning_effort": "medium" + } + } + } + }' + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + fine_tuning_job = client.fine_tuning.jobs.create( + model="gpt-4o-mini", + training_file="file-abc123", + ) + print(fine_tuning_job.id) + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const fineTuningJob = await client.fineTuning.jobs.create({ + model: 'gpt-4o-mini', + training_file: 'file-abc123', + }); + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.finetuning.jobs.FineTuningJob; + import com.openai.models.finetuning.jobs.JobCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + JobCreateParams params = JobCreateParams.builder() + .model(JobCreateParams.Model.GPT_4O_MINI) + .trainingFile("file-abc123") + .build(); + FineTuningJob fineTuningJob = client.fineTuning().jobs().create(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + fine_tuning_job = openai.fine_tuning.jobs.create(model: + :"gpt-4o-mini", training_file: "file-abc123") + + + puts(fine_tuning_job) + response: | + { + "object": "fine_tuning.job", + "id": "ftjob-abc123", + "model": "o4-mini", + "created_at": 1721764800, + "finished_at": null, + "fine_tuned_model": null, + "organization_id": "org-123", + "result_files": [], + "status": "validating_files", + "validation_file": "file-123", + "training_file": "file-abc", + "trained_tokens": null, + "error": {}, + "user_provided_suffix": null, + "seed": 950189191, + "estimated_finish": null, + "integrations": [], + "method": { + "type": "reinforcement", + "reinforcement": { + "hyperparameters": { + "batch_size": "auto", + "learning_rate_multiplier": "auto", + "n_epochs": "auto", + "eval_interval": "auto", + "eval_samples": "auto", + "compute_multiplier": "auto", + "reasoning_effort": "medium" + }, + "grader": { + "type": "string_check", + "name": "Example string check grader", + "input": "{{sample.output_text}}", + "reference": "{{item.label}}", + "operation": "eq" + }, + "response_format": null + } + }, + "metadata": null, + "usage_metrics": null, + "shared_with_openai": false + } + + - title: Validation file + request: + curl: | + curl https://api.openai.com/v1/fine_tuning/jobs \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "training_file": "file-abc123", + "validation_file": "file-abc123", + "model": "gpt-4o-mini" + }' + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + fine_tuning_job = client.fine_tuning.jobs.create( + model="gpt-4o-mini", + training_file="file-abc123", + ) + print(fine_tuning_job.id) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const fineTune = await openai.fineTuning.jobs.create({ + training_file: "file-abc123", + validation_file: "file-abc123" + }); + + console.log(fineTune); + } + + main(); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const fineTuningJob = await client.fineTuning.jobs.create({ + model: 'gpt-4o-mini', + training_file: 'file-abc123', + }); + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.finetuning.jobs.FineTuningJob; + import com.openai.models.finetuning.jobs.JobCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + JobCreateParams params = JobCreateParams.builder() + .model(JobCreateParams.Model.GPT_4O_MINI) + .trainingFile("file-abc123") + .build(); + FineTuningJob fineTuningJob = client.fineTuning().jobs().create(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + fine_tuning_job = openai.fine_tuning.jobs.create(model: + :"gpt-4o-mini", training_file: "file-abc123") + + + puts(fine_tuning_job) + response: | + { + "object": "fine_tuning.job", + "id": "ftjob-abc123", + "model": "gpt-4o-mini-2024-07-18", + "created_at": 1721764800, + "fine_tuned_model": null, + "organization_id": "org-123", + "result_files": [], + "status": "queued", + "validation_file": "file-abc123", + "training_file": "file-abc123", + "method": { + "type": "supervised", + "supervised": { + "hyperparameters": { + "batch_size": "auto", + "learning_rate_multiplier": "auto", + "n_epochs": "auto", + } + } + }, + "metadata": null + } + - title: W&B Integration + request: + curl: | + curl https://api.openai.com/v1/fine_tuning/jobs \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "training_file": "file-abc123", + "validation_file": "file-abc123", + "model": "gpt-4o-mini", + "integrations": [ + { + "type": "wandb", + "wandb": { + "project": "my-wandb-project", + "name": "ft-run-display-name" + "tags": [ + "first-experiment", "v2" + ] + } + } + ] + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const fineTuningJob = await client.fineTuning.jobs.create({ + model: 'gpt-4o-mini', + training_file: 'file-abc123', + }); + + console.log(fineTuningJob.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + fine_tuning_job = client.fine_tuning.jobs.create( + model="gpt-4o-mini", + training_file="file-abc123", + ) + print(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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.finetuning.jobs.FineTuningJob; + import com.openai.models.finetuning.jobs.JobCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + JobCreateParams params = JobCreateParams.builder() + .model(JobCreateParams.Model.GPT_4O_MINI) + .trainingFile("file-abc123") + .build(); + FineTuningJob fineTuningJob = client.fineTuning().jobs().create(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + fine_tuning_job = openai.fine_tuning.jobs.create(model: + :"gpt-4o-mini", training_file: "file-abc123") + + + puts(fine_tuning_job) + response: | + { + "object": "fine_tuning.job", + "id": "ftjob-abc123", + "model": "gpt-4o-mini-2024-07-18", + "created_at": 1721764800, + "fine_tuned_model": null, + "organization_id": "org-123", + "result_files": [], + "status": "queued", + "validation_file": "file-abc123", + "training_file": "file-abc123", + "integrations": [ + { + "type": "wandb", + "wandb": { + "project": "my-wandb-project", + "entity": None, + "run_id": "ftjob-abc123" + } + } + ], + "method": { + "type": "supervised", + "supervised": { + "hyperparameters": { + "batch_size": "auto", + "learning_rate_multiplier": "auto", + "n_epochs": "auto", + } + } + }, + "metadata": null + } + parameters: + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + get: + operationId: listPaginatedFineTuningJobs + tags: + - Fine-tuning + summary: | + List your organization's fine-tuning jobs + parameters: + - name: after + in: query + description: Identifier for the last job from the previous pagination request. + required: false + schema: + type: string + - name: limit + in: query + description: >- + Number of fine-tuning jobs to retrieve. + + + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. + required: false + schema: + type: integer + default: 20 + - in: query + name: metadata + required: false + schema: + type: object + nullable: true + additionalProperties: + type: string + style: deepObject + explode: true + description: > + Optional metadata filter. To filter, use the syntax `metadata[k]=v`. + Alternatively, set `metadata=null` to indicate no metadata. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ListPaginatedFineTuningJobsResponse' + 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 + \ + -H "Authorization: Bearer $OPENAI_API_KEY" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.fine_tuning.jobs.list() + page = page.data[0] + print(page.id) + javascript: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const list = await openai.fineTuning.jobs.list(); + + for await (const fineTune of list) { + console.log(fineTune); + } + } + + main(); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const fineTuningJob of client.fineTuning.jobs.list()) { + console.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\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.finetuning.jobs.JobListPage; + import com.openai.models.finetuning.jobs.JobListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + JobListPage page = client.fineTuning().jobs().list(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + page = openai.fine_tuning.jobs.list + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "object": "fine_tuning.job", + "id": "ftjob-abc123", + "model": "gpt-4o-mini-2024-07-18", + "created_at": 1721764800, + "fine_tuned_model": null, + "organization_id": "org-123", + "result_files": [], + "status": "queued", + "validation_file": null, + "training_file": "file-abc123", + "metadata": { + "key": "value" + } + }, + { ... }, + { ... } + ], "has_more": true + } + /fine_tuning/jobs/{fine_tuning_job_id}: + get: + operationId: retrieveFineTuningJob + tags: + - Fine-tuning + summary: | + Get info about a fine-tuning job. + + [Learn more about fine-tuning](/docs/guides/model-optimization) + parameters: + - in: path + name: fine_tuning_job_id + required: true + schema: + type: string + example: ft-AF1WoRqd3aJAHsqc9NY7iL8F + description: | + The ID of the fine-tuning job. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/FineTuningJob' + x-oaiMeta: + name: Retrieve fine-tuning job + group: fine-tuning + examples: + request: + curl: > + curl + https://api.openai.com/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F + \ + -H "Authorization: Bearer $OPENAI_API_KEY" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + fine_tuning_job = client.fine_tuning.jobs.retrieve( + "ft-AF1WoRqd3aJAHsqc9NY7iL8F", + ) + print(fine_tuning_job.id) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const fineTune = await openai.fineTuning.jobs.retrieve("ftjob-abc123"); + + console.log(fineTune); + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const fineTuningJob = await + client.fineTuning.jobs.retrieve('ft-AF1WoRqd3aJAHsqc9NY7iL8F'); + + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.finetuning.jobs.FineTuningJob; + import com.openai.models.finetuning.jobs.JobRetrieveParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + FineTuningJob fineTuningJob = client.fineTuning().jobs().retrieve("ft-AF1WoRqd3aJAHsqc9NY7iL8F"); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + fine_tuning_job = + openai.fine_tuning.jobs.retrieve("ft-AF1WoRqd3aJAHsqc9NY7iL8F") + + + puts(fine_tuning_job) + response: | + { + "object": "fine_tuning.job", + "id": "ftjob-abc123", + "model": "davinci-002", + "created_at": 1692661014, + "finished_at": 1692661190, + "fine_tuned_model": "ft:davinci-002:my-org:custom_suffix:7q8mpxmy", + "organization_id": "org-123", + "result_files": [ + "file-abc123" + ], + "status": "succeeded", + "validation_file": null, + "training_file": "file-abc123", + "hyperparameters": { + "n_epochs": 4, + "batch_size": 1, + "learning_rate_multiplier": 1.0 + }, + "trained_tokens": 5768, + "integrations": [], + "seed": 0, + "estimated_finish": 0, + "method": { + "type": "supervised", + "supervised": { + "hyperparameters": { + "n_epochs": 4, + "batch_size": 1, + "learning_rate_multiplier": 1.0 + } + } + } + } + /fine_tuning/jobs/{fine_tuning_job_id}/cancel: + post: + operationId: cancelFineTuningJob + tags: + - Fine-tuning + summary: | + Immediately cancel a fine-tune job. + parameters: + - in: path + name: fine_tuning_job_id + required: true + schema: + type: string + example: ft-AF1WoRqd3aJAHsqc9NY7iL8F + description: | + The ID of the fine-tuning job to cancel. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/FineTuningJob' + 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 \ + -H "Authorization: Bearer $OPENAI_API_KEY" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + fine_tuning_job = client.fine_tuning.jobs.cancel( + "ft-AF1WoRqd3aJAHsqc9NY7iL8F", + ) + print(fine_tuning_job.id) + javascript: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const fineTune = await openai.fineTuning.jobs.cancel("ftjob-abc123"); + + console.log(fineTune); + } + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const fineTuningJob = await + client.fineTuning.jobs.cancel('ft-AF1WoRqd3aJAHsqc9NY7iL8F'); + + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.finetuning.jobs.FineTuningJob; + import com.openai.models.finetuning.jobs.JobCancelParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + FineTuningJob fineTuningJob = client.fineTuning().jobs().cancel("ft-AF1WoRqd3aJAHsqc9NY7iL8F"); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + fine_tuning_job = + openai.fine_tuning.jobs.cancel("ft-AF1WoRqd3aJAHsqc9NY7iL8F") + + + puts(fine_tuning_job) + response: | + { + "object": "fine_tuning.job", + "id": "ftjob-abc123", + "model": "gpt-4o-mini-2024-07-18", + "created_at": 1721764800, + "fine_tuned_model": null, + "organization_id": "org-123", + "result_files": [], + "status": "cancelled", + "validation_file": "file-abc123", + "training_file": "file-abc123" + } + /fine_tuning/jobs/{fine_tuning_job_id}/checkpoints: + get: + operationId: listFineTuningJobCheckpoints + tags: + - Fine-tuning + summary: | + List checkpoints for a fine-tuning job. + parameters: + - in: path + name: fine_tuning_job_id + required: true + schema: + type: string + example: ft-AF1WoRqd3aJAHsqc9NY7iL8F + description: | + The ID of the fine-tuning job to get checkpoints for. + - name: after + in: query + description: >- + Identifier for the last checkpoint ID from the previous pagination + request. + required: false + schema: + type: string + - name: limit + in: query + description: >- + Number of checkpoints to retrieve. + + + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. + required: false + schema: + type: integer + default: 10 + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ListFineTuningJobCheckpointsResponse' + 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 + \ + -H "Authorization: Bearer $OPENAI_API_KEY" + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + // Automatically fetches more pages as needed. + + for await (const fineTuningJobCheckpoint of + client.fineTuning.jobs.checkpoints.list( + 'ft-AF1WoRqd3aJAHsqc9NY7iL8F', + )) { + console.log(fineTuningJobCheckpoint.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.fine_tuning.jobs.checkpoints.list( + fine_tuning_job_id="ft-AF1WoRqd3aJAHsqc9NY7iL8F", + ) + page = page.data[0] + print(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; + + + import com.openai.client.OpenAIClient; + + import com.openai.client.okhttp.OpenAIOkHttpClient; + + import + com.openai.models.finetuning.jobs.checkpoints.CheckpointListPage; + + import + com.openai.models.finetuning.jobs.checkpoints.CheckpointListParams; + + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + CheckpointListPage page = client.fineTuning().jobs().checkpoints().list("ft-AF1WoRqd3aJAHsqc9NY7iL8F"); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + page = + openai.fine_tuning.jobs.checkpoints.list("ft-AF1WoRqd3aJAHsqc9NY7iL8F") + + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "object": "fine_tuning.job.checkpoint", + "id": "ftckpt_zc4Q7MP6XxulcVzj4MZdwsAB", + "created_at": 1721764867, + "fine_tuned_model_checkpoint": "ft:gpt-4o-mini-2024-07-18:my-org:custom-suffix:96olL566:ckpt-step-2000", + "metrics": { + "full_valid_loss": 0.134, + "full_valid_mean_token_accuracy": 0.874 + }, + "fine_tuning_job_id": "ftjob-abc123", + "step_number": 2000 + }, + { + "object": "fine_tuning.job.checkpoint", + "id": "ftckpt_enQCFmOTGj3syEpYVhBRLTSy", + "created_at": 1721764800, + "fine_tuned_model_checkpoint": "ft:gpt-4o-mini-2024-07-18:my-org:custom-suffix:7q8mpxmy:ckpt-step-1000", + "metrics": { + "full_valid_loss": 0.167, + "full_valid_mean_token_accuracy": 0.781 + }, + "fine_tuning_job_id": "ftjob-abc123", + "step_number": 1000 + } + ], + "first_id": "ftckpt_zc4Q7MP6XxulcVzj4MZdwsAB", + "last_id": "ftckpt_enQCFmOTGj3syEpYVhBRLTSy", + "has_more": true + } + /fine_tuning/jobs/{fine_tuning_job_id}/events: + get: + operationId: listFineTuningEvents + tags: + - Fine-tuning + summary: | + Get status updates for a fine-tuning job. + parameters: + - in: path + name: fine_tuning_job_id + required: true + schema: + type: string + example: ft-AF1WoRqd3aJAHsqc9NY7iL8F + description: | + The ID of the fine-tuning job to get events for. + - name: after + in: query + description: Identifier for the last event from the previous pagination request. + required: false + schema: + type: string + - name: limit + in: query + description: >- + Number of events to retrieve. + + + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. + required: false + schema: + type: integer + default: 20 + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ListFineTuningJobEventsResponse' + 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 \ + -H "Authorization: Bearer $OPENAI_API_KEY" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.fine_tuning.jobs.list_events( + fine_tuning_job_id="ft-AF1WoRqd3aJAHsqc9NY7iL8F", + ) + page = page.data[0] + print(page.id) + javascript: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const list = await openai.fineTuning.list_events(id="ftjob-abc123", limit=2); + + for await (const fineTune of list) { + console.log(fineTune); + } + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + // Automatically fetches more pages as needed. + + for await (const fineTuningJobEvent of + client.fineTuning.jobs.listEvents( + 'ft-AF1WoRqd3aJAHsqc9NY7iL8F', + )) { + console.log(fineTuningJobEvent.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.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.finetuning.jobs.JobListEventsPage; + import com.openai.models.finetuning.jobs.JobListEventsParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + JobListEventsPage page = client.fineTuning().jobs().listEvents("ft-AF1WoRqd3aJAHsqc9NY7iL8F"); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + page = + openai.fine_tuning.jobs.list_events("ft-AF1WoRqd3aJAHsqc9NY7iL8F") + + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "object": "fine_tuning.job.event", + "id": "ft-event-ddTJfwuMVpfLXseO0Am0Gqjm", + "created_at": 1721764800, + "level": "info", + "message": "Fine tuning job successfully completed", + "data": null, + "type": "message" + }, + { + "object": "fine_tuning.job.event", + "id": "ft-event-tyiGuB72evQncpH87xe505Sv", + "created_at": 1721764800, + "level": "info", + "message": "New fine-tuned model created: ft:gpt-4o-mini:openai::7p4lURel", + "data": null, + "type": "message" + } + ], + "has_more": true + } + /fine_tuning/jobs/{fine_tuning_job_id}/pause: + post: + operationId: pauseFineTuningJob + tags: + - Fine-tuning + summary: | + Pause a fine-tune job. + parameters: + - in: path + name: fine_tuning_job_id + required: true + schema: + type: string + example: ft-AF1WoRqd3aJAHsqc9NY7iL8F + description: | + The ID of the fine-tuning job to pause. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/FineTuningJob' + 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 \ + -H "Authorization: Bearer $OPENAI_API_KEY" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + fine_tuning_job = client.fine_tuning.jobs.pause( + "ft-AF1WoRqd3aJAHsqc9NY7iL8F", + ) + print(fine_tuning_job.id) + javascript: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const fineTune = await openai.fineTuning.jobs.pause("ftjob-abc123"); + + console.log(fineTune); + } + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const fineTuningJob = await + client.fineTuning.jobs.pause('ft-AF1WoRqd3aJAHsqc9NY7iL8F'); + + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.finetuning.jobs.FineTuningJob; + import com.openai.models.finetuning.jobs.JobPauseParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + FineTuningJob fineTuningJob = client.fineTuning().jobs().pause("ft-AF1WoRqd3aJAHsqc9NY7iL8F"); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + fine_tuning_job = + openai.fine_tuning.jobs.pause("ft-AF1WoRqd3aJAHsqc9NY7iL8F") + + + puts(fine_tuning_job) + response: | + { + "object": "fine_tuning.job", + "id": "ftjob-abc123", + "model": "gpt-4o-mini-2024-07-18", + "created_at": 1721764800, + "fine_tuned_model": null, + "organization_id": "org-123", + "result_files": [], + "status": "paused", + "validation_file": "file-abc123", + "training_file": "file-abc123" + } + /fine_tuning/jobs/{fine_tuning_job_id}/resume: + post: + operationId: resumeFineTuningJob + tags: + - Fine-tuning + summary: | + Resume a fine-tune job. + parameters: + - in: path + name: fine_tuning_job_id + required: true + schema: + type: string + example: ft-AF1WoRqd3aJAHsqc9NY7iL8F + description: | + The ID of the fine-tuning job to resume. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/FineTuningJob' + 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 \ + -H "Authorization: Bearer $OPENAI_API_KEY" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + fine_tuning_job = client.fine_tuning.jobs.resume( + "ft-AF1WoRqd3aJAHsqc9NY7iL8F", + ) + print(fine_tuning_job.id) + javascript: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const fineTune = await openai.fineTuning.jobs.resume("ftjob-abc123"); + + console.log(fineTune); + } + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const fineTuningJob = await + client.fineTuning.jobs.resume('ft-AF1WoRqd3aJAHsqc9NY7iL8F'); + + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.finetuning.jobs.FineTuningJob; + import com.openai.models.finetuning.jobs.JobResumeParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + FineTuningJob fineTuningJob = client.fineTuning().jobs().resume("ft-AF1WoRqd3aJAHsqc9NY7iL8F"); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + fine_tuning_job = + openai.fine_tuning.jobs.resume("ft-AF1WoRqd3aJAHsqc9NY7iL8F") + + + puts(fine_tuning_job) + response: | + { + "object": "fine_tuning.job", + "id": "ftjob-abc123", + "model": "gpt-4o-mini-2024-07-18", + "created_at": 1721764800, + "fine_tuned_model": null, + "organization_id": "org-123", + "result_files": [], + "status": "queued", + "validation_file": "file-abc123", + "training_file": "file-abc123" + } +components: + schemas: + ListFineTuningCheckpointPermissionResponse: + type: object + properties: + data: + type: array + items: + $ref: '#/components/schemas/FineTuningCheckpointPermission' + object: + type: string + enum: + - list + x-stainless-const: true + first_id: + type: string + last_id: + type: string + has_more: + type: boolean + required: + - object + - data + - has_more + CreateFineTuningCheckpointPermissionRequest: + type: object + additionalProperties: false + properties: + project_ids: + type: array + description: The project identifiers to grant access to. + items: + type: string + required: + - project_ids + DeleteFineTuningCheckpointPermissionResponse: + type: object + properties: + id: + type: string + description: >- + The ID of the fine-tuned model checkpoint permission that was + deleted. + object: + type: string + description: The object type, which is always "checkpoint.permission". + enum: + - checkpoint.permission + x-stainless-const: true + deleted: + type: boolean + description: >- + Whether the fine-tuned model checkpoint permission was successfully + deleted. + required: + - id + - object + - deleted + CreateFineTuningJobRequest: + type: object + properties: + model: + description: > + The name of the model to fine-tune. You can select one of the + + [supported + models](/docs/guides/fine-tuning#which-models-can-be-fine-tuned). + example: gpt-4o-mini + x-oaiTypeLabel: string + type: string + enum: + - babbage-002 + - davinci-002 + - gpt-3.5-turbo + - gpt-4o-mini + training_file: + description: > + The ID of an uploaded file that contains training data. + + + See [upload file](/docs/api-reference/files/create) for how to + upload a file. + + + Your dataset must be formatted as a JSONL file. Additionally, you + must upload your file with the purpose `fine-tune`. + + + The contents of the file should differ depending on if the model + uses the [chat](/docs/api-reference/fine-tuning/chat-input), + [completions](/docs/api-reference/fine-tuning/completions-input) + format, or if the fine-tuning method uses the + [preference](/docs/api-reference/fine-tuning/preference-input) + format. + + + See the [fine-tuning guide](/docs/guides/model-optimization) for + more details. + type: string + example: file-abc123 + hyperparameters: + type: object + description: > + The hyperparameters used for the fine-tuning job. + + This value is now deprecated in favor of `method`, and should be + passed in under the `method` parameter. + properties: + batch_size: + description: > + Number of examples in each batch. A larger batch size means that + model parameters + + are updated less frequently, but with lower variance. + oneOf: + - type: string + enum: + - auto + x-stainless-const: true + - type: integer + minimum: 1 + maximum: 256 + default: auto + learning_rate_multiplier: + description: > + Scaling factor for the learning rate. A smaller learning rate + may be useful to avoid + + overfitting. + oneOf: + - type: string + enum: + - auto + x-stainless-const: true + - type: number + minimum: 0 + exclusiveMinimum: true + default: auto + n_epochs: + description: > + The number of epochs to train the model for. An epoch refers to + one full cycle + + through the training dataset. + oneOf: + - type: string + enum: + - auto + x-stainless-const: true + - type: integer + minimum: 1 + maximum: 50 + default: auto + deprecated: true + suffix: + description: > + A string of up to 64 characters that will be added to your + fine-tuned model name. + + + For example, a `suffix` of "custom-model-name" would produce a model + name like `ft:gpt-4o-mini:openai:custom-model-name:7p4lURel`. + type: string + minLength: 1 + maxLength: 64 + default: null + nullable: true + validation_file: + description: > + The ID of an uploaded file that contains validation data. + + + If you provide this file, the data is used to generate validation + + metrics periodically during fine-tuning. These metrics can be viewed + in + + the fine-tuning results file. + + The same data should not be present in both train and validation + files. + + + Your dataset must be formatted as a JSONL file. You must upload your + file with the purpose `fine-tune`. + + + See the [fine-tuning guide](/docs/guides/model-optimization) for + more details. + type: string + nullable: true + example: file-abc123 + integrations: + type: array + description: A list of integrations to enable for your fine-tuning job. + nullable: true + items: + type: object + required: + - type + - wandb + properties: type: - description: | - The type of integration to enable. Currently, only "wandb" (Weights and Biases) is supported. + description: > + The type of integration to enable. Currently, only "wandb" + (Weights and Biases) is supported. oneOf: - type: string enum: - wandb + x-stainless-const: true wandb: type: object - description: | - The settings for your integration with Weights and Biases. This payload specifies the project that - metrics will be sent to. Optionally, you can set an explicit display name for your run, add tags - to your run, and set a default entity (team, username, etc) to be associated with your run. + description: > + The settings for your integration with Weights and Biases. + This payload specifies the project that + + metrics will be sent to. Optionally, you can set an explicit + display name for your run, add tags + + to your run, and set a default entity (team, username, etc) to + be associated with your run. required: - project properties: project: - description: | - The name of the project that the new run will be created under. + description: > + The name of the project that the new run will be created + under. type: string example: my-wandb-project name: - description: | - A display name to set for the run. If not set, we will use the Job ID as the name. + description: > + A display name to set for the run. If not set, we will use + the Job ID as the name. nullable: true type: string entity: - description: | - The entity to use for the run. This allows you to set the team or username of the WandB user that you would - like associated with the run. If not set, the default entity for the registered WandB API key is used. + description: > + The entity to use for the run. This allows you to set the + team or username of the WandB user that you would + + like associated with the run. If not set, the default + entity for the registered WandB API key is used. nullable: true type: string tags: - description: | - A list of tags to be attached to the newly created run. These tags are passed through directly to WandB. Some - default tags are generated by OpenAI: "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}". + description: > + A list of tags to be attached to the newly created run. + These tags are passed through directly to WandB. Some + + default tags are generated by OpenAI: "openai/finetune", + "openai/{base-model}", "openai/{ftjob-abcdef}". type: array items: type: string example: custom-tag seed: - description: | - The seed controls the reproducibility of the job. Passing in the same seed and job parameters should produce the same results, but may differ in rare cases. + description: > + The seed controls the reproducibility of the job. Passing in the + same seed and job parameters should produce the same results, but + may differ in rare cases. + If a seed is not specified, one will be generated for you. type: integer nullable: true minimum: 0 maximum: 2147483647 example: 42 + method: + $ref: '#/components/schemas/FineTuneMethod' + metadata: + $ref: '#/components/schemas/Metadata' required: - model - training_file FineTuningJob: type: object title: FineTuningJob - description: | - The `fine_tuning.job` object represents a fine-tuning job that has been created through the API. + description: > + The `fine_tuning.job` object represents a fine-tuning job that has been + created through the API. properties: id: type: string - description: 'The object identifier, which can be referenced in the API endpoints.' + description: The object identifier, which can be referenced in the API endpoints. created_at: type: integer - description: The Unix timestamp (in seconds) for when the fine-tuning job was created. + format: unixtime + description: >- + The Unix timestamp (in seconds) for when the fine-tuning job was + created. error: type: object - nullable: true - description: 'For fine-tuning jobs that have `failed`, this will contain more information on the cause of the failure.' + description: >- + For fine-tuning jobs that have `failed`, this will contain more + information on the cause of the failure. properties: code: type: string @@ -224,59 +2593,109 @@ components: type: string description: A human-readable error message. param: - type: string - description: 'The parameter that was invalid, usually `training_file` or `validation_file`. This field will be null if the failure was not parameter-specific.' - nullable: true + anyOf: + - type: string + description: >- + The parameter that was invalid, usually `training_file` or + `validation_file`. This field will be null if the failure + was not parameter-specific. + - type: 'null' required: - code - message - param fine_tuned_model: type: string - nullable: true - description: The name of the fine-tuned model that is being created. The value will be null if the fine-tuning job is still running. + description: >- + The name of the fine-tuned model that is being created. The value + will be null if the fine-tuning job is still running. finished_at: type: integer - nullable: true - description: The Unix timestamp (in seconds) for when the fine-tuning job was finished. The value will be null if the fine-tuning job is still running. + format: unixtime + description: >- + The Unix timestamp (in seconds) for when the fine-tuning job was + finished. The value will be null if the fine-tuning job is still + running. hyperparameters: type: object - description: 'The hyperparameters used for the fine-tuning job. See the [fine-tuning guide](/docs/guides/fine-tuning) for more details.' + description: >- + The hyperparameters used for the fine-tuning job. This value will + only be returned when running `supervised` jobs. properties: + batch_size: + anyOf: + - description: > + Number of examples in each batch. A larger batch size means + that model parameters + + are updated less frequently, but with lower variance. + oneOf: + - type: string + enum: + - auto + x-stainless-const: true + - type: integer + minimum: 1 + maximum: 256 + default: auto + - type: 'null' + learning_rate_multiplier: + description: > + Scaling factor for the learning rate. A smaller learning rate + may be useful to avoid + + overfitting. + oneOf: + - type: string + enum: + - auto + x-stainless-const: true + - type: number + minimum: 0 + exclusiveMinimum: true + default: auto n_epochs: + description: > + The number of epochs to train the model for. An epoch refers to + one full cycle + + through the training dataset. oneOf: - type: string enum: - auto + x-stainless-const: true - type: integer minimum: 1 maximum: 50 default: auto - description: |- - The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset. - "auto" decides the optimal number of epochs based on the size of the dataset. If setting the number manually, we support any number between 1 and 50 epochs. - required: - - n_epochs model: type: string description: The base model that is being fine-tuned. object: type: string - description: 'The object type, which is always "fine_tuning.job".' + description: The object type, which is always "fine_tuning.job". enum: - fine_tuning.job + x-stainless-const: true organization_id: type: string description: The organization that owns the fine-tuning job. result_files: type: array - description: 'The compiled results file ID(s) for the fine-tuning job. You can retrieve the results with the [Files API](/docs/api-reference/files/retrieve-contents).' + description: >- + The compiled results file ID(s) for the fine-tuning job. You can + retrieve the results with the [Files + API](/docs/api-reference/files/retrieve-contents). items: type: string example: file-abc123 status: type: string - description: 'The current status of the fine-tuning job, which can be either `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`.' + description: >- + The current status of the fine-tuning job, which can be either + `validating_files`, `queued`, `running`, `succeeded`, `failed`, or + `cancelled`. enum: - validating_files - queued @@ -286,972 +2705,1866 @@ components: - cancelled trained_tokens: type: integer - nullable: true - description: The total number of billable tokens processed by this fine-tuning job. The value will be null if the fine-tuning job is still running. + description: >- + The total number of billable tokens processed by this fine-tuning + job. The value will be null if the fine-tuning job is still running. training_file: type: string - description: 'The file ID used for training. You can retrieve the training data with the [Files API](/docs/api-reference/files/retrieve-contents).' + description: >- + The file ID used for training. You can retrieve the training data + with the [Files API](/docs/api-reference/files/retrieve-contents). validation_file: type: string - nullable: true - description: 'The file ID used for validation. You can retrieve the validation results with the [Files API](/docs/api-reference/files/retrieve-contents).' + description: >- + The file ID used for validation. You can retrieve the validation + results with the [Files + API](/docs/api-reference/files/retrieve-contents). integrations: type: array - nullable: true description: A list of integrations to enable for this fine-tuning job. maxItems: 5 items: - oneOf: - - $ref: '#/components/schemas/FineTuningIntegration' - x-oaiExpandable: true - seed: - type: integer - description: The seed used for the fine-tuning job. - estimated_finish: - type: integer - nullable: true - description: The Unix timestamp (in seconds) for when the fine-tuning job is estimated to finish. The value will be null if the fine-tuning job is not running. - required: - - created_at - - error - - finished_at - - fine_tuned_model - - hyperparameters - - id - - model - - object - - organization_id - - result_files - - status - - trained_tokens - - training_file - - validation_file - - seed - x-oaiMeta: - name: The fine-tuning job object - example: | - { - "object": "fine_tuning.job", - "id": "ftjob-abc123", - "model": "davinci-002", - "created_at": 1692661014, - "finished_at": 1692661190, - "fine_tuned_model": "ft:davinci-002:my-org:custom_suffix:7q8mpxmy", - "organization_id": "org-123", - "result_files": [ - "file-abc123" - ], - "status": "succeeded", - "validation_file": null, - "training_file": "file-abc123", - "hyperparameters": { - "n_epochs": 4, - "batch_size": 1, - "learning_rate_multiplier": 1.0 - }, - "trained_tokens": 5768, - "integrations": [], - "seed": 0, - "estimated_finish": 0 - } - FineTuningIntegration: - type: object - title: Fine-Tuning Job Integration - required: - - type - - wandb - properties: - type: - type: string - description: The type of the integration being enabled for the fine-tuning job - enum: - - wandb - wandb: - type: object - description: | - The settings for your integration with Weights and Biases. This payload specifies the project that - metrics will be sent to. Optionally, you can set an explicit display name for your run, add tags - to your run, and set a default entity (team, username, etc) to be associated with your run. - required: - - project - properties: - project: - description: | - The name of the project that the new run will be created under. - type: string - example: my-wandb-project - name: - description: | - A display name to set for the run. If not set, we will use the Job ID as the name. - nullable: true - type: string - entity: - description: | - The entity to use for the run. This allows you to set the team or username of the WandB user that you would - like associated with the run. If not set, the default entity for the registered WandB API key is used. - nullable: true - type: string - tags: - description: | - A list of tags to be attached to the newly created run. These tags are passed through directly to WandB. Some - default tags are generated by OpenAI: "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}". - type: array - items: - type: string - example: custom-tag - ListPaginatedFineTuningJobsResponse: - type: object - properties: - data: - type: array - items: - $ref: '#/components/schemas/FineTuningJob' - has_more: - type: boolean - object: - type: string - enum: - - list - required: - - object - - data - - has_more - ListFineTuningJobCheckpointsResponse: - type: object - properties: - data: - type: array - items: - $ref: '#/components/schemas/FineTuningJobCheckpoint' - object: - type: string - enum: - - list - first_id: - type: string - nullable: true - last_id: - type: string - nullable: true - has_more: - type: boolean - required: - - object - - data - - has_more - FineTuningJobCheckpoint: - type: object - title: FineTuningJobCheckpoint - description: | - The `fine_tuning.job.checkpoint` object represents a model checkpoint for a fine-tuning job that is ready to use. - properties: - id: - type: string - description: 'The checkpoint identifier, which can be referenced in the API endpoints.' - created_at: - type: integer - description: The Unix timestamp (in seconds) for when the checkpoint was created. - fine_tuned_model_checkpoint: - type: string - description: The name of the fine-tuned checkpoint model that is created. - step_number: - type: integer - description: The step number that the checkpoint was created at. - metrics: - type: object - description: Metrics at the step number during the fine-tuning job. - properties: - step: - type: number - train_loss: - type: number - train_mean_token_accuracy: - type: number - valid_loss: - type: number - valid_mean_token_accuracy: - type: number - full_valid_loss: - type: number - full_valid_mean_token_accuracy: - type: number - fine_tuning_job_id: - type: string - description: The name of the fine-tuning job that this checkpoint was created from. - object: - type: string - description: 'The object type, which is always "fine_tuning.job.checkpoint".' - enum: - - fine_tuning.job.checkpoint + oneOf: + - $ref: '#/components/schemas/FineTuningIntegration' + seed: + type: integer + description: The seed used for the fine-tuning job. + estimated_finish: + type: integer + format: unixtime + description: >- + The Unix timestamp (in seconds) for when the fine-tuning job is + estimated to finish. The value will be null if the fine-tuning job + is not running. + method: + $ref: '#/components/schemas/FineTuneMethod' + metadata: + $ref: '#/components/schemas/Metadata' required: - created_at - - fine_tuning_job_id - - fine_tuned_model_checkpoint + - error + - finished_at + - fine_tuned_model + - hyperparameters - id - - metrics + - model - object - - step_number + - organization_id + - result_files + - status + - trained_tokens + - training_file + - validation_file + - seed x-oaiMeta: - name: The fine-tuning job checkpoint object + name: The fine-tuning job object example: | { - "object": "fine_tuning.job.checkpoint", - "id": "ftckpt_qtZ5Gyk4BLq1SfLFWp3RtO3P", - "created_at": 1712211699, - "fine_tuned_model_checkpoint": "ft:gpt-4o-mini-2024-07-18:my-org:custom_suffix:9ABel2dg:ckpt-step-88", - "fine_tuning_job_id": "ftjob-fpbNQ3H1GrMehXRf8cO97xTN", - "metrics": { - "step": 88, - "train_loss": 0.478, - "train_mean_token_accuracy": 0.924, - "valid_loss": 10.112, - "valid_mean_token_accuracy": 0.145, - "full_valid_loss": 0.567, - "full_valid_mean_token_accuracy": 0.944 + "object": "fine_tuning.job", + "id": "ftjob-abc123", + "model": "davinci-002", + "created_at": 1692661014, + "finished_at": 1692661190, + "fine_tuned_model": "ft:davinci-002:my-org:custom_suffix:7q8mpxmy", + "organization_id": "org-123", + "result_files": [ + "file-abc123" + ], + "status": "succeeded", + "validation_file": null, + "training_file": "file-abc123", + "hyperparameters": { + "n_epochs": 4, + "batch_size": 1, + "learning_rate_multiplier": 1.0 }, - "step_number": 88 + "trained_tokens": 5768, + "integrations": [], + "seed": 0, + "estimated_finish": 0, + "method": { + "type": "supervised", + "supervised": { + "hyperparameters": { + "n_epochs": 4, + "batch_size": 1, + "learning_rate_multiplier": 1.0 + } + } + }, + "metadata": { + "key": "value" + } } - ListFineTuningJobEventsResponse: + ListPaginatedFineTuningJobsResponse: type: object properties: data: type: array items: - $ref: '#/components/schemas/FineTuningJobEvent' + $ref: '#/components/schemas/FineTuningJob' + has_more: + type: boolean object: type: string enum: - list + x-stainless-const: true required: - object - data - FineTuningJobEvent: + - has_more + ListFineTuningJobCheckpointsResponse: type: object - description: Fine-tuning job event object properties: - id: - type: string - created_at: - type: integer - level: - type: string - enum: - - info - - warn - - error - message: - type: string - object: - type: string - enum: - - fine_tuning.job.event - required: - - id - - object - - created_at - - level - - message - x-oaiMeta: - name: The fine-tuning job event object - example: | - { - "object": "fine_tuning.job.event", - "id": "ftevent-abc123" - "created_at": 1677610602, - "level": "info", - "message": "Created fine-tuning job" - } - responses: {} - securitySchemes: - ApiKeyAuth: - type: http - scheme: bearer - x-stackQL-resources: - jobs: - id: openai.fine_tuning.jobs - name: jobs - title: Jobs - methods: - create_fine_tuning_job: - operation: - $ref: '#/paths/~1fine_tuning~1jobs/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/FineTuningJob' - list_paginated_fine_tuning_jobs: - operation: - $ref: '#/paths/~1fine_tuning~1jobs/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ListPaginatedFineTuningJobsResponse' - objectKey: $.data - retrieve_fine_tuning_job: - operation: - $ref: '#/paths/~1fine_tuning~1jobs~1{fine_tuning_job_id}/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/FineTuningJob' - cancel_fine_tuning_job: - operation: - $ref: '#/paths/~1fine_tuning~1jobs~1{fine_tuning_job_id}~1cancel/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/FineTuningJob' - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/jobs/methods/retrieve_fine_tuning_job' - - $ref: '#/components/x-stackQL-resources/jobs/methods/list_paginated_fine_tuning_jobs' - insert: - - $ref: '#/components/x-stackQL-resources/jobs/methods/create_fine_tuning_job' - update: [] - replace: [] - delete: [] - job_checkpoints: - id: openai.fine_tuning.job_checkpoints - name: job_checkpoints - title: Job Checkpoints - methods: - list_fine_tuning_job_checkpoints: - operation: - $ref: '#/paths/~1fine_tuning~1jobs~1{fine_tuning_job_id}~1checkpoints/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ListFineTuningJobCheckpointsResponse' - objectKey: $.data - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/job_checkpoints/methods/list_fine_tuning_job_checkpoints' - insert: [] - update: [] - replace: [] - delete: [] - events: - id: openai.fine_tuning.events - name: events - title: Events - methods: - list_fine_tuning_events: - operation: - $ref: '#/paths/~1fine_tuning~1jobs~1{fine_tuning_job_id}~1events/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ListFineTuningJobEventsResponse' - objectKey: $.data - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/events/methods/list_fine_tuning_events' - insert: [] - update: [] - replace: [] - delete: [] -paths: - /fine_tuning/jobs: - post: - operationId: createFineTuningJob - tags: - - Fine-tuning - summary: | - Creates a fine-tuning job which begins the process of creating a new model from a given dataset. - - Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. - - [Learn more about fine-tuning](/docs/guides/fine-tuning) - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CreateFineTuningJobRequest' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/FineTuningJob' - x-oaiMeta: - name: Create fine-tuning job - group: fine-tuning - returns: 'A [fine-tuning.job](/docs/api-reference/fine-tuning/object) object.' - examples: - - title: Default - request: - curl: | - curl https://api.openai.com/v1/fine_tuning/jobs \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "training_file": "file-BK7bzQj3FfZFXr7DbL6xJwfo", - "model": "gpt-4o-mini" - }' - python: | - from openai import OpenAI - client = OpenAI() - - client.fine_tuning.jobs.create( - training_file="file-abc123", - model="gpt-4o-mini" - ) - node.js: | - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const fineTune = await openai.fineTuning.jobs.create({ - training_file: "file-abc123" - }); - - console.log(fineTune); - } - - main(); - response: | - { - "object": "fine_tuning.job", - "id": "ftjob-abc123", - "model": "gpt-4o-mini-2024-07-18", - "created_at": 1721764800, - "fine_tuned_model": null, - "organization_id": "org-123", - "result_files": [], - "status": "queued", - "validation_file": null, - "training_file": "file-abc123", - } - - title: Epochs - request: - curl: | - curl https://api.openai.com/v1/fine_tuning/jobs \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "training_file": "file-abc123", - "model": "gpt-4o-mini", - "hyperparameters": { - "n_epochs": 2 - } - }' - python: | - from openai import OpenAI - client = OpenAI() - - client.fine_tuning.jobs.create( - training_file="file-abc123", - model="gpt-4o-mini", - hyperparameters={ - "n_epochs":2 - } - ) - node.js: | - import OpenAI from "openai"; + data: + type: array + items: + $ref: '#/components/schemas/FineTuningJobCheckpoint' + object: + type: string + enum: + - list + x-stainless-const: true + first_id: + type: string + last_id: + type: string + has_more: + type: boolean + required: + - object + - data + - has_more + ListFineTuningJobEventsResponse: + type: object + properties: + data: + type: array + items: + $ref: '#/components/schemas/FineTuningJobEvent' + object: + type: string + enum: + - list + x-stainless-const: true + has_more: + type: boolean + required: + - object + - data + - has_more + FineTuningCheckpointPermission: + type: object + title: FineTuningCheckpointPermission + description: > + The `checkpoint.permission` object represents a permission for a + fine-tuned model checkpoint. + properties: + id: + type: string + description: >- + The permission identifier, which can be referenced in the API + endpoints. + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the permission was created. + project_id: + type: string + description: The project identifier that the permission is for. + object: + type: string + description: The object type, which is always "checkpoint.permission". + enum: + - checkpoint.permission + x-stainless-const: true + required: + - created_at + - id + - object + - project_id + x-oaiMeta: + name: The fine-tuned model checkpoint permission object + example: | + { + "object": "checkpoint.permission", + "id": "cp_zc4Q7MP6XxulcVzj4MZdwsAB", + "created_at": 1712211699, + "project_id": "proj_abGMw1llN8IrBb6SvvY5A1iH" + } + FineTuneMethod: + type: object + description: The method used for fine-tuning. + properties: + type: + type: string + description: >- + The type of method. Is either `supervised`, `dpo`, or + `reinforcement`. + enum: + - supervised + - dpo + - reinforcement + supervised: + $ref: '#/components/schemas/FineTuneSupervisedMethod' + dpo: + $ref: '#/components/schemas/FineTuneDPOMethod' + reinforcement: + $ref: '#/components/schemas/FineTuneReinforcementMethod' + required: + - type + Metadata: + type: object + description: > + Set of 16 key-value pairs that can be attached to an object. This can be - const openai = new OpenAI(); + useful for storing additional information about the object in a + structured - async function main() { - const fineTune = await openai.fineTuning.jobs.create({ - training_file: "file-abc123", - model: "gpt-4o-mini", - hyperparameters: { n_epochs: 2 } - }); + format, and querying for objects via API or the dashboard. - console.log(fineTune); - } - main(); - response: | - { - "object": "fine_tuning.job", - "id": "ftjob-abc123", - "model": "gpt-4o-mini-2024-07-18", - "created_at": 1721764800, - "fine_tuned_model": null, - "organization_id": "org-123", - "result_files": [], - "status": "queued", - "validation_file": null, - "training_file": "file-abc123", - "hyperparameters": {"n_epochs": 2}, - } - - title: Validation file - request: - curl: | - curl https://api.openai.com/v1/fine_tuning/jobs \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "training_file": "file-abc123", - "validation_file": "file-abc123", - "model": "gpt-4o-mini" - }' - python: | - from openai import OpenAI - client = OpenAI() + Keys are strings with a maximum length of 64 characters. Values are + strings - client.fine_tuning.jobs.create( - training_file="file-abc123", - validation_file="file-def456", - model="gpt-4o-mini" - ) - node.js: | - import OpenAI from "openai"; + with a maximum length of 512 characters. + additionalProperties: + type: string + x-oaiTypeLabel: map + FineTuningIntegration: + type: object + title: Fine-Tuning Job Integration + required: + - type + - wandb + properties: + type: + type: string + description: The type of the integration being enabled for the fine-tuning job + enum: + - wandb + x-stainless-const: true + wandb: + type: object + description: > + The settings for your integration with Weights and Biases. This + payload specifies the project that - const openai = new OpenAI(); + metrics will be sent to. Optionally, you can set an explicit display + name for your run, add tags - async function main() { - const fineTune = await openai.fineTuning.jobs.create({ - training_file: "file-abc123", - validation_file: "file-abc123" - }); + to your run, and set a default entity (team, username, etc) to be + associated with your run. + required: + - project + properties: + project: + description: | + The name of the project that the new run will be created under. + type: string + example: my-wandb-project + name: + anyOf: + - description: > + A display name to set for the run. If not set, we will use + the Job ID as the name. + type: string + - type: 'null' + entity: + anyOf: + - description: > + The entity to use for the run. This allows you to set the + team or username of the WandB user that you would - console.log(fineTune); - } + like associated with the run. If not set, the default entity + for the registered WandB API key is used. + type: string + - type: 'null' + tags: + description: > + A list of tags to be attached to the newly created run. These + tags are passed through directly to WandB. Some - main(); - response: | - { - "object": "fine_tuning.job", - "id": "ftjob-abc123", - "model": "gpt-4o-mini-2024-07-18", - "created_at": 1721764800, - "fine_tuned_model": null, - "organization_id": "org-123", - "result_files": [], - "status": "queued", - "validation_file": "file-abc123", - "training_file": "file-abc123", - } - - title: W&B Integration - request: - curl: | - curl https://api.openai.com/v1/fine_tuning/jobs \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "training_file": "file-abc123", - "validation_file": "file-abc123", - "model": "gpt-4o-mini", - "integrations": [ - { - "type": "wandb", - "wandb": { - "project": "my-wandb-project", - "name": "ft-run-display-name" - "tags": [ - "first-experiment", "v2" - ] - } - } - ] - }' - response: | - { - "object": "fine_tuning.job", - "id": "ftjob-abc123", - "model": "gpt-4o-mini-2024-07-18", - "created_at": 1721764800, - "fine_tuned_model": null, - "organization_id": "org-123", - "result_files": [], - "status": "queued", - "validation_file": "file-abc123", - "training_file": "file-abc123", - "integrations": [ - { - "type": "wandb", - "wandb": { - "project": "my-wandb-project", - "entity": None, - "run_id": "ftjob-abc123" - } - } - ] - } - get: - operationId: listPaginatedFineTuningJobs - tags: - - Fine-tuning - summary: | - List your organization's fine-tuning jobs - parameters: - - name: after - in: query - description: Identifier for the last job from the previous pagination request. - required: false - schema: - type: string - - name: limit - in: query - description: Number of fine-tuning jobs to retrieve. - required: false - schema: - type: integer - default: 20 - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ListPaginatedFineTuningJobsResponse' + default tags are generated by OpenAI: "openai/finetune", + "openai/{base-model}", "openai/{ftjob-abcdef}". + type: array + items: + type: string + example: custom-tag + FineTuningJobCheckpoint: + type: object + title: FineTuningJobCheckpoint + description: > + The `fine_tuning.job.checkpoint` object represents a model checkpoint + for a fine-tuning job that is ready to use. + properties: + id: + type: string + description: >- + The checkpoint identifier, which can be referenced in the API + endpoints. + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the checkpoint was created. + fine_tuned_model_checkpoint: + type: string + description: The name of the fine-tuned checkpoint model that is created. + step_number: + type: integer + description: The step number that the checkpoint was created at. + metrics: + type: object + description: Metrics at the step number during the fine-tuning job. + properties: + step: + type: number + train_loss: + type: number + train_mean_token_accuracy: + type: number + valid_loss: + type: number + valid_mean_token_accuracy: + type: number + full_valid_loss: + type: number + full_valid_mean_token_accuracy: + type: number + fine_tuning_job_id: + type: string + description: >- + The name of the fine-tuning job that this checkpoint was created + from. + object: + type: string + description: The object type, which is always "fine_tuning.job.checkpoint". + enum: + - fine_tuning.job.checkpoint + x-stainless-const: true + required: + - created_at + - fine_tuning_job_id + - fine_tuned_model_checkpoint + - id + - metrics + - object + - step_number x-oaiMeta: - name: List fine-tuning jobs - group: fine-tuning - returns: 'A list of paginated [fine-tuning job](/docs/api-reference/fine-tuning/object) objects.' - examples: - request: - curl: | - curl https://api.openai.com/v1/fine_tuning/jobs?limit=2 \ - -H "Authorization: Bearer $OPENAI_API_KEY" - python: | - from openai import OpenAI - client = OpenAI() + name: The fine-tuning job checkpoint object + example: | + { + "object": "fine_tuning.job.checkpoint", + "id": "ftckpt_qtZ5Gyk4BLq1SfLFWp3RtO3P", + "created_at": 1712211699, + "fine_tuned_model_checkpoint": "ft:gpt-4o-mini-2024-07-18:my-org:custom_suffix:9ABel2dg:ckpt-step-88", + "fine_tuning_job_id": "ftjob-fpbNQ3H1GrMehXRf8cO97xTN", + "metrics": { + "step": 88, + "train_loss": 0.478, + "train_mean_token_accuracy": 0.924, + "valid_loss": 10.112, + "valid_mean_token_accuracy": 0.145, + "full_valid_loss": 0.567, + "full_valid_mean_token_accuracy": 0.944 + }, + "step_number": 88 + } + FineTuningJobEvent: + type: object + description: Fine-tuning job event object + properties: + object: + type: string + description: The object type, which is always "fine_tuning.job.event". + enum: + - fine_tuning.job.event + x-stainless-const: true + id: + type: string + description: The object identifier. + created_at: + type: integer + format: unixtime + description: >- + The Unix timestamp (in seconds) for when the fine-tuning job was + created. + level: + type: string + description: The log level of the event. + enum: + - info + - warn + - error + message: + type: string + description: The message of the event. + type: + type: string + description: The type of event. + enum: + - message + - metrics + data: + type: string + description: The data associated with the event. (opaque JSON object) + required: + - id + - object + - created_at + - level + - message + x-oaiMeta: + name: The fine-tuning job event object + example: | + { + "object": "fine_tuning.job.event", + "id": "ftevent-abc123" + "created_at": 1677610602, + "level": "info", + "message": "Created fine-tuning job", + "data": {}, + "type": "message" + } + FineTuneSupervisedMethod: + type: object + description: Configuration for the supervised fine-tuning method. + properties: + hyperparameters: + $ref: '#/components/schemas/FineTuneSupervisedHyperparameters' + FineTuneDPOMethod: + type: object + description: Configuration for the DPO fine-tuning method. + properties: + hyperparameters: + $ref: '#/components/schemas/FineTuneDPOHyperparameters' + FineTuneReinforcementMethod: + type: object + description: Configuration for the reinforcement fine-tuning method. + properties: + grader: + type: object + description: The grader used for the fine-tuning job. + title: StringCheckGrader + properties: + type: + type: string + enum: + - string_check + description: The object type, which is always `string_check`. + x-stainless-const: true + name: + type: string + description: The name of the grader. + input: + type: string + description: The input text. This may include template strings. + reference: + type: string + description: The reference text. This may include template strings. + operation: + type: string + enum: + - eq + - ne + - like + - ilike + description: >- + The string check operation to perform. One of `eq`, `ne`, + `like`, or `ilike`. + evaluation_metric: + type: string + enum: + - cosine + - fuzzy_match + - bleu + - gleu + - meteor + - rouge_1 + - rouge_2 + - rouge_3 + - rouge_4 + - rouge_5 + - rouge_l + description: > + The evaluation metric to use. One of `cosine`, `fuzzy_match`, + `bleu`, - client.fine_tuning.jobs.list() - node.js: |- - import OpenAI from "openai"; + `gleu`, `meteor`, `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, + `rouge_5`, - const openai = new OpenAI(); + or `rouge_l`. + source: + type: string + description: The source code of the python script. + image_tag: + type: string + description: The image tag to use for the python script. + model: + type: string + description: The model to use for the evaluation. + sampling_params: + type: object + description: The sampling parameters for the model. + properties: + seed: + anyOf: + - type: integer + description: > + A seed value to initialize the randomness, during + sampling. + - type: 'null' + top_p: + anyOf: + - type: number + default: 1 + example: 1 + description: > + An alternative to temperature for nucleus sampling; 1.0 + includes all tokens. + - type: 'null' + temperature: + anyOf: + - type: number + description: > + A higher temperature increases randomness in the + outputs. + - type: 'null' + max_completions_tokens: + anyOf: + - type: integer + minimum: 1 + description: > + The maximum number of tokens the grader model may + generate in its response. + - type: 'null' + reasoning_effort: + $ref: '#/components/schemas/ReasoningEffort' + range: + type: array + items: + type: number + min_items: 2 + max_items: 2 + description: The range of the score. Defaults to `[0, 1]`. + graders: + type: object + title: StringCheckGrader + description: > + A StringCheckGrader object that performs a string comparison + between input and reference using a specified operation. + properties: + type: + type: string + enum: + - string_check + description: The object type, which is always `string_check`. + x-stainless-const: true + name: + type: string + description: The name of the grader. + input: + type: string + description: The input text. This may include template strings. + reference: + type: string + description: The reference text. This may include template strings. + operation: + type: string + enum: + - eq + - ne + - like + - ilike + description: >- + The string check operation to perform. One of `eq`, `ne`, + `like`, or `ilike`. + evaluation_metric: + type: string + enum: + - cosine + - fuzzy_match + - bleu + - gleu + - meteor + - rouge_1 + - rouge_2 + - rouge_3 + - rouge_4 + - rouge_5 + - rouge_l + description: > + The evaluation metric to use. One of `cosine`, + `fuzzy_match`, `bleu`, - async function main() { - const list = await openai.fineTuning.jobs.list(); + `gleu`, `meteor`, `rouge_1`, `rouge_2`, `rouge_3`, + `rouge_4`, `rouge_5`, - for await (const fineTune of list) { - console.log(fineTune); - } + or `rouge_l`. + source: + type: string + description: The source code of the python script. + image_tag: + type: string + description: The image tag to use for the python script. + model: + type: string + description: The model to use for the evaluation. + sampling_params: + type: object + description: The sampling parameters for the model. + properties: + seed: + anyOf: + - type: integer + description: > + A seed value to initialize the randomness, during + sampling. + - type: 'null' + top_p: + anyOf: + - type: number + default: 1 + example: 1 + description: > + An alternative to temperature for nucleus sampling; + 1.0 includes all tokens. + - type: 'null' + temperature: + anyOf: + - type: number + description: > + A higher temperature increases randomness in the + outputs. + - type: 'null' + max_completions_tokens: + anyOf: + - type: integer + minimum: 1 + description: > + The maximum number of tokens the grader model may + generate in its response. + - type: 'null' + reasoning_effort: + $ref: '#/components/schemas/ReasoningEffort' + range: + type: array + items: + type: number + min_items: 2 + max_items: 2 + description: The range of the score. Defaults to `[0, 1]`. + labels: + type: array + items: + type: string + description: The labels to assign to each item in the evaluation. + passing_labels: + type: array + items: + type: string + description: >- + The labels that indicate a passing result. Must be a subset + of labels. + required: + - type + - name + - input + - reference + - operation + - evaluation_metric + - source + - model + - passing_labels + - labels + x-oaiMeta: + name: String Check Grader + group: graders + example: | + { + "type": "string_check", + "name": "Example string check grader", + "input": "{{sample.output_text}}", + "reference": "{{item.label}}", + "operation": "eq" + } + calculate_output: + type: string + description: A formula to calculate the output based on grader results. + required: + - type + - name + - input + - reference + - operation + - evaluation_metric + - source + - model + - graders + - calculate_output + x-oaiMeta: + name: String Check Grader + group: graders + example: | + { + "type": "string_check", + "name": "Example string check grader", + "input": "{{sample.output_text}}", + "reference": "{{item.label}}", + "operation": "eq" } - - main(); - response: | - { - "object": "list", - "data": [ - { - "object": "fine_tuning.job.event", - "id": "ft-event-TjX0lMfOniCZX64t9PUQT5hn", - "created_at": 1689813489, - "level": "warn", - "message": "Fine tuning process stopping due to job cancellation", - "data": null, - "type": "message" - }, - { ... }, - { ... } - ], "has_more": true - } - '/fine_tuning/jobs/{fine_tuning_job_id}': - get: - operationId: retrieveFineTuningJob - tags: - - Fine-tuning - summary: | - Get info about a fine-tuning job. - - [Learn more about fine-tuning](/docs/guides/fine-tuning) - parameters: - - in: path - name: fine_tuning_job_id - required: true - schema: - type: string - example: ft-AF1WoRqd3aJAHsqc9NY7iL8F - description: | - The ID of the fine-tuning job. - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/FineTuningJob' + hyperparameters: + $ref: '#/components/schemas/FineTuneReinforcementHyperparameters' + required: + - grader + FineTuneSupervisedHyperparameters: + type: object + description: The hyperparameters used for the fine-tuning job. + properties: + batch_size: + description: > + Number of examples in each batch. A larger batch size means that + model parameters are updated less frequently, but with lower + variance. + default: auto + type: string + enum: + - auto + x-stainless-const: true + minimum: 1 + maximum: 256 + learning_rate_multiplier: + description: > + Scaling factor for the learning rate. A smaller learning rate may be + useful to avoid overfitting. + default: auto + type: string + enum: + - auto + x-stainless-const: true + minimum: 0 + exclusiveMinimum: true + n_epochs: + description: > + The number of epochs to train the model for. An epoch refers to one + full cycle through the training dataset. + default: auto + type: string + enum: + - auto + x-stainless-const: true + minimum: 1 + maximum: 50 + FineTuneDPOHyperparameters: + type: object + description: The hyperparameters used for the DPO fine-tuning job. + properties: + beta: + description: > + The beta value for the DPO method. A higher beta value will increase + the weight of the penalty between the policy and reference model. + default: auto + type: string + enum: + - auto + x-stainless-const: true + minimum: 0 + maximum: 2 + exclusiveMinimum: true + batch_size: + description: > + Number of examples in each batch. A larger batch size means that + model parameters are updated less frequently, but with lower + variance. + default: auto + type: string + enum: + - auto + x-stainless-const: true + minimum: 1 + maximum: 256 + learning_rate_multiplier: + description: > + Scaling factor for the learning rate. A smaller learning rate may be + useful to avoid overfitting. + default: auto + type: string + enum: + - auto + x-stainless-const: true + minimum: 0 + exclusiveMinimum: true + n_epochs: + description: > + The number of epochs to train the model for. An epoch refers to one + full cycle through the training dataset. + default: auto + type: string + enum: + - auto + x-stainless-const: true + minimum: 1 + maximum: 50 + GraderStringCheck: + type: object + title: StringCheckGrader + description: > + A StringCheckGrader object that performs a string comparison between + input and reference using a specified operation. + properties: + type: + type: string + enum: + - string_check + description: The object type, which is always `string_check`. + x-stainless-const: true + name: + type: string + description: The name of the grader. + input: + type: string + description: The input text. This may include template strings. + reference: + type: string + description: The reference text. This may include template strings. + operation: + type: string + enum: + - eq + - ne + - like + - ilike + description: >- + The string check operation to perform. One of `eq`, `ne`, `like`, or + `ilike`. + required: + - type + - name + - input + - reference + - operation x-oaiMeta: - name: Retrieve fine-tuning job - group: fine-tuning - returns: 'The [fine-tuning](/docs/api-reference/fine-tuning/object) object with the given ID.' - examples: - request: - curl: | - curl https://api.openai.com/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F \ - -H "Authorization: Bearer $OPENAI_API_KEY" - python: | - from openai import OpenAI - client = OpenAI() + name: String Check Grader + group: graders + example: | + { + "type": "string_check", + "name": "Example string check grader", + "input": "{{sample.output_text}}", + "reference": "{{item.label}}", + "operation": "eq" + } + GraderTextSimilarity: + type: object + title: TextSimilarityGrader + description: > + A TextSimilarityGrader object which grades text based on similarity + metrics. + properties: + type: + type: string + enum: + - text_similarity + default: text_similarity + description: The type of grader. + x-stainless-const: true + name: + type: string + description: The name of the grader. + input: + type: string + description: The text being graded. + reference: + type: string + description: The text being graded against. + evaluation_metric: + type: string + enum: + - cosine + - fuzzy_match + - bleu + - gleu + - meteor + - rouge_1 + - rouge_2 + - rouge_3 + - rouge_4 + - rouge_5 + - rouge_l + description: > + The evaluation metric to use. One of `cosine`, `fuzzy_match`, + `bleu`, - client.fine_tuning.jobs.retrieve("ftjob-abc123") - node.js: | - import OpenAI from "openai"; + `gleu`, `meteor`, `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, + `rouge_5`, - const openai = new OpenAI(); + or `rouge_l`. + required: + - type + - name + - input + - reference + - evaluation_metric + x-oaiMeta: + name: Text Similarity Grader + group: graders + example: | + { + "type": "text_similarity", + "name": "Example text similarity grader", + "input": "{{sample.output_text}}", + "reference": "{{item.label}}", + "evaluation_metric": "fuzzy_match" + } + GraderPython: + type: object + title: PythonGrader + description: | + A PythonGrader object that runs a python script on the input. + properties: + type: + type: string + enum: + - python + description: The object type, which is always `python`. + x-stainless-const: true + name: + type: string + description: The name of the grader. + source: + type: string + description: The source code of the python script. + image_tag: + type: string + description: The image tag to use for the python script. + required: + - type + - name + - source + x-oaiMeta: + name: Python Grader + group: graders + example: | + { + "type": "python", + "name": "Example python grader", + "image_tag": "2025-05-08", + "source": """ + def grade(sample: dict, item: dict) -> float: + \""" + Returns 1.0 if `output_text` equals `label`, otherwise 0.0. + \""" + output = sample.get("output_text") + label = item.get("label") + return 1.0 if output == label else 0.0 + """, + } + GraderScoreModel: + type: object + title: ScoreModelGrader + description: > + A ScoreModelGrader object that uses a model to assign a score to the + input. + properties: + type: + type: string + enum: + - score_model + description: The object type, which is always `score_model`. + x-stainless-const: true + name: + type: string + description: The name of the grader. + model: + type: string + description: The model to use for the evaluation. + sampling_params: + type: object + description: The sampling parameters for the model. + properties: + seed: + anyOf: + - type: integer + description: | + A seed value to initialize the randomness, during sampling. + - type: 'null' + top_p: + anyOf: + - type: number + default: 1 + example: 1 + description: > + An alternative to temperature for nucleus sampling; 1.0 + includes all tokens. + - type: 'null' + temperature: + anyOf: + - type: number + description: | + A higher temperature increases randomness in the outputs. + - type: 'null' + max_completions_tokens: + anyOf: + - type: integer + minimum: 1 + description: > + The maximum number of tokens the grader model may generate + in its response. + - type: 'null' + reasoning_effort: + $ref: '#/components/schemas/ReasoningEffort' + input: + type: array + items: + $ref: '#/components/schemas/EvalItem' + description: > + The input messages evaluated by the grader. Supports text, output + text, input image, and input audio content blocks, and may include + template strings. + range: + type: array + items: + type: number + min_items: 2 + max_items: 2 + description: The range of the score. Defaults to `[0, 1]`. + required: + - type + - name + - input + - model + x-oaiMeta: + name: Score Model Grader + group: graders + example: | + { + "type": "score_model", + "name": "Example score model grader", + "input": [ + { + "role": "user", + "content": [ + { + "type": "input_text", + "text": ( + "Score how close the reference answer is to the model answer. Score 1.0 if they are the same and 0.0 if they are different." + " Return just a floating point score\n\n" + " Reference answer: {{item.label}}\n\n" + " Model answer: {{sample.output_text}}" + ) + }, + { + "type": "input_image", + "image_url": "https://example.com/reference.png", + "file_id": null, + "detail": "auto" + } + ], + } + ], + "model": "gpt-5-mini", + "sampling_params": { + "temperature": 1, + "top_p": 1, + "seed": 42, + "max_completions_tokens": 32768, + "reasoning_effort": "medium" + }, + } + GraderMulti: + type: object + title: MultiGrader + description: >- + A MultiGrader object combines the output of multiple graders to produce + a single score. + properties: + type: + type: string + enum: + - multi + default: multi + description: The object type, which is always `multi`. + x-stainless-const: true + name: + type: string + description: The name of the grader. + graders: + type: object + title: StringCheckGrader + description: > + A StringCheckGrader object that performs a string comparison between + input and reference using a specified operation. + properties: + type: + type: string + enum: + - string_check + description: The object type, which is always `string_check`. + x-stainless-const: true + name: + type: string + description: The name of the grader. + input: + type: string + description: The input text. This may include template strings. + reference: + type: string + description: The reference text. This may include template strings. + operation: + type: string + enum: + - eq + - ne + - like + - ilike + description: >- + The string check operation to perform. One of `eq`, `ne`, + `like`, or `ilike`. + evaluation_metric: + type: string + enum: + - cosine + - fuzzy_match + - bleu + - gleu + - meteor + - rouge_1 + - rouge_2 + - rouge_3 + - rouge_4 + - rouge_5 + - rouge_l + description: > + The evaluation metric to use. One of `cosine`, `fuzzy_match`, + `bleu`, - async function main() { - const fineTune = await openai.fineTuning.jobs.retrieve("ftjob-abc123"); + `gleu`, `meteor`, `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, + `rouge_5`, - console.log(fineTune); + or `rouge_l`. + source: + type: string + description: The source code of the python script. + image_tag: + type: string + description: The image tag to use for the python script. + model: + type: string + description: The model to use for the evaluation. + sampling_params: + type: object + description: The sampling parameters for the model. + properties: + seed: + anyOf: + - type: integer + description: > + A seed value to initialize the randomness, during + sampling. + - type: 'null' + top_p: + anyOf: + - type: number + default: 1 + example: 1 + description: > + An alternative to temperature for nucleus sampling; 1.0 + includes all tokens. + - type: 'null' + temperature: + anyOf: + - type: number + description: > + A higher temperature increases randomness in the + outputs. + - type: 'null' + max_completions_tokens: + anyOf: + - type: integer + minimum: 1 + description: > + The maximum number of tokens the grader model may + generate in its response. + - type: 'null' + reasoning_effort: + $ref: '#/components/schemas/ReasoningEffort' + range: + type: array + items: + type: number + min_items: 2 + max_items: 2 + description: The range of the score. Defaults to `[0, 1]`. + labels: + type: array + items: + type: string + description: The labels to assign to each item in the evaluation. + passing_labels: + type: array + items: + type: string + description: >- + The labels that indicate a passing result. Must be a subset of + labels. + required: + - type + - name + - input + - reference + - operation + - evaluation_metric + - source + - model + - passing_labels + - labels + x-oaiMeta: + name: String Check Grader + group: graders + example: | + { + "type": "string_check", + "name": "Example string check grader", + "input": "{{sample.output_text}}", + "reference": "{{item.label}}", + "operation": "eq" } - - main(); - response: | - { - "object": "fine_tuning.job", - "id": "ftjob-abc123", - "model": "davinci-002", - "created_at": 1692661014, - "finished_at": 1692661190, - "fine_tuned_model": "ft:davinci-002:my-org:custom_suffix:7q8mpxmy", - "organization_id": "org-123", - "result_files": [ - "file-abc123" - ], - "status": "succeeded", - "validation_file": null, - "training_file": "file-abc123", - "hyperparameters": { - "n_epochs": 4, - "batch_size": 1, - "learning_rate_multiplier": 1.0 + calculate_output: + type: string + description: A formula to calculate the output based on grader results. + required: + - name + - type + - graders + - calculate_output + x-oaiMeta: + name: Multi Grader + group: graders + example: | + { + "type": "multi", + "name": "example multi grader", + "graders": [ + { + "type": "text_similarity", + "name": "example text similarity grader", + "input": "The graded text", + "reference": "The reference text", + "evaluation_metric": "fuzzy_match" }, - "trained_tokens": 5768, - "integrations": [], - "seed": 0, - "estimated_finish": 0 - } - '/fine_tuning/jobs/{fine_tuning_job_id}/cancel': - post: - operationId: cancelFineTuningJob - tags: - - Fine-tuning - summary: | - Immediately cancel a fine-tune job. - parameters: - - in: path - name: fine_tuning_job_id - required: true - schema: - type: string - example: ft-AF1WoRqd3aJAHsqc9NY7iL8F + { + "type": "string_check", + "name": "Example string check grader", + "input": "{{sample.output_text}}", + "reference": "{{item.label}}", + "operation": "eq" + } + ], + "calculate_output": "0.5 * text_similarity_score + 0.5 * string_check_score)" + } + FineTuneReinforcementHyperparameters: + type: object + description: The hyperparameters used for the reinforcement fine-tuning job. + properties: + batch_size: + description: > + Number of examples in each batch. A larger batch size means that + model parameters are updated less frequently, but with lower + variance. + default: auto + type: string + enum: + - auto + x-stainless-const: true + minimum: 1 + maximum: 256 + learning_rate_multiplier: + description: > + Scaling factor for the learning rate. A smaller learning rate may be + useful to avoid overfitting. + default: auto + type: string + enum: + - auto + x-stainless-const: true + minimum: 0 + exclusiveMinimum: true + n_epochs: + description: > + The number of epochs to train the model for. An epoch refers to one + full cycle through the training dataset. + default: auto + type: string + enum: + - auto + x-stainless-const: true + minimum: 1 + maximum: 50 + reasoning_effort: description: | - The ID of the fine-tuning job to cancel. - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/FineTuningJob' - x-oaiMeta: - name: Cancel fine-tuning - group: fine-tuning - returns: 'The cancelled [fine-tuning](/docs/api-reference/fine-tuning/object) object.' - examples: - request: - curl: | - curl -X POST https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/cancel \ - -H "Authorization: Bearer $OPENAI_API_KEY" - python: | - from openai import OpenAI - client = OpenAI() + Level of reasoning effort. + type: string + enum: + - default + - low + - medium + - high + default: default + compute_multiplier: + description: > + Multiplier on amount of compute used for exploring search space + during training. + default: auto + type: string + enum: + - auto + x-stainless-const: true + minimum: 0.00001 + maximum: 10 + exclusiveMinimum: true + eval_interval: + description: | + The number of training steps between evaluation runs. + default: auto + type: string + enum: + - auto + x-stainless-const: true + minimum: 1 + eval_samples: + description: | + Number of evaluation samples to generate per training step. + default: auto + type: string + enum: + - auto + x-stainless-const: true + minimum: 1 + ReasoningEffort: + type: string + enum: + - none + - minimal + - low + - medium + - high + - xhigh + default: medium + description: > + Constrains effort on reasoning for - client.fine_tuning.jobs.cancel("ftjob-abc123") - node.js: |- - import OpenAI from "openai"; + [reasoning models](https://platform.openai.com/docs/guides/reasoning). - const openai = new OpenAI(); + Currently supported values are `none`, `minimal`, `low`, `medium`, + `high`, and `xhigh`. Reducing - async function main() { - const fineTune = await openai.fineTuning.jobs.cancel("ftjob-abc123"); + reasoning effort can result in faster responses and fewer tokens used - console.log(fineTune); - } - main(); - response: | - { - "object": "fine_tuning.job", - "id": "ftjob-abc123", - "model": "gpt-4o-mini-2024-07-18", - "created_at": 1721764800, - "fine_tuned_model": null, - "organization_id": "org-123", - "result_files": [], - "hyperparameters": { - "n_epochs": "auto" - }, - "status": "cancelled", - "validation_file": "file-abc123", - "training_file": "file-abc123" - } - '/fine_tuning/jobs/{fine_tuning_job_id}/checkpoints': - get: - operationId: listFineTuningJobCheckpoints - tags: - - Fine-tuning - summary: | - List checkpoints for a fine-tuning job. - parameters: - - in: path - name: fine_tuning_job_id - required: true - schema: - type: string - example: ft-AF1WoRqd3aJAHsqc9NY7iL8F - description: | - The ID of the fine-tuning job to get checkpoints for. - - name: after - in: query - description: Identifier for the last checkpoint ID from the previous pagination request. - required: false - schema: - type: string - - name: limit - in: query - description: Number of checkpoints to retrieve. - required: false - schema: - type: integer - default: 10 - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ListFineTuningJobCheckpointsResponse' - x-oaiMeta: - name: List fine-tuning checkpoints - group: fine-tuning - returns: 'A list of fine-tuning [checkpoint objects](/docs/api-reference/fine-tuning/checkpoint-object) for a fine-tuning job.' - examples: - request: - curl: | - curl https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/checkpoints \ - -H "Authorization: Bearer $OPENAI_API_KEY" - response: | - { - "object": "list" - "data": [ - { - "object": "fine_tuning.job.checkpoint", - "id": "ftckpt_zc4Q7MP6XxulcVzj4MZdwsAB", - "created_at": 1721764867, - "fine_tuned_model_checkpoint": "ft:gpt-4o-mini-2024-07-18:my-org:custom-suffix:96olL566:ckpt-step-2000", - "metrics": { - "full_valid_loss": 0.134, - "full_valid_mean_token_accuracy": 0.874 - }, - "fine_tuning_job_id": "ftjob-abc123", - "step_number": 2000, - }, - { - "object": "fine_tuning.job.checkpoint", - "id": "ftckpt_enQCFmOTGj3syEpYVhBRLTSy", - "created_at": 1721764800, - "fine_tuned_model_checkpoint": "ft:gpt-4o-mini-2024-07-18:my-org:custom-suffix:7q8mpxmy:ckpt-step-1000", - "metrics": { - "full_valid_loss": 0.167, - "full_valid_mean_token_accuracy": 0.781 - }, - "fine_tuning_job_id": "ftjob-abc123", - "step_number": 1000, - }, - ], - "first_id": "ftckpt_zc4Q7MP6XxulcVzj4MZdwsAB", - "last_id": "ftckpt_enQCFmOTGj3syEpYVhBRLTSy", - "has_more": true - } - '/fine_tuning/jobs/{fine_tuning_job_id}/events': - get: - operationId: listFineTuningEvents - tags: - - Fine-tuning - summary: | - Get status updates for a fine-tuning job. - parameters: - - in: path - name: fine_tuning_job_id - required: true - schema: - type: string - example: ft-AF1WoRqd3aJAHsqc9NY7iL8F - description: | - The ID of the fine-tuning job to get events for. - - name: after - in: query - description: Identifier for the last event from the previous pagination request. - required: false - schema: - type: string - - name: limit - in: query - description: Number of events to retrieve. - required: false - schema: - type: integer - default: 20 - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ListFineTuningJobEventsResponse' - x-oaiMeta: - name: List fine-tuning events - group: fine-tuning - returns: A list of fine-tuning event objects. - examples: - request: - curl: | - curl https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/events \ - -H "Authorization: Bearer $OPENAI_API_KEY" - python: | - from openai import OpenAI - client = OpenAI() + on reasoning in a response. - client.fine_tuning.jobs.list_events( - fine_tuning_job_id="ftjob-abc123", - limit=2 - ) - node.js: |- - import OpenAI from "openai"; - const openai = new OpenAI(); + - `gpt-5.1` defaults to `none`, which does not perform reasoning. The + supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, + and `high`. Tool calls are supported for all reasoning values in + gpt-5.1. - async function main() { - const list = await openai.fineTuning.list_events(id="ftjob-abc123", limit=2); + - All models before `gpt-5.1` default to `medium` reasoning effort, and + do not support `none`. - for await (const fineTune of list) { - console.log(fineTune); + - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning + effort. + + - `xhigh` is supported for all models after `gpt-5.1-codex-max`. + EvalItem: + type: object + title: Eval message object + description: > + A message input to the model with a role indicating instruction + following + + hierarchy. Instructions given with the `developer` or `system` role take + + precedence over instructions given with the `user` role. Messages with + the + + `assistant` role are presumed to have been generated by the model in + previous + + interactions. + properties: + role: + type: string + description: > + The role of the message input. One of `user`, `assistant`, `system`, + or + + `developer`. + enum: + - user + - assistant + - system + - developer + content: + $ref: '#/components/schemas/EvalItemContent' + type: + type: string + description: | + The type of the message input. Always `message`. + enum: + - message + x-stainless-const: true + required: + - role + - content + GraderLabelModel: + type: object + title: LabelModelGrader + description: > + A LabelModelGrader object which uses a model to assign labels to each + item + + in the evaluation. + properties: + type: + description: The object type, which is always `label_model`. + type: string + enum: + - label_model + x-stainless-const: true + name: + type: string + description: The name of the grader. + model: + type: string + description: >- + The model to use for the evaluation. Must support structured + outputs. + input: + type: array + items: + $ref: '#/components/schemas/EvalItem' + labels: + type: array + items: + type: string + description: The labels to assign to each item in the evaluation. + passing_labels: + type: array + items: + type: string + description: >- + The labels that indicate a passing result. Must be a subset of + labels. + required: + - type + - model + - input + - passing_labels + - labels + - name + x-oaiMeta: + name: Label Model Grader + group: graders + example: | + { + "name": "First label grader", + "type": "label_model", + "model": "gpt-4o-2024-08-06", + "input": [ + { + "type": "message", + "role": "system", + "content": { + "type": "input_text", + "text": "Classify the sentiment of the following statement as one of positive, neutral, or negative" + } + }, + { + "type": "message", + "role": "user", + "content": { + "type": "input_text", + "text": "Statement: {{item.response}}" } } + ], + "passing_labels": [ + "positive" + ], + "labels": [ + "positive", + "neutral", + "negative" + ] + } + EvalItemContent: + title: Eval content + description: > + Inputs to the model - can contain template strings. Supports text, + output text, input images, and input audio, either as a single item or + an array of items. + type: string + properties: + type: + type: string + enum: + - input_text + description: The type of the input item. Always `input_text`. + default: input_text + x-stainless-const: true + text: + type: string + description: The text input to the model. + image_url: + type: string + format: uri + description: | + The URL of the image input. + detail: + type: string + description: > + The detail level of the image to be sent to the model. One of + `high`, `low`, or `auto`. Defaults to `auto`. + input_audio: + type: object + properties: + data: + type: string + description: | + Base64-encoded audio data. + format: + type: string + description: > + The format of the audio data. Currently supported formats are + `mp3` and - main(); - response: | - { - "object": "list", - "data": [ - { - "object": "fine_tuning.job.event", - "id": "ft-event-ddTJfwuMVpfLXseO0Am0Gqjm", - "created_at": 1721764800, - "level": "info", - "message": "Fine tuning job successfully completed", - "data": null, - "type": "message" - }, - { - "object": "fine_tuning.job.event", - "id": "ft-event-tyiGuB72evQncpH87xe505Sv", - "created_at": 1721764800, - "level": "info", - "message": "New fine-tuned model created: ft:gpt-4o-mini:openai::7p4lURel", - "data": null, - "type": "message" - } - ], - "has_more": true - } + `wav`. + enum: + - mp3 + - wav + required: + - data + - format + required: + - type + - text + - image_url + - input_audio + items: + $ref: '#/components/schemas/EvalItemContentItem' + EvalItemContentItem: + title: Eval content item + description: > + A single content item: input text, output text, input image, or input + audio. + type: string + properties: + type: + type: string + enum: + - input_text + description: The type of the input item. Always `input_text`. + default: input_text + x-stainless-const: true + text: + type: string + description: The text input to the model. + image_url: + type: string + format: uri + description: | + The URL of the image input. + detail: + type: string + description: > + The detail level of the image to be sent to the model. One of + `high`, `low`, or `auto`. Defaults to `auto`. + input_audio: + type: object + properties: + data: + type: string + description: | + Base64-encoded audio data. + format: + type: string + description: > + The format of the audio data. Currently supported formats are + `mp3` and + + `wav`. + enum: + - mp3 + - wav + required: + - data + - format + required: + - type + - text + - image_url + - input_audio + EvalItemContentArray: + type: array + title: An array of Input text, Output text, Input image, and Input audio + description: > + A list of inputs, each of which may be either an input text, output + text, input + + image, or input audio object. + items: + $ref: '#/components/schemas/EvalItemContentItem' + EvalItemContentText: + type: string + title: Text input + description: | + A text input to the model. + InputTextContent: + properties: + type: + type: string + enum: + - input_text + description: The type of the input item. Always `input_text`. + default: input_text + x-stainless-const: true + text: + type: string + description: The text input to the model. + type: object + required: + - type + - text + title: Input text + description: A text input to the model. + EvalItemContentOutputText: + type: object + title: Output text + description: | + A text output from the model. + properties: + type: + type: string + description: | + The type of the output text. Always `output_text`. + enum: + - output_text + x-stainless-const: true + text: + type: string + description: | + The text output from the model. + required: + - type + - text + EvalItemInputImage: + title: Input image + description: An image input block used within EvalItem content arrays. + type: object + properties: + type: + type: string + description: | + The type of the image input. Always `input_image`. + enum: + - input_image + x-stainless-const: true + image_url: + type: string + format: uri + description: | + The URL of the image input. + detail: + type: string + description: > + The detail level of the image to be sent to the model. One of + `high`, `low`, or `auto`. Defaults to `auto`. + required: + - type + - image_url + InputAudio: + type: object + title: Input audio + description: | + An audio input to the model. + properties: + type: + type: string + description: | + The type of the input item. Always `input_audio`. + enum: + - input_audio + x-stainless-const: true + input_audio: + type: object + properties: + data: + type: string + description: | + Base64-encoded audio data. + format: + type: string + description: > + The format of the audio data. Currently supported formats are + `mp3` and + + `wav`. + enum: + - mp3 + - wav + required: + - data + - format + required: + - type + - input_audio + x-stackQL-resources: + checkpoint_permissions: + id: openai.fine_tuning.checkpoint_permissions + name: checkpoint_permissions + title: Checkpoint Permissions + methods: + list: + operation: + $ref: >- + #/paths/~1fine_tuning~1checkpoints~1{fine_tuned_model_checkpoint}~1permissions/get + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: >- + #/paths/~1fine_tuning~1checkpoints~1{fine_tuned_model_checkpoint}~1permissions/post + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: >- + #/paths/~1fine_tuning~1checkpoints~1{fine_tuned_model_checkpoint}~1permissions~1{permission_id}/delete + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: >- + #/components/x-stackQL-resources/checkpoint_permissions/methods/list + insert: + - $ref: >- + #/components/x-stackQL-resources/checkpoint_permissions/methods/create + update: [] + delete: + - $ref: >- + #/components/x-stackQL-resources/checkpoint_permissions/methods/delete + replace: [] + jobs: + id: openai.fine_tuning.jobs + name: jobs + title: Jobs + methods: + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1fine_tuning~1jobs/post' + response: + mediaType: application/json + openAPIDocKey: '200' + list: + operation: + $ref: '#/paths/~1fine_tuning~1jobs/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + get: + operation: + $ref: '#/paths/~1fine_tuning~1jobs~1{fine_tuning_job_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + cancel: + operation: + $ref: '#/paths/~1fine_tuning~1jobs~1{fine_tuning_job_id}~1cancel/post' + response: + mediaType: application/json + openAPIDocKey: '200' + pause: + operation: + $ref: '#/paths/~1fine_tuning~1jobs~1{fine_tuning_job_id}~1pause/post' + response: + mediaType: application/json + openAPIDocKey: '200' + resume: + operation: + $ref: '#/paths/~1fine_tuning~1jobs~1{fine_tuning_job_id}~1resume/post' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/jobs/methods/get' + - $ref: '#/components/x-stackQL-resources/jobs/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/jobs/methods/create' + update: [] + delete: [] + replace: [] + checkpoints: + id: openai.fine_tuning.checkpoints + name: checkpoints + title: Checkpoints + methods: + list: + operation: + $ref: '#/paths/~1fine_tuning~1jobs~1{fine_tuning_job_id}~1checkpoints/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/checkpoints/methods/list' + insert: [] + update: [] + delete: [] + replace: [] + events: + id: openai.fine_tuning.events + name: events + title: Events + methods: + list: + operation: + $ref: '#/paths/~1fine_tuning~1jobs~1{fine_tuning_job_id}~1events/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/events/methods/list' + insert: [] + update: [] + delete: [] + replace: [] +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.last_id + location: body + queryParamPushdown: + top: + paramName: limit + maxValue: 100 diff --git a/providers/src/openai/v00.00.00000/services/images.yaml b/providers/src/openai/v00.00.00000/services/images.yaml deleted file mode 100644 index eed63a8c..00000000 --- a/providers/src/openai/v00.00.00000/services/images.yaml +++ /dev/null @@ -1,531 +0,0 @@ -openapi: 3.0.0 -servers: - - url: 'https://api.openai.com/v1' -info: - version: 2.3.0 - termsOfService: 'https://openai.com/policies/terms-of-use' - contact: - name: OpenAI Support - url: 'https://help.openai.com/' - license: - name: MIT - url: 'https://github.com/openai/openai-openapi/blob/master/LICENSE' - title: OpenAI API - images - description: 'Given a prompt and/or an input image, the model will generate a new image.' -security: - - ApiKeyAuth: [] -tags: - - name: Assistants - description: Build Assistants that can call models and use tools. - - name: Audio - description: Turn audio into text or text into audio. - - name: Chat - description: 'Given a list of messages comprising a conversation, the model will return a response.' - - name: Completions - description: 'Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.' - - name: Embeddings - description: Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. - - name: Fine-tuning - description: Manage fine-tuning jobs to tailor a model to your specific training data. - - name: Batch - description: Create large batches of API requests to run asynchronously. - - name: Files - description: Files are used to upload documents that can be used with features like Assistants and Fine-tuning. - - name: Uploads - description: Use Uploads to upload large files in multiple parts. - - name: Images - description: 'Given a prompt and/or an input image, the model will generate a new image.' - - name: Models - description: List and describe the various models available in the API. - - name: Moderations - description: 'Given text and/or image inputs, classifies if those inputs are potentially harmful.' - - name: Audit Logs - description: List user actions and configuration changes within this organization. -components: - schemas: - CreateImageEditRequest: - type: object - properties: - image: - description: 'The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.' - type: string - format: binary - prompt: - description: A text description of the desired image(s). The maximum length is 1000 characters. - type: string - example: A cute baby sea otter wearing a beret - mask: - description: 'An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where `image` should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`.' - type: string - format: binary - model: - anyOf: - - type: string - - type: string - enum: - - dall-e-2 - x-oaiTypeLabel: string - default: dall-e-2 - example: dall-e-2 - nullable: true - description: The model to use for image generation. Only `dall-e-2` is supported at this time. - 'n': - type: integer - minimum: 1 - maximum: 10 - default: 1 - example: 1 - nullable: true - description: The number of images to generate. Must be between 1 and 10. - size: - type: string - enum: - - 256x256 - - 512x512 - - 1024x1024 - default: 1024x1024 - example: 1024x1024 - nullable: true - description: 'The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.' - response_format: - type: string - enum: - - url - - b64_json - default: url - example: url - nullable: true - description: The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. - user: - type: string - example: user-1234 - description: | - A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - required: - - prompt - - image - ImagesResponse: - properties: - created: - type: integer - data: - type: array - items: - $ref: '#/components/schemas/Image' - required: - - created - - data - Image: - type: object - description: Represents the url or the content of an image generated by the OpenAI API. - properties: - b64_json: - type: string - description: 'The base64-encoded JSON of the generated image, if `response_format` is `b64_json`.' - url: - type: string - description: 'The URL of the generated image, if `response_format` is `url` (default).' - revised_prompt: - type: string - description: 'The prompt that was used to generate the image, if there was any revision to the prompt.' - x-oaiMeta: - name: The image object - example: | - { - "url": "...", - "revised_prompt": "..." - } - CreateImageRequest: - type: object - properties: - prompt: - description: A text description of the desired image(s). The maximum length is 1000 characters for `dall-e-2` and 4000 characters for `dall-e-3`. - type: string - example: A cute baby sea otter - model: - anyOf: - - type: string - - type: string - enum: - - dall-e-2 - - dall-e-3 - x-oaiTypeLabel: string - default: dall-e-2 - example: dall-e-3 - nullable: true - description: The model to use for image generation. - 'n': - type: integer - minimum: 1 - maximum: 10 - default: 1 - example: 1 - nullable: true - description: 'The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only `n=1` is supported.' - quality: - type: string - enum: - - standard - - hd - default: standard - example: standard - description: The quality of the image that will be generated. `hd` creates images with finer details and greater consistency across the image. This param is only supported for `dall-e-3`. - response_format: - type: string - enum: - - url - - b64_json - default: url - example: url - nullable: true - description: The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. - size: - type: string - enum: - - 256x256 - - 512x512 - - 1024x1024 - - 1792x1024 - - 1024x1792 - default: 1024x1024 - example: 1024x1024 - nullable: true - description: 'The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`. Must be one of `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3` models.' - style: - type: string - enum: - - vivid - - natural - default: vivid - example: vivid - nullable: true - description: 'The style of the generated images. Must be one of `vivid` or `natural`. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images. This param is only supported for `dall-e-3`.' - user: - type: string - example: user-1234 - description: | - A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - required: - - prompt - CreateImageVariationRequest: - type: object - properties: - image: - description: 'The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.' - type: string - format: binary - model: - anyOf: - - type: string - - type: string - enum: - - dall-e-2 - x-oaiTypeLabel: string - default: dall-e-2 - example: dall-e-2 - nullable: true - description: The model to use for image generation. Only `dall-e-2` is supported at this time. - 'n': - type: integer - minimum: 1 - maximum: 10 - default: 1 - example: 1 - nullable: true - description: 'The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only `n=1` is supported.' - response_format: - type: string - enum: - - url - - b64_json - default: url - example: url - nullable: true - description: The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. - size: - type: string - enum: - - 256x256 - - 512x512 - - 1024x1024 - default: 1024x1024 - example: 1024x1024 - nullable: true - description: 'The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.' - user: - type: string - example: user-1234 - description: | - A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - required: - - image - responses: {} - securitySchemes: - ApiKeyAuth: - type: http - scheme: bearer - x-stackQL-resources: - image_edits: - id: openai.images.image_edits - name: image_edits - title: Image Edits - methods: - create_image_edit: - operation: - $ref: '#/paths/~1images~1edits/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ImagesResponse' - sqlVerbs: - select: [] - insert: - - $ref: '#/components/x-stackQL-resources/image_edits/methods/create_image_edit' - update: [] - replace: [] - delete: [] - images: - id: openai.images.images - name: images - title: Images - methods: - create_image: - operation: - $ref: '#/paths/~1images~1generations/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ImagesResponse' - sqlVerbs: - select: [] - insert: - - $ref: '#/components/x-stackQL-resources/images/methods/create_image' - update: [] - replace: [] - delete: [] - image_variations: - id: openai.images.image_variations - name: image_variations - title: Image Variations - methods: - create_image_variation: - operation: - $ref: '#/paths/~1images~1variations/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ImagesResponse' - sqlVerbs: - select: [] - insert: - - $ref: '#/components/x-stackQL-resources/image_variations/methods/create_image_variation' - update: [] - replace: [] - delete: [] -paths: - /images/edits: - post: - operationId: createImageEdit - tags: - - Images - summary: Creates an edited or extended image given an original image and a prompt. - requestBody: - required: true - content: - multipart/form-data: - schema: - $ref: '#/components/schemas/CreateImageEditRequest' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ImagesResponse' - x-oaiMeta: - name: Create image edit - group: images - returns: 'Returns a list of [image](/docs/api-reference/images/object) objects.' - examples: - request: - curl: | - curl https://api.openai.com/v1/images/edits \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -F image="@otter.png" \ - -F mask="@mask.png" \ - -F prompt="A cute baby sea otter wearing a beret" \ - -F n=2 \ - -F size="1024x1024" - python: | - from openai import OpenAI - client = OpenAI() - - client.images.edit( - image=open("otter.png", "rb"), - mask=open("mask.png", "rb"), - prompt="A cute baby sea otter wearing a beret", - n=2, - size="1024x1024" - ) - node.js: |- - import fs from "fs"; - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const image = await openai.images.edit({ - image: fs.createReadStream("otter.png"), - mask: fs.createReadStream("mask.png"), - prompt: "A cute baby sea otter wearing a beret", - }); - - console.log(image.data); - } - main(); - response: | - { - "created": 1589478378, - "data": [ - { - "url": "https://..." - }, - { - "url": "https://..." - } - ] - } - /images/generations: - post: - operationId: createImage - tags: - - Images - summary: Creates an image given a prompt. - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CreateImageRequest' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ImagesResponse' - x-oaiMeta: - name: Create image - group: images - returns: 'Returns a list of [image](/docs/api-reference/images/object) objects.' - examples: - request: - curl: | - curl https://api.openai.com/v1/images/generations \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "model": "dall-e-3", - "prompt": "A cute baby sea otter", - "n": 1, - "size": "1024x1024" - }' - python: | - from openai import OpenAI - client = OpenAI() - - client.images.generate( - model="dall-e-3", - prompt="A cute baby sea otter", - n=1, - size="1024x1024" - ) - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const image = await openai.images.generate({ model: "dall-e-3", prompt: "A cute baby sea otter" }); - - console.log(image.data); - } - main(); - response: | - { - "created": 1589478378, - "data": [ - { - "url": "https://..." - }, - { - "url": "https://..." - } - ] - } - /images/variations: - post: - operationId: createImageVariation - tags: - - Images - summary: Creates a variation of a given image. - requestBody: - required: true - content: - multipart/form-data: - schema: - $ref: '#/components/schemas/CreateImageVariationRequest' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ImagesResponse' - x-oaiMeta: - name: Create image variation - group: images - returns: 'Returns a list of [image](/docs/api-reference/images/object) objects.' - examples: - request: - curl: | - curl https://api.openai.com/v1/images/variations \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -F image="@otter.png" \ - -F n=2 \ - -F size="1024x1024" - python: | - from openai import OpenAI - client = OpenAI() - - response = client.images.create_variation( - image=open("image_edit_original.png", "rb"), - n=2, - size="1024x1024" - ) - node.js: |- - import fs from "fs"; - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const image = await openai.images.createVariation({ - image: fs.createReadStream("otter.png"), - }); - - console.log(image.data); - } - main(); - response: | - { - "created": 1589478378, - "data": [ - { - "url": "https://..." - }, - { - "url": "https://..." - } - ] - } diff --git a/providers/src/openai/v00.00.00000/services/invites.yaml b/providers/src/openai/v00.00.00000/services/invites.yaml deleted file mode 100644 index a36d3575..00000000 --- a/providers/src/openai/v00.00.00000/services/invites.yaml +++ /dev/null @@ -1,400 +0,0 @@ -openapi: 3.0.0 -servers: - - url: 'https://api.openai.com/v1' -info: - version: 2.3.0 - termsOfService: 'https://openai.com/policies/terms-of-use' - contact: - name: OpenAI Support - url: 'https://help.openai.com/' - license: - name: MIT - url: 'https://github.com/openai/openai-openapi/blob/master/LICENSE' - title: OpenAI API - invites - description: Invites -security: - - ApiKeyAuth: [] -tags: - - name: Assistants - description: Build Assistants that can call models and use tools. - - name: Audio - description: Turn audio into text or text into audio. - - name: Chat - description: 'Given a list of messages comprising a conversation, the model will return a response.' - - name: Completions - description: 'Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.' - - name: Embeddings - description: Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. - - name: Fine-tuning - description: Manage fine-tuning jobs to tailor a model to your specific training data. - - name: Batch - description: Create large batches of API requests to run asynchronously. - - name: Files - description: Files are used to upload documents that can be used with features like Assistants and Fine-tuning. - - name: Uploads - description: Use Uploads to upload large files in multiple parts. - - name: Images - description: 'Given a prompt and/or an input image, the model will generate a new image.' - - name: Models - description: List and describe the various models available in the API. - - name: Moderations - description: 'Given text and/or image inputs, classifies if those inputs are potentially harmful.' - - name: Audit Logs - description: List user actions and configuration changes within this organization. -components: - schemas: - InviteListResponse: - type: object - properties: - object: - type: string - enum: - - list - description: 'The object type, which is always `list`' - data: - type: array - items: - $ref: '#/components/schemas/Invite' - first_id: - type: string - description: The first `invite_id` in the retrieved `list` - last_id: - type: string - description: The last `invite_id` in the retrieved `list` - has_more: - type: boolean - description: The `has_more` property is used for pagination to indicate there are additional results. - required: - - object - - data - Invite: - type: object - description: Represents an individual `invite` to the organization. - properties: - object: - type: string - enum: - - organization.invite - description: 'The object type, which is always `organization.invite`' - id: - type: string - description: 'The identifier, which can be referenced in API endpoints' - email: - type: string - description: The email address of the individual to whom the invite was sent - role: - type: string - enum: - - owner - - reader - description: '`owner` or `reader`' - status: - type: string - enum: - - accepted - - expired - - pending - description: '`accepted`,`expired`, or `pending`' - invited_at: - type: integer - description: The Unix timestamp (in seconds) of when the invite was sent. - expires_at: - type: integer - description: The Unix timestamp (in seconds) of when the invite expires. - accepted_at: - type: integer - description: The Unix timestamp (in seconds) of when the invite was accepted. - required: - - object - - id - - email - - role - - status - - invited_at - - expires_at - x-oaiMeta: - name: The invite object - example: | - { - "object": "organization.invite", - "id": "invite-abc", - "email": "user@example.com", - "role": "owner", - "status": "accepted", - "invited_at": 1711471533, - "expires_at": 1711471533, - "accepted_at": 1711471533 - } - InviteRequest: - type: object - properties: - email: - type: string - description: Send an email to this address - role: - type: string - enum: - - reader - - owner - description: '`owner` or `reader`' - required: - - email - - role - InviteDeleteResponse: - type: object - properties: - object: - type: string - enum: - - organization.invite.deleted - description: 'The object type, which is always `organization.invite.deleted`' - id: - type: string - deleted: - type: boolean - required: - - object - - id - - deleted - responses: {} - securitySchemes: - ApiKeyAuth: - type: http - scheme: bearer - x-stackQL-resources: - invites: - id: openai.invites.invites - name: invites - title: Invites - methods: - list_invites: - operation: - $ref: '#/paths/~1organization~1invites/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/InviteListResponse' - objectKey: $.data - retrieve_invite: - operation: - $ref: '#/paths/~1organization~1invites~1{invite_id}/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/Invite' - delete_invite: - operation: - $ref: '#/paths/~1organization~1invites~1{invite_id}/delete' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/InviteDeleteResponse' - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/invites/methods/retrieve_invite' - - $ref: '#/components/x-stackQL-resources/invites/methods/list_invites' - insert: [] - update: [] - replace: [] - delete: - - $ref: '#/components/x-stackQL-resources/invites/methods/delete_invite' - users: - id: openai.invites.users - name: users - title: Users - methods: - invite_user: - operation: - $ref: '#/paths/~1organization~1invites/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/Invite' - sqlVerbs: - select: [] - insert: [] - update: [] - replace: [] - delete: [] -paths: - /organization/invites: - get: - summary: Returns a list of invites in the organization. - operationId: list-invites - tags: - - Invites - parameters: - - name: limit - in: query - description: | - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - required: false - schema: - type: integer - default: 20 - - name: after - in: query - 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. - required: false - schema: - type: string - responses: - '200': - description: Invites listed successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/InviteListResponse' - x-oaiMeta: - name: List invites - group: administration - returns: 'A list of [Invite](/docs/api-reference/invite/object) objects.' - examples: - request: - curl: | - curl https://api.openai.com/v1/organization/invites?after=invite-abc&limit=20 \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" - response: - content: | - { - "object": "list", - "data": [ - { - "object": "organization.invite", - "id": "invite-abc", - "email": "user@example.com", - "role": "owner", - "status": "accepted", - "invited_at": 1711471533, - "expires_at": 1711471533, - "accepted_at": 1711471533 - } - ], - "first_id": "invite-abc", - "last_id": "invite-abc", - "has_more": false - } - post: - summary: Create an invite for a user to the organization. The invite must be accepted by the user before they have access to the organization. - operationId: inviteUser - tags: - - Invites - requestBody: - description: The invite request payload. - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/InviteRequest' - responses: - '200': - description: User invited successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/Invite' - x-oaiMeta: - name: Create invite - group: administration - returns: 'The created [Invite](/docs/api-reference/invite/object) object.' - examples: - request: - curl: | - curl -X POST https://api.openai.com/v1/organization/invites \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" \ - -d '{ - "email": "user@example.com", - "role": "owner" - }' - response: - content: | - { - "object": "organization.invite", - "id": "invite-abc", - "email": "user@example.com", - "role": "owner", - "invited_at": 1711471533, - "expires_at": 1711471533, - "accepted_at": null - } - '/organization/invites/{invite_id}': - get: - summary: Retrieves an invite. - operationId: retrieve-invite - tags: - - Invites - parameters: - - in: path - name: invite_id - required: true - schema: - type: string - description: The ID of the invite to retrieve. - responses: - '200': - description: Invite retrieved successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/Invite' - x-oaiMeta: - name: Retrieve invite - group: administration - returns: 'The [Invite](/docs/api-reference/invite/object) object matching the specified ID.' - examples: - request: - curl: | - curl https://api.openai.com/v1/organization/invites/invite-abc \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.invite", - "id": "invite-abc", - "email": "user@example.com", - "role": "owner", - "status": "accepted", - "invited_at": 1711471533, - "expires_at": 1711471533, - "accepted_at": 1711471533 - } - delete: - summary: 'Delete an invite. If the invite has already been accepted, it cannot be deleted.' - operationId: delete-invite - tags: - - Invites - parameters: - - in: path - name: invite_id - required: true - schema: - type: string - description: The ID of the invite to delete. - responses: - '200': - description: Invite deleted successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/InviteDeleteResponse' - x-oaiMeta: - name: Delete invite - group: administration - returns: Confirmation that the invite has been deleted - examples: - request: - curl: | - curl -X DELETE https://api.openai.com/v1/organization/invites/invite-abc \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.invite.deleted", - "id": "invite-abc", - "deleted": true - } diff --git a/providers/src/openai/v00.00.00000/services/models.yaml b/providers/src/openai/v00.00.00000/services/models.yaml index ff4b9af3..06202039 100644 --- a/providers/src/openai/v00.00.00000/services/models.yaml +++ b/providers/src/openai/v00.00.00000/services/models.yaml @@ -1,156 +1,17 @@ -openapi: 3.0.0 -servers: - - url: 'https://api.openai.com/v1' +openapi: 3.1.0 info: + title: models API + description: openai API version: 2.3.0 - termsOfService: 'https://openai.com/policies/terms-of-use' - contact: - name: OpenAI Support - url: 'https://help.openai.com/' - license: - name: MIT - url: 'https://github.com/openai/openai-openapi/blob/master/LICENSE' - title: OpenAI API - models - description: List and describe the various models available in the API. -security: - - ApiKeyAuth: [] -tags: - - name: Assistants - description: Build Assistants that can call models and use tools. - - name: Audio - description: Turn audio into text or text into audio. - - name: Chat - description: 'Given a list of messages comprising a conversation, the model will return a response.' - - name: Completions - description: 'Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.' - - name: Embeddings - description: Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. - - name: Fine-tuning - description: Manage fine-tuning jobs to tailor a model to your specific training data. - - name: Batch - description: Create large batches of API requests to run asynchronously. - - name: Files - description: Files are used to upload documents that can be used with features like Assistants and Fine-tuning. - - name: Uploads - description: Use Uploads to upload large files in multiple parts. - - name: Images - description: 'Given a prompt and/or an input image, the model will generate a new image.' - - name: Models - description: List and describe the various models available in the API. - - name: Moderations - description: 'Given text and/or image inputs, classifies if those inputs are potentially harmful.' - - name: Audit Logs - description: List user actions and configuration changes within this organization. -components: - schemas: - ListModelsResponse: - type: object - properties: - object: - type: string - enum: - - list - data: - type: array - items: - $ref: '#/components/schemas/Model' - required: - - object - - data - Model: - title: Model - description: Describes an OpenAI model offering that can be used with the API. - properties: - id: - type: string - description: 'The model identifier, which can be referenced in the API endpoints.' - created: - type: integer - description: The Unix timestamp (in seconds) when the model was created. - object: - type: string - description: 'The object type, which is always "model".' - enum: - - model - owned_by: - type: string - description: The organization that owns the model. - required: - - id - - object - - created - - owned_by - x-oaiMeta: - name: The model object - example: | - { - "id": "VAR_model_id", - "object": "model", - "created": 1686935002, - "owned_by": "openai" - } - DeleteModelResponse: - type: object - properties: - id: - type: string - deleted: - type: boolean - object: - type: string - required: - - id - - object - - deleted - responses: {} - securitySchemes: - ApiKeyAuth: - type: http - scheme: bearer - x-stackQL-resources: - models: - id: openai.models.models - name: models - title: Models - methods: - list_models: - operation: - $ref: '#/paths/~1models/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ListModelsResponse' - objectKey: $.data - retrieve_model: - operation: - $ref: '#/paths/~1models~1{model}/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/Model' - delete_model: - operation: - $ref: '#/paths/~1models~1{model}/delete' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/DeleteModelResponse' - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/models/methods/retrieve_model' - - $ref: '#/components/x-stackQL-resources/models/methods/list_models' - insert: [] - update: [] - replace: [] - delete: - - $ref: '#/components/x-stackQL-resources/models/methods/delete_model' paths: /models: get: operationId: listModels tags: - Models - summary: 'Lists the currently available models, and provides basic information about each one such as the owner and availability.' + summary: >- + Lists the currently available models, and provides basic information + about each one such as the owner and availability. responses: '200': description: OK @@ -161,18 +22,22 @@ paths: x-oaiMeta: name: List models group: models - returns: 'A list of [model](/docs/api-reference/models/object) objects.' examples: request: curl: | curl https://api.openai.com/v1/models \ -H "Authorization: Bearer $OPENAI_API_KEY" - python: | + python: |- + import os from openai import OpenAI - client = OpenAI() - client.models.list() - node.js: |- + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.models.list() + page = page.data[0] + print(page.id) + javascript: |- import OpenAI from "openai"; const openai = new OpenAI(); @@ -185,6 +50,56 @@ paths: } } main(); + csharp: | + using System; + + using OpenAI.Models; + + OpenAIModelClient client = new( + apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY") + ); + + foreach (var model in client.GetModels().Value) + { + Console.WriteLine(model.Id); + } + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const model of client.models.list()) { + console.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\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.models.ModelListPage; + import com.openai.models.models.ModelListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ModelListPage page = client.models().list(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + page = openai.models.list + + puts(page) response: | { "object": "list", @@ -207,15 +122,35 @@ paths: "created": 1686935002, "owned_by": "openai" }, - ], - "object": "list" + ] } - '/models/{model}': + parameters: + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + /models/{model}: get: operationId: retrieveModel tags: - Models - summary: 'Retrieves a model instance, providing basic information about the model such as the owner and permissioning.' + summary: >- + Retrieves a model instance, providing basic information about the model + such as the owner and permissioning. parameters: - in: path name: model @@ -224,6 +159,24 @@ paths: type: string example: gpt-4o-mini description: The ID of the model to use for this request + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string responses: '200': description: OK @@ -234,32 +187,85 @@ paths: x-oaiMeta: name: Retrieve model group: models - returns: 'The [model](/docs/api-reference/models/object) object matching the specified ID.' examples: request: curl: | - curl https://api.openai.com/v1/models/VAR_model_id \ + curl https://api.openai.com/v1/models/VAR_chat_model_id \ -H "Authorization: Bearer $OPENAI_API_KEY" - python: | + python: |- + import os from openai import OpenAI - client = OpenAI() - client.models.retrieve("VAR_model_id") - node.js: |- + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + model = client.models.retrieve( + "gpt-4o-mini", + ) + print(model.id) + javascript: |- import OpenAI from "openai"; const openai = new OpenAI(); async function main() { - const model = await openai.models.retrieve("VAR_model_id"); + const model = await openai.models.retrieve("VAR_chat_model_id"); console.log(model); } main(); + csharp: | + using System; + using System.ClientModel; + + using OpenAI.Models; + + OpenAIModelClient client = new( + apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY") + ); + + ClientResult model = client.GetModel("babbage-002"); + Console.WriteLine(model.Value.Id); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const model = await client.models.retrieve('gpt-4o-mini'); + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.models.Model; + import com.openai.models.models.ModelRetrieveParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Model model = client.models().retrieve("gpt-4o-mini"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + model = openai.models.retrieve("gpt-4o-mini") + + puts(model) response: | { - "id": "VAR_model_id", + "id": "VAR_chat_model_id", "object": "model", "created": 1686935002, "owned_by": "openai" @@ -268,15 +274,35 @@ paths: operationId: deleteModel tags: - Models - summary: Delete a fine-tuned model. You must have the Owner role in your organization to delete a model. + summary: >- + Delete a fine-tuned model. You must have the Owner role in your + organization to delete a model. parameters: - in: path name: model required: true schema: type: string - example: 'ft:gpt-4o-mini:acemeco:suffix:abc123' + example: ft:gpt-4o-mini:acemeco:suffix:abc123 description: The model to delete + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string responses: '200': description: OK @@ -287,32 +313,214 @@ paths: x-oaiMeta: name: Delete a fine-tuned model group: models - returns: Deletion status. examples: request: - curl: | - curl https://api.openai.com/v1/models/ft:gpt-4o-mini:acemeco:suffix:abc123 \ + curl: > + curl + https://api.openai.com/v1/models/ft:gpt-4o-mini:acemeco:suffix:abc123 + \ -X DELETE \ -H "Authorization: Bearer $OPENAI_API_KEY" - python: | + python: |- + import os from openai import OpenAI - client = OpenAI() - client.models.delete("ft:gpt-4o-mini:acemeco:suffix:abc123") - node.js: |- + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + model_deleted = client.models.delete( + "ft:gpt-4o-mini:acemeco:suffix:abc123", + ) + print(model_deleted.id) + javascript: |- import OpenAI from "openai"; const openai = new OpenAI(); async function main() { - const model = await openai.models.del("ft:gpt-4o-mini:acemeco:suffix:abc123"); - + const model = await openai.models.delete("ft:gpt-4o-mini:acemeco:suffix:abc123"); + console.log(model); } main(); + csharp: > + using System; + + using System.ClientModel; + + + using OpenAI.Models; + + + OpenAIModelClient client = new( + apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY") + ); + + + ClientResult success = + client.DeleteModel("ft:gpt-4o-mini:acemeco:suffix:abc123"); + + Console.WriteLine(success); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const modelDeleted = await + client.models.delete('ft:gpt-4o-mini:acemeco:suffix:abc123'); + + + console.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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.models.ModelDeleteParams; + import com.openai.models.models.ModelDeleted; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ModelDeleted modelDeleted = client.models().delete("ft:gpt-4o-mini:acemeco:suffix:abc123"); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + model_deleted = + openai.models.delete("ft:gpt-4o-mini:acemeco:suffix:abc123") + + + puts(model_deleted) response: | { "id": "ft:gpt-4o-mini:acemeco:suffix:abc123", "object": "model", "deleted": true } +components: + schemas: + ListModelsResponse: + type: object + properties: + object: + type: string + enum: + - list + x-stainless-const: true + data: + type: array + items: + $ref: '#/components/schemas/Model' + required: + - object + - data + Model: + title: Model + description: Describes an OpenAI model offering that can be used with the API. + properties: + id: + type: string + description: The model identifier, which can be referenced in the API endpoints. + created: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) when the model was created. + object: + type: string + description: The object type, which is always "model". + enum: + - model + x-stainless-const: true + owned_by: + type: string + description: The organization that owns the model. + required: + - id + - object + - created + - owned_by + x-oaiMeta: + name: The model object + example: | + { + "id": "VAR_chat_model_id", + "object": "model", + "created": 1686935002, + "owned_by": "openai" + } + type: object + DeleteModelResponse: + type: object + properties: + id: + type: string + deleted: + type: boolean + object: + type: string + required: + - id + - object + - deleted + x-stackQL-resources: + models: + id: openai.models.models + name: models + title: Models + methods: + list: + operation: + $ref: '#/paths/~1models/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + get: + operation: + $ref: '#/paths/~1models~1{model}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1models~1{model}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/models/methods/get' + - $ref: '#/components/x-stackQL-resources/models/methods/list' + insert: [] + update: [] + delete: + - $ref: '#/components/x-stackQL-resources/models/methods/delete' + replace: [] +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.last_id + location: body + queryParamPushdown: + top: + paramName: limit + maxValue: 100 diff --git a/providers/src/openai/v00.00.00000/services/moderations.yaml b/providers/src/openai/v00.00.00000/services/moderations.yaml deleted file mode 100644 index 1ef184cb..00000000 --- a/providers/src/openai/v00.00.00000/services/moderations.yaml +++ /dev/null @@ -1,731 +0,0 @@ -openapi: 3.0.0 -servers: - - url: 'https://api.openai.com/v1' -info: - version: 2.3.0 - termsOfService: 'https://openai.com/policies/terms-of-use' - contact: - name: OpenAI Support - url: 'https://help.openai.com/' - license: - name: MIT - url: 'https://github.com/openai/openai-openapi/blob/master/LICENSE' - title: OpenAI API - moderations - description: 'Given text and/or image inputs, classifies if those inputs are potentially harmful.' -security: - - ApiKeyAuth: [] -tags: - - name: Assistants - description: Build Assistants that can call models and use tools. - - name: Audio - description: Turn audio into text or text into audio. - - name: Chat - description: 'Given a list of messages comprising a conversation, the model will return a response.' - - name: Completions - description: 'Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.' - - name: Embeddings - description: Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. - - name: Fine-tuning - description: Manage fine-tuning jobs to tailor a model to your specific training data. - - name: Batch - description: Create large batches of API requests to run asynchronously. - - name: Files - description: Files are used to upload documents that can be used with features like Assistants and Fine-tuning. - - name: Uploads - description: Use Uploads to upload large files in multiple parts. - - name: Images - description: 'Given a prompt and/or an input image, the model will generate a new image.' - - name: Models - description: List and describe the various models available in the API. - - name: Moderations - description: 'Given text and/or image inputs, classifies if those inputs are potentially harmful.' - - name: Audit Logs - description: List user actions and configuration changes within this organization. -components: - schemas: - CreateModerationRequest: - type: object - properties: - input: - description: | - Input (or inputs) to classify. Can be a single string, an array of strings, or - an array of multi-modal input objects similar to other models. - oneOf: - - type: string - description: A string of text to classify for moderation. - default: '' - example: I want to kill them. - - type: array - description: An array of strings to classify for moderation. - items: - type: string - default: '' - example: I want to kill them. - - type: array - description: An array of multi-modal inputs to the moderation model. - items: - x-oaiExpandable: true - oneOf: - - type: object - description: An object describing an image to classify. - properties: - type: - description: Always `image_url`. - type: string - enum: - - image_url - image_url: - type: object - description: Contains either an image URL or a data URL for a base64 encoded image. - properties: - url: - type: string - description: Either a URL of the image or the base64 encoded image data. - format: uri - example: 'https://example.com/image.jpg' - required: - - url - required: - - type - - image_url - - type: object - description: An object describing text to classify. - properties: - type: - description: Always `text`. - type: string - enum: - - text - text: - description: A string of text to classify. - type: string - example: I want to kill them - required: - - type - - text - x-oaiExpandable: true - model: - description: | - The content moderation model you would like to use. Learn more in - [the moderation guide](/docs/guides/moderation), and learn about - available models [here](/docs/models/moderation). - nullable: false - default: omni-moderation-latest - example: omni-moderation-2024-09-26 - anyOf: - - type: string - - type: string - enum: - - omni-moderation-latest - - omni-moderation-2024-09-26 - - text-moderation-latest - - text-moderation-stable - x-oaiTypeLabel: string - required: - - input - CreateModerationResponse: - type: object - description: Represents if a given text input is potentially harmful. - properties: - id: - type: string - description: The unique identifier for the moderation request. - model: - type: string - description: The model used to generate the moderation results. - results: - type: array - description: A list of moderation objects. - items: - type: object - properties: - flagged: - type: boolean - description: Whether any of the below categories are flagged. - categories: - type: object - description: 'A list of the categories, and whether they are flagged or not.' - properties: - hate: - type: boolean - description: 'Content that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. Hateful content aimed at non-protected groups (e.g., chess players) is harassment.' - hate/threatening: - type: boolean - description: 'Hateful content that also includes violence or serious harm towards the targeted group based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste.' - harassment: - type: boolean - description: 'Content that expresses, incites, or promotes harassing language towards any target.' - harassment/threatening: - type: boolean - description: Harassment content that also includes violence or serious harm towards any target. - illicit: - type: boolean - description: 'Content that includes instructions or advice that facilitate the planning or execution of wrongdoing, or that gives advice or instruction on how to commit illicit acts. For example, "how to shoplift" would fit this category.' - illicit/violent: - type: boolean - description: 'Content that includes instructions or advice that facilitate the planning or execution of wrongdoing that also includes violence, or that gives advice or instruction on the procurement of any weapon.' - self-harm: - type: boolean - description: 'Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.' - self-harm/intent: - type: boolean - description: 'Content where the speaker expresses that they are engaging or intend to engage in acts of self-harm, such as suicide, cutting, and eating disorders.' - self-harm/instructions: - type: boolean - description: 'Content that encourages performing acts of self-harm, such as suicide, cutting, and eating disorders, or that gives instructions or advice on how to commit such acts.' - sexual: - type: boolean - description: 'Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).' - sexual/minors: - type: boolean - description: Sexual content that includes an individual who is under 18 years old. - violence: - type: boolean - description: 'Content that depicts death, violence, or physical injury.' - violence/graphic: - type: boolean - description: 'Content that depicts death, violence, or physical injury in graphic detail.' - required: - - hate - - hate/threatening - - harassment - - harassment/threatening - - illicit - - illicit/violent - - self-harm - - self-harm/intent - - self-harm/instructions - - sexual - - sexual/minors - - violence - - violence/graphic - category_scores: - type: object - description: A list of the categories along with their scores as predicted by model. - properties: - hate: - type: number - description: The score for the category 'hate'. - hate/threatening: - type: number - description: The score for the category 'hate/threatening'. - harassment: - type: number - description: The score for the category 'harassment'. - harassment/threatening: - type: number - description: The score for the category 'harassment/threatening'. - illicit: - type: number - description: The score for the category 'illicit'. - illicit/violent: - type: number - description: The score for the category 'illicit/violent'. - self-harm: - type: number - description: The score for the category 'self-harm'. - self-harm/intent: - type: number - description: The score for the category 'self-harm/intent'. - self-harm/instructions: - type: number - description: The score for the category 'self-harm/instructions'. - sexual: - type: number - description: The score for the category 'sexual'. - sexual/minors: - type: number - description: The score for the category 'sexual/minors'. - violence: - type: number - description: The score for the category 'violence'. - violence/graphic: - type: number - description: The score for the category 'violence/graphic'. - required: - - hate - - hate/threatening - - harassment - - harassment/threatening - - illicit - - illicit/violent - - self-harm - - self-harm/intent - - self-harm/instructions - - sexual - - sexual/minors - - violence - - violence/graphic - category_applied_input_types: - type: object - description: A list of the categories along with the input type(s) that the score applies to. - properties: - hate: - type: array - description: The applied input type(s) for the category 'hate'. - items: - type: string - enum: - - text - hate/threatening: - type: array - description: The applied input type(s) for the category 'hate/threatening'. - items: - type: string - enum: - - text - harassment: - type: array - description: The applied input type(s) for the category 'harassment'. - items: - type: string - enum: - - text - harassment/threatening: - type: array - description: The applied input type(s) for the category 'harassment/threatening'. - items: - type: string - enum: - - text - illicit: - type: array - description: The applied input type(s) for the category 'illicit'. - items: - type: string - enum: - - text - illicit/violent: - type: array - description: The applied input type(s) for the category 'illicit/violent'. - items: - type: string - enum: - - text - self-harm: - type: array - description: The applied input type(s) for the category 'self-harm'. - items: - type: string - enum: - - text - - image - self-harm/intent: - type: array - description: The applied input type(s) for the category 'self-harm/intent'. - items: - type: string - enum: - - text - - image - self-harm/instructions: - type: array - description: The applied input type(s) for the category 'self-harm/instructions'. - items: - type: string - enum: - - text - - image - sexual: - type: array - description: The applied input type(s) for the category 'sexual'. - items: - type: string - enum: - - text - - image - sexual/minors: - type: array - description: The applied input type(s) for the category 'sexual/minors'. - items: - type: string - enum: - - text - violence: - type: array - description: The applied input type(s) for the category 'violence'. - items: - type: string - enum: - - text - - image - violence/graphic: - type: array - description: The applied input type(s) for the category 'violence/graphic'. - items: - type: string - enum: - - text - - image - required: - - hate - - hate/threatening - - harassment - - harassment/threatening - - illicit - - illicit/violent - - self-harm - - self-harm/intent - - self-harm/instructions - - sexual - - sexual/minors - - violence - - violence/graphic - required: - - flagged - - categories - - category_scores - - category_applied_input_types - required: - - id - - model - - results - x-oaiMeta: - name: The moderation object - example: | - { - "id": "modr-0d9740456c391e43c445bf0f010940c7", - "model": "omni-moderation-latest", - "results": [ - { - "flagged": true, - "categories": { - "harassment": true, - "harassment/threatening": true, - "sexual": false, - "hate": false, - "hate/threatening": false, - "illicit": false, - "illicit/violent": false, - "self-harm/intent": false, - "self-harm/instructions": false, - "self-harm": false, - "sexual/minors": false, - "violence": true, - "violence/graphic": true - }, - "category_scores": { - "harassment": 0.8189693396524255, - "harassment/threatening": 0.804985420696006, - "sexual": 1.573112165348997e-6, - "hate": 0.007562942636942845, - "hate/threatening": 0.004208854591835476, - "illicit": 0.030535955153511665, - "illicit/violent": 0.008925306722380033, - "self-harm/intent": 0.00023023930975076432, - "self-harm/instructions": 0.0002293869201073356, - "self-harm": 0.012598046106750154, - "sexual/minors": 2.212566909570261e-8, - "violence": 0.9999992735124786, - "violence/graphic": 0.843064871157054 - }, - "category_applied_input_types": { - "harassment": [ - "text" - ], - "harassment/threatening": [ - "text" - ], - "sexual": [ - "text", - "image" - ], - "hate": [ - "text" - ], - "hate/threatening": [ - "text" - ], - "illicit": [ - "text" - ], - "illicit/violent": [ - "text" - ], - "self-harm/intent": [ - "text", - "image" - ], - "self-harm/instructions": [ - "text", - "image" - ], - "self-harm": [ - "text", - "image" - ], - "sexual/minors": [ - "text" - ], - "violence": [ - "text", - "image" - ], - "violence/graphic": [ - "text", - "image" - ] - } - } - ] - } - responses: {} - securitySchemes: - ApiKeyAuth: - type: http - scheme: bearer - x-stackQL-resources: - moderations: - id: openai.moderations.moderations - name: moderations - title: Moderations - methods: - create_moderation: - operation: - $ref: '#/paths/~1moderations/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/CreateModerationResponse' - sqlVerbs: - select: [] - insert: - - $ref: '#/components/x-stackQL-resources/moderations/methods/create_moderation' - update: [] - replace: [] - delete: [] -paths: - /moderations: - post: - operationId: createModeration - tags: - - Moderations - summary: | - Classifies if text and/or image inputs are potentially harmful. Learn - more in the [moderation guide](/docs/guides/moderation). - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CreateModerationRequest' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/CreateModerationResponse' - x-oaiMeta: - name: Create moderation - group: moderations - returns: 'A [moderation](/docs/api-reference/moderations/object) object.' - examples: - - title: Single string - request: - curl: | - curl https://api.openai.com/v1/moderations \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "input": "I want to kill them." - }' - python: | - from openai import OpenAI - client = OpenAI() - - moderation = client.moderations.create(input="I want to kill them.") - print(moderation) - node.js: | - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const moderation = await openai.moderations.create({ input: "I want to kill them." }); - - console.log(moderation); - } - main(); - response: | - { - "id": "modr-AB8CjOTu2jiq12hp1AQPfeqFWaORR", - "model": "text-moderation-007", - "results": [ - { - "flagged": true, - "categories": { - "sexual": false, - "hate": false, - "harassment": true, - "self-harm": false, - "sexual/minors": false, - "hate/threatening": false, - "violence/graphic": false, - "self-harm/intent": false, - "self-harm/instructions": false, - "harassment/threatening": true, - "violence": true - }, - "category_scores": { - "sexual": 0.000011726012417057063, - "hate": 0.22706663608551025, - "harassment": 0.5215635299682617, - "self-harm": 2.227119921371923e-6, - "sexual/minors": 7.107352217872176e-8, - "hate/threatening": 0.023547329008579254, - "violence/graphic": 0.00003391829886822961, - "self-harm/intent": 1.646940972932498e-6, - "self-harm/instructions": 1.1198755256458526e-9, - "harassment/threatening": 0.5694745779037476, - "violence": 0.9971134662628174 - } - } - ] - } - - title: Image and text - request: - curl: | - curl https://api.openai.com/v1/moderations \ - -X POST \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "model": "omni-moderation-latest", - "input": [ - { "type": "text", "text": "...text to classify goes here..." }, - { - "type": "image_url", - "image_url": { - "url": "https://example.com/image.png" - } - } - ] - }' - python: | - from openai import OpenAI - client = OpenAI() - - response = client.moderations.create( - model="omni-moderation-latest", - input=[ - {"type": "text", "text": "...text to classify goes here..."}, - { - "type": "image_url", - "image_url": { - "url": "https://example.com/image.png", - # can also use base64 encoded image URLs - # "url": "data:image/jpeg;base64,abcdefg..." - } - }, - ], - ) - - print(response) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); - - const moderation = await openai.moderations.create({ - model: "omni-moderation-latest", - input: [ - { type: "text", text: "...text to classify goes here..." }, - { - type: "image_url", - image_url: { - url: "https://example.com/image.png" - // can also use base64 encoded image URLs - // url: "data:image/jpeg;base64,abcdefg..." - } - } - ], - }); - - console.log(moderation); - response: | - { - "id": "modr-0d9740456c391e43c445bf0f010940c7", - "model": "omni-moderation-latest", - "results": [ - { - "flagged": true, - "categories": { - "harassment": true, - "harassment/threatening": true, - "sexual": false, - "hate": false, - "hate/threatening": false, - "illicit": false, - "illicit/violent": false, - "self-harm/intent": false, - "self-harm/instructions": false, - "self-harm": false, - "sexual/minors": false, - "violence": true, - "violence/graphic": true - }, - "category_scores": { - "harassment": 0.8189693396524255, - "harassment/threatening": 0.804985420696006, - "sexual": 1.573112165348997e-6, - "hate": 0.007562942636942845, - "hate/threatening": 0.004208854591835476, - "illicit": 0.030535955153511665, - "illicit/violent": 0.008925306722380033, - "self-harm/intent": 0.00023023930975076432, - "self-harm/instructions": 0.0002293869201073356, - "self-harm": 0.012598046106750154, - "sexual/minors": 2.212566909570261e-8, - "violence": 0.9999992735124786, - "violence/graphic": 0.843064871157054 - }, - "category_applied_input_types": { - "harassment": [ - "text" - ], - "harassment/threatening": [ - "text" - ], - "sexual": [ - "text", - "image" - ], - "hate": [ - "text" - ], - "hate/threatening": [ - "text" - ], - "illicit": [ - "text" - ], - "illicit/violent": [ - "text" - ], - "self-harm/intent": [ - "text", - "image" - ], - "self-harm/instructions": [ - "text", - "image" - ], - "self-harm": [ - "text", - "image" - ], - "sexual/minors": [ - "text" - ], - "violence": [ - "text", - "image" - ], - "violence/graphic": [ - "text", - "image" - ] - } - } - ] - } diff --git a/providers/src/openai/v00.00.00000/services/projects.yaml b/providers/src/openai/v00.00.00000/services/projects.yaml deleted file mode 100644 index 973c6522..00000000 --- a/providers/src/openai/v00.00.00000/services/projects.yaml +++ /dev/null @@ -1,1615 +0,0 @@ -openapi: 3.0.0 -servers: - - url: 'https://api.openai.com/v1' -info: - version: 2.3.0 - termsOfService: 'https://openai.com/policies/terms-of-use' - contact: - name: OpenAI Support - url: 'https://help.openai.com/' - license: - name: MIT - url: 'https://github.com/openai/openai-openapi/blob/master/LICENSE' - title: OpenAI API - projects - description: Projects -security: - - ApiKeyAuth: [] -tags: - - name: Assistants - description: Build Assistants that can call models and use tools. - - name: Audio - description: Turn audio into text or text into audio. - - name: Chat - description: 'Given a list of messages comprising a conversation, the model will return a response.' - - name: Completions - description: 'Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.' - - name: Embeddings - description: Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. - - name: Fine-tuning - description: Manage fine-tuning jobs to tailor a model to your specific training data. - - name: Batch - description: Create large batches of API requests to run asynchronously. - - name: Files - description: Files are used to upload documents that can be used with features like Assistants and Fine-tuning. - - name: Uploads - description: Use Uploads to upload large files in multiple parts. - - name: Images - description: 'Given a prompt and/or an input image, the model will generate a new image.' - - name: Models - description: List and describe the various models available in the API. - - name: Moderations - description: 'Given text and/or image inputs, classifies if those inputs are potentially harmful.' - - name: Audit Logs - description: List user actions and configuration changes within this organization. -components: - schemas: - ProjectListResponse: - type: object - properties: - object: - type: string - enum: - - list - data: - type: array - items: - $ref: '#/components/schemas/Project' - first_id: - type: string - last_id: - type: string - has_more: - type: boolean - required: - - object - - data - - first_id - - last_id - - has_more - Project: - type: object - description: Represents an individual project. - properties: - id: - type: string - description: 'The identifier, which can be referenced in API endpoints' - object: - type: string - enum: - - organization.project - description: 'The object type, which is always `organization.project`' - name: - type: string - description: The name of the project. This appears in reporting. - created_at: - type: integer - description: The Unix timestamp (in seconds) of when the project was created. - archived_at: - type: integer - nullable: true - description: The Unix timestamp (in seconds) of when the project was archived or `null`. - status: - type: string - enum: - - active - - archived - description: '`active` or `archived`' - required: - - id - - object - - name - - created_at - - status - x-oaiMeta: - name: The project object - example: | - { - "id": "proj_abc", - "object": "organization.project", - "name": "Project example", - "created_at": 1711471533, - "archived_at": null, - "status": "active" - } - ProjectCreateRequest: - type: object - properties: - name: - type: string - description: 'The friendly name of the project, this name appears in reports.' - required: - - name - ProjectUpdateRequest: - type: object - properties: - name: - type: string - description: 'The updated name of the project, this name appears in reports.' - required: - - name - ErrorResponse: - type: object - properties: - error: - $ref: '#/components/schemas/Error' - required: - - error - Error: - type: object - properties: - code: - type: string - nullable: true - message: - type: string - nullable: false - param: - type: string - nullable: true - type: - type: string - nullable: false - required: - - type - - message - - param - - code - ProjectApiKeyListResponse: - type: object - properties: - object: - type: string - enum: - - list - data: - type: array - items: - $ref: '#/components/schemas/ProjectApiKey' - first_id: - type: string - last_id: - type: string - has_more: - type: boolean - required: - - object - - data - - first_id - - last_id - - has_more - ProjectApiKey: - type: object - description: Represents an individual API key in a project. - properties: - object: - type: string - enum: - - organization.project.api_key - description: 'The object type, which is always `organization.project.api_key`' - redacted_value: - type: string - description: The redacted value of the API key - name: - type: string - description: The name of the API key - created_at: - type: integer - description: The Unix timestamp (in seconds) of when the API key was created - id: - type: string - description: 'The identifier, which can be referenced in API endpoints' - owner: - type: object - properties: - type: - type: string - enum: - - user - - service_account - description: '`user` or `service_account`' - user: - $ref: '#/components/schemas/ProjectUser' - service_account: - $ref: '#/components/schemas/ProjectServiceAccount' - required: - - object - - redacted_value - - name - - created_at - - id - - owner - x-oaiMeta: - name: The project API key object - example: | - { - "object": "organization.project.api_key", - "redacted_value": "sk-abc...def", - "name": "My API Key", - "created_at": 1711471533, - "id": "key_abc", - "owner": { - "type": "user", - "user": { - "object": "organization.project.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "created_at": 1711471533 - } - } - } - ProjectUser: - type: object - description: Represents an individual user in a project. - properties: - object: - type: string - enum: - - organization.project.user - description: 'The object type, which is always `organization.project.user`' - id: - type: string - description: 'The identifier, which can be referenced in API endpoints' - name: - type: string - description: The name of the user - email: - type: string - description: The email address of the user - role: - type: string - enum: - - owner - - member - description: '`owner` or `member`' - added_at: - type: integer - description: The Unix timestamp (in seconds) of when the project was added. - required: - - object - - id - - name - - email - - role - - added_at - x-oaiMeta: - name: The project user object - example: | - { - "object": "organization.project.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } - ProjectServiceAccount: - type: object - description: Represents an individual service account in a project. - properties: - object: - type: string - enum: - - organization.project.service_account - description: 'The object type, which is always `organization.project.service_account`' - id: - type: string - description: 'The identifier, which can be referenced in API endpoints' - name: - type: string - description: The name of the service account - role: - type: string - enum: - - owner - - member - description: '`owner` or `member`' - created_at: - type: integer - description: The Unix timestamp (in seconds) of when the service account was created - required: - - object - - id - - name - - role - - created_at - x-oaiMeta: - name: The project service account object - example: | - { - "object": "organization.project.service_account", - "id": "svc_acct_abc", - "name": "Service Account", - "role": "owner", - "created_at": 1711471533 - } - ProjectApiKeyDeleteResponse: - type: object - properties: - object: - type: string - enum: - - organization.project.api_key.deleted - id: - type: string - deleted: - type: boolean - required: - - object - - id - - deleted - ProjectServiceAccountListResponse: - type: object - properties: - object: - type: string - enum: - - list - data: - type: array - items: - $ref: '#/components/schemas/ProjectServiceAccount' - first_id: - type: string - last_id: - type: string - has_more: - type: boolean - required: - - object - - data - - first_id - - last_id - - has_more - ProjectServiceAccountCreateRequest: - type: object - properties: - name: - type: string - description: The name of the service account being created. - required: - - name - ProjectServiceAccountCreateResponse: - type: object - properties: - object: - type: string - enum: - - organization.project.service_account - id: - type: string - name: - type: string - role: - type: string - enum: - - member - description: Service accounts can only have one role of type `member` - created_at: - type: integer - api_key: - $ref: '#/components/schemas/ProjectServiceAccountApiKey' - required: - - object - - id - - name - - role - - created_at - - api_key - ProjectServiceAccountApiKey: - type: object - properties: - object: - type: string - enum: - - organization.project.service_account.api_key - description: 'The object type, which is always `organization.project.service_account.api_key`' - value: - type: string - name: - type: string - created_at: - type: integer - id: - type: string - required: - - object - - value - - name - - created_at - - id - ProjectServiceAccountDeleteResponse: - type: object - properties: - object: - type: string - enum: - - organization.project.service_account.deleted - id: - type: string - deleted: - type: boolean - required: - - object - - id - - deleted - ProjectUserListResponse: - type: object - properties: - object: - type: string - data: - type: array - items: - $ref: '#/components/schemas/ProjectUser' - first_id: - type: string - last_id: - type: string - has_more: - type: boolean - required: - - object - - data - - first_id - - last_id - - has_more - ProjectUserCreateRequest: - type: object - properties: - user_id: - type: string - description: The ID of the user. - role: - type: string - enum: - - owner - - member - description: '`owner` or `member`' - required: - - user_id - - role - ProjectUserUpdateRequest: - type: object - properties: - role: - type: string - enum: - - owner - - member - description: '`owner` or `member`' - required: - - role - ProjectUserDeleteResponse: - type: object - properties: - object: - type: string - enum: - - organization.project.user.deleted - id: - type: string - deleted: - type: boolean - required: - - object - - id - - deleted - responses: {} - securitySchemes: - ApiKeyAuth: - type: http - scheme: bearer - x-stackQL-resources: - projects: - id: openai.projects.projects - name: projects - title: Projects - methods: - list_projects: - operation: - $ref: '#/paths/~1organization~1projects/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ProjectListResponse' - objectKey: $.data - create_project: - operation: - $ref: '#/paths/~1organization~1projects/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/Project' - retrieve_project: - operation: - $ref: '#/paths/~1organization~1projects~1{project_id}/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/Project' - modify_project: - operation: - $ref: '#/paths/~1organization~1projects~1{project_id}/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/Project' - archive_project: - operation: - $ref: '#/paths/~1organization~1projects~1{project_id}~1archive/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/Project' - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/projects/methods/retrieve_project' - - $ref: '#/components/x-stackQL-resources/projects/methods/list_projects' - insert: - - $ref: '#/components/x-stackQL-resources/projects/methods/create_project' - update: - - $ref: '#/components/x-stackQL-resources/projects/methods/modify_project' - replace: [] - delete: [] - project_api_keys: - id: openai.projects.project_api_keys - name: project_api_keys - title: Project Api Keys - methods: - list_project_api_keys: - operation: - $ref: '#/paths/~1organization~1projects~1{project_id}~1api_keys/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ProjectApiKeyListResponse' - objectKey: $.data - retrieve_project_api_key: - operation: - $ref: '#/paths/~1organization~1projects~1{project_id}~1api_keys~1{key_id}/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ProjectApiKey' - delete_project_api_key: - operation: - $ref: '#/paths/~1organization~1projects~1{project_id}~1api_keys~1{key_id}/delete' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ProjectApiKeyDeleteResponse' - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/project_api_keys/methods/retrieve_project_api_key' - - $ref: '#/components/x-stackQL-resources/project_api_keys/methods/list_project_api_keys' - insert: [] - update: [] - replace: [] - delete: - - $ref: '#/components/x-stackQL-resources/project_api_keys/methods/delete_project_api_key' - project_service_accounts: - id: openai.projects.project_service_accounts - name: project_service_accounts - title: Project Service Accounts - methods: - list_project_service_accounts: - operation: - $ref: '#/paths/~1organization~1projects~1{project_id}~1service_accounts/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ProjectServiceAccountListResponse' - objectKey: $.data - create_project_service_account: - operation: - $ref: '#/paths/~1organization~1projects~1{project_id}~1service_accounts/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ProjectServiceAccountCreateResponse' - retrieve_project_service_account: - operation: - $ref: '#/paths/~1organization~1projects~1{project_id}~1service_accounts~1{service_account_id}/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ProjectServiceAccount' - delete_project_service_account: - operation: - $ref: '#/paths/~1organization~1projects~1{project_id}~1service_accounts~1{service_account_id}/delete' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ProjectServiceAccountDeleteResponse' - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/project_service_accounts/methods/retrieve_project_service_account' - - $ref: '#/components/x-stackQL-resources/project_service_accounts/methods/list_project_service_accounts' - insert: - - $ref: '#/components/x-stackQL-resources/project_service_accounts/methods/create_project_service_account' - update: [] - replace: [] - delete: - - $ref: '#/components/x-stackQL-resources/project_service_accounts/methods/delete_project_service_account' - project_users: - id: openai.projects.project_users - name: project_users - title: Project Users - methods: - list_project_users: - operation: - $ref: '#/paths/~1organization~1projects~1{project_id}~1users/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ProjectUserListResponse' - objectKey: $.data - create_project_user: - operation: - $ref: '#/paths/~1organization~1projects~1{project_id}~1users/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ProjectUser' - retrieve_project_user: - operation: - $ref: '#/paths/~1organization~1projects~1{project_id}~1users~1{user_id}/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ProjectUser' - modify_project_user: - operation: - $ref: '#/paths/~1organization~1projects~1{project_id}~1users~1{user_id}/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ProjectUser' - delete_project_user: - operation: - $ref: '#/paths/~1organization~1projects~1{project_id}~1users~1{user_id}/delete' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ProjectUserDeleteResponse' - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/project_users/methods/retrieve_project_user' - - $ref: '#/components/x-stackQL-resources/project_users/methods/list_project_users' - insert: - - $ref: '#/components/x-stackQL-resources/project_users/methods/create_project_user' - update: - - $ref: '#/components/x-stackQL-resources/project_users/methods/modify_project_user' - replace: [] - delete: - - $ref: '#/components/x-stackQL-resources/project_users/methods/delete_project_user' -paths: - /organization/projects: - get: - summary: Returns a list of projects. - operationId: list-projects - tags: - - Projects - parameters: - - name: limit - in: query - description: | - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - required: false - schema: - type: integer - default: 20 - - name: after - in: query - 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. - required: false - schema: - type: string - - name: include_archived - in: query - schema: - type: boolean - default: false - description: If `true` returns all projects including those that have been `archived`. Archived projects are not included by default. - responses: - '200': - description: Projects listed successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/ProjectListResponse' - x-oaiMeta: - name: List projects - group: administration - returns: 'A list of [Project](/docs/api-reference/projects/object) objects.' - examples: - request: - curl: | - curl https://api.openai.com/v1/organization/projects?after=proj_abc&limit=20&include_archived=false \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" - response: - content: | - { - "object": "list", - "data": [ - { - "id": "proj_abc", - "object": "organization.project", - "name": "Project example", - "created_at": 1711471533, - "archived_at": null, - "status": "active" - } - ], - "first_id": "proj-abc", - "last_id": "proj-xyz", - "has_more": false - } - post: - summary: 'Create a new project in the organization. Projects can be created and archived, but cannot be deleted.' - operationId: create-project - tags: - - Projects - requestBody: - description: The project create request payload. - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/ProjectCreateRequest' - responses: - '200': - description: Project created successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/Project' - x-oaiMeta: - name: Create project - group: administration - returns: 'The created [Project](/docs/api-reference/projects/object) object.' - examples: - request: - curl: | - curl -X POST https://api.openai.com/v1/organization/projects \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" \ - -d '{ - "name": "Project ABC" - }' - response: - content: | - { - "id": "proj_abc", - "object": "organization.project", - "name": "Project ABC", - "created_at": 1711471533, - "archived_at": null, - "status": "active" - } - '/organization/projects/{project_id}': - get: - summary: Retrieves a project. - operationId: retrieve-project - tags: - - Projects - parameters: - - name: project_id - in: path - description: The ID of the project. - required: true - schema: - type: string - responses: - '200': - description: Project retrieved successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/Project' - x-oaiMeta: - name: Retrieve project - group: administration - description: Retrieve a project. - returns: 'The [Project](/docs/api-reference/projects/object) object matching the specified ID.' - examples: - request: - curl: | - curl https://api.openai.com/v1/organization/projects/proj_abc \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" - response: - content: | - { - "id": "proj_abc", - "object": "organization.project", - "name": "Project example", - "created_at": 1711471533, - "archived_at": null, - "status": "active" - } - post: - summary: Modifies a project in the organization. - operationId: modify-project - tags: - - Projects - parameters: - - name: project_id - in: path - description: The ID of the project. - required: true - schema: - type: string - requestBody: - description: The project update request payload. - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/ProjectUpdateRequest' - responses: - '200': - description: Project updated successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/Project' - '400': - description: Error response when updating the default project. - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorResponse' - x-oaiMeta: - name: Modify project - group: administration - returns: 'The updated [Project](/docs/api-reference/projects/object) object.' - examples: - request: - curl: | - curl -X POST https://api.openai.com/v1/organization/projects/proj_abc \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" \ - -d '{ - "name": "Project DEF" - }' - '/organization/projects/{project_id}/api_keys': - get: - summary: Returns a list of API keys in the project. - operationId: list-project-api-keys - tags: - - Projects - parameters: - - name: project_id - in: path - description: The ID of the project. - required: true - schema: - type: string - - name: limit - in: query - description: | - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - required: false - schema: - type: integer - default: 20 - - name: after - in: query - 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. - required: false - schema: - type: string - responses: - '200': - description: Project API keys listed successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/ProjectApiKeyListResponse' - x-oaiMeta: - name: List project API keys - group: administration - returns: 'A list of [ProjectApiKey](/docs/api-reference/project-api-keys/object) objects.' - examples: - request: - curl: | - curl https://api.openai.com/v1/organization/projects/proj_abc/api_keys?after=key_abc&limit=20 \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" - response: - content: | - { - "object": "list", - "data": [ - { - "object": "organization.project.api_key", - "redacted_value": "sk-abc...def", - "name": "My API Key", - "created_at": 1711471533, - "id": "key_abc", - "owner": { - "type": "user", - "user": { - "object": "organization.project.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } - } - } - ], - "first_id": "key_abc", - "last_id": "key_xyz", - "has_more": false - } - error_response: - content: | - { - "code": 400, - "message": "Project {name} is archived" - } - '/organization/projects/{project_id}/api_keys/{key_id}': - get: - summary: Retrieves an API key in the project. - operationId: retrieve-project-api-key - tags: - - Projects - parameters: - - name: project_id - in: path - description: The ID of the project. - required: true - schema: - type: string - - name: key_id - in: path - description: The ID of the API key. - required: true - schema: - type: string - responses: - '200': - description: Project API key retrieved successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/ProjectApiKey' - x-oaiMeta: - name: Retrieve project API key - group: administration - returns: 'The [ProjectApiKey](/docs/api-reference/project-api-keys/object) object matching the specified ID.' - examples: - request: - curl: | - curl https://api.openai.com/v1/organization/projects/proj_abc/api_keys/key_abc \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.project.api_key", - "redacted_value": "sk-abc...def", - "name": "My API Key", - "created_at": 1711471533, - "id": "key_abc", - "owner": { - "type": "user", - "user": { - "object": "organization.project.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } - } - } - delete: - summary: Deletes an API key from the project. - operationId: delete-project-api-key - tags: - - Projects - parameters: - - name: project_id - in: path - description: The ID of the project. - required: true - schema: - type: string - - name: key_id - in: path - description: The ID of the API key. - required: true - schema: - type: string - responses: - '200': - description: Project API key deleted successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/ProjectApiKeyDeleteResponse' - '400': - description: Error response for various conditions. - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorResponse' - x-oaiMeta: - name: Delete project API key - group: administration - returns: Confirmation of the key's deletion or an error if the key belonged to a service account - examples: - request: - curl: | - curl -X DELETE https://api.openai.com/v1/organization/projects/proj_abc/api_keys/key_abc \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.project.api_key.deleted", - "id": "key_abc", - "deleted": true - } - error_response: - content: | - { - "code": 400, - "message": "API keys cannot be deleted for service accounts, please delete the service account" - } - '/organization/projects/{project_id}/archive': - post: - summary: Archives a project in the organization. Archived projects cannot be used or updated. - operationId: archive-project - tags: - - Projects - parameters: - - name: project_id - in: path - description: The ID of the project. - required: true - schema: - type: string - responses: - '200': - description: Project archived successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/Project' - x-oaiMeta: - name: Archive project - group: administration - returns: 'The archived [Project](/docs/api-reference/projects/object) object.' - examples: - request: - curl: | - curl -X POST https://api.openai.com/v1/organization/projects/proj_abc/archive \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" - response: - content: | - { - "id": "proj_abc", - "object": "organization.project", - "name": "Project DEF", - "created_at": 1711471533, - "archived_at": 1711471533, - "status": "archived" - } - '/organization/projects/{project_id}/service_accounts': - get: - summary: Returns a list of service accounts in the project. - operationId: list-project-service-accounts - tags: - - Projects - parameters: - - name: project_id - in: path - description: The ID of the project. - required: true - schema: - type: string - - name: limit - in: query - description: | - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - required: false - schema: - type: integer - default: 20 - - name: after - in: query - 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. - required: false - schema: - type: string - responses: - '200': - description: Project service accounts listed successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/ProjectServiceAccountListResponse' - '400': - description: Error response when project is archived. - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorResponse' - x-oaiMeta: - name: List project service accounts - group: administration - returns: 'A list of [ProjectServiceAccount](/docs/api-reference/project-service-accounts/object) objects.' - examples: - request: - curl: | - curl https://api.openai.com/v1/organization/projects/proj_abc/service_accounts?after=custom_id&limit=20 \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" - response: - content: | - { - "object": "list", - "data": [ - { - "object": "organization.project.service_account", - "id": "svc_acct_abc", - "name": "Service Account", - "role": "owner", - "created_at": 1711471533 - } - ], - "first_id": "svc_acct_abc", - "last_id": "svc_acct_xyz", - "has_more": false - } - post: - summary: Creates a new service account in the project. This also returns an unredacted API key for the service account. - operationId: create-project-service-account - tags: - - Projects - parameters: - - name: project_id - in: path - description: The ID of the project. - required: true - schema: - type: string - requestBody: - description: The project service account create request payload. - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/ProjectServiceAccountCreateRequest' - responses: - '200': - description: Project service account created successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/ProjectServiceAccountCreateResponse' - '400': - description: Error response when project is archived. - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorResponse' - x-oaiMeta: - name: Create project service account - group: administration - returns: 'The created [ProjectServiceAccount](/docs/api-reference/project-service-accounts/object) object.' - examples: - request: - curl: | - curl -X POST https://api.openai.com/v1/organization/projects/proj_abc/service_accounts \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" \ - -d '{ - "name": "Production App" - }' - response: - content: | - { - "object": "organization.project.service_account", - "id": "svc_acct_abc", - "name": "Production App", - "role": "member", - "created_at": 1711471533, - "api_key": { - "object": "organization.project.service_account.api_key", - "value": "sk-abcdefghijklmnop123", - "name": "Secret Key", - "created_at": 1711471533, - "id": "key_abc" - } - } - '/organization/projects/{project_id}/service_accounts/{service_account_id}': - get: - summary: Retrieves a service account in the project. - operationId: retrieve-project-service-account - tags: - - Projects - parameters: - - name: project_id - in: path - description: The ID of the project. - required: true - schema: - type: string - - name: service_account_id - in: path - description: The ID of the service account. - required: true - schema: - type: string - responses: - '200': - description: Project service account retrieved successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/ProjectServiceAccount' - x-oaiMeta: - name: Retrieve project service account - group: administration - returns: 'The [ProjectServiceAccount](/docs/api-reference/project-service-accounts/object) object matching the specified ID.' - examples: - request: - curl: | - curl https://api.openai.com/v1/organization/projects/proj_abc/service_accounts/svc_acct_abc \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.project.service_account", - "id": "svc_acct_abc", - "name": "Service Account", - "role": "owner", - "created_at": 1711471533 - } - delete: - summary: Deletes a service account from the project. - operationId: delete-project-service-account - tags: - - Projects - parameters: - - name: project_id - in: path - description: The ID of the project. - required: true - schema: - type: string - - name: service_account_id - in: path - description: The ID of the service account. - required: true - schema: - type: string - responses: - '200': - description: Project service account deleted successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/ProjectServiceAccountDeleteResponse' - x-oaiMeta: - name: Delete project service account - group: administration - returns: 'Confirmation of service account being deleted, or an error in case of an archived project, which has no service accounts' - examples: - request: - curl: | - curl -X DELETE https://api.openai.com/v1/organization/projects/proj_abc/service_accounts/svc_acct_abc \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.project.service_account.deleted", - "id": "svc_acct_abc", - "deleted": true - } - '/organization/projects/{project_id}/users': - get: - summary: Returns a list of users in the project. - operationId: list-project-users - tags: - - Projects - parameters: - - name: project_id - in: path - description: The ID of the project. - required: true - schema: - type: string - - name: limit - in: query - description: | - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - required: false - schema: - type: integer - default: 20 - - name: after - in: query - 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. - required: false - schema: - type: string - responses: - '200': - description: Project users listed successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/ProjectUserListResponse' - '400': - description: Error response when project is archived. - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorResponse' - x-oaiMeta: - name: List project users - group: administration - returns: 'A list of [ProjectUser](/docs/api-reference/project-users/object) objects.' - examples: - request: - curl: | - curl https://api.openai.com/v1/organization/projects/proj_abc/users?after=user_abc&limit=20 \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" - response: - content: | - { - "object": "list", - "data": [ - { - "object": "organization.project.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } - ], - "first_id": "user-abc", - "last_id": "user-xyz", - "has_more": false - } - error_response: - content: | - { - "code": 400, - "message": "Project {name} is archived" - } - post: - summary: Adds a user to the project. Users must already be members of the organization to be added to a project. - operationId: create-project-user - parameters: - - name: project_id - in: path - description: The ID of the project. - required: true - schema: - type: string - tags: - - Projects - requestBody: - description: The project user create request payload. - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/ProjectUserCreateRequest' - responses: - '200': - description: User added to project successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/ProjectUser' - '400': - description: Error response for various conditions. - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorResponse' - x-oaiMeta: - name: Create project user - group: administration - returns: 'The created [ProjectUser](/docs/api-reference/project-users/object) object.' - examples: - request: - curl: | - curl -X POST https://api.openai.com/v1/organization/projects/proj_abc/users \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" \ - -d '{ - "user_id": "user_abc", - "role": "member" - }' - response: - content: | - { - "object": "organization.project.user", - "id": "user_abc", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } - error_response: - content: | - { - "code": 400, - "message": "Project {name} is archived" - } - '/organization/projects/{project_id}/users/{user_id}': - get: - summary: Retrieves a user in the project. - operationId: retrieve-project-user - tags: - - Projects - parameters: - - name: project_id - in: path - description: The ID of the project. - required: true - schema: - type: string - - name: user_id - in: path - description: The ID of the user. - required: true - schema: - type: string - responses: - '200': - description: Project user retrieved successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/ProjectUser' - x-oaiMeta: - name: Retrieve project user - group: administration - returns: 'The [ProjectUser](/docs/api-reference/project-users/object) object matching the specified ID.' - examples: - request: - curl: | - curl https://api.openai.com/v1/organization/projects/proj_abc/users/user_abc \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.project.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } - post: - summary: Modifies a user's role in the project. - operationId: modify-project-user - tags: - - Projects - parameters: - - name: project_id - in: path - description: The ID of the project. - required: true - schema: - type: string - - name: user_id - in: path - description: The ID of the user. - required: true - schema: - type: string - requestBody: - description: The project user update request payload. - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/ProjectUserUpdateRequest' - responses: - '200': - description: Project user's role updated successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/ProjectUser' - '400': - description: Error response for various conditions. - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorResponse' - x-oaiMeta: - name: Modify project user - group: administration - returns: 'The updated [ProjectUser](/docs/api-reference/project-users/object) object.' - examples: - request: - curl: | - curl -X POST https://api.openai.com/v1/organization/projects/proj_abc/users/user_abc \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" \ - -d '{ - "role": "owner" - }' - response: - content: | - { - "object": "organization.project.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } - delete: - summary: Deletes a user from the project. - operationId: delete-project-user - tags: - - Projects - parameters: - - name: project_id - in: path - description: The ID of the project. - required: true - schema: - type: string - - name: user_id - in: path - description: The ID of the user. - required: true - schema: - type: string - responses: - '200': - description: Project user deleted successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/ProjectUserDeleteResponse' - '400': - description: Error response for various conditions. - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorResponse' - x-oaiMeta: - name: Delete project user - group: administration - returns: 'Confirmation that project has been deleted or an error in case of an archived project, which has no users' - examples: - request: - curl: | - curl -X DELETE https://api.openai.com/v1/organization/projects/proj_abc/users/user_abc \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.project.user.deleted", - "id": "user_abc", - "deleted": true - } diff --git a/providers/src/openai/v00.00.00000/services/skills.yaml b/providers/src/openai/v00.00.00000/services/skills.yaml new file mode 100644 index 00000000..b2a93266 --- /dev/null +++ b/providers/src/openai/v00.00.00000/services/skills.yaml @@ -0,0 +1,1238 @@ +openapi: 3.1.0 +info: + title: skills API + description: openai API + version: 2.3.0 +paths: + /skills: + post: + tags: + - Skills + summary: Create a new skill. + operationId: CreateSkill + parameters: + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + requestBody: + content: + multipart/form-data: + schema: + $ref: '#/components/schemas/CreateSkillBody' + application/json: + schema: + $ref: '#/components/schemas/CreateSkillBody' + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/SkillResource' + x-oaiMeta: + examples: + response: '' + request: + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const skill = await client.skills.create(); + + console.log(skill.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + skill = client.skills.create() + print(skill.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\tskill, err := client.Skills.New(context.TODO(), openai.SkillNewParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", skill.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.skills.Skill; + import com.openai.models.skills.SkillCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Skill skill = client.skills().create(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + skill = openai.skills.create + + puts(skill) + get: + tags: + - Skills + summary: List all skills for the current project. + operationId: ListSkills + parameters: + - name: limit + in: query + description: >- + Number of items to retrieve + + + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. + required: false + schema: + type: integer + minimum: 0 + maximum: 100 + - name: order + in: query + description: >- + Sort order of results by timestamp. Use `asc` for ascending order or + `desc` for descending order. + required: false + schema: + $ref: '#/components/schemas/OrderEnum' + - name: after + in: query + description: Identifier for the last item from the previous pagination request + required: false + schema: + description: Identifier for the last item from the previous pagination request + type: string + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/SkillListResource' + x-oaiMeta: + examples: + response: '' + request: + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const skill of client.skills.list()) { + console.log(skill.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.skills.list() + page = page.data[0] + print(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.Skills.List(context.TODO(), openai.SkillListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.skills.SkillListPage; + import com.openai.models.skills.SkillListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + SkillListPage page = client.skills().list(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + page = openai.skills.list + + puts(page) + /skills/{skill_id}: + delete: + tags: + - Skills + summary: Delete a skill by its ID. + operationId: DeleteSkill + parameters: + - name: skill_id + in: path + description: The identifier of the skill to delete. + required: true + schema: + example: skill_123 + type: string + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/DeletedSkillResource' + x-oaiMeta: + examples: + response: '' + request: + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const deletedSkill = await client.skills.delete('skill_123'); + + console.log(deletedSkill.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + deleted_skill = client.skills.delete( + "skill_123", + ) + print(deleted_skill.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\tdeletedSkill, err := client.Skills.Delete(context.TODO(), \"skill_123\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", deletedSkill.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.skills.DeletedSkill; + import com.openai.models.skills.SkillDeleteParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + DeletedSkill deletedSkill = client.skills().delete("skill_123"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + deleted_skill = openai.skills.delete("skill_123") + + puts(deleted_skill) + get: + tags: + - Skills + summary: Get a skill by its ID. + operationId: GetSkill + parameters: + - name: skill_id + in: path + description: The identifier of the skill to retrieve. + required: true + schema: + example: skill_123 + type: string + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/SkillResource' + x-oaiMeta: + examples: + response: '' + request: + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const skill = await client.skills.retrieve('skill_123'); + + console.log(skill.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + skill = client.skills.retrieve( + "skill_123", + ) + print(skill.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\tskill, err := client.Skills.Get(context.TODO(), \"skill_123\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", skill.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.skills.Skill; + import com.openai.models.skills.SkillRetrieveParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Skill skill = client.skills().retrieve("skill_123"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + skill = openai.skills.retrieve("skill_123") + + puts(skill) + post: + tags: + - Skills + summary: Update the default version pointer for a skill. + operationId: UpdateSkillDefaultVersion + parameters: + - name: skill_id + in: path + description: The identifier of the skill. + required: true + schema: + example: skill_123 + type: string + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SetDefaultSkillVersionBody' + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/SetDefaultSkillVersionBody' + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/SkillResource' + x-oaiMeta: + examples: + response: '' + request: + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const skill = await client.skills.update('skill_123', { + default_version: 'default_version' }); + + + console.log(skill.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + skill = client.skills.update( + skill_id="skill_123", + default_version="default_version", + ) + print(skill.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\tskill, err := client.Skills.Update(\n\t\tcontext.TODO(),\n\t\t\"skill_123\",\n\t\topenai.SkillUpdateParams{\n\t\t\tDefaultVersion: \"default_version\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", skill.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.skills.Skill; + import com.openai.models.skills.SkillUpdateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + SkillUpdateParams params = SkillUpdateParams.builder() + .skillId("skill_123") + .defaultVersion("default_version") + .build(); + Skill skill = client.skills().update(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + skill = openai.skills.update("skill_123", default_version: + "default_version") + + + puts(skill) + /skills/{skill_id}/versions: + post: + tags: + - Skills + summary: Create a new immutable skill version. + operationId: CreateSkillVersion + parameters: + - name: skill_id + in: path + description: The identifier of the skill to version. + required: true + schema: + example: skill_123 + type: string + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + requestBody: + content: + multipart/form-data: + schema: + $ref: '#/components/schemas/CreateSkillVersionBody' + application/json: + schema: + $ref: '#/components/schemas/CreateSkillVersionBody' + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/SkillVersionResource' + x-oaiMeta: + examples: + response: '' + request: + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const skillVersion = await + client.skills.versions.create('skill_123'); + + + console.log(skillVersion.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + skill_version = client.skills.versions.create( + skill_id="skill_123", + ) + print(skill_version.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\tskillVersion, err := client.Skills.Versions.New(\n\t\tcontext.TODO(),\n\t\t\"skill_123\",\n\t\topenai.SkillVersionNewParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", skillVersion.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.skills.versions.SkillVersion; + import com.openai.models.skills.versions.VersionCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + SkillVersion skillVersion = client.skills().versions().create("skill_123"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + skill_version = openai.skills.versions.create("skill_123") + + puts(skill_version) + get: + tags: + - Skills + summary: List skill versions for a skill. + operationId: ListSkillVersions + parameters: + - name: skill_id + in: path + description: The identifier of the skill. + required: true + schema: + example: skill_123 + type: string + - name: limit + in: query + description: >- + Number of versions to retrieve. + + + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. + required: false + schema: + type: integer + minimum: 0 + maximum: 100 + - name: order + in: query + description: Sort order of results by version number. + required: false + schema: + $ref: '#/components/schemas/OrderEnum' + - name: after + in: query + description: The skill version ID to start after. + required: false + schema: + example: skillver_123 + type: string + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/SkillVersionListResource' + x-oaiMeta: + examples: + response: '' + request: + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + // Automatically fetches more pages as needed. + + for await (const skillVersion of + client.skills.versions.list('skill_123')) { + console.log(skillVersion.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.skills.versions.list( + skill_id="skill_123", + ) + page = page.data[0] + print(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.Skills.Versions.List(\n\t\tcontext.TODO(),\n\t\t\"skill_123\",\n\t\topenai.SkillVersionListParams{},\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.skills.versions.VersionListPage; + import com.openai.models.skills.versions.VersionListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + VersionListPage page = client.skills().versions().list("skill_123"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + page = openai.skills.versions.list("skill_123") + + puts(page) + /skills/{skill_id}/versions/{version}: + get: + tags: + - Skills + summary: Get a specific skill version. + operationId: GetSkillVersion + parameters: + - name: skill_id + in: path + description: The identifier of the skill. + required: true + schema: + example: skill_123 + type: string + - name: version + in: path + description: The version number to retrieve. + required: true + schema: + description: The version number to retrieve. + type: string + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/SkillVersionResource' + x-oaiMeta: + examples: + response: '' + request: + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const skillVersion = await + client.skills.versions.retrieve('version', { skill_id: 'skill_123' + }); + + + console.log(skillVersion.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + skill_version = client.skills.versions.retrieve( + version="version", + skill_id="skill_123", + ) + print(skill_version.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\tskillVersion, err := client.Skills.Versions.Get(\n\t\tcontext.TODO(),\n\t\t\"skill_123\",\n\t\t\"version\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", skillVersion.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.skills.versions.SkillVersion; + import com.openai.models.skills.versions.VersionRetrieveParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + VersionRetrieveParams params = VersionRetrieveParams.builder() + .skillId("skill_123") + .version("version") + .build(); + SkillVersion skillVersion = client.skills().versions().retrieve(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + skill_version = openai.skills.versions.retrieve("version", + skill_id: "skill_123") + + + puts(skill_version) + delete: + tags: + - Skills + summary: Delete a skill version. + operationId: DeleteSkillVersion + parameters: + - name: skill_id + in: path + description: The identifier of the skill. + required: true + schema: + example: skill_123 + type: string + - name: version + in: path + description: The skill version number. + required: true + schema: + description: The skill version number. + type: string + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/DeletedSkillVersionResource' + x-oaiMeta: + examples: + response: '' + request: + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const deletedSkillVersion = await + client.skills.versions.delete('version', { + skill_id: 'skill_123', + }); + + + console.log(deletedSkillVersion.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + deleted_skill_version = client.skills.versions.delete( + version="version", + skill_id="skill_123", + ) + print(deleted_skill_version.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\tdeletedSkillVersion, err := client.Skills.Versions.Delete(\n\t\tcontext.TODO(),\n\t\t\"skill_123\",\n\t\t\"version\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", deletedSkillVersion.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.skills.versions.DeletedSkillVersion; + import com.openai.models.skills.versions.VersionDeleteParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + VersionDeleteParams params = VersionDeleteParams.builder() + .skillId("skill_123") + .version("version") + .build(); + DeletedSkillVersion deletedSkillVersion = client.skills().versions().delete(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + deleted_skill_version = openai.skills.versions.delete("version", + skill_id: "skill_123") + + + puts(deleted_skill_version) +components: + schemas: + CreateSkillBody: + properties: {} + type: object + required: [] + title: Create skill request + description: >- + Uploads a skill either as a directory (multipart `files[]`) or as a + single zip file. + SkillResource: + properties: + id: + type: string + description: Unique identifier for the skill. + object: + type: string + enum: + - skill + description: The object type, which is `skill`. + default: skill + x-stainless-const: true + name: + type: string + description: Name of the skill. + description: + type: string + description: Description of the skill. + created_at: + type: integer + format: unixtime + description: Unix timestamp (seconds) for when the skill was created. + default_version: + type: string + description: Default version for the skill. + latest_version: + type: string + description: Latest version for the skill. + type: object + required: + - id + - object + - name + - description + - created_at + - default_version + - latest_version + OrderEnum: + type: string + enum: + - asc + - desc + SkillListResource: + properties: + object: + type: string + enum: + - list + description: The type of object returned, must be `list`. + default: list + x-stainless-const: true + data: + items: + $ref: '#/components/schemas/SkillResource' + type: array + description: A list of items + first_id: + type: string + description: The ID of the first item in the list. + last_id: + type: string + description: The ID of the last item in the list. + has_more: + type: boolean + description: Whether there are more items available. + type: object + required: + - object + - data + - first_id + - last_id + - has_more + DeletedSkillResource: + properties: + object: + type: string + enum: + - skill.deleted + default: skill.deleted + x-stainless-const: true + deleted: + type: boolean + id: + type: string + type: object + required: + - object + - deleted + - id + SetDefaultSkillVersionBody: + properties: + default_version: + type: string + description: The skill version number to set as default. + type: object + required: + - default_version + title: Update skill request + description: Updates the default version pointer for a skill. + CreateSkillVersionBody: + properties: + default: + type: boolean + description: Whether to set this version as the default. + type: object + required: [] + title: Create skill version request + description: Uploads a new immutable version of a skill. + SkillVersionResource: + properties: + object: + type: string + enum: + - skill.version + description: The object type, which is `skill.version`. + default: skill.version + x-stainless-const: true + id: + type: string + description: Unique identifier for the skill version. + skill_id: + type: string + description: Identifier of the skill for this version. + version: + type: string + description: Version number for this skill. + created_at: + type: integer + format: unixtime + description: Unix timestamp (seconds) for when the version was created. + name: + type: string + description: Name of the skill version. + description: + type: string + description: Description of the skill version. + type: object + required: + - object + - id + - skill_id + - version + - created_at + - name + - description + SkillVersionListResource: + properties: + object: + type: string + enum: + - list + description: The type of object returned, must be `list`. + default: list + x-stainless-const: true + data: + items: + $ref: '#/components/schemas/SkillVersionResource' + type: array + description: A list of items + first_id: + type: string + description: The ID of the first item in the list. + last_id: + type: string + description: The ID of the last item in the list. + has_more: + type: boolean + description: Whether there are more items available. + type: object + required: + - object + - data + - first_id + - last_id + - has_more + DeletedSkillVersionResource: + properties: + object: + type: string + enum: + - skill.version.deleted + default: skill.version.deleted + x-stainless-const: true + deleted: + type: boolean + id: + type: string + version: + type: string + description: The deleted skill version. + type: object + required: + - object + - deleted + - id + - version + x-stackQL-resources: + skills: + id: openai.skills.skills + name: skills + title: Skills + methods: + list: + operation: + $ref: '#/paths/~1skills/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + delete: + operation: + $ref: '#/paths/~1skills~1{skill_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + get: + operation: + $ref: '#/paths/~1skills~1{skill_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + update: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1skills~1{skill_id}/post' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/skills/methods/get' + - $ref: '#/components/x-stackQL-resources/skills/methods/list' + insert: [] + update: + - $ref: '#/components/x-stackQL-resources/skills/methods/update' + delete: + - $ref: '#/components/x-stackQL-resources/skills/methods/delete' + replace: [] + versions: + id: openai.skills.versions + name: versions + title: Versions + methods: + list: + operation: + $ref: '#/paths/~1skills~1{skill_id}~1versions/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + get: + operation: + $ref: '#/paths/~1skills~1{skill_id}~1versions~1{version}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1skills~1{skill_id}~1versions~1{version}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/versions/methods/get' + - $ref: '#/components/x-stackQL-resources/versions/methods/list' + insert: [] + update: [] + delete: + - $ref: '#/components/x-stackQL-resources/versions/methods/delete' + replace: [] +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.last_id + location: body + queryParamPushdown: + top: + paramName: limit + maxValue: 100 diff --git a/providers/src/openai/v00.00.00000/services/uploads.yaml b/providers/src/openai/v00.00.00000/services/uploads.yaml index 07fe9435..6f3b5635 100644 --- a/providers/src/openai/v00.00.00000/services/uploads.yaml +++ b/providers/src/openai/v00.00.00000/services/uploads.yaml @@ -1,46 +1,443 @@ -openapi: 3.0.0 -servers: - - url: 'https://api.openai.com/v1' +openapi: 3.1.0 info: + title: uploads API + description: openai API version: 2.3.0 - termsOfService: 'https://openai.com/policies/terms-of-use' - contact: - name: OpenAI Support - url: 'https://help.openai.com/' - license: - name: MIT - url: 'https://github.com/openai/openai-openapi/blob/master/LICENSE' - title: OpenAI API - uploads - description: Use Uploads to upload large files in multiple parts. -security: - - ApiKeyAuth: [] -tags: - - name: Assistants - description: Build Assistants that can call models and use tools. - - name: Audio - description: Turn audio into text or text into audio. - - name: Chat - description: 'Given a list of messages comprising a conversation, the model will return a response.' - - name: Completions - description: 'Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.' - - name: Embeddings - description: Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. - - name: Fine-tuning - description: Manage fine-tuning jobs to tailor a model to your specific training data. - - name: Batch - description: Create large batches of API requests to run asynchronously. - - name: Files - description: Files are used to upload documents that can be used with features like Assistants and Fine-tuning. - - name: Uploads - description: Use Uploads to upload large files in multiple parts. - - name: Images - description: 'Given a prompt and/or an input image, the model will generate a new image.' - - name: Models - description: List and describe the various models available in the API. - - name: Moderations - description: 'Given text and/or image inputs, classifies if those inputs are potentially harmful.' - - name: Audit Logs - description: List user actions and configuration changes within this organization. +paths: + /uploads: + post: + operationId: createUpload + tags: + - Uploads + summary: > + Creates an intermediate [Upload](/docs/api-reference/uploads/object) + object + + that you can add [Parts](/docs/api-reference/uploads/part-object) to. + + Currently, an Upload can accept at most 8 GB in total and expires after + an + + hour after you create it. + + + Once you complete the Upload, we will create a + + [File](/docs/api-reference/files/object) object that contains all the + parts + + you uploaded. This File is usable in the rest of our platform as a + regular + + File object. + + + For certain `purpose` values, the correct `mime_type` must be + specified. + + Please refer to documentation for the + + [supported MIME types for your use + case](/docs/assistants/tools/file-search#supported-files). + + + For guidance on the proper filename extensions for each purpose, please + + follow the documentation on [creating a + + File](/docs/api-reference/files/create). + + + Returns the Upload object with status `pending`. + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateUploadRequest' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Upload' + x-oaiMeta: + name: Create upload + group: uploads + examples: + request: + curl: | + curl https://api.openai.com/v1/uploads \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "purpose": "fine-tune", + "filename": "training_examples.jsonl", + "bytes": 2147483648, + "mime_type": "text/jsonl", + "expires_after": { + "anchor": "created_at", + "seconds": 3600 + } + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const upload = await client.uploads.create({ + bytes: 0, + filename: 'filename', + mime_type: 'mime_type', + purpose: 'assistants', + }); + + console.log(upload.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + upload = client.uploads.create( + bytes=0, + filename="filename", + mime_type="mime_type", + purpose="assistants", + ) + print(upload.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\tupload, err := client.Uploads.New(context.TODO(), openai.UploadNewParams{\n\t\tBytes: 0,\n\t\tFilename: \"filename\",\n\t\tMimeType: \"mime_type\",\n\t\tPurpose: openai.FilePurposeAssistants,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", upload.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.files.FilePurpose; + import com.openai.models.uploads.Upload; + import com.openai.models.uploads.UploadCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UploadCreateParams params = UploadCreateParams.builder() + .bytes(0L) + .filename("filename") + .mimeType("mime_type") + .purpose(FilePurpose.ASSISTANTS) + .build(); + Upload upload = client.uploads().create(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + upload = openai.uploads.create(bytes: 0, filename: "filename", + mime_type: "mime_type", purpose: :assistants) + + + puts(upload) + response: | + { + "id": "upload_abc123", + "object": "upload", + "bytes": 2147483648, + "created_at": 1719184911, + "filename": "training_examples.jsonl", + "purpose": "fine-tune", + "status": "pending", + "expires_at": 1719127296 + } + parameters: + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + /uploads/{upload_id}/cancel: + post: + operationId: cancelUpload + tags: + - Uploads + summary: | + Cancels the Upload. No Parts may be added after an Upload is cancelled. + + Returns the Upload object with status `cancelled`. + parameters: + - in: path + name: upload_id + required: true + schema: + type: string + example: upload_abc123 + description: | + The ID of the Upload. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Upload' + x-oaiMeta: + name: Cancel upload + group: uploads + examples: + request: + curl: | + curl https://api.openai.com/v1/uploads/upload_abc123/cancel + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const upload = await client.uploads.cancel('upload_abc123'); + + console.log(upload.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + upload = client.uploads.cancel( + "upload_abc123", + ) + print(upload.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\tupload, err := client.Uploads.Cancel(context.TODO(), \"upload_abc123\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", upload.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.uploads.Upload; + import com.openai.models.uploads.UploadCancelParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Upload upload = client.uploads().cancel("upload_abc123"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + upload = openai.uploads.cancel("upload_abc123") + + puts(upload) + response: | + { + "id": "upload_abc123", + "object": "upload", + "bytes": 2147483648, + "created_at": 1719184911, + "filename": "training_examples.jsonl", + "purpose": "fine-tune", + "status": "cancelled", + "expires_at": 1719127296 + } + /uploads/{upload_id}/complete: + post: + operationId: completeUpload + tags: + - Uploads + summary: > + Completes the [Upload](/docs/api-reference/uploads/object). + + + Within the returned Upload object, there is a nested + [File](/docs/api-reference/files/object) object that is ready to use in + the rest of the platform. + + + You can specify the order of the Parts by passing in an ordered list of + the Part IDs. + + + The number of bytes uploaded upon completion must match the number of + bytes initially specified when creating the Upload object. No Parts may + be added after an Upload is completed. + + Returns the Upload object with status `completed`, including an + additional `file` property containing the created usable File object. + parameters: + - in: path + name: upload_id + required: true + schema: + type: string + example: upload_abc123 + description: | + The ID of the Upload. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CompleteUploadRequest' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Upload' + x-oaiMeta: + name: Complete upload + group: uploads + examples: + request: + curl: | + curl https://api.openai.com/v1/uploads/upload_abc123/complete + -d '{ + "part_ids": ["part_def456", "part_ghi789"] + }' + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const upload = await client.uploads.complete('upload_abc123', { + part_ids: ['string'] }); + + + console.log(upload.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + upload = client.uploads.complete( + upload_id="upload_abc123", + part_ids=["string"], + ) + print(upload.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\tupload, err := client.Uploads.Complete(\n\t\tcontext.TODO(),\n\t\t\"upload_abc123\",\n\t\topenai.UploadCompleteParams{\n\t\t\tPartIDs: []string{\"string\"},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", upload.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.uploads.Upload; + import com.openai.models.uploads.UploadCompleteParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UploadCompleteParams params = UploadCompleteParams.builder() + .uploadId("upload_abc123") + .addPartId("string") + .build(); + Upload upload = client.uploads().complete(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + upload = openai.uploads.complete("upload_abc123", part_ids: + ["string"]) + + + puts(upload) + response: | + { + "id": "upload_abc123", + "object": "upload", + "bytes": 2147483648, + "created_at": 1719184911, + "filename": "training_examples.jsonl", + "purpose": "fine-tune", + "status": "completed", + "expires_at": 1719127296, + "file": { + "id": "file-xyz321", + "object": "file", + "bytes": 2147483648, + "created_at": 1719186911, + "expires_at": 1719127296, + "filename": "training_examples.jsonl", + "purpose": "fine-tune", + } + } components: schemas: CreateUploadRequest: @@ -55,7 +452,8 @@ components: description: | The intended purpose of the uploaded file. - See the [documentation on File purposes](/docs/api-reference/files/create#files-create-purpose). + See the [documentation on File + purposes](/docs/api-reference/files/create#files-create-purpose). type: string enum: - assistants @@ -67,11 +465,18 @@ components: The number of bytes in the file you are uploading. type: integer mime_type: - description: | + description: > The MIME type of the file. - This must fall within the supported MIME types for your file purpose. See the supported MIME types for assistants and vision. + + + This must fall within the supported MIME types for your file + purpose. See + + the supported MIME types for assistants and vision. type: string + expires_after: + $ref: '#/components/schemas/FileExpirationAfter' required: - filename - purpose @@ -85,9 +490,12 @@ components: properties: id: type: string - description: 'The Upload unique identifier, which can be referenced in API endpoints.' + description: >- + The Upload unique identifier, which can be referenced in API + endpoints. created_at: type: integer + format: unixtime description: The Unix timestamp (in seconds) for when the Upload was created. filename: type: string @@ -97,7 +505,10 @@ components: description: The intended number of bytes to be uploaded. purpose: type: string - description: 'The intended purpose of the file. [Please refer here](/docs/api-reference/files/object#files/object-purpose) for acceptable values.' + description: >- + The intended purpose of the file. [Please refer + here](/docs/api-reference/files/object#files/object-purpose) for + acceptable values. status: type: string description: The status of the Upload. @@ -108,16 +519,98 @@ components: - expired expires_at: type: integer - description: The Unix timestamp (in seconds) for when the Upload was created. + format: unixtime + description: The Unix timestamp (in seconds) for when the Upload will expire. object: type: string - description: 'The object type, which is always "upload".' + description: The object type, which is always "upload". enum: - upload + x-stainless-const: true file: - $ref: '#/components/schemas/OpenAIFile' + title: OpenAIFile + description: >- + The `File` object represents a document that has been uploaded to + OpenAI. + properties: + id: + type: string + description: >- + The file identifier, which can be referenced in the API + endpoints. + bytes: + type: integer + description: The size of the file, in bytes. + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the file was created. + expires_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the file will expire. + filename: + type: string + description: The name of the file. + object: + type: string + description: The object type, which is always `file`. + enum: + - file + x-stainless-const: true + purpose: + type: string + description: >- + The intended purpose of the file. Supported values are + `assistants`, `assistants_output`, `batch`, `batch_output`, + `fine-tune`, `fine-tune-results`, `vision`, and `user_data`. + enum: + - assistants + - assistants_output + - batch + - batch_output + - fine-tune + - fine-tune-results + - vision + - user_data + status: + type: string + deprecated: true + description: >- + Deprecated. The current status of the file, which can be either + `uploaded`, `processed`, or `error`. + enum: + - uploaded + - processed + - error + status_details: + type: string + deprecated: true + description: >- + Deprecated. For details on why a fine-tuning training file + failed validation, see the `error` field on `fine_tuning.job`. + required: + - id + - object + - bytes + - created_at + - filename + - purpose + - status + x-oaiMeta: + name: The file object + example: | + { + "id": "file-abc123", + "object": "file", + "bytes": 120000, + "created_at": 1677610602, + "expires_at": 1680202602, + "filename": "salesOverview.pdf", + "purpose": "assistants", + } + type: object nullable: true - description: The ready File object after the Upload is completed. required: - bytes - created_at @@ -147,30 +640,85 @@ components: "purpose": "fine-tune", } } + CompleteUploadRequest: + type: object + additionalProperties: false + properties: + part_ids: + type: array + description: | + The ordered list of Part IDs. + items: + type: string + md5: + description: > + The optional md5 checksum for the file contents to verify if the + bytes uploaded matches what you expect. + type: string + required: + - part_ids + FileExpirationAfter: + type: object + title: File expiration policy + description: >- + The expiration policy for a file. By default, files with `purpose=batch` + expire after 30 days and all other files are persisted until they are + manually deleted. + properties: + anchor: + description: >- + Anchor timestamp after which the expiration policy applies. + Supported anchors: `created_at`. + type: string + enum: + - created_at + x-stainless-const: true + seconds: + description: >- + The number of seconds after the anchor time that the file will + expire. Must be between 3600 (1 hour) and 2592000 (30 days). + type: integer + format: int64 + minimum: 3600 + maximum: 2592000 + required: + - anchor + - seconds OpenAIFile: title: OpenAIFile - description: The `File` object represents a document that has been uploaded to OpenAI. + description: >- + The `File` object represents a document that has been uploaded to + OpenAI. properties: id: type: string - description: 'The file identifier, which can be referenced in the API endpoints.' + description: The file identifier, which can be referenced in the API endpoints. bytes: type: integer - description: 'The size of the file, in bytes.' + description: The size of the file, in bytes. created_at: type: integer + format: unixtime description: The Unix timestamp (in seconds) for when the file was created. + expires_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) for when the file will expire. filename: type: string description: The name of the file. object: type: string - description: 'The object type, which is always `file`.' + description: The object type, which is always `file`. enum: - file + x-stainless-const: true purpose: type: string - description: 'The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`.' + description: >- + The intended purpose of the file. Supported values are `assistants`, + `assistants_output`, `batch`, `batch_output`, `fine-tune`, + `fine-tune-results`, `vision`, and `user_data`. enum: - assistants - assistants_output @@ -179,10 +727,13 @@ components: - fine-tune - fine-tune-results - vision + - user_data status: type: string deprecated: true - description: 'Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.' + description: >- + Deprecated. The current status of the file, which can be either + `uploaded`, `processed`, or `error`. enum: - uploaded - processed @@ -190,7 +741,9 @@ components: status_details: type: string deprecated: true - description: 'Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.' + description: >- + Deprecated. For details on why a fine-tuning training file failed + validation, see the `error` field on `fine_tuning.job`. required: - id - object @@ -207,335 +760,59 @@ components: "object": "file", "bytes": 120000, "created_at": 1677610602, + "expires_at": 1680202602, "filename": "salesOverview.pdf", "purpose": "assistants", } - CompleteUploadRequest: - type: object - additionalProperties: false - properties: - part_ids: - type: array - description: | - The ordered list of Part IDs. - items: - type: string - md5: - description: | - The optional md5 checksum for the file contents to verify if the bytes uploaded matches what you expect. - type: string - required: - - part_ids - AddUploadPartRequest: - type: object - additionalProperties: false - properties: - data: - description: | - The chunk of bytes for this Part. - type: string - format: binary - required: - - data - UploadPart: type: object - title: UploadPart - description: | - The upload Part represents a chunk of bytes we can add to an Upload object. - properties: - id: - type: string - description: 'The upload Part unique identifier, which can be referenced in API endpoints.' - created_at: - type: integer - description: The Unix timestamp (in seconds) for when the Part was created. - upload_id: - type: string - description: The ID of the Upload object that this Part was added to. - object: - type: string - description: 'The object type, which is always `upload.part`.' - enum: - - upload.part - required: - - created_at - - id - - object - - upload_id - x-oaiMeta: - name: The upload part object - example: | - { - "id": "part_def456", - "object": "upload.part", - "created_at": 1719186911, - "upload_id": "upload_abc123" - } - responses: {} - securitySchemes: - ApiKeyAuth: - type: http - scheme: bearer x-stackQL-resources: uploads: id: openai.uploads.uploads name: uploads title: Uploads methods: - create_upload: + create: + config: + requestBodyTranslate: + algorithm: naive operation: $ref: '#/paths/~1uploads/post' response: mediaType: application/json openAPIDocKey: '200' - schemaRef: '#/components/schemas/Upload' - cancel_upload: + cancel: operation: $ref: '#/paths/~1uploads~1{upload_id}~1cancel/post' response: mediaType: application/json openAPIDocKey: '200' - schemaRef: '#/components/schemas/Upload' - complete_upload: + complete: + config: + requestBodyTranslate: + algorithm: naive operation: $ref: '#/paths/~1uploads~1{upload_id}~1complete/post' response: mediaType: application/json openAPIDocKey: '200' - schemaRef: '#/components/schemas/Upload' sqlVerbs: select: [] insert: - - $ref: '#/components/x-stackQL-resources/uploads/methods/create_upload' + - $ref: '#/components/x-stackQL-resources/uploads/methods/create' update: [] - replace: [] delete: [] - upload_parts: - id: openai.uploads.upload_parts - name: upload_parts - title: Upload Parts - methods: - add_upload_part: - operation: - $ref: '#/paths/~1uploads~1{upload_id}~1parts/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/UploadPart' - sqlVerbs: - select: [] - insert: - - $ref: '#/components/x-stackQL-resources/upload_parts/methods/add_upload_part' - update: [] replace: [] - delete: [] -paths: - /uploads: - post: - operationId: createUpload - tags: - - Uploads - summary: | - Creates an intermediate [Upload](/docs/api-reference/uploads/object) object that you can add [Parts](/docs/api-reference/uploads/part-object) to. Currently, an Upload can accept at most 8 GB in total and expires after an hour after you create it. - - Once you complete the Upload, we will create a [File](/docs/api-reference/files/object) object that contains all the parts you uploaded. This File is usable in the rest of our platform as a regular File object. - - For certain `purpose`s, the correct `mime_type` must be specified. Please refer to documentation for the supported MIME types for your use case: - - [Assistants](/docs/assistants/tools/file-search/supported-files) - - For guidance on the proper filename extensions for each purpose, please follow the documentation on [creating a File](/docs/api-reference/files/create). - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CreateUploadRequest' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Upload' - x-oaiMeta: - name: Create upload - group: uploads - returns: 'The [Upload](/docs/api-reference/uploads/object) object with status `pending`.' - examples: - request: - curl: | - curl https://api.openai.com/v1/uploads \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "purpose": "fine-tune", - "filename": "training_examples.jsonl", - "bytes": 2147483648, - "mime_type": "text/jsonl" - }' - response: | - { - "id": "upload_abc123", - "object": "upload", - "bytes": 2147483648, - "created_at": 1719184911, - "filename": "training_examples.jsonl", - "purpose": "fine-tune", - "status": "pending", - "expires_at": 1719127296 - } - '/uploads/{upload_id}/cancel': - post: - operationId: cancelUpload - tags: - - Uploads - summary: | - Cancels the Upload. No Parts may be added after an Upload is cancelled. - parameters: - - in: path - name: upload_id - required: true - schema: - type: string - example: upload_abc123 - description: | - The ID of the Upload. - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Upload' - x-oaiMeta: - name: Cancel upload - group: uploads - returns: 'The [Upload](/docs/api-reference/uploads/object) object with status `cancelled`.' - examples: - request: - curl: | - curl https://api.openai.com/v1/uploads/upload_abc123/cancel - response: | - { - "id": "upload_abc123", - "object": "upload", - "bytes": 2147483648, - "created_at": 1719184911, - "filename": "training_examples.jsonl", - "purpose": "fine-tune", - "status": "cancelled", - "expires_at": 1719127296 - } - '/uploads/{upload_id}/complete': - post: - operationId: completeUpload - tags: - - Uploads - summary: | - Completes the [Upload](/docs/api-reference/uploads/object). - - Within the returned Upload object, there is a nested [File](/docs/api-reference/files/object) object that is ready to use in the rest of the platform. - - You can specify the order of the Parts by passing in an ordered list of the Part IDs. - - The number of bytes uploaded upon completion must match the number of bytes initially specified when creating the Upload object. No Parts may be added after an Upload is completed. - parameters: - - in: path - name: upload_id - required: true - schema: - type: string - example: upload_abc123 - description: | - The ID of the Upload. - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CompleteUploadRequest' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Upload' - x-oaiMeta: - name: Complete upload - group: uploads - returns: 'The [Upload](/docs/api-reference/uploads/object) object with status `completed` with an additional `file` property containing the created usable File object.' - examples: - request: - curl: | - curl https://api.openai.com/v1/uploads/upload_abc123/complete - -d '{ - "part_ids": ["part_def456", "part_ghi789"] - }' - response: | - { - "id": "upload_abc123", - "object": "upload", - "bytes": 2147483648, - "created_at": 1719184911, - "filename": "training_examples.jsonl", - "purpose": "fine-tune", - "status": "completed", - "expires_at": 1719127296, - "file": { - "id": "file-xyz321", - "object": "file", - "bytes": 2147483648, - "created_at": 1719186911, - "filename": "training_examples.jsonl", - "purpose": "fine-tune", - } - } - '/uploads/{upload_id}/parts': - post: - operationId: addUploadPart - tags: - - Uploads - summary: | - Adds a [Part](/docs/api-reference/uploads/part-object) to an [Upload](/docs/api-reference/uploads/object) object. A Part represents a chunk of bytes from the file you are trying to upload. - - Each Part can be at most 64 MB, and you can add Parts until you hit the Upload maximum of 8 GB. - - It is possible to add multiple Parts in parallel. You can decide the intended order of the Parts when you [complete the Upload](/docs/api-reference/uploads/complete). - parameters: - - in: path - name: upload_id - required: true - schema: - type: string - example: upload_abc123 - description: | - The ID of the Upload. - requestBody: - required: true - content: - multipart/form-data: - schema: - $ref: '#/components/schemas/AddUploadPartRequest' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/UploadPart' - x-oaiMeta: - name: Add upload part - group: uploads - returns: 'The upload [Part](/docs/api-reference/uploads/part-object) object.' - examples: - request: - curl: | - curl https://api.openai.com/v1/uploads/upload_abc123/parts - -F data="aHR0cHM6Ly9hcGkub3BlbmFpLmNvbS92MS91cGxvYWRz..." - response: | - { - "id": "part_def456", - "object": "upload.part", - "created_at": 1719185911, - "upload_id": "upload_abc123" - } +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.last_id + location: body + queryParamPushdown: + top: + paramName: limit + maxValue: 100 diff --git a/providers/src/openai/v00.00.00000/services/users.yaml b/providers/src/openai/v00.00.00000/services/users.yaml deleted file mode 100644 index 57d845c8..00000000 --- a/providers/src/openai/v00.00.00000/services/users.yaml +++ /dev/null @@ -1,372 +0,0 @@ -openapi: 3.0.0 -servers: - - url: 'https://api.openai.com/v1' -info: - version: 2.3.0 - termsOfService: 'https://openai.com/policies/terms-of-use' - contact: - name: OpenAI Support - url: 'https://help.openai.com/' - license: - name: MIT - url: 'https://github.com/openai/openai-openapi/blob/master/LICENSE' - title: OpenAI API - users - description: Users -security: - - ApiKeyAuth: [] -tags: - - name: Assistants - description: Build Assistants that can call models and use tools. - - name: Audio - description: Turn audio into text or text into audio. - - name: Chat - description: 'Given a list of messages comprising a conversation, the model will return a response.' - - name: Completions - description: 'Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.' - - name: Embeddings - description: Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. - - name: Fine-tuning - description: Manage fine-tuning jobs to tailor a model to your specific training data. - - name: Batch - description: Create large batches of API requests to run asynchronously. - - name: Files - description: Files are used to upload documents that can be used with features like Assistants and Fine-tuning. - - name: Uploads - description: Use Uploads to upload large files in multiple parts. - - name: Images - description: 'Given a prompt and/or an input image, the model will generate a new image.' - - name: Models - description: List and describe the various models available in the API. - - name: Moderations - description: 'Given text and/or image inputs, classifies if those inputs are potentially harmful.' - - name: Audit Logs - description: List user actions and configuration changes within this organization. -components: - schemas: - UserListResponse: - type: object - properties: - object: - type: string - enum: - - list - data: - type: array - items: - $ref: '#/components/schemas/User' - first_id: - type: string - last_id: - type: string - has_more: - type: boolean - required: - - object - - data - - first_id - - last_id - - has_more - User: - type: object - description: Represents an individual `user` within an organization. - properties: - object: - type: string - enum: - - organization.user - description: 'The object type, which is always `organization.user`' - id: - type: string - description: 'The identifier, which can be referenced in API endpoints' - name: - type: string - description: The name of the user - email: - type: string - description: The email address of the user - role: - type: string - enum: - - owner - - reader - description: '`owner` or `reader`' - added_at: - type: integer - description: The Unix timestamp (in seconds) of when the user was added. - required: - - object - - id - - name - - email - - role - - added_at - x-oaiMeta: - name: The user object - example: | - { - "object": "organization.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } - UserRoleUpdateRequest: - type: object - properties: - role: - type: string - enum: - - owner - - reader - description: '`owner` or `reader`' - required: - - role - UserDeleteResponse: - type: object - properties: - object: - type: string - enum: - - organization.user.deleted - id: - type: string - deleted: - type: boolean - required: - - object - - id - - deleted - responses: {} - securitySchemes: - ApiKeyAuth: - type: http - scheme: bearer - x-stackQL-resources: - users: - id: openai.users.users - name: users - title: Users - methods: - list_users: - operation: - $ref: '#/paths/~1organization~1users/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/UserListResponse' - objectKey: $.data - retrieve_user: - operation: - $ref: '#/paths/~1organization~1users~1{user_id}/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/User' - modify_user: - operation: - $ref: '#/paths/~1organization~1users~1{user_id}/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/User' - delete_user: - operation: - $ref: '#/paths/~1organization~1users~1{user_id}/delete' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/UserDeleteResponse' - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/users/methods/retrieve_user' - - $ref: '#/components/x-stackQL-resources/users/methods/list_users' - insert: [] - update: - - $ref: '#/components/x-stackQL-resources/users/methods/modify_user' - replace: [] - delete: - - $ref: '#/components/x-stackQL-resources/users/methods/delete_user' -paths: - /organization/users: - get: - summary: Lists all of the users in the organization. - operationId: list-users - tags: - - Users - parameters: - - name: limit - in: query - description: | - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - required: false - schema: - type: integer - default: 20 - - name: after - in: query - 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. - required: false - schema: - type: string - responses: - '200': - description: Users listed successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/UserListResponse' - x-oaiMeta: - name: List users - group: administration - returns: 'A list of [User](/docs/api-reference/users/object) objects.' - examples: - request: - curl: | - curl https://api.openai.com/v1/organization/users?after=user_abc&limit=20 \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" - response: - content: | - { - "object": "list", - "data": [ - { - "object": "organization.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } - ], - "first_id": "user-abc", - "last_id": "user-xyz", - "has_more": false - } - '/organization/users/{user_id}': - get: - summary: Retrieves a user by their identifier. - operationId: retrieve-user - tags: - - Users - parameters: - - name: user_id - in: path - description: The ID of the user. - required: true - schema: - type: string - responses: - '200': - description: User retrieved successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/User' - x-oaiMeta: - name: Retrieve user - group: administration - returns: 'The [User](/docs/api-reference/users/object) object matching the specified ID.' - examples: - request: - curl: | - curl https://api.openai.com/v1/organization/users/user_abc \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } - post: - summary: Modifies a user's role in the organization. - operationId: modify-user - tags: - - Users - parameters: - - name: user_id - in: path - description: The ID of the user. - required: true - schema: - type: string - requestBody: - description: The new user role to modify. This must be one of `owner` or `member`. - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/UserRoleUpdateRequest' - responses: - '200': - description: User role updated successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/User' - x-oaiMeta: - name: Modify user - group: administration - returns: 'The updated [User](/docs/api-reference/users/object) object.' - examples: - request: - curl: | - curl -X POST https://api.openai.com/v1/organization/users/user_abc \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" \ - -d '{ - "role": "owner" - }' - response: - content: | - { - "object": "organization.user", - "id": "user_abc", - "name": "First Last", - "email": "user@example.com", - "role": "owner", - "added_at": 1711471533 - } - delete: - summary: Deletes a user from the organization. - operationId: delete-user - tags: - - Users - parameters: - - name: user_id - in: path - description: The ID of the user. - required: true - schema: - type: string - responses: - '200': - description: User deleted successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/UserDeleteResponse' - x-oaiMeta: - name: Delete user - group: administration - returns: Confirmation of the deleted user - examples: - request: - curl: | - curl -X DELETE https://api.openai.com/v1/organization/users/user_abc \ - -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ - -H "Content-Type: application/json" - response: - content: | - { - "object": "organization.user.deleted", - "id": "user_abc", - "deleted": true - } diff --git a/providers/src/openai/v00.00.00000/services/vector_stores.yaml b/providers/src/openai/v00.00.00000/services/vector_stores.yaml index 39f9038c..c54e7875 100644 --- a/providers/src/openai/v00.00.00000/services/vector_stores.yaml +++ b/providers/src/openai/v00.00.00000/services/vector_stores.yaml @@ -1,818 +1,190 @@ -openapi: 3.0.0 -servers: - - url: 'https://api.openai.com/v1' +openapi: 3.1.0 info: + title: vector_stores API + description: openai API version: 2.3.0 - termsOfService: 'https://openai.com/policies/terms-of-use' - contact: - name: OpenAI Support - url: 'https://help.openai.com/' - license: - name: MIT - url: 'https://github.com/openai/openai-openapi/blob/master/LICENSE' - title: OpenAI API - vector_stores - description: Vector stores -security: - - ApiKeyAuth: [] -tags: - - name: Assistants - description: Build Assistants that can call models and use tools. - - name: Audio - description: Turn audio into text or text into audio. - - name: Chat - description: 'Given a list of messages comprising a conversation, the model will return a response.' - - name: Completions - description: 'Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.' - - name: Embeddings - description: Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. - - name: Fine-tuning - description: Manage fine-tuning jobs to tailor a model to your specific training data. - - name: Batch - description: Create large batches of API requests to run asynchronously. - - name: Files - description: Files are used to upload documents that can be used with features like Assistants and Fine-tuning. - - name: Uploads - description: Use Uploads to upload large files in multiple parts. - - name: Images - description: 'Given a prompt and/or an input image, the model will generate a new image.' - - name: Models - description: List and describe the various models available in the API. - - name: Moderations - description: 'Given text and/or image inputs, classifies if those inputs are potentially harmful.' - - name: Audit Logs - description: List user actions and configuration changes within this organization. -components: - schemas: - ListVectorStoresResponse: - properties: - object: - type: string - example: list - data: - type: array - items: - $ref: '#/components/schemas/VectorStoreObject' - first_id: - type: string - example: vs_abc123 - last_id: - type: string - example: vs_abc456 - has_more: - type: boolean - example: false - required: - - object - - data - - first_id - - last_id - - has_more - VectorStoreObject: - type: object - title: Vector store - description: A vector store is a collection of processed files can be used by the `file_search` tool. - properties: - id: - description: 'The identifier, which can be referenced in API endpoints.' - type: string - object: - description: 'The object type, which is always `vector_store`.' - type: string - enum: - - vector_store - created_at: - description: The Unix timestamp (in seconds) for when the vector store was created. - type: integer - name: - description: The name of the vector store. - type: string - usage_bytes: - description: The total number of bytes used by the files in the vector store. - type: integer - file_counts: - type: object - properties: - in_progress: - description: The number of files that are currently being processed. - type: integer - completed: - description: The number of files that have been successfully processed. - type: integer - failed: - description: The number of files that have failed to process. - type: integer - cancelled: - description: The number of files that were cancelled. - type: integer - total: - description: The total number of files. - type: integer - required: - - in_progress - - completed - - failed - - cancelled - - total - status: - description: 'The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use.' - type: string - enum: - - expired - - in_progress - - completed - expires_after: - $ref: '#/components/schemas/VectorStoreExpirationAfter' - expires_at: - description: The Unix timestamp (in seconds) for when the vector store will expire. - type: integer - nullable: true - last_active_at: - description: The Unix timestamp (in seconds) for when the vector store was last active. - type: integer - nullable: true - metadata: - description: | - Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true - required: - - id - - object - - usage_bytes - - created_at - - status - - last_active_at - - name - - file_counts - - metadata - x-oaiMeta: - name: The vector store object - beta: true - example: | - { - "id": "vs_123", - "object": "vector_store", - "created_at": 1698107661, - "usage_bytes": 123456, - "last_active_at": 1698107661, - "name": "my_vector_store", - "status": "completed", - "file_counts": { - "in_progress": 0, - "completed": 100, - "cancelled": 0, - "failed": 0, - "total": 100 - }, - "metadata": {}, - "last_used_at": 1698107661 - } - VectorStoreExpirationAfter: - type: object - title: Vector store expiration policy - description: The expiration policy for a vector store. - properties: - anchor: - description: 'Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`.' - type: string - enum: - - last_active_at - days: - description: The number of days after the anchor time that the vector store will expire. - type: integer - minimum: 1 - maximum: 365 - required: - - anchor - - days - CreateVectorStoreRequest: - type: object - additionalProperties: false - properties: - file_ids: - description: 'A list of [File](/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files.' - type: array - maxItems: 500 - items: - type: string - name: - description: The name of the vector store. - type: string - expires_after: - $ref: '#/components/schemas/VectorStoreExpirationAfter' - chunking_strategy: - type: object - description: 'The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. Only applicable if `file_ids` is non-empty.' - oneOf: - - $ref: '#/components/schemas/AutoChunkingStrategyRequestParam' - - $ref: '#/components/schemas/StaticChunkingStrategyRequestParam' - x-oaiExpandable: true - metadata: - description: | - Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true - AutoChunkingStrategyRequestParam: - type: object - title: Auto Chunking Strategy - description: The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`. - additionalProperties: false - properties: - type: - type: string - description: Always `auto`. - enum: - - auto - required: - - type - StaticChunkingStrategyRequestParam: - type: object - title: Static Chunking Strategy - additionalProperties: false - properties: - type: - type: string - description: Always `static`. - enum: - - static - static: - $ref: '#/components/schemas/StaticChunkingStrategy' - required: - - type - - static - StaticChunkingStrategy: - type: object - additionalProperties: false - properties: - max_chunk_size_tokens: - type: integer - minimum: 100 - maximum: 4096 - description: The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`. - chunk_overlap_tokens: - type: integer - description: | - The number of tokens that overlap between chunks. The default value is `400`. +paths: + /vector_stores: + get: + operationId: listVectorStores + tags: + - Vector stores + summary: Returns a list of vector stores. + parameters: + - name: limit + in: query + description: >- + A limit on the number of objects to be returned. Limit can range + between 1 and 100, and the default is 20. - Note that the overlap must not exceed half of `max_chunk_size_tokens`. - required: - - max_chunk_size_tokens - - chunk_overlap_tokens - UpdateVectorStoreRequest: - type: object - additionalProperties: false - properties: - name: - description: The name of the vector store. - type: string - nullable: true - expires_after: - $ref: '#/components/schemas/VectorStoreExpirationAfter' - nullable: true - metadata: - description: | - Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true - DeleteVectorStoreResponse: - type: object - properties: - id: - type: string - deleted: - type: boolean - object: - type: string - enum: - - vector_store.deleted - required: - - id - - object - - deleted - CreateVectorStoreFileBatchRequest: - type: object - additionalProperties: false - properties: - file_ids: - description: 'A list of [File](/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files.' - type: array - minItems: 1 - maxItems: 500 - items: + + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: > + Sort order by the `created_at` timestamp of the objects. `asc` for + ascending order and `desc` for descending order. + schema: type: string - chunking_strategy: - $ref: '#/components/schemas/ChunkingStrategyRequestParam' - required: - - file_ids - VectorStoreFileBatchObject: - type: object - title: Vector store file batch - description: A batch of files attached to a vector store. - properties: - id: - description: 'The identifier, which can be referenced in API endpoints.' - type: string - object: - description: 'The object type, which is always `vector_store.file_batch`.' - type: string - enum: - - vector_store.files_batch - created_at: - description: The Unix timestamp (in seconds) for when the vector store files batch was created. - type: integer - vector_store_id: - description: 'The ID of the [vector store](/docs/api-reference/vector-stores/object) that the [File](/docs/api-reference/files) is attached to.' - type: string - status: - description: 'The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`.' - type: string - enum: - - in_progress - - completed - - cancelled - - failed - file_counts: - type: object - properties: - in_progress: - description: The number of files that are currently being processed. - type: integer - completed: - description: The number of files that have been processed. - type: integer - failed: - description: The number of files that have failed to process. - type: integer - cancelled: - description: The number of files that where cancelled. - type: integer - total: - description: The total number of files. - type: integer - required: - - in_progress - - completed - - cancelled - - failed - - total - required: - - id - - object - - created_at - - vector_store_id - - status - - file_counts - x-oaiMeta: - name: The vector store files batch object - beta: true - example: | - { - "id": "vsfb_123", - "object": "vector_store.files_batch", - "created_at": 1698107661, - "vector_store_id": "vs_abc123", - "status": "completed", - "file_counts": { - "in_progress": 0, - "completed": 100, - "failed": 0, - "cancelled": 0, - "total": 100 - } - } - ChunkingStrategyRequestParam: - type: object - description: 'The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy.' - oneOf: - - $ref: '#/components/schemas/AutoChunkingStrategyRequestParam' - - $ref: '#/components/schemas/StaticChunkingStrategyRequestParam' - x-oaiExpandable: true - ListVectorStoreFilesResponse: - properties: - object: - type: string - example: list - data: - type: array - items: - $ref: '#/components/schemas/VectorStoreFileObject' - first_id: - type: string - example: file-abc123 - last_id: - type: string - example: file-abc456 - has_more: - type: boolean - example: false - required: - - object - - data - - first_id - - last_id - - has_more - VectorStoreFileObject: - type: object - title: Vector store files - description: A list of files attached to a vector store. - properties: - id: - description: 'The identifier, which can be referenced in API endpoints.' - type: string - object: - description: 'The object type, which is always `vector_store.file`.' - type: string - enum: - - vector_store.file - usage_bytes: - description: The total vector store usage in bytes. Note that this may be different from the original file size. - type: integer - created_at: - description: The Unix timestamp (in seconds) for when the vector store file was created. - type: integer - vector_store_id: - description: 'The ID of the [vector store](/docs/api-reference/vector-stores/object) that the [File](/docs/api-reference/files) is attached to.' - type: string - status: - description: 'The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use.' - type: string - enum: - - in_progress - - completed - - cancelled - - failed - last_error: - type: object - description: The last error associated with this vector store file. Will be `null` if there are no errors. - nullable: true - properties: - code: - type: string - description: One of `server_error` or `rate_limit_exceeded`. - enum: - - server_error - - unsupported_file - - invalid_file - message: - type: string - description: A human-readable description of the error. - required: - - code - - message - chunking_strategy: - type: object - description: The strategy used to chunk the file. - oneOf: - - $ref: '#/components/schemas/StaticChunkingStrategyResponseParam' - - $ref: '#/components/schemas/OtherChunkingStrategyResponseParam' - x-oaiExpandable: true - required: - - id - - object - - usage_bytes - - created_at - - vector_store_id - - status - - last_error + default: desc + enum: + - asc + - desc + - name: after + in: query + 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 + - name: before + in: query + 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 + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ListVectorStoresResponse' x-oaiMeta: - name: The vector store file object - beta: true - example: | - { - "id": "file-abc123", - "object": "vector_store.file", - "usage_bytes": 1234, - "created_at": 1698107661, - "vector_store_id": "vs_abc123", - "status": "completed", - "last_error": null, - "chunking_strategy": { - "type": "static", - "static": { - "max_chunk_size_tokens": 800, - "chunk_overlap_tokens": 400 + name: List vector stores + group: vector_stores + examples: + request: + curl: | + curl https://api.openai.com/v1/vector_stores \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.vector_stores.list() + page = page.data[0] + print(page.id) + javascript: | + import OpenAI from "openai"; + const openai = new OpenAI(); + + async function main() { + const vectorStores = await openai.vectorStores.list(); + console.log(vectorStores); + } + + main(); + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const vectorStore of client.vectorStores.list()) { + console.log(vectorStore.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.VectorStores.List(context.TODO(), openai.VectorStoreListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.vectorstores.VectorStoreListPage; + import com.openai.models.vectorstores.VectorStoreListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + VectorStoreListPage page = client.vectorStores().list(); + } } - } - } - StaticChunkingStrategyResponseParam: - type: object - title: Static Chunking Strategy - additionalProperties: false - properties: - type: - type: string - description: Always `static`. - enum: - - static - static: - $ref: '#/components/schemas/StaticChunkingStrategy' - required: - - type - - static - OtherChunkingStrategyResponseParam: - type: object - title: Other Chunking Strategy - description: 'This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the `chunking_strategy` concept was introduced in the API.' - additionalProperties: false - properties: - type: - type: string - description: Always `other`. - enum: - - other - required: - - type - CreateVectorStoreFileRequest: - type: object - additionalProperties: false - properties: - file_id: - description: 'A [File](/docs/api-reference/files) ID that the vector store should use. Useful for tools like `file_search` that can access files.' - type: string - chunking_strategy: - $ref: '#/components/schemas/ChunkingStrategyRequestParam' - required: - - file_id - DeleteVectorStoreFileResponse: - type: object - properties: - id: - type: string - deleted: - type: boolean - object: - type: string - enum: - - vector_store.file.deleted - required: - - id - - object - - deleted - responses: {} - securitySchemes: - ApiKeyAuth: - type: http - scheme: bearer - x-stackQL-resources: - vector_stores: - id: openai.vector_stores.vector_stores - name: vector_stores - title: Vector Stores - methods: - list_vector_stores: - operation: - $ref: '#/paths/~1vector_stores/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ListVectorStoresResponse' - create_vector_store: - operation: - $ref: '#/paths/~1vector_stores/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/VectorStoreObject' - get_vector_store: - operation: - $ref: '#/paths/~1vector_stores~1{vector_store_id}/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/VectorStoreObject' - modify_vector_store: - operation: - $ref: '#/paths/~1vector_stores~1{vector_store_id}/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/VectorStoreObject' - delete_vector_store: - operation: - $ref: '#/paths/~1vector_stores~1{vector_store_id}/delete' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/DeleteVectorStoreResponse' - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/vector_stores/methods/get_vector_store' - - $ref: '#/components/x-stackQL-resources/vector_stores/methods/list_vector_stores' - insert: - - $ref: '#/components/x-stackQL-resources/vector_stores/methods/create_vector_store' - update: - - $ref: '#/components/x-stackQL-resources/vector_stores/methods/modify_vector_store' - replace: [] - delete: - - $ref: '#/components/x-stackQL-resources/vector_stores/methods/delete_vector_store' - vector_store_file_batches: - id: openai.vector_stores.vector_store_file_batches - name: vector_store_file_batches - title: Vector Store File Batches - methods: - create_vector_store_file_batch: - operation: - $ref: '#/paths/~1vector_stores~1{vector_store_id}~1file_batches/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/VectorStoreFileBatchObject' - get_vector_store_file_batch: - operation: - $ref: '#/paths/~1vector_stores~1{vector_store_id}~1file_batches~1{batch_id}/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/VectorStoreFileBatchObject' - cancel_vector_store_file_batch: - operation: - $ref: '#/paths/~1vector_stores~1{vector_store_id}~1file_batches~1{batch_id}~1cancel/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/VectorStoreFileBatchObject' - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/vector_store_file_batches/methods/get_vector_store_file_batch' - insert: - - $ref: '#/components/x-stackQL-resources/vector_store_file_batches/methods/create_vector_store_file_batch' - update: [] - replace: [] - delete: [] - files_in_vector_store_batches: - id: openai.vector_stores.files_in_vector_store_batches - name: files_in_vector_store_batches - title: Files In Vector Store Batches - methods: - list_files_in_vector_store_batch: - operation: - $ref: '#/paths/~1vector_stores~1{vector_store_id}~1file_batches~1{batch_id}~1files/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ListVectorStoreFilesResponse' - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/files_in_vector_store_batches/methods/list_files_in_vector_store_batch' - insert: [] - update: [] - replace: [] - delete: [] - vector_store_files: - id: openai.vector_stores.vector_store_files - name: vector_store_files - title: Vector Store Files - methods: - list_vector_store_files: - operation: - $ref: '#/paths/~1vector_stores~1{vector_store_id}~1files/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/ListVectorStoreFilesResponse' - create_vector_store_file: - operation: - $ref: '#/paths/~1vector_stores~1{vector_store_id}~1files/post' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/VectorStoreFileObject' - get_vector_store_file: - operation: - $ref: '#/paths/~1vector_stores~1{vector_store_id}~1files~1{file_id}/get' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/VectorStoreFileObject' - delete_vector_store_file: - operation: - $ref: '#/paths/~1vector_stores~1{vector_store_id}~1files~1{file_id}/delete' - response: - mediaType: application/json - openAPIDocKey: '200' - schemaRef: '#/components/schemas/DeleteVectorStoreFileResponse' - sqlVerbs: - select: - - $ref: '#/components/x-stackQL-resources/vector_store_files/methods/get_vector_store_file' - - $ref: '#/components/x-stackQL-resources/vector_store_files/methods/list_vector_store_files' - insert: - - $ref: '#/components/x-stackQL-resources/vector_store_files/methods/create_vector_store_file' - update: [] - replace: [] - delete: - - $ref: '#/components/x-stackQL-resources/vector_store_files/methods/delete_vector_store_file' -paths: - /vector_stores: - get: - operationId: listVectorStores - tags: - - Vector stores - summary: Returns a list of vector stores. - parameters: - - name: limit - in: query - description: | - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - required: false - schema: - type: integer - default: 20 - - name: order - in: query - description: | - Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. - schema: - type: string - default: desc - enum: - - asc - - desc - - name: after - in: query - 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 - - name: before - in: query - 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, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - schema: - type: string - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ListVectorStoresResponse' - x-oaiMeta: - name: List vector stores - group: vector_stores - beta: true - returns: 'A list of [vector store](/docs/api-reference/vector-stores/object) objects.' - examples: - request: - curl: | - curl https://api.openai.com/v1/vector_stores \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from openai import OpenAI - client = OpenAI() - - vector_stores = client.beta.vector_stores.list() - print(vector_stores) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); - - async function main() { - const vectorStores = await openai.beta.vectorStores.list(); - console.log(vectorStores); - } - - main(); - response: | - { - "object": "list", - "data": [ - { - "id": "vs_abc123", - "object": "vector_store", - "created_at": 1699061776, - "name": "Support FAQ", - "bytes": 139920, - "file_counts": { - "in_progress": 0, - "completed": 3, - "failed": 0, - "cancelled": 0, - "total": 3 - } - }, - { - "id": "vs_abc456", - "object": "vector_store", - "created_at": 1699061776, - "name": "Support FAQ v2", - "bytes": 139920, - "file_counts": { - "in_progress": 0, - "completed": 3, - "failed": 0, - "cancelled": 0, - "total": 3 - } - } - ], - "first_id": "vs_abc123", - "last_id": "vs_abc456", - "has_more": false + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + page = openai.vector_stores.list + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "id": "vs_abc123", + "object": "vector_store", + "created_at": 1699061776, + "name": "Support FAQ", + "description": "Contains commonly asked questions and answers, organized by topic.", + "bytes": 139920, + "file_counts": { + "in_progress": 0, + "completed": 3, + "failed": 0, + "cancelled": 0, + "total": 3 + } + }, + { + "id": "vs_abc456", + "object": "vector_store", + "created_at": 1699061776, + "name": "Support FAQ v2", + "description": null, + "bytes": 139920, + "file_counts": { + "in_progress": 0, + "completed": 3, + "failed": 0, + "cancelled": 0, + "total": 3 + } + } + ], + "first_id": "vs_abc123", + "last_id": "vs_abc456", + "has_more": false } post: operationId: createVectorStore @@ -835,45 +207,81 @@ paths: x-oaiMeta: name: Create vector store group: vector_stores - beta: true - returns: 'A [vector store](/docs/api-reference/vector-stores/object) object.' examples: request: curl: | curl https://api.openai.com/v1/vector_stores \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" + -H "OpenAI-Beta: assistants=v2" \ -d '{ "name": "Support FAQ" }' - python: | + python: |- + import os from openai import OpenAI - client = OpenAI() - vector_store = client.beta.vector_stores.create( - name="Support FAQ" + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted ) - print(vector_store) - node.js: | + vector_store = client.vector_stores.create() + print(vector_store.id) + javascript: | import OpenAI from "openai"; const openai = new OpenAI(); async function main() { - const vectorStore = await openai.beta.vectorStores.create({ + const vectorStore = await openai.vectorStores.create({ name: "Support FAQ" }); console.log(vectorStore); } main(); - response: | - { - "id": "vs_abc123", - "object": "vector_store", - "created_at": 1699061776, - "name": "Support FAQ", - "bytes": 139920, + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + const vectorStore = await client.vectorStores.create(); + + console.log(vectorStore.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\tvectorStore, err := client.VectorStores.New(context.TODO(), openai.VectorStoreNewParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", vectorStore.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.vectorstores.VectorStore; + import com.openai.models.vectorstores.VectorStoreCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + VectorStore vectorStore = client.vectorStores().create(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + vector_store = openai.vector_stores.create + + puts(vector_store) + response: | + { + "id": "vs_abc123", + "object": "vector_store", + "created_at": 1699061776, + "name": "Support FAQ", + "description": "Contains commonly asked questions and answers, organized by topic.", + "bytes": 139920, "file_counts": { "in_progress": 0, "completed": 3, @@ -882,7 +290,26 @@ paths: "total": 3 } } - '/vector_stores/{vector_store_id}': + parameters: + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + /vector_stores/{vector_store_id}: get: operationId: getVectorStore tags: @@ -895,6 +322,24 @@ paths: schema: type: string description: The ID of the vector store to retrieve. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string responses: '200': description: OK @@ -905,8 +350,6 @@ paths: x-oaiMeta: name: Retrieve vector store group: vector_stores - beta: true - returns: 'The [vector store](/docs/api-reference/vector-stores/object) object matching the specified ID.' examples: request: curl: | @@ -914,26 +357,69 @@ paths: -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" - python: | + python: |- + import os from openai import OpenAI - client = OpenAI() - vector_store = client.beta.vector_stores.retrieve( - vector_store_id="vs_abc123" + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + vector_store = client.vector_stores.retrieve( + "vector_store_id", ) - print(vector_store) - node.js: | + print(vector_store.id) + javascript: | import OpenAI from "openai"; const openai = new OpenAI(); async function main() { - const vectorStore = await openai.beta.vectorStores.retrieve( + const vectorStore = await openai.vectorStores.retrieve( "vs_abc123" ); console.log(vectorStore); } main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const vectorStore = await + client.vectorStores.retrieve('vector_store_id'); + + + console.log(vectorStore.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\tvectorStore, err := client.VectorStores.Get(context.TODO(), \"vector_store_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", vectorStore.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.vectorstores.VectorStore; + import com.openai.models.vectorstores.VectorStoreRetrieveParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + VectorStore vectorStore = client.vectorStores().retrieve("vector_store_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + vector_store = openai.vector_stores.retrieve("vector_store_id") + + puts(vector_store) response: | { "id": "vs_abc123", @@ -952,6 +438,24 @@ paths: schema: type: string description: The ID of the vector store to modify. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string requestBody: required: true content: @@ -968,8 +472,6 @@ paths: x-oaiMeta: name: Modify vector store group: vector_stores - beta: true - returns: 'The modified [vector store](/docs/api-reference/vector-stores/object) object.' examples: request: curl: | @@ -980,21 +482,23 @@ paths: -d '{ "name": "Support FAQ" }' - python: | + python: |- + import os from openai import OpenAI - client = OpenAI() - vector_store = client.beta.vector_stores.update( - vector_store_id="vs_abc123", - name="Support FAQ" + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted ) - print(vector_store) - node.js: | + vector_store = client.vector_stores.update( + vector_store_id="vector_store_id", + ) + print(vector_store.id) + javascript: | import OpenAI from "openai"; const openai = new OpenAI(); async function main() { - const vectorStore = await openai.beta.vectorStores.update( + const vectorStore = await openai.vectorStores.update( "vs_abc123", { name: "Support FAQ" @@ -1004,12 +508,53 @@ paths: } main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const vectorStore = await + client.vectorStores.update('vector_store_id'); + + + console.log(vectorStore.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\tvectorStore, err := client.VectorStores.Update(\n\t\tcontext.TODO(),\n\t\t\"vector_store_id\",\n\t\topenai.VectorStoreUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", vectorStore.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.vectorstores.VectorStore; + import com.openai.models.vectorstores.VectorStoreUpdateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + VectorStore vectorStore = client.vectorStores().update("vector_store_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + vector_store = openai.vector_stores.update("vector_store_id") + + puts(vector_store) response: | { "id": "vs_abc123", "object": "vector_store", "created_at": 1699061776, "name": "Support FAQ", + "description": "Contains commonly asked questions and answers, organized by topic.", "bytes": 139920, "file_counts": { "in_progress": 0, @@ -1031,6 +576,24 @@ paths: schema: type: string description: The ID of the vector store to delete. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string responses: '200': description: OK @@ -1039,723 +602,2944 @@ paths: schema: $ref: '#/components/schemas/DeleteVectorStoreResponse' x-oaiMeta: - name: Delete vector store - group: vector_stores + name: Delete vector store + group: vector_stores + examples: + request: + curl: | + curl https://api.openai.com/v1/vector_stores/vs_abc123 \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" \ + -X DELETE + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + vector_store_deleted = client.vector_stores.delete( + "vector_store_id", + ) + print(vector_store_deleted.id) + javascript: | + import OpenAI from "openai"; + const openai = new OpenAI(); + + async function main() { + const deletedVectorStore = await openai.vectorStores.delete( + "vs_abc123" + ); + console.log(deletedVectorStore); + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const vectorStoreDeleted = await + client.vectorStores.delete('vector_store_id'); + + + console.log(vectorStoreDeleted.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\tvectorStoreDeleted, err := client.VectorStores.Delete(context.TODO(), \"vector_store_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", vectorStoreDeleted.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.vectorstores.VectorStoreDeleteParams; + import com.openai.models.vectorstores.VectorStoreDeleted; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + VectorStoreDeleted vectorStoreDeleted = client.vectorStores().delete("vector_store_id"); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + vector_store_deleted = + openai.vector_stores.delete("vector_store_id") + + + puts(vector_store_deleted) + response: | + { + id: "vs_abc123", + object: "vector_store.deleted", + deleted: true + } + /vector_stores/{vector_store_id}/file_batches: + post: + operationId: createVectorStoreFileBatch + tags: + - Vector stores + summary: Create a vector store file batch. + description: > + The maximum number of files in a single batch request is 2000. + + Vector store file attach requests are rate limited per vector store (300 + requests per minute across both this endpoint and + `/vector_stores/{vector_store_id}/files`). + + For ingesting multiple files into the same vector store, this batch + endpoint is recommended. + parameters: + - in: path + name: vector_store_id + required: true + schema: + type: string + example: vs_abc123 + description: | + The ID of the vector store for which to create a File Batch. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateVectorStoreFileBatchRequest' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/VectorStoreFileBatchObject' + x-oaiMeta: + name: Create vector store file batch + group: vector_stores + description: > + Attaches multiple files to a vector store in one request. This is the + recommended approach for multi-file ingestion, especially because + per-vector-store file attach writes are rate-limited (300 + requests/minute shared with `/vector_stores/{vector_store_id}/files`). + examples: + request: + curl: > + curl + https://api.openai.com/v1/vector_stores/vs_abc123/file_batches \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "files": [ + { + "file_id": "file-abc123", + "attributes": {"category": "finance"} + }, + { + "file_id": "file-abc456", + "chunking_strategy": { + "type": "static", + "max_chunk_size_tokens": 1200, + "chunk_overlap_tokens": 200 + } + } + ] + }' + python: >- + import os + + from openai import OpenAI + + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + + vector_store_file_batch = + client.vector_stores.file_batches.create( + vector_store_id="vs_abc123", + ) + + print(vector_store_file_batch.id) + javascript: | + import OpenAI from "openai"; + const openai = new OpenAI(); + + async function main() { + const myVectorStoreFileBatch = await openai.vectorStores.fileBatches.create( + "vs_abc123", + { + files: [ + { + file_id: "file-abc123", + attributes: { category: "finance" }, + }, + { + file_id: "file-abc456", + chunking_strategy: { + type: "static", + max_chunk_size_tokens: 1200, + chunk_overlap_tokens: 200, + }, + }, + ] + } + ); + console.log(myVectorStoreFileBatch); + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const vectorStoreFileBatch = await + client.vectorStores.fileBatches.create('vs_abc123'); + + + console.log(vectorStoreFileBatch.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\tvectorStoreFileBatch, err := client.VectorStores.FileBatches.New(\n\t\tcontext.TODO(),\n\t\t\"vs_abc123\",\n\t\topenai.VectorStoreFileBatchNewParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", vectorStoreFileBatch.ID)\n}\n" + java: >- + package com.openai.example; + + + import com.openai.client.OpenAIClient; + + import com.openai.client.okhttp.OpenAIOkHttpClient; + + import + com.openai.models.vectorstores.filebatches.FileBatchCreateParams; + + import + com.openai.models.vectorstores.filebatches.VectorStoreFileBatch; + + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + VectorStoreFileBatch vectorStoreFileBatch = client.vectorStores().fileBatches().create("vs_abc123"); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + vector_store_file_batch = + openai.vector_stores.file_batches.create("vs_abc123") + + + puts(vector_store_file_batch) + response: | + { + "id": "vsfb_abc123", + "object": "vector_store.file_batch", + "created_at": 1699061776, + "vector_store_id": "vs_abc123", + "status": "in_progress", + "file_counts": { + "in_progress": 1, + "completed": 1, + "failed": 0, + "cancelled": 0, + "total": 0, + } + } + /vector_stores/{vector_store_id}/file_batches/{batch_id}: + get: + operationId: getVectorStoreFileBatch + tags: + - Vector stores + summary: Retrieves a vector store file batch. + parameters: + - in: path + name: vector_store_id + required: true + schema: + type: string + example: vs_abc123 + description: The ID of the vector store that the file batch belongs to. + - in: path + name: batch_id + required: true + schema: + type: string + example: vsfb_abc123 + description: The ID of the file batch being retrieved. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/VectorStoreFileBatchObject' + x-oaiMeta: + name: Retrieve vector store file batch + group: vector_stores + examples: + request: + curl: > + curl + https://api.openai.com/v1/vector_stores/vs_abc123/file_batches/vsfb_abc123 + \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + python: >- + import os + + from openai import OpenAI + + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + + vector_store_file_batch = + client.vector_stores.file_batches.retrieve( + batch_id="vsfb_abc123", + vector_store_id="vs_abc123", + ) + + print(vector_store_file_batch.id) + javascript: | + import OpenAI from "openai"; + const openai = new OpenAI(); + + async function main() { + const vectorStoreFileBatch = await openai.vectorStores.fileBatches.retrieve( + "vsfb_abc123", + { vector_store_id: "vs_abc123" } + ); + console.log(vectorStoreFileBatch); + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const vectorStoreFileBatch = await + client.vectorStores.fileBatches.retrieve('vsfb_abc123', { + vector_store_id: 'vs_abc123', + }); + + + console.log(vectorStoreFileBatch.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\tvectorStoreFileBatch, err := client.VectorStores.FileBatches.Get(\n\t\tcontext.TODO(),\n\t\t\"vs_abc123\",\n\t\t\"vsfb_abc123\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", vectorStoreFileBatch.ID)\n}\n" + java: >- + package com.openai.example; + + + import com.openai.client.OpenAIClient; + + import com.openai.client.okhttp.OpenAIOkHttpClient; + + import + com.openai.models.vectorstores.filebatches.FileBatchRetrieveParams; + + import + com.openai.models.vectorstores.filebatches.VectorStoreFileBatch; + + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + FileBatchRetrieveParams params = FileBatchRetrieveParams.builder() + .vectorStoreId("vs_abc123") + .batchId("vsfb_abc123") + .build(); + VectorStoreFileBatch vectorStoreFileBatch = client.vectorStores().fileBatches().retrieve(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + vector_store_file_batch = + openai.vector_stores.file_batches.retrieve("vsfb_abc123", + vector_store_id: "vs_abc123") + + + puts(vector_store_file_batch) + response: | + { + "id": "vsfb_abc123", + "object": "vector_store.file_batch", + "created_at": 1699061776, + "vector_store_id": "vs_abc123", + "status": "in_progress", + "file_counts": { + "in_progress": 1, + "completed": 1, + "failed": 0, + "cancelled": 0, + "total": 0, + } + } + /vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel: + post: + operationId: cancelVectorStoreFileBatch + tags: + - Vector stores + summary: >- + Cancel a vector store file batch. This attempts to cancel the processing + of files in this batch as soon as possible. + parameters: + - in: path + name: vector_store_id + required: true + schema: + type: string + description: The ID of the vector store that the file batch belongs to. + - in: path + name: batch_id + required: true + schema: + type: string + description: The ID of the file batch to cancel. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/VectorStoreFileBatchObject' + x-oaiMeta: + name: Cancel vector store file batch + group: vector_stores + examples: + request: + curl: > + curl + https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/cancel + \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" \ + -X POST + python: >- + import os + + from openai import OpenAI + + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + + vector_store_file_batch = + client.vector_stores.file_batches.cancel( + batch_id="batch_id", + vector_store_id="vector_store_id", + ) + + print(vector_store_file_batch.id) + javascript: | + import OpenAI from "openai"; + const openai = new OpenAI(); + + async function main() { + const deletedVectorStoreFileBatch = await openai.vectorStores.fileBatches.cancel( + "vsfb_abc123", + { vector_store_id: "vs_abc123" } + ); + console.log(deletedVectorStoreFileBatch); + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const vectorStoreFileBatch = await + client.vectorStores.fileBatches.cancel('batch_id', { + vector_store_id: 'vector_store_id', + }); + + + console.log(vectorStoreFileBatch.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\tvectorStoreFileBatch, err := client.VectorStores.FileBatches.Cancel(\n\t\tcontext.TODO(),\n\t\t\"vector_store_id\",\n\t\t\"batch_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", vectorStoreFileBatch.ID)\n}\n" + java: >- + package com.openai.example; + + + import com.openai.client.OpenAIClient; + + import com.openai.client.okhttp.OpenAIOkHttpClient; + + import + com.openai.models.vectorstores.filebatches.FileBatchCancelParams; + + import + com.openai.models.vectorstores.filebatches.VectorStoreFileBatch; + + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + FileBatchCancelParams params = FileBatchCancelParams.builder() + .vectorStoreId("vector_store_id") + .batchId("batch_id") + .build(); + VectorStoreFileBatch vectorStoreFileBatch = client.vectorStores().fileBatches().cancel(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + vector_store_file_batch = + openai.vector_stores.file_batches.cancel("batch_id", + vector_store_id: "vector_store_id") + + + puts(vector_store_file_batch) + response: | + { + "id": "vsfb_abc123", + "object": "vector_store.file_batch", + "created_at": 1699061776, + "vector_store_id": "vs_abc123", + "status": "in_progress", + "file_counts": { + "in_progress": 12, + "completed": 3, + "failed": 0, + "cancelled": 0, + "total": 15, + } + } + /vector_stores/{vector_store_id}/file_batches/{batch_id}/files: + get: + operationId: listFilesInVectorStoreBatch + tags: + - Vector stores + summary: Returns a list of vector store files in a batch. + parameters: + - name: vector_store_id + in: path + description: The ID of the vector store that the files belong to. + required: true + schema: + type: string + - name: batch_id + in: path + description: The ID of the file batch that the files belong to. + required: true + schema: + type: string + - name: limit + in: query + description: >- + A limit on the number of objects to be returned. Limit can range + between 1 and 100, and the default is 20. + + + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: > + Sort order by the `created_at` timestamp of the objects. `asc` for + ascending order and `desc` for descending order. + schema: + type: string + default: desc + enum: + - asc + - desc + - name: after + in: query + 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 + - name: before + in: query + 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 + - name: filter + in: query + description: >- + Filter by file status. One of `in_progress`, `completed`, `failed`, + `cancelled`. + schema: + type: string + enum: + - in_progress + - completed + - failed + - cancelled + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ListVectorStoreFilesResponse' + x-oaiMeta: + name: List vector store files in a batch + group: vector_stores + examples: + request: + curl: > + curl + https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/files + \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.vector_stores.file_batches.list_files( + batch_id="batch_id", + vector_store_id="vector_store_id", + ) + page = page.data[0] + print(page.id) + javascript: | + import OpenAI from "openai"; + const openai = new OpenAI(); + + async function main() { + const vectorStoreFiles = await openai.vectorStores.fileBatches.listFiles( + "vsfb_abc123", + { vector_store_id: "vs_abc123" } + ); + console.log(vectorStoreFiles); + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + // Automatically fetches more pages as needed. + + for await (const vectorStoreFile of + client.vectorStores.fileBatches.listFiles('batch_id', { + vector_store_id: 'vector_store_id', + })) { + console.log(vectorStoreFile.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.VectorStores.FileBatches.ListFiles(\n\t\tcontext.TODO(),\n\t\t\"vector_store_id\",\n\t\t\"batch_id\",\n\t\topenai.VectorStoreFileBatchListFilesParams{},\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; + + + import com.openai.client.OpenAIClient; + + import com.openai.client.okhttp.OpenAIOkHttpClient; + + import + com.openai.models.vectorstores.filebatches.FileBatchListFilesPage; + + import + com.openai.models.vectorstores.filebatches.FileBatchListFilesParams; + + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + FileBatchListFilesParams params = FileBatchListFilesParams.builder() + .vectorStoreId("vector_store_id") + .batchId("batch_id") + .build(); + FileBatchListFilesPage page = client.vectorStores().fileBatches().listFiles(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + page = openai.vector_stores.file_batches.list_files("batch_id", + vector_store_id: "vector_store_id") + + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "id": "file-abc123", + "object": "vector_store.file", + "created_at": 1699061776, + "vector_store_id": "vs_abc123" + }, + { + "id": "file-abc456", + "object": "vector_store.file", + "created_at": 1699061776, + "vector_store_id": "vs_abc123" + } + ], + "first_id": "file-abc123", + "last_id": "file-abc456", + "has_more": false + } + /vector_stores/{vector_store_id}/files: + get: + operationId: listVectorStoreFiles + tags: + - Vector stores + summary: Returns a list of vector store files. + parameters: + - name: vector_store_id + in: path + description: The ID of the vector store that the files belong to. + required: true + schema: + type: string + - name: limit + in: query + description: >- + A limit on the number of objects to be returned. Limit can range + between 1 and 100, and the default is 20. + + + Automatically applied from a SQL `LIMIT` clause - `SELECT ... LIMIT + 10` sends `limit=10` on the wire. Setting it explicitly in a `WHERE` + clause is not required. + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: > + Sort order by the `created_at` timestamp of the objects. `asc` for + ascending order and `desc` for descending order. + schema: + type: string + default: desc + enum: + - asc + - desc + - name: after + in: query + 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 + - name: before + in: query + 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 + - name: filter + in: query + description: >- + Filter by file status. One of `in_progress`, `completed`, `failed`, + `cancelled`. + schema: + type: string + enum: + - in_progress + - completed + - failed + - cancelled + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ListVectorStoreFilesResponse' + x-oaiMeta: + name: List vector store files + group: vector_stores + examples: + request: + curl: | + curl https://api.openai.com/v1/vector_stores/vs_abc123/files \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.vector_stores.files.list( + vector_store_id="vector_store_id", + ) + page = page.data[0] + print(page.id) + javascript: | + import OpenAI from "openai"; + const openai = new OpenAI(); + + async function main() { + const vectorStoreFiles = await openai.vectorStores.files.list( + "vs_abc123" + ); + console.log(vectorStoreFiles); + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + // Automatically fetches more pages as needed. + + for await (const vectorStoreFile of + client.vectorStores.files.list('vector_store_id')) { + console.log(vectorStoreFile.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.VectorStores.Files.List(\n\t\tcontext.TODO(),\n\t\t\"vector_store_id\",\n\t\topenai.VectorStoreFileListParams{},\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.vectorstores.files.FileListPage; + import com.openai.models.vectorstores.files.FileListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + FileListPage page = client.vectorStores().files().list("vector_store_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + page = openai.vector_stores.files.list("vector_store_id") + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "id": "file-abc123", + "object": "vector_store.file", + "created_at": 1699061776, + "vector_store_id": "vs_abc123" + }, + { + "id": "file-abc456", + "object": "vector_store.file", + "created_at": 1699061776, + "vector_store_id": "vs_abc123" + } + ], + "first_id": "file-abc123", + "last_id": "file-abc456", + "has_more": false + } + post: + operationId: createVectorStoreFile + tags: + - Vector stores + summary: >- + Create a vector store file by attaching a + [File](/docs/api-reference/files) to a [vector + store](/docs/api-reference/vector-stores/object). + description: >- + This endpoint is subject to a per-vector-store write rate limit of 300 + requests per minute, shared with + `/vector_stores/{vector_store_id}/file_batches`. + + For uploading multiple files to the same vector store, use the file + batches endpoint to reduce request volume. + parameters: + - in: path + name: vector_store_id + required: true + schema: + type: string + example: vs_abc123 + description: | + The ID of the vector store for which to create a File. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateVectorStoreFileRequest' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/VectorStoreFileObject' + x-oaiMeta: + name: Create vector store file + group: vector_stores + description: > + Attaches one file to a vector store. File attach writes are + rate-limited per vector store (300 requests/minute shared with + `/vector_stores/{vector_store_id}/file_batches`), so use file batches + when uploading multiple files. + examples: + request: + curl: | + curl https://api.openai.com/v1/vector_stores/vs_abc123/files \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "file_id": "file-abc123" + }' + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + vector_store_file = client.vector_stores.files.create( + vector_store_id="vs_abc123", + file_id="file_id", + ) + print(vector_store_file.id) + javascript: | + import OpenAI from "openai"; + const openai = new OpenAI(); + + async function main() { + const myVectorStoreFile = await openai.vectorStores.files.create( + "vs_abc123", + { + file_id: "file-abc123" + } + ); + console.log(myVectorStoreFile); + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const vectorStoreFile = await + client.vectorStores.files.create('vs_abc123', { file_id: 'file_id' + }); + + + console.log(vectorStoreFile.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\tvectorStoreFile, err := client.VectorStores.Files.New(\n\t\tcontext.TODO(),\n\t\t\"vs_abc123\",\n\t\topenai.VectorStoreFileNewParams{\n\t\t\tFileID: \"file_id\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", vectorStoreFile.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.vectorstores.files.FileCreateParams; + import com.openai.models.vectorstores.files.VectorStoreFile; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + FileCreateParams params = FileCreateParams.builder() + .vectorStoreId("vs_abc123") + .fileId("file_id") + .build(); + VectorStoreFile vectorStoreFile = client.vectorStores().files().create(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + vector_store_file = openai.vector_stores.files.create("vs_abc123", + file_id: "file_id") + + + puts(vector_store_file) + response: | + { + "id": "file-abc123", + "object": "vector_store.file", + "created_at": 1699061776, + "usage_bytes": 1234, + "vector_store_id": "vs_abcd", + "status": "completed", + "last_error": null + } + /vector_stores/{vector_store_id}/files/{file_id}: + get: + operationId: getVectorStoreFile + tags: + - Vector stores + summary: Retrieves a vector store file. + parameters: + - in: path + name: vector_store_id + required: true + schema: + type: string + example: vs_abc123 + description: The ID of the vector store that the file belongs to. + - in: path + name: file_id + required: true + schema: + type: string + example: file-abc123 + description: The ID of the file being retrieved. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/VectorStoreFileObject' + x-oaiMeta: + name: Retrieve vector store file + group: vector_stores + examples: + request: + curl: > + curl + https://api.openai.com/v1/vector_stores/vs_abc123/files/file-abc123 + \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + vector_store_file = client.vector_stores.files.retrieve( + file_id="file-abc123", + vector_store_id="vs_abc123", + ) + print(vector_store_file.id) + javascript: | + import OpenAI from "openai"; + const openai = new OpenAI(); + + async function main() { + const vectorStoreFile = await openai.vectorStores.files.retrieve( + "file-abc123", + { vector_store_id: "vs_abc123" } + ); + console.log(vectorStoreFile); + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const vectorStoreFile = await + client.vectorStores.files.retrieve('file-abc123', { + vector_store_id: 'vs_abc123', + }); + + + console.log(vectorStoreFile.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\tvectorStoreFile, err := client.VectorStores.Files.Get(\n\t\tcontext.TODO(),\n\t\t\"vs_abc123\",\n\t\t\"file-abc123\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", vectorStoreFile.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.vectorstores.files.FileRetrieveParams; + import com.openai.models.vectorstores.files.VectorStoreFile; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + FileRetrieveParams params = FileRetrieveParams.builder() + .vectorStoreId("vs_abc123") + .fileId("file-abc123") + .build(); + VectorStoreFile vectorStoreFile = client.vectorStores().files().retrieve(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + vector_store_file = + openai.vector_stores.files.retrieve("file-abc123", + vector_store_id: "vs_abc123") + + + puts(vector_store_file) + response: | + { + "id": "file-abc123", + "object": "vector_store.file", + "created_at": 1699061776, + "vector_store_id": "vs_abcd", + "status": "completed", + "last_error": null + } + delete: + operationId: deleteVectorStoreFile + tags: + - Vector stores + summary: >- + Delete a vector store file. This will remove the file from the vector + store but the file itself will not be deleted. To delete the file, use + the [delete file](/docs/api-reference/files/delete) endpoint. + parameters: + - in: path + name: vector_store_id + required: true + schema: + type: string + description: The ID of the vector store that the file belongs to. + - in: path + name: file_id + required: true + schema: + type: string + description: The ID of the file to delete. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/DeleteVectorStoreFileResponse' + x-oaiMeta: + name: Delete vector store file + group: vector_stores + examples: + request: + curl: > + curl + https://api.openai.com/v1/vector_stores/vs_abc123/files/file-abc123 + \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" \ + -X DELETE + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + vector_store_file_deleted = client.vector_stores.files.delete( + file_id="file_id", + vector_store_id="vector_store_id", + ) + print(vector_store_file_deleted.id) + javascript: | + import OpenAI from "openai"; + const openai = new OpenAI(); + + async function main() { + const deletedVectorStoreFile = await openai.vectorStores.files.delete( + "file-abc123", + { vector_store_id: "vs_abc123" } + ); + console.log(deletedVectorStoreFile); + } + + main(); + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const vectorStoreFileDeleted = await + client.vectorStores.files.delete('file_id', { + vector_store_id: 'vector_store_id', + }); + + + console.log(vectorStoreFileDeleted.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\tvectorStoreFileDeleted, err := client.VectorStores.Files.Delete(\n\t\tcontext.TODO(),\n\t\t\"vector_store_id\",\n\t\t\"file_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", vectorStoreFileDeleted.ID)\n}\n" + java: >- + package com.openai.example; + + + import com.openai.client.OpenAIClient; + + import com.openai.client.okhttp.OpenAIOkHttpClient; + + import com.openai.models.vectorstores.files.FileDeleteParams; + + import + com.openai.models.vectorstores.files.VectorStoreFileDeleted; + + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + FileDeleteParams params = FileDeleteParams.builder() + .vectorStoreId("vector_store_id") + .fileId("file_id") + .build(); + VectorStoreFileDeleted vectorStoreFileDeleted = client.vectorStores().files().delete(params); + } + } + ruby: >- + require "openai" + + + openai = OpenAI::Client.new(api_key: "My API Key") + + + vector_store_file_deleted = + openai.vector_stores.files.delete("file_id", vector_store_id: + "vector_store_id") + + + puts(vector_store_file_deleted) + response: | + { + id: "file-abc123", + object: "vector_store.file.deleted", + deleted: true + } + post: + operationId: updateVectorStoreFileAttributes + tags: + - Vector stores + summary: Update attributes on a vector store file. + parameters: + - in: path + name: vector_store_id + required: true + schema: + type: string + example: vs_abc123 + description: The ID of the vector store the file belongs to. + - in: path + name: file_id + required: true + schema: + type: string + example: file-abc123 + description: The ID of the file to update attributes. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateVectorStoreFileAttributesRequest' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/VectorStoreFileObject' + x-oaiMeta: + name: Update vector store file attributes + group: vector_stores + examples: + request: + curl: > + curl + https://api.openai.com/v1/vector_stores/{vector_store_id}/files/{file_id} + \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"attributes": {"key1": "value1", "key2": 2}}' + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + const vectorStoreFile = await + client.vectorStores.files.update('file-abc123', { + vector_store_id: 'vs_abc123', + attributes: { foo: 'string' }, + }); + + + console.log(vectorStoreFile.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + vector_store_file = client.vector_stores.files.update( + file_id="file-abc123", + vector_store_id="vs_abc123", + attributes={ + "foo": "string" + }, + ) + print(vector_store_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\tvectorStoreFile, err := client.VectorStores.Files.Update(\n\t\tcontext.TODO(),\n\t\t\"vs_abc123\",\n\t\t\"file-abc123\",\n\t\topenai.VectorStoreFileUpdateParams{\n\t\t\tAttributes: map[string]openai.VectorStoreFileUpdateParamsAttributeUnion{\n\t\t\t\t\"foo\": {\n\t\t\t\t\tOfString: openai.String(\"string\"),\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\", vectorStoreFile.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.core.JsonValue; + import com.openai.models.vectorstores.files.FileUpdateParams; + import com.openai.models.vectorstores.files.VectorStoreFile; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + FileUpdateParams params = FileUpdateParams.builder() + .vectorStoreId("vs_abc123") + .fileId("file-abc123") + .attributes(FileUpdateParams.Attributes.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build()) + .build(); + VectorStoreFile vectorStoreFile = client.vectorStores().files().update(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + vector_store_file = openai.vector_stores.files.update( + "file-abc123", + vector_store_id: "vs_abc123", + attributes: {foo: "string"} + ) + + puts(vector_store_file) + response: | + { + "id": "file-abc123", + "object": "vector_store.file", + "usage_bytes": 1234, + "created_at": 1699061776, + "vector_store_id": "vs_abcd", + "status": "completed", + "last_error": null, + "chunking_strategy": {...}, + "attributes": {"key1": "value1", "key2": 2} + } + /vector_stores/{vector_store_id}/search: + post: + operationId: searchVectorStore + tags: + - Vector stores + summary: >- + Search a vector store for relevant chunks based on a query and file + attributes filter. + parameters: + - in: path + name: vector_store_id + required: true + schema: + type: string + example: vs_abc123 + description: The ID of the vector store to search. + - name: openai-organization + in: header + required: false + description: >- + Optionally scope the request to a specific organization (overrides + the default associated with the API key). Addressable in SQL as + `openai_organization`. + schema: + type: string + - name: openai-project + in: header + required: false + description: >- + Optionally scope the request to a specific project (overrides the + default associated with the API key). Addressable in SQL as + `openai_project`. + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/VectorStoreSearchRequest' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/VectorStoreSearchResultsPage' + x-oaiMeta: + name: Search vector store + group: vector_stores + examples: + request: + curl: | + curl -X POST \ + https://api.openai.com/v1/vector_stores/vs_abc123/search \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"query": "What is the return policy?", "filters": {...}}' + node.js: >- + import OpenAI from 'openai'; + + + const client = new OpenAI({ + apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted + }); + + + // Automatically fetches more pages as needed. + + for await (const vectorStoreSearchResponse of + client.vectorStores.search('vs_abc123', { + query: 'string', + })) { + console.log(vectorStoreSearchResponse.file_id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted + ) + page = client.vector_stores.search( + vector_store_id="vs_abc123", + query="string", + ) + page = page.data[0] + print(page.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\tpage, err := client.VectorStores.Search(\n\t\tcontext.TODO(),\n\t\t\"vs_abc123\",\n\t\topenai.VectorStoreSearchParams{\n\t\t\tQuery: openai.VectorStoreSearchParamsQueryUnion{\n\t\t\t\tOfString: openai.String(\"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\", page)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.vectorstores.VectorStoreSearchPage; + import com.openai.models.vectorstores.VectorStoreSearchParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + VectorStoreSearchParams params = VectorStoreSearchParams.builder() + .vectorStoreId("vs_abc123") + .query("string") + .build(); + VectorStoreSearchPage page = client.vectorStores().search(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(api_key: "My API Key") + + page = openai.vector_stores.search("vs_abc123", query: "string") + + puts(page) + response: | + { + "object": "vector_store.search_results.page", + "search_query": "What is the return policy?", + "data": [ + { + "file_id": "file_123", + "filename": "document.pdf", + "score": 0.95, + "attributes": { + "author": "John Doe", + "date": "2023-01-01" + }, + "content": [ + { + "type": "text", + "text": "Relevant chunk" + } + ] + }, + { + "file_id": "file_456", + "filename": "notes.txt", + "score": 0.89, + "attributes": { + "author": "Jane Smith", + "date": "2023-01-02" + }, + "content": [ + { + "type": "text", + "text": "Sample text content from the vector store." + } + ] + } + ], + "has_more": false, + "next_page": null + } +components: + schemas: + ListVectorStoresResponse: + properties: + object: + type: string + example: list + data: + type: array + items: + $ref: '#/components/schemas/VectorStoreObject' + first_id: + type: string + example: vs_abc123 + last_id: + type: string + example: vs_abc456 + has_more: + type: boolean + example: false + required: + - object + - data + - first_id + - last_id + - has_more + type: object + CreateVectorStoreRequest: + type: object + additionalProperties: false + properties: + file_ids: + description: >- + A list of [File](/docs/api-reference/files) IDs that the vector + store should use. Useful for tools like `file_search` that can + access files. + type: array + maxItems: 500 + items: + type: string + name: + description: The name of the vector store. + type: string + description: + description: >- + A description for the vector store. Can be used to describe the + vector store's purpose. + type: string + expires_after: + $ref: '#/components/schemas/VectorStoreExpirationAfter' + chunking_strategy: + type: object + description: >- + The chunking strategy used to chunk the file(s). If not set, will + use the `auto` strategy. Only applicable if `file_ids` is non-empty. + title: Auto Chunking Strategy + additionalProperties: false + properties: + type: + type: string + description: Always `auto`. + enum: + - auto + x-stainless-const: true + static: + $ref: '#/components/schemas/StaticChunkingStrategy' + required: + - type + - static + metadata: + $ref: '#/components/schemas/Metadata' + VectorStoreObject: + type: object + title: Vector store + description: >- + A vector store is a collection of processed files can be used by the + `file_search` tool. + properties: + id: + description: The identifier, which can be referenced in API endpoints. + type: string + object: + description: The object type, which is always `vector_store`. + type: string + enum: + - vector_store + x-stainless-const: true + created_at: + description: >- + The Unix timestamp (in seconds) for when the vector store was + created. + type: integer + format: unixtime + name: + description: The name of the vector store. + type: string + usage_bytes: + description: The total number of bytes used by the files in the vector store. + type: integer + file_counts: + type: object + properties: + in_progress: + description: The number of files that are currently being processed. + type: integer + completed: + description: The number of files that have been successfully processed. + type: integer + failed: + description: The number of files that have failed to process. + type: integer + cancelled: + description: The number of files that were cancelled. + type: integer + total: + description: The total number of files. + type: integer + required: + - in_progress + - completed + - failed + - cancelled + - total + status: + description: >- + The status of the vector store, which can be either `expired`, + `in_progress`, or `completed`. A status of `completed` indicates + that the vector store is ready for use. + type: string + enum: + - expired + - in_progress + - completed + expires_after: + $ref: '#/components/schemas/VectorStoreExpirationAfter' + expires_at: + description: >- + The Unix timestamp (in seconds) for when the vector store will + expire. + type: integer + format: unixtime + last_active_at: + description: >- + The Unix timestamp (in seconds) for when the vector store was last + active. + type: integer + format: unixtime + metadata: + $ref: '#/components/schemas/Metadata' + required: + - id + - object + - usage_bytes + - created_at + - status + - last_active_at + - name + - file_counts + - metadata + x-oaiMeta: + name: The vector store object + example: | + { + "id": "vs_123", + "object": "vector_store", + "created_at": 1698107661, + "usage_bytes": 123456, + "last_active_at": 1698107661, + "name": "my_vector_store", + "status": "completed", + "file_counts": { + "in_progress": 0, + "completed": 100, + "cancelled": 0, + "failed": 0, + "total": 100 + }, + "last_used_at": 1698107661 + } + UpdateVectorStoreRequest: + type: object + additionalProperties: false + properties: + name: + description: The name of the vector store. + type: string + nullable: true + expires_after: + type: object + title: Vector store expiration policy + description: The expiration policy for a vector store. + properties: + anchor: + description: >- + Anchor timestamp after which the expiration policy applies. + Supported anchors: `last_active_at`. + type: string + enum: + - last_active_at + x-stainless-const: true + days: + description: >- + The number of days after the anchor time that the vector store + will expire. + type: integer + minimum: 1 + maximum: 365 + required: + - anchor + - days + nullable: true + metadata: + $ref: '#/components/schemas/Metadata' + DeleteVectorStoreResponse: + type: object + properties: + id: + type: string + deleted: + type: boolean + object: + type: string + enum: + - vector_store.deleted + x-stainless-const: true + required: + - id + - object + - deleted + CreateVectorStoreFileBatchRequest: + type: object + additionalProperties: false + properties: + file_ids: + description: >- + A list of [File](/docs/api-reference/files) IDs that the vector + store should use. Useful for tools like `file_search` that can + access files. If `attributes` or `chunking_strategy` are provided, + they will be applied to all files in the batch. The maximum batch + size is 2000 files. This endpoint is recommended for multi-file + ingestion and helps reduce per-vector-store write request pressure. + Mutually exclusive with `files`. + type: array + minItems: 1 + maxItems: 2000 + items: + type: string + files: + description: >- + A list of objects that each include a `file_id` plus optional + `attributes` or `chunking_strategy`. Use this when you need to + override metadata for specific files. The global `attributes` or + `chunking_strategy` will be ignored and must be specified for each + file. The maximum batch size is 2000 files. This endpoint is + recommended for multi-file ingestion and helps reduce + per-vector-store write request pressure. Mutually exclusive with + `file_ids`. + type: array + minItems: 1 + maxItems: 2000 + items: + $ref: '#/components/schemas/CreateVectorStoreFileRequest' + chunking_strategy: + $ref: '#/components/schemas/ChunkingStrategyRequestParam' + attributes: + $ref: '#/components/schemas/VectorStoreFileAttributes' + required: + - file_ids + - files + VectorStoreFileBatchObject: + type: object + title: Vector store file batch + description: A batch of files attached to a vector store. + properties: + id: + description: The identifier, which can be referenced in API endpoints. + type: string + object: + description: The object type, which is always `vector_store.file_batch`. + type: string + enum: + - vector_store.files_batch + x-stainless-const: true + created_at: + description: >- + The Unix timestamp (in seconds) for when the vector store files + batch was created. + type: integer + format: unixtime + vector_store_id: + description: >- + The ID of the [vector + store](/docs/api-reference/vector-stores/object) that the + [File](/docs/api-reference/files) is attached to. + type: string + status: + description: >- + The status of the vector store files batch, which can be either + `in_progress`, `completed`, `cancelled` or `failed`. + type: string + enum: + - in_progress + - completed + - cancelled + - failed + file_counts: + type: object + properties: + in_progress: + description: The number of files that are currently being processed. + type: integer + completed: + description: The number of files that have been processed. + type: integer + failed: + description: The number of files that have failed to process. + type: integer + cancelled: + description: The number of files that where cancelled. + type: integer + total: + description: The total number of files. + type: integer + required: + - in_progress + - completed + - cancelled + - failed + - total + required: + - id + - object + - created_at + - vector_store_id + - status + - file_counts + x-oaiMeta: + name: The vector store files batch object beta: true - returns: Deletion status - examples: - request: - curl: | - curl https://api.openai.com/v1/vector_stores/vs_abc123 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" \ - -X DELETE - python: | - from openai import OpenAI - client = OpenAI() - - deleted_vector_store = client.beta.vector_stores.delete( - vector_store_id="vs_abc123" - ) - print(deleted_vector_store) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); - - async function main() { - const deletedVectorStore = await openai.beta.vectorStores.del( - "vs_abc123" - ); - console.log(deletedVectorStore); - } - - main(); - response: | - { - id: "vs_abc123", - object: "vector_store.deleted", - deleted: true + example: | + { + "id": "vsfb_123", + "object": "vector_store.files_batch", + "created_at": 1698107661, + "vector_store_id": "vs_abc123", + "status": "completed", + "file_counts": { + "in_progress": 0, + "completed": 100, + "failed": 0, + "cancelled": 0, + "total": 100 } - '/vector_stores/{vector_store_id}/file_batches': - post: - operationId: createVectorStoreFileBatch - tags: - - Vector stores - summary: Create a vector store file batch. - parameters: - - in: path - name: vector_store_id - required: true - schema: - type: string - example: vs_abc123 - description: | - The ID of the vector store for which to create a File Batch. - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CreateVectorStoreFileBatchRequest' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/VectorStoreFileBatchObject' + } + ListVectorStoreFilesResponse: + properties: + object: + type: string + example: list + data: + type: array + items: + $ref: '#/components/schemas/VectorStoreFileObject' + first_id: + type: string + example: file-abc123 + last_id: + type: string + example: file-abc456 + has_more: + type: boolean + example: false + required: + - object + - data + - first_id + - last_id + - has_more + type: object + CreateVectorStoreFileRequest: + type: object + additionalProperties: false + properties: + file_id: + description: >- + A [File](/docs/api-reference/files) ID that the vector store should + use. Useful for tools like `file_search` that can access files. For + multi-file ingestion, we recommend + [`file_batches`](/docs/api-reference/vector-stores-file-batches/createBatch) + to minimize per-vector-store write requests. + type: string + chunking_strategy: + $ref: '#/components/schemas/ChunkingStrategyRequestParam' + attributes: + $ref: '#/components/schemas/VectorStoreFileAttributes' + required: + - file_id + VectorStoreFileObject: + type: object + title: Vector store files + description: A list of files attached to a vector store. + properties: + id: + description: The identifier, which can be referenced in API endpoints. + type: string + object: + description: The object type, which is always `vector_store.file`. + type: string + enum: + - vector_store.file + x-stainless-const: true + usage_bytes: + description: >- + The total vector store usage in bytes. Note that this may be + different from the original file size. + type: integer + created_at: + description: >- + The Unix timestamp (in seconds) for when the vector store file was + created. + type: integer + format: unixtime + vector_store_id: + description: >- + The ID of the [vector + store](/docs/api-reference/vector-stores/object) that the + [File](/docs/api-reference/files) is attached to. + type: string + status: + description: >- + The status of the vector store file, which can be either + `in_progress`, `completed`, `cancelled`, or `failed`. The status + `completed` indicates that the vector store file is ready for use. + type: string + enum: + - in_progress + - completed + - cancelled + - failed + last_error: + type: object + description: >- + The last error associated with this vector store file. Will be + `null` if there are no errors. + properties: + code: + type: string + description: One of `server_error`, `unsupported_file`, or `invalid_file`. + enum: + - server_error + - unsupported_file + - invalid_file + message: + type: string + description: A human-readable description of the error. + required: + - code + - message + chunking_strategy: + type: object + description: The strategy used to chunk the file. + title: Static Chunking Strategy + additionalProperties: false + properties: + type: + type: string + description: Always `static`. + enum: + - static + x-stainless-const: true + static: + $ref: '#/components/schemas/StaticChunkingStrategy' + required: + - type + - static + attributes: + $ref: '#/components/schemas/VectorStoreFileAttributes' + required: + - id + - object + - usage_bytes + - created_at + - vector_store_id + - status + - last_error x-oaiMeta: - name: Create vector store file batch - group: vector_stores + name: The vector store file object beta: true - returns: 'A [vector store file batch](/docs/api-reference/vector-stores-file-batches/batch-object) object.' - examples: - request: - curl: | - curl https://api.openai.com/v1/vector_stores/vs_abc123/file_batches \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json \ - -H "OpenAI-Beta: assistants=v2" \ - -d '{ - "file_ids": ["file-abc123", "file-abc456"] - }' - python: | - from openai import OpenAI - client = OpenAI() - - vector_store_file_batch = client.beta.vector_stores.file_batches.create( - vector_store_id="vs_abc123", - file_ids=["file-abc123", "file-abc456"] - ) - print(vector_store_file_batch) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); - - async function main() { - const myVectorStoreFileBatch = await openai.beta.vectorStores.fileBatches.create( - "vs_abc123", - { - file_ids: ["file-abc123", "file-abc456"] - } - ); - console.log(myVectorStoreFileBatch); - } - - main(); - response: | - { - "id": "vsfb_abc123", - "object": "vector_store.file_batch", - "created_at": 1699061776, - "vector_store_id": "vs_abc123", - "status": "in_progress", - "file_counts": { - "in_progress": 1, - "completed": 1, - "failed": 0, - "cancelled": 0, - "total": 0, + example: | + { + "id": "file-abc123", + "object": "vector_store.file", + "usage_bytes": 1234, + "created_at": 1698107661, + "vector_store_id": "vs_abc123", + "status": "completed", + "last_error": null, + "chunking_strategy": { + "type": "static", + "static": { + "max_chunk_size_tokens": 800, + "chunk_overlap_tokens": 400 } } - '/vector_stores/{vector_store_id}/file_batches/{batch_id}': - get: - operationId: getVectorStoreFileBatch - tags: - - Vector stores - summary: Retrieves a vector store file batch. - parameters: - - in: path - name: vector_store_id - required: true - schema: - type: string - example: vs_abc123 - description: The ID of the vector store that the file batch belongs to. - - in: path - name: batch_id - required: true - schema: - type: string - example: vsfb_abc123 - description: The ID of the file batch being retrieved. - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/VectorStoreFileBatchObject' + } + DeleteVectorStoreFileResponse: + type: object + properties: + id: + type: string + deleted: + type: boolean + object: + type: string + enum: + - vector_store.file.deleted + x-stainless-const: true + required: + - id + - object + - deleted + UpdateVectorStoreFileAttributesRequest: + type: object + additionalProperties: false + properties: + attributes: + $ref: '#/components/schemas/VectorStoreFileAttributes' + required: + - attributes x-oaiMeta: - name: Retrieve vector store file batch - group: vector_stores - beta: true - returns: 'The [vector store file batch](/docs/api-reference/vector-stores-file-batches/batch-object) object.' - examples: - request: - curl: | - curl https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from openai import OpenAI - client = OpenAI() + name: Update vector store file attributes request + VectorStoreSearchRequest: + type: object + additionalProperties: false + properties: + query: + description: A query string for a search + type: string + items: + type: string + description: A list of queries to search for. + minItems: 1 + rewrite_query: + description: Whether to rewrite the natural language query for vector search. + type: boolean + default: false + max_num_results: + description: >- + The maximum number of results to return. This number should be + between 1 and 50 inclusive. + type: integer + default: 10 + minimum: 1 + maximum: 50 + filters: + description: A filter to apply based on file attributes. + type: object + additionalProperties: false + title: Comparison Filter + properties: + type: + type: string + default: eq + enum: + - eq + - ne + - gt + - gte + - lt + - lte + - in + - nin + description: > + Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, + `lt`, `lte`, `in`, `nin`. - vector_store_file_batch = client.beta.vector_stores.file_batches.retrieve( - vector_store_id="vs_abc123", - batch_id="vsfb_abc123" - ) - print(vector_store_file_batch) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + - `eq`: equals - async function main() { - const vectorStoreFileBatch = await openai.beta.vectorStores.fileBatches.retrieve( - "vs_abc123", - "vsfb_abc123" - ); - console.log(vectorStoreFileBatch); - } + - `ne`: not equal - main(); - response: | - { - "id": "vsfb_abc123", - "object": "vector_store.file_batch", - "created_at": 1699061776, - "vector_store_id": "vs_abc123", - "status": "in_progress", - "file_counts": { - "in_progress": 1, - "completed": 1, - "failed": 0, - "cancelled": 0, - "total": 0, - } - } - '/vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel': - post: - operationId: cancelVectorStoreFileBatch - tags: - - Vector stores - summary: Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. - parameters: - - in: path - name: vector_store_id - required: true - schema: - type: string - description: The ID of the vector store that the file batch belongs to. - - in: path - name: batch_id - required: true - schema: - type: string - description: The ID of the file batch to cancel. - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/VectorStoreFileBatchObject' - x-oaiMeta: - name: Cancel vector store file batch - group: vector_stores - beta: true - returns: The modified vector store file batch object. - examples: - request: - curl: | - curl https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/cancel \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" \ - -X POST - python: | - from openai import OpenAI - client = OpenAI() + - `gt`: greater than - deleted_vector_store_file_batch = client.beta.vector_stores.file_batches.cancel( - vector_store_id="vs_abc123", - file_batch_id="vsfb_abc123" - ) - print(deleted_vector_store_file_batch) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + - `gte`: greater than or equal - async function main() { - const deletedVectorStoreFileBatch = await openai.vector_stores.fileBatches.cancel( - "vs_abc123", - "vsfb_abc123" - ); - console.log(deletedVectorStoreFileBatch); - } + - `lt`: less than - main(); - response: | - { - "id": "vsfb_abc123", - "object": "vector_store.file_batch", - "created_at": 1699061776, - "vector_store_id": "vs_abc123", - "status": "cancelling", - "file_counts": { - "in_progress": 12, - "completed": 3, - "failed": 0, - "cancelled": 0, - "total": 15, - } - } - '/vector_stores/{vector_store_id}/file_batches/{batch_id}/files': - get: - operationId: listFilesInVectorStoreBatch - tags: - - Vector stores - summary: Returns a list of vector store files in a batch. - parameters: - - name: vector_store_id - in: path - description: The ID of the vector store that the files belong to. - required: true - schema: - type: string - - name: batch_id - in: path - description: The ID of the file batch that the files belong to. - required: true - schema: - type: string - - name: limit - in: query - description: | - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - required: false - schema: - type: integer - default: 20 - - name: order - in: query - description: | - Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. - schema: - type: string - default: desc - enum: - - asc - - desc - - name: after - in: query - 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 - - name: before - in: query - 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, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - schema: - type: string - - name: filter - in: query - description: 'Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`.' - schema: + - `lte`: less than or equal + + - `in`: in + + - `nin`: not in + key: + type: string + description: The key to compare against the value. + value: + description: >- + The value to compare against the attribute key; supports string, + number, or boolean types. + type: string + items: + oneOf: + - type: string + - type: number + filters: + type: array + description: >- + Array of filters to combine. Items can be `ComparisonFilter` or + `CompoundFilter`. + items: + oneOf: + - $ref: '#/components/schemas/ComparisonFilter' + - $recursiveRef: '#' + discriminator: + propertyName: type + required: + - type + - key + - value + - filters + x-oaiMeta: + name: ComparisonFilter + $recursiveAnchor: true + ranking_options: + description: Ranking options for search. + type: object + additionalProperties: false + properties: + ranker: + description: >- + Enable re-ranking; set to `none` to disable, which can help + reduce latency. + type: string + enum: + - none + - auto + - default-2024-11-15 + default: auto + score_threshold: + type: number + minimum: 0 + maximum: 1 + default: 0 + required: + - query + x-oaiMeta: + name: Vector store search request + VectorStoreSearchResultsPage: + type: object + additionalProperties: false + properties: + object: + type: string + enum: + - vector_store.search_results.page + description: The object type, which is always `vector_store.search_results.page` + x-stainless-const: true + search_query: + type: array + items: type: string - enum: - - in_progress - - completed - - failed - - cancelled - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ListVectorStoreFilesResponse' + description: The query used for this search. + minItems: 1 + data: + type: array + description: The list of search result items. + items: + $ref: '#/components/schemas/VectorStoreSearchResultItem' + has_more: + type: boolean + description: Indicates if there are more results to fetch. + next_page: + type: string + description: The token for the next page, if any. + required: + - object + - search_query + - data + - has_more + - next_page x-oaiMeta: - name: List vector store files in a batch - group: vector_stores - beta: true - returns: 'A list of [vector store file](/docs/api-reference/vector-stores-files/file-object) objects.' - examples: - request: - curl: | - curl https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/files \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from openai import OpenAI - client = OpenAI() + name: Vector store search results page + VectorStoreExpirationAfter: + type: object + title: Vector store expiration policy + description: The expiration policy for a vector store. + properties: + anchor: + description: >- + Anchor timestamp after which the expiration policy applies. + Supported anchors: `last_active_at`. + type: string + enum: + - last_active_at + x-stainless-const: true + days: + description: >- + The number of days after the anchor time that the vector store will + expire. + type: integer + minimum: 1 + maximum: 365 + required: + - anchor + - days + AutoChunkingStrategyRequestParam: + type: object + title: Auto Chunking Strategy + description: >- + The default strategy. This strategy currently uses a + `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`. + additionalProperties: false + properties: + type: + type: string + description: Always `auto`. + enum: + - auto + x-stainless-const: true + required: + - type + StaticChunkingStrategyRequestParam: + type: object + title: Static Chunking Strategy + description: >- + Customize your own chunking strategy by setting chunk size and chunk + overlap. + additionalProperties: false + properties: + type: + type: string + description: Always `static`. + enum: + - static + x-stainless-const: true + static: + $ref: '#/components/schemas/StaticChunkingStrategy' + required: + - type + - static + Metadata: + type: object + description: > + Set of 16 key-value pairs that can be attached to an object. This can be - vector_store_files = client.beta.vector_stores.file_batches.list_files( - vector_store_id="vs_abc123", - batch_id="vsfb_abc123" - ) - print(vector_store_files) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + useful for storing additional information about the object in a + structured - async function main() { - const vectorStoreFiles = await openai.beta.vectorStores.fileBatches.listFiles( - "vs_abc123", - "vsfb_abc123" - ); - console.log(vectorStoreFiles); - } + format, and querying for objects via API or the dashboard. - main(); - response: | - { - "object": "list", - "data": [ - { - "id": "file-abc123", - "object": "vector_store.file", - "created_at": 1699061776, - "vector_store_id": "vs_abc123" - }, - { - "id": "file-abc456", - "object": "vector_store.file", - "created_at": 1699061776, - "vector_store_id": "vs_abc123" - } - ], - "first_id": "file-abc123", - "last_id": "file-abc456", - "has_more": false - } - '/vector_stores/{vector_store_id}/files': - get: - operationId: listVectorStoreFiles - tags: - - Vector stores - summary: Returns a list of vector store files. - parameters: - - name: vector_store_id - in: path - description: The ID of the vector store that the files belong to. - required: true - schema: - type: string - - name: limit - in: query - description: | - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - required: false - schema: - type: integer - default: 20 - - name: order - in: query - description: | - Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. - schema: - type: string - default: desc - enum: - - asc - - desc - - name: after - in: query - 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 - - name: before - in: query - 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, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - schema: - type: string - - name: filter - in: query - description: 'Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`.' - schema: - type: string - enum: - - in_progress - - completed - - failed - - cancelled - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ListVectorStoreFilesResponse' - x-oaiMeta: - name: List vector store files - group: vector_stores - beta: true - returns: 'A list of [vector store file](/docs/api-reference/vector-stores-files/file-object) objects.' - examples: - request: - curl: | - curl https://api.openai.com/v1/vector_stores/vs_abc123/files \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from openai import OpenAI - client = OpenAI() - vector_store_files = client.beta.vector_stores.files.list( - vector_store_id="vs_abc123" - ) - print(vector_store_files) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + Keys are strings with a maximum length of 64 characters. Values are + strings - async function main() { - const vectorStoreFiles = await openai.beta.vectorStores.files.list( - "vs_abc123" - ); - console.log(vectorStoreFiles); - } + with a maximum length of 512 characters. + additionalProperties: + type: string + x-oaiTypeLabel: map + ChunkingStrategyRequestParam: + type: object + description: >- + The chunking strategy used to chunk the file(s). If not set, will use + the `auto` strategy. + discriminator: + propertyName: type + title: Auto Chunking Strategy + additionalProperties: false + properties: + type: + type: string + description: Always `auto`. + enum: + - auto + x-stainless-const: true + static: + $ref: '#/components/schemas/StaticChunkingStrategy' + required: + - type + - static + VectorStoreFileAttributes: + type: object + description: > + Set of 16 key-value pairs that can be attached to an object. This can be - main(); - response: | - { - "object": "list", - "data": [ - { - "id": "file-abc123", - "object": "vector_store.file", - "created_at": 1699061776, - "vector_store_id": "vs_abc123" - }, - { - "id": "file-abc456", - "object": "vector_store.file", - "created_at": 1699061776, - "vector_store_id": "vs_abc123" - } - ], - "first_id": "file-abc123", - "last_id": "file-abc456", - "has_more": false - } - post: - operationId: createVectorStoreFile - tags: - - Vector stores - summary: 'Create a vector store file by attaching a [File](/docs/api-reference/files) to a [vector store](/docs/api-reference/vector-stores/object).' - parameters: - - in: path - name: vector_store_id - required: true - schema: - type: string - example: vs_abc123 - description: | - The ID of the vector store for which to create a File. - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CreateVectorStoreFileRequest' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/VectorStoreFileObject' - x-oaiMeta: - name: Create vector store file - group: vector_stores - beta: true - returns: 'A [vector store file](/docs/api-reference/vector-stores-files/file-object) object.' - examples: - request: - curl: | - curl https://api.openai.com/v1/vector_stores/vs_abc123/files \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" \ - -d '{ - "file_id": "file-abc123" - }' - python: | - from openai import OpenAI - client = OpenAI() + useful for storing additional information about the object in a + structured - vector_store_file = client.beta.vector_stores.files.create( - vector_store_id="vs_abc123", - file_id="file-abc123" - ) - print(vector_store_file) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + format, and querying for objects via API or the dashboard. Keys are + strings - async function main() { - const myVectorStoreFile = await openai.beta.vectorStores.files.create( - "vs_abc123", - { - file_id: "file-abc123" - } - ); - console.log(myVectorStoreFile); - } + with a maximum length of 64 characters. Values are strings with a + maximum - main(); - response: | - { - "id": "file-abc123", - "object": "vector_store.file", - "created_at": 1699061776, - "usage_bytes": 1234, - "vector_store_id": "vs_abcd", - "status": "completed", - "last_error": null - } - '/vector_stores/{vector_store_id}/files/{file_id}': - get: - operationId: getVectorStoreFile - tags: - - Vector stores - summary: Retrieves a vector store file. - parameters: - - in: path - name: vector_store_id - required: true - schema: - type: string - example: vs_abc123 - description: The ID of the vector store that the file belongs to. - - in: path - name: file_id - required: true - schema: - type: string - example: file-abc123 - description: The ID of the file being retrieved. - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/VectorStoreFileObject' - x-oaiMeta: - name: Retrieve vector store file - group: vector_stores - beta: true - returns: 'The [vector store file](/docs/api-reference/vector-stores-files/file-object) object.' - examples: - request: - curl: | - curl https://api.openai.com/v1/vector_stores/vs_abc123/files/file-abc123 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from openai import OpenAI - client = OpenAI() + length of 512 characters, booleans, or numbers. + maxProperties: 16 + propertyNames: + type: string + maxLength: 64 + additionalProperties: + oneOf: + - type: string + maxLength: 512 + - type: number + - type: boolean + x-oaiTypeLabel: map + StaticChunkingStrategyResponseParam: + type: object + title: Static Chunking Strategy + additionalProperties: false + properties: + type: + type: string + description: Always `static`. + enum: + - static + x-stainless-const: true + static: + $ref: '#/components/schemas/StaticChunkingStrategy' + required: + - type + - static + OtherChunkingStrategyResponseParam: + type: object + title: Other Chunking Strategy + description: >- + This is returned when the chunking strategy is unknown. Typically, this + is because the file was indexed before the `chunking_strategy` concept + was introduced in the API. + additionalProperties: false + properties: + type: + type: string + description: Always `other`. + enum: + - other + x-stainless-const: true + required: + - type + ComparisonFilter: + type: object + additionalProperties: false + title: Comparison Filter + description: > + A filter used to compare a specified attribute key to a given value + using a defined comparison operation. + properties: + type: + type: string + default: eq + enum: + - eq + - ne + - gt + - gte + - lt + - lte + - in + - nin + description: > + Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, + `lte`, `in`, `nin`. - vector_store_file = client.beta.vector_stores.files.retrieve( - vector_store_id="vs_abc123", - file_id="file-abc123" - ) - print(vector_store_file) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + - `eq`: equals - async function main() { - const vectorStoreFile = await openai.beta.vectorStores.files.retrieve( - "vs_abc123", - "file-abc123" - ); - console.log(vectorStoreFile); - } + - `ne`: not equal - main(); - response: | - { - "id": "file-abc123", - "object": "vector_store.file", - "created_at": 1699061776, - "vector_store_id": "vs_abcd", - "status": "completed", - "last_error": null - } - delete: - operationId: deleteVectorStoreFile - tags: - - Vector stores - summary: 'Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. To delete the file, use the [delete file](/docs/api-reference/files/delete) endpoint.' - parameters: - - in: path - name: vector_store_id - required: true - schema: - type: string - description: The ID of the vector store that the file belongs to. - - in: path - name: file_id - required: true - schema: - type: string - description: The ID of the file to delete. - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/DeleteVectorStoreFileResponse' - x-oaiMeta: - name: Delete vector store file - group: vector_stores - beta: true - returns: Deletion status - examples: - request: - curl: | - curl https://api.openai.com/v1/vector_stores/vs_abc123/files/file-abc123 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" \ - -X DELETE - python: | - from openai import OpenAI - client = OpenAI() + - `gt`: greater than - deleted_vector_store_file = client.beta.vector_stores.files.delete( - vector_store_id="vs_abc123", - file_id="file-abc123" - ) - print(deleted_vector_store_file) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + - `gte`: greater than or equal - async function main() { - const deletedVectorStoreFile = await openai.beta.vectorStores.files.del( - "vs_abc123", - "file-abc123" - ); - console.log(deletedVectorStoreFile); - } + - `lt`: less than - main(); - response: | - { - id: "file-abc123", - object: "vector_store.file.deleted", - deleted: true - } + - `lte`: less than or equal + + - `in`: in + + - `nin`: not in + key: + type: string + description: The key to compare against the value. + value: + description: >- + The value to compare against the attribute key; supports string, + number, or boolean types. + type: string + items: + oneOf: + - type: string + - type: number + required: + - type + - key + - value + x-oaiMeta: + name: ComparisonFilter + CompoundFilter: + $recursiveAnchor: true + type: object + additionalProperties: false + title: Compound Filter + description: Combine multiple filters using `and` or `or`. + properties: + type: + type: string + description: 'Type of operation: `and` or `or`.' + enum: + - and + - or + filters: + type: array + description: >- + Array of filters to combine. Items can be `ComparisonFilter` or + `CompoundFilter`. + items: + oneOf: + - $ref: '#/components/schemas/ComparisonFilter' + - $recursiveRef: '#' + discriminator: + propertyName: type + required: + - type + - filters + x-oaiMeta: + name: CompoundFilter + VectorStoreSearchResultItem: + type: object + additionalProperties: false + properties: + file_id: + type: string + description: The ID of the vector store file. + filename: + type: string + description: The name of the vector store file. + score: + type: number + description: The similarity score for the result. + minimum: 0 + maximum: 1 + attributes: + $ref: '#/components/schemas/VectorStoreFileAttributes' + content: + type: array + description: Content chunks from the file. + items: + $ref: '#/components/schemas/VectorStoreSearchResultContentObject' + required: + - file_id + - filename + - score + - attributes + - content + x-oaiMeta: + name: Vector store search result item + StaticChunkingStrategy: + type: object + additionalProperties: false + properties: + max_chunk_size_tokens: + type: integer + minimum: 100 + maximum: 4096 + description: >- + The maximum number of tokens in each chunk. The default value is + `800`. The minimum value is `100` and the maximum value is `4096`. + chunk_overlap_tokens: + type: integer + description: > + The number of tokens that overlap between chunks. The default value + is `400`. + + + Note that the overlap must not exceed half of + `max_chunk_size_tokens`. + required: + - max_chunk_size_tokens + - chunk_overlap_tokens + VectorStoreSearchResultContentObject: + type: object + additionalProperties: false + properties: + type: + description: The type of content. + type: string + enum: + - text + text: + description: The text content returned from search. + type: string + required: + - type + - text + x-oaiMeta: + name: Vector store search result content object + x-stackQL-resources: + vector_stores: + id: openai.vector_stores.vector_stores + name: vector_stores + title: Vector Stores + methods: + list: + operation: + $ref: '#/paths/~1vector_stores/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1vector_stores/post' + response: + mediaType: application/json + openAPIDocKey: '200' + get: + operation: + $ref: '#/paths/~1vector_stores~1{vector_store_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + update: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1vector_stores~1{vector_store_id}/post' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1vector_stores~1{vector_store_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + search: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1vector_stores~1{vector_store_id}~1search/post' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/vector_stores/methods/get' + - $ref: '#/components/x-stackQL-resources/vector_stores/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/vector_stores/methods/create' + update: + - $ref: '#/components/x-stackQL-resources/vector_stores/methods/update' + delete: + - $ref: '#/components/x-stackQL-resources/vector_stores/methods/delete' + replace: [] + file_batches: + id: openai.vector_stores.file_batches + name: file_batches + title: File Batches + methods: + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1vector_stores~1{vector_store_id}~1file_batches/post' + response: + mediaType: application/json + openAPIDocKey: '200' + get: + operation: + $ref: >- + #/paths/~1vector_stores~1{vector_store_id}~1file_batches~1{batch_id}/get + response: + mediaType: application/json + openAPIDocKey: '200' + cancel: + operation: + $ref: >- + #/paths/~1vector_stores~1{vector_store_id}~1file_batches~1{batch_id}~1cancel/post + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/file_batches/methods/get' + insert: + - $ref: '#/components/x-stackQL-resources/file_batches/methods/create' + update: [] + delete: [] + replace: [] + file_batch_files: + id: openai.vector_stores.file_batch_files + name: file_batch_files + title: File Batch Files + methods: + list: + operation: + $ref: >- + #/paths/~1vector_stores~1{vector_store_id}~1file_batches~1{batch_id}~1files/get + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/file_batch_files/methods/list' + insert: [] + update: [] + delete: [] + replace: [] + files: + id: openai.vector_stores.files + name: files + title: Files + methods: + list: + operation: + $ref: '#/paths/~1vector_stores~1{vector_store_id}~1files/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1vector_stores~1{vector_store_id}~1files/post' + response: + mediaType: application/json + openAPIDocKey: '200' + get: + operation: + $ref: '#/paths/~1vector_stores~1{vector_store_id}~1files~1{file_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: >- + #/paths/~1vector_stores~1{vector_store_id}~1files~1{file_id}/delete + response: + mediaType: application/json + openAPIDocKey: '200' + update: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1vector_stores~1{vector_store_id}~1files~1{file_id}/post' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/files/methods/get' + - $ref: '#/components/x-stackQL-resources/files/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/files/methods/create' + update: + - $ref: '#/components/x-stackQL-resources/files/methods/update' + delete: + - $ref: '#/components/x-stackQL-resources/files/methods/delete' + replace: [] +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.last_id + location: body + queryParamPushdown: + top: + paramName: limit + maxValue: 100 diff --git a/providers/src/openai_admin/v00.00.00000/provider.yaml b/providers/src/openai_admin/v00.00.00000/provider.yaml new file mode 100644 index 00000000..71397502 --- /dev/null +++ b/providers/src/openai_admin/v00.00.00000/provider.yaml @@ -0,0 +1,98 @@ +id: openai_admin +name: openai_admin +version: v00.00.00000 +providerServices: + admin_api_keys: + id: admin_api_keys:v00.00.00000 + name: admin_api_keys + preferred: true + service: + $ref: openai_admin/v00.00.00000/services/admin_api_keys.yaml + title: admin_api_keys API + version: v00.00.00000 + description: openai_admin API + audit_logs: + id: audit_logs:v00.00.00000 + name: audit_logs + preferred: true + service: + $ref: openai_admin/v00.00.00000/services/audit_logs.yaml + title: audit_logs API + version: v00.00.00000 + description: openai_admin API + certificates: + id: certificates:v00.00.00000 + name: certificates + preferred: true + service: + $ref: openai_admin/v00.00.00000/services/certificates.yaml + title: certificates API + version: v00.00.00000 + description: openai_admin API + costs: + id: costs:v00.00.00000 + name: costs + preferred: true + service: + $ref: openai_admin/v00.00.00000/services/costs.yaml + title: costs API + version: v00.00.00000 + description: openai_admin API + groups: + id: groups:v00.00.00000 + name: groups + preferred: true + service: + $ref: openai_admin/v00.00.00000/services/groups.yaml + title: groups API + version: v00.00.00000 + description: openai_admin API + invites: + id: invites:v00.00.00000 + name: invites + preferred: true + service: + $ref: openai_admin/v00.00.00000/services/invites.yaml + title: invites API + version: v00.00.00000 + description: openai_admin API + projects: + id: projects:v00.00.00000 + name: projects + preferred: true + service: + $ref: openai_admin/v00.00.00000/services/projects.yaml + title: projects API + version: v00.00.00000 + description: openai_admin API + roles: + id: roles:v00.00.00000 + name: roles + preferred: true + service: + $ref: openai_admin/v00.00.00000/services/roles.yaml + title: roles API + version: v00.00.00000 + description: openai_admin API + usage: + id: usage:v00.00.00000 + name: usage + preferred: true + service: + $ref: openai_admin/v00.00.00000/services/usage.yaml + title: usage API + version: v00.00.00000 + description: openai_admin API + users: + id: users:v00.00.00000 + name: users + preferred: true + service: + $ref: openai_admin/v00.00.00000/services/users.yaml + title: users API + version: v00.00.00000 + description: openai_admin API +config: + auth: + type: bearer + credentialsenvvar: OPENAI_ADMIN_KEY diff --git a/providers/src/openai_admin/v00.00.00000/services/admin_api_keys.yaml b/providers/src/openai_admin/v00.00.00000/services/admin_api_keys.yaml new file mode 100644 index 00000000..84c10eaf --- /dev/null +++ b/providers/src/openai_admin/v00.00.00000/services/admin_api_keys.yaml @@ -0,0 +1,689 @@ +openapi: 3.1.0 +info: + title: admin_api_keys API + description: openai_admin API + version: 2.3.0 +paths: + /organization/admin_api_keys: + get: + security: + - AdminApiKeyAuth: [] + summary: List organization API keys + operationId: admin-api-keys-list + description: Retrieve a paginated list of organization admin API keys. + parameters: + - in: query + name: after + required: false + schema: + type: string + nullable: true + description: Return keys with IDs that come after this ID in the pagination order. + - in: query + name: order + required: false + schema: + type: string + enum: + - asc + - desc + default: asc + description: Order results by creation time, ascending or descending. + - in: query + name: limit + required: false + schema: + type: integer + default: 20 + description: Maximum number of keys to return. + responses: + '200': + description: A list of organization API keys. + content: + application/json: + schema: + $ref: '#/components/schemas/ApiKeyList' + x-oaiMeta: + name: List all organization and project API keys. + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/admin_api_keys?after=key_abc&limit=20 \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const adminAPIKey of client.admin.organization.adminAPIKeys.list()) { + console.log(adminAPIKey.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.admin_api_keys.list() + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.AdminAPIKeys.List(context.TODO(), openai.AdminOrganizationAdminAPIKeyListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.adminapikeys.AdminApiKeyListPage; + import com.openai.models.admin.organization.adminapikeys.AdminApiKeyListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + AdminApiKeyListPage page = client.admin().organization().adminApiKeys().list(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.admin_api_keys.list + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "object": "organization.admin_api_key", + "id": "key_abc", + "name": "Main Admin Key", + "redacted_value": "sk-admin...def", + "created_at": 1711471533, + "last_used_at": 1711471534, + "owner": { + "type": "service_account", + "object": "organization.service_account", + "id": "sa_456", + "name": "My Service Account", + "created_at": 1711471533, + "role": "member" + } + } + ], + "first_id": "key_abc", + "last_id": "key_abc", + "has_more": false + } + tags: + - Admin API Keys + post: + security: + - AdminApiKeyAuth: [] + summary: Create an organization admin API key + operationId: admin-api-keys-create + description: Create a new admin-level API key for the organization. + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - name + properties: + name: + type: string + example: New Admin Key + responses: + '200': + description: The newly created admin API key. + content: + application/json: + schema: + $ref: '#/components/schemas/AdminApiKeyCreateResponse' + x-oaiMeta: + name: Create admin API key + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/organization/admin_api_keys \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "New Admin Key" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const adminAPIKey = await client.admin.organization.adminAPIKeys.create({ name: 'New Admin Key' }); + + console.log(adminAPIKey); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + admin_api_key = client.admin.organization.admin_api_keys.create( + name="New Admin Key", + ) + print(admin_api_key) + 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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tadminAPIKey, err := client.Admin.Organization.AdminAPIKeys.New(context.TODO(), openai.AdminOrganizationAdminAPIKeyNewParams{\n\t\tName: \"New Admin Key\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", adminAPIKey)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.adminapikeys.AdminApiKeyCreateParams; + import com.openai.models.admin.organization.adminapikeys.AdminApiKeyCreateResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + AdminApiKeyCreateParams params = AdminApiKeyCreateParams.builder() + .name("New Admin Key") + .build(); + AdminApiKeyCreateResponse adminApiKey = client.admin().organization().adminApiKeys().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + admin_api_key = openai.admin.organization.admin_api_keys.create(name: "New Admin Key") + + puts(admin_api_key) + response: | + { + "object": "organization.admin_api_key", + "id": "key_xyz", + "name": "New Admin Key", + "redacted_value": "sk-admin...xyz", + "created_at": 1711471533, + "last_used_at": 1711471534, + "owner": { + "type": "user", + "object": "organization.user", + "id": "user_123", + "name": "John Doe", + "created_at": 1711471533, + "role": "owner" + }, + "value": "sk-admin-1234abcd" + } + tags: + - Admin API Keys + /organization/admin_api_keys/{key_id}: + get: + security: + - AdminApiKeyAuth: [] + summary: Retrieve a single organization API key + operationId: admin-api-keys-get + description: Get details for a specific organization API key by its ID. + parameters: + - in: path + name: key_id + required: true + schema: + type: string + description: The ID of the API key. + responses: + '200': + description: Details of the requested API key. + content: + application/json: + schema: + $ref: '#/components/schemas/AdminApiKey' + x-oaiMeta: + name: Retrieve admin API key + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/admin_api_keys/key_abc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const adminAPIKey = await client.admin.organization.adminAPIKeys.retrieve('key_id'); + + console.log(adminAPIKey.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + admin_api_key = client.admin.organization.admin_api_keys.retrieve( + "key_id", + ) + print(admin_api_key.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tadminAPIKey, err := client.Admin.Organization.AdminAPIKeys.Get(context.TODO(), \"key_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", adminAPIKey.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.adminapikeys.AdminApiKey; + import com.openai.models.admin.organization.adminapikeys.AdminApiKeyRetrieveParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + AdminApiKey adminApiKey = client.admin().organization().adminApiKeys().retrieve("key_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + admin_api_key = openai.admin.organization.admin_api_keys.retrieve("key_id") + + puts(admin_api_key) + response: | + { + "object": "organization.admin_api_key", + "id": "key_abc", + "name": "Main Admin Key", + "redacted_value": "sk-admin...xyz", + "created_at": 1711471533, + "last_used_at": 1711471534, + "owner": { + "type": "user", + "object": "organization.user", + "id": "user_123", + "name": "John Doe", + "created_at": 1711471533, + "role": "owner" + } + } + tags: + - Admin API Keys + delete: + security: + - AdminApiKeyAuth: [] + summary: Delete an organization admin API key + operationId: admin-api-keys-delete + description: Delete the specified admin API key. + parameters: + - in: path + name: key_id + required: true + schema: + type: string + description: The ID of the API key to be deleted. + responses: + '200': + description: Confirmation that the API key was deleted. + content: + application/json: + schema: + type: object + properties: + id: + type: string + example: key_abc + object: + type: string + enum: + - organization.admin_api_key.deleted + example: organization.admin_api_key.deleted + x-stainless-const: true + deleted: + type: boolean + example: true + required: + - id + - object + - deleted + x-oaiMeta: + name: Delete admin API key + group: administration + examples: + request: + curl: | + curl -X DELETE https://api.openai.com/v1/organization/admin_api_keys/key_abc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const adminAPIKey = await client.admin.organization.adminAPIKeys.delete('key_id'); + + console.log(adminAPIKey.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + admin_api_key = client.admin.organization.admin_api_keys.delete( + "key_id", + ) + print(admin_api_key.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tadminAPIKey, err := client.Admin.Organization.AdminAPIKeys.Delete(context.TODO(), \"key_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", adminAPIKey.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.adminapikeys.AdminApiKeyDeleteParams; + import com.openai.models.admin.organization.adminapikeys.AdminApiKeyDeleteResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + AdminApiKeyDeleteResponse adminApiKey = client.admin().organization().adminApiKeys().delete("key_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + admin_api_key = openai.admin.organization.admin_api_keys.delete("key_id") + + puts(admin_api_key) + response: | + { + "id": "key_abc", + "object": "organization.admin_api_key.deleted", + "deleted": true + } + tags: + - Admin API Keys +components: + schemas: + ApiKeyList: + type: object + properties: + object: + type: string + enum: + - list + example: list + x-stainless-const: true + data: + type: array + items: + $ref: '#/components/schemas/AdminApiKey' + has_more: + type: boolean + example: false + first_id: + example: key_abc + type: string + last_id: + example: key_xyz + type: string + required: + - object + - data + - has_more + AdminApiKeyCreateResponse: + type: object + description: Represents an individual Admin API key in an org. + properties: + object: + type: string + enum: + - organization.admin_api_key + description: The object type, which is always `organization.admin_api_key` + x-stainless-const: true + id: + type: string + example: key_abc + description: The identifier, which can be referenced in API endpoints + name: + example: Administration Key + description: The name of the API key + type: string + redacted_value: + type: string + example: sk-admin...def + description: The redacted value of the API key + created_at: + type: integer + format: unixtime + example: 1711471533 + description: The Unix timestamp (in seconds) of when the API key was created + last_used_at: + type: integer + format: unixtime + example: 1711471534 + description: The Unix timestamp (in seconds) of when the API key was last used + owner: + type: object + properties: + type: + type: string + example: user + description: Always `user` + object: + type: string + example: organization.user + description: The object type, which is always organization.user + id: + type: string + example: sa_456 + description: The identifier, which can be referenced in API endpoints + name: + type: string + example: My Service Account + description: The name of the user + created_at: + type: integer + format: unixtime + example: 1711471533 + description: The Unix timestamp (in seconds) of when the user was created + role: + type: string + example: owner + description: Always `owner` + value: + type: string + example: sk-admin-1234abcd + description: The value of the API key. Only shown on create. + required: + - object + - redacted_value + - created_at + - id + - owner + - value + x-oaiMeta: + name: The admin API key object + example: | + { + "object": "organization.admin_api_key", + "id": "key_abc", + "name": "Main Admin Key", + "redacted_value": "sk-admin...xyz", + "created_at": 1711471533, + "last_used_at": 1711471534, + "owner": { + "type": "user", + "object": "organization.user", + "id": "user_123", + "name": "John Doe", + "created_at": 1711471533, + "role": "owner" + } + } + AdminApiKey: + type: object + description: Represents an individual Admin API key in an org. + properties: + object: + type: string + enum: + - organization.admin_api_key + description: The object type, which is always `organization.admin_api_key` + x-stainless-const: true + id: + type: string + example: key_abc + description: The identifier, which can be referenced in API endpoints + name: + example: Administration Key + description: The name of the API key + type: string + redacted_value: + type: string + example: sk-admin...def + description: The redacted value of the API key + created_at: + type: integer + format: unixtime + example: 1711471533 + description: The Unix timestamp (in seconds) of when the API key was created + last_used_at: + type: integer + format: unixtime + example: 1711471534 + description: The Unix timestamp (in seconds) of when the API key was last used + owner: + type: object + properties: + type: + type: string + example: user + description: Always `user` + object: + type: string + example: organization.user + description: The object type, which is always organization.user + id: + type: string + example: sa_456 + description: The identifier, which can be referenced in API endpoints + name: + type: string + example: My Service Account + description: The name of the user + created_at: + type: integer + format: unixtime + example: 1711471533 + description: The Unix timestamp (in seconds) of when the user was created + role: + type: string + example: owner + description: Always `owner` + required: + - object + - redacted_value + - created_at + - id + - owner + x-oaiMeta: + name: The admin API key object + example: | + { + "object": "organization.admin_api_key", + "id": "key_abc", + "name": "Main Admin Key", + "redacted_value": "sk-admin...xyz", + "created_at": 1711471533, + "last_used_at": 1711471534, + "owner": { + "type": "user", + "object": "organization.user", + "id": "user_123", + "name": "John Doe", + "created_at": 1711471533, + "role": "owner" + } + } + x-stackQL-resources: + admin_api_keys: + id: openai_admin.admin_api_keys.admin_api_keys + name: admin_api_keys + title: Admin Api Keys + methods: + list: + operation: + $ref: '#/paths/~1organization~1admin_api_keys/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1admin_api_keys/post' + response: + mediaType: application/json + openAPIDocKey: '200' + get: + operation: + $ref: '#/paths/~1organization~1admin_api_keys~1{key_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1organization~1admin_api_keys~1{key_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/admin_api_keys/methods/get' + - $ref: '#/components/x-stackQL-resources/admin_api_keys/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/admin_api_keys/methods/create' + update: [] + delete: + - $ref: '#/components/x-stackQL-resources/admin_api_keys/methods/delete' + replace: [] +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.last_id + location: body diff --git a/providers/src/openai_admin/v00.00.00000/services/audit_logs.yaml b/providers/src/openai_admin/v00.00.00000/services/audit_logs.yaml new file mode 100644 index 00000000..0cb410ce --- /dev/null +++ b/providers/src/openai_admin/v00.00.00000/services/audit_logs.yaml @@ -0,0 +1,1064 @@ +openapi: 3.1.0 +info: + title: audit_logs API + description: openai_admin API + version: 2.3.0 +paths: + /organization/audit_logs: + get: + security: + - AdminApiKeyAuth: [] + summary: List user actions and configuration changes within this organization. + operationId: list-audit-logs + tags: + - Audit Logs + parameters: + - name: effective_at[gt] + in: query + required: false + description: Return only events whose `effective_at` (Unix seconds) is greater than this value. + schema: + type: integer + - name: effective_at[gte] + in: query + required: false + description: Return only events whose `effective_at` (Unix seconds) is greater than or equal to this value. + schema: + type: integer + - name: effective_at[lt] + in: query + required: false + description: Return only events whose `effective_at` (Unix seconds) is less than this value. + schema: + type: integer + - name: effective_at[lte] + in: query + required: false + description: Return only events whose `effective_at` (Unix seconds) is less than or equal to this value. + schema: + type: integer + - name: project_ids[] + in: query + description: Return only events for these projects. + required: false + schema: + type: array + items: + type: string + - name: event_types[] + in: query + description: Return only events with a `type` in one of these values. For example, `project.created`. For all options, see the documentation for the [audit log object](/docs/api-reference/audit-logs/object). + required: false + schema: + type: array + items: + $ref: '#/components/schemas/AuditLogEventType' + - name: actor_ids[] + in: query + description: Return only events performed by these actors. Can be a user ID, a service account ID, or an api key tracking ID. + required: false + schema: + type: array + items: + type: string + - name: actor_emails[] + in: query + description: Return only events performed by users with these emails. + required: false + schema: + type: array + items: + type: string + - name: resource_ids[] + in: query + description: Return only events performed on these targets. For example, a project ID updated. + required: false + schema: + type: array + items: + type: string + - name: limit + in: query + description: | + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + required: false + schema: + type: integer + default: 20 + - name: after + in: query + 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 + - name: before + in: query + 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 + responses: + '200': + description: Audit logs listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ListAuditLogsResponse' + x-oaiMeta: + name: List audit logs + group: audit-logs + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/audit_logs \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const auditLogListResponse of client.admin.organization.auditLogs.list()) { + console.log(auditLogListResponse.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.audit_logs.list() + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.AuditLogs.List(context.TODO(), openai.AdminOrganizationAuditLogListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.auditlogs.AuditLogListPage; + import com.openai.models.admin.organization.auditlogs.AuditLogListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + AuditLogListPage page = client.admin().organization().auditLogs().list(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.audit_logs.list + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "id": "audit_log-xxx_yyyymmdd", + "type": "project.archived", + "effective_at": 1722461446, + "actor": { + "type": "api_key", + "api_key": { + "type": "user", + "user": { + "id": "user-xxx", + "email": "user@example.com" + } + } + }, + "project.archived": { + "id": "proj_abc" + }, + }, + { + "id": "audit_log-yyy__20240101", + "type": "api_key.updated", + "effective_at": 1720804190, + "actor": { + "type": "session", + "session": { + "user": { + "id": "user-xxx", + "email": "user@example.com" + }, + "ip_address": "127.0.0.1", + "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36", + "ja3": "a497151ce4338a12c4418c44d375173e", + "ja4": "q13d0313h3_55b375c5d22e_c7319ce65786", + "ip_address_details": { + "country": "US", + "city": "San Francisco", + "region": "California", + "region_code": "CA", + "asn": "1234", + "latitude": "37.77490", + "longitude": "-122.41940" + } + } + }, + "api_key.updated": { + "id": "key_xxxx", + "data": { + "scopes": ["resource_2.operation_2"] + } + }, + } + ], + "first_id": "audit_log-xxx__20240101", + "last_id": "audit_log_yyy__20240101", + "has_more": true + } +components: + schemas: + AuditLogEventType: + type: string + description: The event type. + enum: + - api_key.created + - api_key.updated + - api_key.deleted + - certificate.created + - certificate.updated + - certificate.deleted + - certificates.activated + - certificates.deactivated + - checkpoint.permission.created + - checkpoint.permission.deleted + - external_key.registered + - external_key.removed + - group.created + - group.updated + - group.deleted + - invite.sent + - invite.accepted + - invite.deleted + - ip_allowlist.created + - ip_allowlist.updated + - ip_allowlist.deleted + - ip_allowlist.config.activated + - ip_allowlist.config.deactivated + - login.succeeded + - login.failed + - logout.succeeded + - logout.failed + - organization.updated + - project.created + - project.updated + - project.archived + - project.deleted + - rate_limit.updated + - rate_limit.deleted + - resource.deleted + - tunnel.created + - tunnel.updated + - tunnel.deleted + - role.created + - role.updated + - role.deleted + - role.assignment.created + - role.assignment.deleted + - scim.enabled + - scim.disabled + - service_account.created + - service_account.updated + - service_account.deleted + - user.added + - user.updated + - user.deleted + ListAuditLogsResponse: + type: object + properties: + object: + type: string + enum: + - list + x-stainless-const: true + data: + type: array + items: + $ref: '#/components/schemas/AuditLog' + first_id: + example: audit_log-defb456h8dks + type: string + last_id: + example: audit_log-hnbkd8s93s + type: string + has_more: + type: boolean + required: + - object + - data + - has_more + AuditLog: + type: object + description: A log of a user action or configuration change within this organization. + properties: + id: + type: string + description: The ID of this log. + type: + $ref: '#/components/schemas/AuditLogEventType' + effective_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of the event. + project: + type: object + description: The project that the action was scoped to. Absent for actions not scoped to projects. Note that any admin actions taken via Admin API keys are associated with the default project. + properties: + id: + type: string + description: The project ID. + name: + type: string + description: The project title. + actor: + type: object + description: The actor who performed the audit logged action. + properties: + type: + type: string + description: The type of actor. Is either `session` or `api_key`. + enum: + - session + - api_key + session: + $ref: '#/components/schemas/AuditLogActorSession' + api_key: + $ref: '#/components/schemas/AuditLogActorApiKey' + api_key.created: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The tracking ID of the API key. + data: + type: object + description: The payload used to create the API key. + properties: + scopes: + type: array + items: + type: string + description: A list of scopes allowed for the API key, e.g. `["api.model.request"]` + api_key.updated: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The tracking ID of the API key. + changes_requested: + type: object + description: The payload used to update the API key. + properties: + scopes: + type: array + items: + type: string + description: A list of scopes allowed for the API key, e.g. `["api.model.request"]` + api_key.deleted: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The tracking ID of the API key. + checkpoint.permission.created: + type: object + description: The project and fine-tuned model checkpoint that the checkpoint permission was created for. + properties: + id: + type: string + description: The ID of the checkpoint permission. + data: + type: object + description: The payload used to create the checkpoint permission. + properties: + project_id: + type: string + description: The ID of the project that the checkpoint permission was created for. + fine_tuned_model_checkpoint: + type: string + description: The ID of the fine-tuned model checkpoint. + checkpoint.permission.deleted: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The ID of the checkpoint permission. + external_key.registered: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The ID of the external key configuration. + data: + type: string + description: The configuration for the external key. (opaque JSON object) + external_key.removed: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The ID of the external key configuration. + group.created: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The ID of the group. + data: + type: object + description: Information about the created group. + properties: + group_name: + type: string + description: The group name. + group.updated: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The ID of the group. + changes_requested: + type: object + description: The payload used to update the group. + properties: + group_name: + type: string + description: The updated group name. + group.deleted: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The ID of the group. + scim.enabled: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The ID of the SCIM was enabled for. + scim.disabled: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The ID of the SCIM was disabled for. + invite.sent: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The ID of the invite. + data: + type: object + description: The payload used to create the invite. + properties: + email: + type: string + description: The email invited to the organization. + role: + type: string + description: The role the email was invited to be. Is either `owner` or `member`. + invite.accepted: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The ID of the invite. + invite.deleted: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The ID of the invite. + ip_allowlist.created: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The ID of the IP allowlist configuration. + name: + type: string + description: The name of the IP allowlist configuration. + allowed_ips: + type: array + description: The IP addresses or CIDR ranges included in the configuration. + items: + type: string + ip_allowlist.updated: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The ID of the IP allowlist configuration. + allowed_ips: + type: array + description: The updated set of IP addresses or CIDR ranges in the configuration. + items: + type: string + ip_allowlist.deleted: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The ID of the IP allowlist configuration. + name: + type: string + description: The name of the IP allowlist configuration. + allowed_ips: + type: array + description: The IP addresses or CIDR ranges that were in the configuration. + items: + type: string + ip_allowlist.config.activated: + type: object + description: The details for events with this `type`. + properties: + configs: + type: array + description: The configurations that were activated. + items: + type: object + properties: + id: + type: string + description: The ID of the IP allowlist configuration. + name: + type: string + description: The name of the IP allowlist configuration. + ip_allowlist.config.deactivated: + type: object + description: The details for events with this `type`. + properties: + configs: + type: array + description: The configurations that were deactivated. + items: + type: object + properties: + id: + type: string + description: The ID of the IP allowlist configuration. + name: + type: string + description: The name of the IP allowlist configuration. + login.succeeded: + type: string + description: This event has no additional fields beyond the standard audit log attributes. (opaque JSON object) + login.failed: + type: object + description: The details for events with this `type`. + properties: + error_code: + type: string + description: The error code of the failure. + error_message: + type: string + description: The error message of the failure. + logout.succeeded: + type: string + description: This event has no additional fields beyond the standard audit log attributes. (opaque JSON object) + logout.failed: + type: object + description: The details for events with this `type`. + properties: + error_code: + type: string + description: The error code of the failure. + error_message: + type: string + description: The error message of the failure. + organization.updated: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The organization ID. + changes_requested: + type: object + description: The payload used to update the organization settings. + properties: + title: + type: string + description: The organization title. + description: + type: string + description: The organization description. + name: + type: string + description: The organization name. + threads_ui_visibility: + type: string + description: Visibility of the threads page which shows messages created with the Assistants API and Playground. One of `ANY_ROLE`, `OWNERS`, or `NONE`. + usage_dashboard_visibility: + type: string + description: Visibility of the usage dashboard which shows activity and costs for your organization. One of `ANY_ROLE` or `OWNERS`. + api_call_logging: + type: string + description: How your organization logs data from supported API calls. One of `disabled`, `enabled_per_call`, `enabled_for_all_projects`, or `enabled_for_selected_projects` + api_call_logging_project_ids: + type: string + description: The list of project ids if api_call_logging is set to `enabled_for_selected_projects` + project.created: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The project ID. + data: + type: object + description: The payload used to create the project. + properties: + name: + type: string + description: The project name. + title: + type: string + description: The title of the project as seen on the dashboard. + project.updated: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The project ID. + changes_requested: + type: object + description: The payload used to update the project. + properties: + title: + type: string + description: The title of the project as seen on the dashboard. + project.archived: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The project ID. + project.deleted: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The project ID. + rate_limit.updated: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The rate limit ID + changes_requested: + type: object + description: The payload used to update the rate limits. + properties: + max_requests_per_1_minute: + type: integer + description: The maximum requests per minute. + max_tokens_per_1_minute: + type: integer + description: The maximum tokens per minute. + max_images_per_1_minute: + type: integer + description: The maximum images per minute. Only relevant for certain models. + max_audio_megabytes_per_1_minute: + type: integer + description: The maximum audio megabytes per minute. Only relevant for certain models. + max_requests_per_1_day: + type: integer + description: The maximum requests per day. Only relevant for certain models. + batch_1_day_max_input_tokens: + type: integer + description: The maximum batch input tokens per day. Only relevant for certain models. + rate_limit.deleted: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The rate limit ID + role.created: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The role ID. + role_name: + type: string + description: The name of the role. + permissions: + type: array + items: + type: string + description: The permissions granted by the role. + resource_type: + type: string + description: The type of resource the role belongs to. + resource_id: + type: string + description: The resource the role is scoped to. + role.updated: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The role ID. + changes_requested: + type: object + description: The payload used to update the role. + properties: + role_name: + type: string + description: The updated role name, when provided. + resource_id: + type: string + description: The resource the role is scoped to. + resource_type: + type: string + description: The type of resource the role belongs to. + permissions_added: + type: array + items: + type: string + description: The permissions added to the role. + permissions_removed: + type: array + items: + type: string + description: The permissions removed from the role. + description: + type: string + description: The updated role description, when provided. + metadata: + type: string + description: Additional metadata stored on the role. (opaque JSON object) + role.deleted: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The role ID. + role.assignment.created: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The identifier of the role assignment. + principal_id: + type: string + description: The principal (user or group) that received the role. + principal_type: + type: string + description: The type of principal (user or group) that received the role. + resource_id: + type: string + description: The resource the role assignment is scoped to. + resource_type: + type: string + description: The type of resource the role assignment is scoped to. + role.assignment.deleted: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The identifier of the role assignment. + principal_id: + type: string + description: The principal (user or group) that had the role removed. + principal_type: + type: string + description: The type of principal (user or group) that had the role removed. + resource_id: + type: string + description: The resource the role assignment was scoped to. + resource_type: + type: string + description: The type of resource the role assignment was scoped to. + service_account.created: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The service account ID. + data: + type: object + description: The payload used to create the service account. + properties: + role: + type: string + description: The role of the service account. Is either `owner` or `member`. + service_account.updated: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The service account ID. + changes_requested: + type: object + description: The payload used to updated the service account. + properties: + role: + type: string + description: The role of the service account. Is either `owner` or `member`. + service_account.deleted: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The service account ID. + user.added: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The user ID. + data: + type: object + description: The payload used to add the user to the project. + properties: + role: + type: string + description: The role of the user. Is either `owner` or `member`. + user.updated: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The project ID. + changes_requested: + type: object + description: The payload used to update the user. + properties: + role: + type: string + description: The role of the user. Is either `owner` or `member`. + user.deleted: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The user ID. + certificate.created: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The certificate ID. + name: + type: string + description: The name of the certificate. + certificate.updated: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The certificate ID. + name: + type: string + description: The name of the certificate. + certificate.deleted: + type: object + description: The details for events with this `type`. + properties: + id: + type: string + description: The certificate ID. + name: + type: string + description: The name of the certificate. + certificate: + type: string + description: The certificate content in PEM format. + certificates.activated: + type: object + description: The details for events with this `type`. + properties: + certificates: + type: array + items: + type: object + properties: + id: + type: string + description: The certificate ID. + name: + type: string + description: The name of the certificate. + certificates.deactivated: + type: object + description: The details for events with this `type`. + properties: + certificates: + type: array + items: + type: object + properties: + id: + type: string + description: The certificate ID. + name: + type: string + description: The name of the certificate. + required: + - id + - type + - effective_at + x-oaiMeta: + name: The audit log object + example: | + { + "id": "req_xxx_20240101", + "type": "api_key.created", + "effective_at": 1720804090, + "actor": { + "type": "session", + "session": { + "user": { + "id": "user-xxx", + "email": "user@example.com" + }, + "ip_address": "127.0.0.1", + "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" + } + }, + "api_key.created": { + "id": "key_xxxx", + "data": { + "scopes": ["resource.operation"] + } + } + } + AuditLogActor: + type: object + description: The actor who performed the audit logged action. + properties: + type: + type: string + description: The type of actor. Is either `session` or `api_key`. + enum: + - session + - api_key + session: + $ref: '#/components/schemas/AuditLogActorSession' + api_key: + $ref: '#/components/schemas/AuditLogActorApiKey' + AuditLogActorSession: + type: object + description: The session in which the audit logged action was performed. + properties: + user: + $ref: '#/components/schemas/AuditLogActorUser' + ip_address: + type: string + description: The IP address from which the action was performed. + AuditLogActorApiKey: + type: object + description: The API Key used to perform the audit logged action. + properties: + id: + type: string + description: The tracking id of the API key. + type: + type: string + description: The type of API key. Can be either `user` or `service_account`. + enum: + - user + - service_account + user: + $ref: '#/components/schemas/AuditLogActorUser' + service_account: + $ref: '#/components/schemas/AuditLogActorServiceAccount' + AuditLogActorUser: + type: object + description: The user who performed the audit logged action. + properties: + id: + type: string + description: The user id. + email: + type: string + description: The user email. + AuditLogActorServiceAccount: + type: object + description: The service account that performed the audit logged action. + properties: + id: + type: string + description: The service account id. + x-stackQL-resources: + audit_logs: + id: openai_admin.audit_logs.audit_logs + name: audit_logs + title: Audit Logs + methods: + list: + operation: + $ref: '#/paths/~1organization~1audit_logs/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/audit_logs/methods/list' + insert: [] + update: [] + delete: [] + replace: [] +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.last_id + location: body diff --git a/providers/src/openai_admin/v00.00.00000/services/certificates.yaml b/providers/src/openai_admin/v00.00.00000/services/certificates.yaml new file mode 100644 index 00000000..702d9669 --- /dev/null +++ b/providers/src/openai_admin/v00.00.00000/services/certificates.yaml @@ -0,0 +1,1555 @@ +openapi: 3.1.0 +info: + title: certificates API + description: openai_admin API + version: 2.3.0 +paths: + /organization/certificates: + get: + security: + - AdminApiKeyAuth: [] + summary: List uploaded certificates for this organization. + operationId: listOrganizationCertificates + tags: + - Certificates + parameters: + - name: limit + in: query + description: | + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + required: false + schema: + type: integer + default: 20 + - name: after + in: query + 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. + required: false + schema: + type: string + - name: order + in: query + description: | + Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. + schema: + type: string + default: desc + enum: + - asc + - desc + responses: + '200': + description: Certificates listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ListCertificatesResponse' + x-oaiMeta: + name: List organization certificates + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/certificates \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const certificateListResponse of client.admin.organization.certificates.list()) { + console.log(certificateListResponse.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.certificates.list() + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Certificates.List(context.TODO(), openai.AdminOrganizationCertificateListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.certificates.CertificateListPage; + import com.openai.models.admin.organization.certificates.CertificateListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + CertificateListPage page = client.admin().organization().certificates().list(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.certificates.list + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "object": "organization.certificate", + "id": "cert_abc", + "name": "My Example Certificate", + "active": true, + "created_at": 1234567, + "certificate_details": { + "valid_at": 12345667, + "expires_at": 12345678 + } + }, + ], + "first_id": "cert_abc", + "last_id": "cert_abc", + "has_more": false + } + post: + security: + - AdminApiKeyAuth: [] + summary: | + Upload a certificate to the organization. This does **not** automatically activate the certificate. + + Organizations can upload up to 50 certificates. + operationId: uploadCertificate + tags: + - Certificates + requestBody: + description: The certificate upload payload. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UploadCertificateRequest' + responses: + '200': + description: Certificate uploaded successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/Certificate' + x-oaiMeta: + name: Upload certificate + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/organization/certificates \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "My Example Certificate", + "certificate": "-----BEGIN CERTIFICATE-----\\nMIIDeT...\\n-----END CERTIFICATE-----" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const certificate = await client.admin.organization.certificates.create({ + certificate: 'certificate', + }); + + console.log(certificate.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + certificate = client.admin.organization.certificates.create( + certificate="certificate", + ) + print(certificate.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tcertificate, err := client.Admin.Organization.Certificates.New(context.TODO(), openai.AdminOrganizationCertificateNewParams{\n\t\tCertificate: \"certificate\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", certificate.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.certificates.Certificate; + import com.openai.models.admin.organization.certificates.CertificateCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + CertificateCreateParams params = CertificateCreateParams.builder() + .certificate("certificate") + .build(); + Certificate certificate = client.admin().organization().certificates().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + certificate = openai.admin.organization.certificates.create(certificate: "certificate") + + puts(certificate) + response: | + { + "object": "certificate", + "id": "cert_abc", + "name": "My Example Certificate", + "created_at": 1234567, + "certificate_details": { + "valid_at": 12345667, + "expires_at": 12345678 + } + } + /organization/certificates/activate: + post: + security: + - AdminApiKeyAuth: [] + summary: | + Activate certificates at the organization level. + + You can atomically and idempotently activate up to 10 certificates at a time. + operationId: activateOrganizationCertificates + tags: + - Certificates + requestBody: + description: The certificate activation payload. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ToggleCertificatesRequest' + responses: + '200': + description: Certificates activated successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/OrganizationCertificateActivationResponse' + x-oaiMeta: + name: Activate certificates for organization + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/certificates/activate \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "certificate_ids": ["cert_abc", "cert_def"] + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const certificateActivateResponse of client.admin.organization.certificates.activate({ + certificate_ids: ['cert_abc'], + })) { + console.log(certificateActivateResponse.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.certificates.activate( + certificate_ids=["cert_abc"], + ) + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Certificates.Activate(context.TODO(), openai.AdminOrganizationCertificateActivateParams{\n\t\tCertificateIDs: []string{\"cert_abc\"},\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.certificates.CertificateActivatePage; + import com.openai.models.admin.organization.certificates.CertificateActivateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + CertificateActivateParams params = CertificateActivateParams.builder() + .addCertificateId("cert_abc") + .build(); + CertificateActivatePage page = client.admin().organization().certificates().activate(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.certificates.activate(certificate_ids: ["cert_abc"]) + + puts(page) + response: | + { + "object": "organization.certificate.activation", + "data": [ + { + "object": "organization.certificate", + "id": "cert_abc", + "name": "My Example Certificate", + "active": true, + "created_at": 1234567, + "certificate_details": { + "valid_at": 12345667, + "expires_at": 12345678 + } + }, + { + "object": "organization.certificate", + "id": "cert_def", + "name": "My Example Certificate 2", + "active": true, + "created_at": 1234567, + "certificate_details": { + "valid_at": 12345667, + "expires_at": 12345678 + } + }, + ], + } + /organization/certificates/deactivate: + post: + security: + - AdminApiKeyAuth: [] + summary: | + Deactivate certificates at the organization level. + + You can atomically and idempotently deactivate up to 10 certificates at a time. + operationId: deactivateOrganizationCertificates + tags: + - Certificates + requestBody: + description: The certificate deactivation payload. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ToggleCertificatesRequest' + responses: + '200': + description: Certificates deactivated successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/OrganizationCertificateDeactivationResponse' + x-oaiMeta: + name: Deactivate certificates for organization + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/certificates/deactivate \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "certificate_ids": ["cert_abc", "cert_def"] + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const certificateDeactivateResponse of client.admin.organization.certificates.deactivate( + { certificate_ids: ['cert_abc'] }, + )) { + console.log(certificateDeactivateResponse.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.certificates.deactivate( + certificate_ids=["cert_abc"], + ) + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Certificates.Deactivate(context.TODO(), openai.AdminOrganizationCertificateDeactivateParams{\n\t\tCertificateIDs: []string{\"cert_abc\"},\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.certificates.CertificateDeactivatePage; + import com.openai.models.admin.organization.certificates.CertificateDeactivateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + CertificateDeactivateParams params = CertificateDeactivateParams.builder() + .addCertificateId("cert_abc") + .build(); + CertificateDeactivatePage page = client.admin().organization().certificates().deactivate(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.certificates.deactivate(certificate_ids: ["cert_abc"]) + + puts(page) + response: | + { + "object": "organization.certificate.deactivation", + "data": [ + { + "object": "organization.certificate", + "id": "cert_abc", + "name": "My Example Certificate", + "active": false, + "created_at": 1234567, + "certificate_details": { + "valid_at": 12345667, + "expires_at": 12345678 + } + }, + { + "object": "organization.certificate", + "id": "cert_def", + "name": "My Example Certificate 2", + "active": false, + "created_at": 1234567, + "certificate_details": { + "valid_at": 12345667, + "expires_at": 12345678 + } + }, + ], + } + /organization/certificates/{certificate_id}: + get: + security: + - AdminApiKeyAuth: [] + summary: | + Get a certificate that has been uploaded to the organization. + + You can get a certificate regardless of whether it is active or not. + operationId: getCertificate + tags: + - Certificates + parameters: + - name: certificate_id + in: path + description: Unique ID of the certificate to retrieve. + required: true + schema: + type: string + - name: include + in: query + description: A list of additional fields to include in the response. Currently the only supported value is `content` to fetch the PEM content of the certificate. + required: false + schema: + type: array + items: + type: string + enum: + - content + responses: + '200': + description: Certificate retrieved successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/Certificate' + x-oaiMeta: + name: Get certificate + group: administration + examples: + request: + curl: | + curl "https://api.openai.com/v1/organization/certificates/cert_abc?include[]=content" \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const certificate = await client.admin.organization.certificates.retrieve('certificate_id'); + + console.log(certificate.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + certificate = client.admin.organization.certificates.retrieve( + certificate_id="certificate_id", + ) + print(certificate.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tcertificate, err := client.Admin.Organization.Certificates.Get(\n\t\tcontext.TODO(),\n\t\t\"certificate_id\",\n\t\topenai.AdminOrganizationCertificateGetParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", certificate.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.certificates.Certificate; + import com.openai.models.admin.organization.certificates.CertificateRetrieveParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Certificate certificate = client.admin().organization().certificates().retrieve("certificate_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + certificate = openai.admin.organization.certificates.retrieve("certificate_id") + + puts(certificate) + response: | + { + "object": "certificate", + "id": "cert_abc", + "name": "My Example Certificate", + "created_at": 1234567, + "certificate_details": { + "valid_at": 1234567, + "expires_at": 12345678, + "content": "-----BEGIN CERTIFICATE-----MIIDeT...-----END CERTIFICATE-----" + } + } + post: + security: + - AdminApiKeyAuth: [] + summary: | + Modify a certificate. Note that only the name can be modified. + operationId: modifyCertificate + tags: + - Certificates + parameters: + - name: certificate_id + in: path + description: Unique ID of the certificate to modify. + required: true + schema: + type: string + requestBody: + description: The certificate modification payload. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ModifyCertificateRequest' + responses: + '200': + description: Certificate modified successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/Certificate' + x-oaiMeta: + name: Modify certificate + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/organization/certificates/cert_abc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "Renamed Certificate" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const certificate = await client.admin.organization.certificates.update('certificate_id'); + + console.log(certificate.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + certificate = client.admin.organization.certificates.update( + certificate_id="certificate_id", + ) + print(certificate.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tcertificate, err := client.Admin.Organization.Certificates.Update(\n\t\tcontext.TODO(),\n\t\t\"certificate_id\",\n\t\topenai.AdminOrganizationCertificateUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", certificate.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.certificates.Certificate; + import com.openai.models.admin.organization.certificates.CertificateUpdateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Certificate certificate = client.admin().organization().certificates().update("certificate_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + certificate = openai.admin.organization.certificates.update("certificate_id") + + puts(certificate) + response: | + { + "object": "certificate", + "id": "cert_abc", + "name": "Renamed Certificate", + "created_at": 1234567, + "certificate_details": { + "valid_at": 12345667, + "expires_at": 12345678 + } + } + delete: + security: + - AdminApiKeyAuth: [] + summary: | + Delete a certificate from the organization. + + The certificate must be inactive for the organization and all projects. + operationId: deleteCertificate + tags: + - Certificates + parameters: + - name: certificate_id + in: path + description: Unique ID of the certificate to delete. + required: true + schema: + type: string + responses: + '200': + description: Certificate deleted successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/DeleteCertificateResponse' + x-oaiMeta: + name: Delete certificate + group: administration + examples: + request: + curl: | + curl -X DELETE https://api.openai.com/v1/organization/certificates/cert_abc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const certificate = await client.admin.organization.certificates.delete('certificate_id'); + + console.log(certificate.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + certificate = client.admin.organization.certificates.delete( + "certificate_id", + ) + print(certificate.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tcertificate, err := client.Admin.Organization.Certificates.Delete(context.TODO(), \"certificate_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", certificate.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.certificates.CertificateDeleteParams; + import com.openai.models.admin.organization.certificates.CertificateDeleteResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + CertificateDeleteResponse certificate = client.admin().organization().certificates().delete("certificate_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + certificate = openai.admin.organization.certificates.delete("certificate_id") + + puts(certificate) + response: | + { + "object": "certificate.deleted", + "id": "cert_abc" + } + /organization/projects/{project_id}/certificates: + get: + security: + - AdminApiKeyAuth: [] + summary: List certificates for this project. + operationId: listProjectCertificates + tags: + - Certificates + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + - name: limit + in: query + description: | + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + required: false + schema: + type: integer + default: 20 + - name: after + in: query + 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. + required: false + schema: + type: string + - name: order + in: query + description: | + Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. + schema: + type: string + default: desc + enum: + - asc + - desc + responses: + '200': + description: Certificates listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ListProjectCertificatesResponse' + x-oaiMeta: + name: List project certificates + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/projects/proj_abc/certificates \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const certificateListResponse of client.admin.organization.projects.certificates.list( + 'project_id', + )) { + console.log(certificateListResponse.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.projects.certificates.list( + project_id="project_id", + ) + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Projects.Certificates.List(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\topenai.AdminOrganizationProjectCertificateListParams{},\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.certificates.CertificateListPage; + import com.openai.models.admin.organization.projects.certificates.CertificateListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + CertificateListPage page = client.admin().organization().projects().certificates().list("project_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.projects.certificates.list("project_id") + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "object": "organization.project.certificate", + "id": "cert_abc", + "name": "My Example Certificate", + "active": true, + "created_at": 1234567, + "certificate_details": { + "valid_at": 12345667, + "expires_at": 12345678 + } + }, + ], + "first_id": "cert_abc", + "last_id": "cert_abc", + "has_more": false + } + /organization/projects/{project_id}/certificates/activate: + post: + security: + - AdminApiKeyAuth: [] + summary: | + Activate certificates at the project level. + + You can atomically and idempotently activate up to 10 certificates at a time. + operationId: activateProjectCertificates + tags: + - Certificates + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + requestBody: + description: The certificate activation payload. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ToggleCertificatesRequest' + responses: + '200': + description: Certificates activated successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/OrganizationProjectCertificateActivationResponse' + x-oaiMeta: + name: Activate certificates for project + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/projects/proj_abc/certificates/activate \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "certificate_ids": ["cert_abc", "cert_def"] + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const certificateActivateResponse of client.admin.organization.projects.certificates.activate( + 'project_id', + { certificate_ids: ['cert_abc'] }, + )) { + console.log(certificateActivateResponse.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.projects.certificates.activate( + project_id="project_id", + certificate_ids=["cert_abc"], + ) + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Projects.Certificates.Activate(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\topenai.AdminOrganizationProjectCertificateActivateParams{\n\t\t\tCertificateIDs: []string{\"cert_abc\"},\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.certificates.CertificateActivatePage; + import com.openai.models.admin.organization.projects.certificates.CertificateActivateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + CertificateActivateParams params = CertificateActivateParams.builder() + .projectId("project_id") + .addCertificateId("cert_abc") + .build(); + CertificateActivatePage page = client.admin().organization().projects().certificates().activate(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.projects.certificates.activate("project_id", certificate_ids: ["cert_abc"]) + + puts(page) + response: | + { + "object": "organization.project.certificate.activation", + "data": [ + { + "object": "organization.project.certificate", + "id": "cert_abc", + "name": "My Example Certificate", + "active": true, + "created_at": 1234567, + "certificate_details": { + "valid_at": 12345667, + "expires_at": 12345678 + } + }, + { + "object": "organization.project.certificate", + "id": "cert_def", + "name": "My Example Certificate 2", + "active": true, + "created_at": 1234567, + "certificate_details": { + "valid_at": 12345667, + "expires_at": 12345678 + } + }, + ], + } + /organization/projects/{project_id}/certificates/deactivate: + post: + security: + - AdminApiKeyAuth: [] + summary: | + Deactivate certificates at the project level. You can atomically and + idempotently deactivate up to 10 certificates at a time. + operationId: deactivateProjectCertificates + tags: + - Certificates + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + requestBody: + description: The certificate deactivation payload. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ToggleCertificatesRequest' + responses: + '200': + description: Certificates deactivated successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/OrganizationProjectCertificateDeactivationResponse' + x-oaiMeta: + name: Deactivate certificates for project + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/projects/proj_abc/certificates/deactivate \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "certificate_ids": ["cert_abc", "cert_def"] + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const certificateDeactivateResponse of client.admin.organization.projects.certificates.deactivate( + 'project_id', + { certificate_ids: ['cert_abc'] }, + )) { + console.log(certificateDeactivateResponse.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.projects.certificates.deactivate( + project_id="project_id", + certificate_ids=["cert_abc"], + ) + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Projects.Certificates.Deactivate(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\topenai.AdminOrganizationProjectCertificateDeactivateParams{\n\t\t\tCertificateIDs: []string{\"cert_abc\"},\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.certificates.CertificateDeactivatePage; + import com.openai.models.admin.organization.projects.certificates.CertificateDeactivateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + CertificateDeactivateParams params = CertificateDeactivateParams.builder() + .projectId("project_id") + .addCertificateId("cert_abc") + .build(); + CertificateDeactivatePage page = client.admin().organization().projects().certificates().deactivate(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.projects.certificates.deactivate("project_id", certificate_ids: ["cert_abc"]) + + puts(page) + response: | + { + "object": "organization.project.certificate.deactivation", + "data": [ + { + "object": "organization.project.certificate", + "id": "cert_abc", + "name": "My Example Certificate", + "active": false, + "created_at": 1234567, + "certificate_details": { + "valid_at": 12345667, + "expires_at": 12345678 + } + }, + { + "object": "organization.project.certificate", + "id": "cert_def", + "name": "My Example Certificate 2", + "active": false, + "created_at": 1234567, + "certificate_details": { + "valid_at": 12345667, + "expires_at": 12345678 + } + }, + ], + } +components: + schemas: + ListCertificatesResponse: + type: object + properties: + data: + type: array + items: + $ref: '#/components/schemas/OrganizationCertificate' + first_id: + example: cert_abc + type: string + last_id: + example: cert_abc + type: string + has_more: + type: boolean + object: + type: string + enum: + - list + x-stainless-const: true + required: + - object + - data + - has_more + - first_id + - last_id + UploadCertificateRequest: + type: object + properties: + name: + type: string + description: An optional name for the certificate + certificate: + type: string + description: The certificate content in PEM format + required: + - certificate + Certificate: + type: object + description: Represents an individual `certificate` uploaded to the organization. + properties: + object: + type: string + enum: + - certificate + - organization.certificate + - organization.project.certificate + description: | + The object type. + + - If creating, updating, or getting a specific certificate, the object type is `certificate`. + - If listing, activating, or deactivating certificates for the organization, the object type is `organization.certificate`. + - If listing, activating, or deactivating certificates for a project, the object type is `organization.project.certificate`. + x-stainless-const: true + id: + type: string + description: The identifier, which can be referenced in API endpoints + name: + description: The name of the certificate. + type: string + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the certificate was uploaded. + certificate_details: + type: object + properties: + valid_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the certificate becomes valid. + expires_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the certificate expires. + content: + type: string + description: The content of the certificate in PEM format. + active: + type: boolean + description: Whether the certificate is currently active at the specified scope. Not returned when getting details for a specific certificate. + required: + - object + - id + - name + - created_at + - certificate_details + x-oaiMeta: + name: The certificate object + example: | + { + "object": "certificate", + "id": "cert_abc", + "name": "My Certificate", + "created_at": 1234567, + "certificate_details": { + "valid_at": 1234567, + "expires_at": 12345678, + "content": "-----BEGIN CERTIFICATE----- MIIGAjCCA...6znFlOW+ -----END CERTIFICATE-----" + } + } + ToggleCertificatesRequest: + type: object + properties: + certificate_ids: + type: array + items: + type: string + example: cert_abc + minItems: 1 + maxItems: 10 + required: + - certificate_ids + OrganizationCertificateActivationResponse: + type: object + properties: + object: + type: string + enum: + - organization.certificate.activation + description: The organization certificate activation result type. + x-stainless-const: true + data: + type: array + items: + $ref: '#/components/schemas/OrganizationCertificate' + required: + - object + - data + OrganizationCertificateDeactivationResponse: + type: object + properties: + object: + type: string + enum: + - organization.certificate.deactivation + description: The organization certificate deactivation result type. + x-stainless-const: true + data: + type: array + items: + $ref: '#/components/schemas/OrganizationCertificate' + required: + - object + - data + ModifyCertificateRequest: + type: object + properties: + name: + type: string + description: The updated name for the certificate + DeleteCertificateResponse: + type: object + properties: + object: + type: string + description: The object type, must be `certificate.deleted`. + enum: + - certificate.deleted + x-stainless-const: true + id: + type: string + description: The ID of the certificate that was deleted. + required: + - object + - id + ListProjectCertificatesResponse: + type: object + properties: + data: + type: array + items: + $ref: '#/components/schemas/OrganizationProjectCertificate' + first_id: + example: cert_abc + type: string + last_id: + example: cert_abc + type: string + has_more: + type: boolean + object: + type: string + enum: + - list + x-stainless-const: true + required: + - object + - data + - has_more + - first_id + - last_id + OrganizationProjectCertificateActivationResponse: + type: object + properties: + object: + type: string + enum: + - organization.project.certificate.activation + description: The project certificate activation result type. + x-stainless-const: true + data: + type: array + items: + $ref: '#/components/schemas/OrganizationProjectCertificate' + required: + - object + - data + OrganizationProjectCertificateDeactivationResponse: + type: object + properties: + object: + type: string + enum: + - organization.project.certificate.deactivation + description: The project certificate deactivation result type. + x-stainless-const: true + data: + type: array + items: + $ref: '#/components/schemas/OrganizationProjectCertificate' + required: + - object + - data + OrganizationCertificate: + type: object + description: Represents an individual certificate configured at the organization level. + properties: + object: + type: string + enum: + - organization.certificate + description: The object type, which is always `organization.certificate`. + x-stainless-const: true + id: + type: string + description: The identifier, which can be referenced in API endpoints + name: + description: The name of the certificate. + type: string + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the certificate was uploaded. + certificate_details: + type: object + properties: + valid_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the certificate becomes valid. + expires_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the certificate expires. + active: + type: boolean + description: Whether the certificate is currently active at the organization level. + required: + - object + - id + - name + - created_at + - certificate_details + - active + OrganizationProjectCertificate: + type: object + description: Represents an individual certificate configured at the project level. + properties: + object: + type: string + enum: + - organization.project.certificate + description: The object type, which is always `organization.project.certificate`. + x-stainless-const: true + id: + type: string + description: The identifier, which can be referenced in API endpoints + name: + description: The name of the certificate. + type: string + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the certificate was uploaded. + certificate_details: + type: object + properties: + valid_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the certificate becomes valid. + expires_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the certificate expires. + active: + type: boolean + description: Whether the certificate is currently active at the project level. + required: + - object + - id + - name + - created_at + - certificate_details + - active + x-stackQL-resources: + certificates: + id: openai_admin.certificates.certificates + name: certificates + title: Certificates + methods: + list: + operation: + $ref: '#/paths/~1organization~1certificates/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + upload: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1certificates/post' + response: + mediaType: application/json + openAPIDocKey: '200' + activate: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1certificates~1activate/post' + response: + mediaType: application/json + openAPIDocKey: '200' + deactivate: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1certificates~1deactivate/post' + response: + mediaType: application/json + openAPIDocKey: '200' + get: + operation: + $ref: '#/paths/~1organization~1certificates~1{certificate_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + update: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1certificates~1{certificate_id}/post' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1organization~1certificates~1{certificate_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/certificates/methods/get' + - $ref: '#/components/x-stackQL-resources/certificates/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/certificates/methods/upload' + update: + - $ref: '#/components/x-stackQL-resources/certificates/methods/update' + delete: + - $ref: '#/components/x-stackQL-resources/certificates/methods/delete' + replace: [] + project_certificates: + id: openai_admin.certificates.project_certificates + name: project_certificates + title: Project Certificates + methods: + list: + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1certificates/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + activate: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1certificates~1activate/post' + response: + mediaType: application/json + openAPIDocKey: '200' + deactivate: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1certificates~1deactivate/post' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/project_certificates/methods/list' + insert: [] + update: [] + delete: [] + replace: [] +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.last_id + location: body diff --git a/providers/src/openai_admin/v00.00.00000/services/costs.yaml b/providers/src/openai_admin/v00.00.00000/services/costs.yaml new file mode 100644 index 00000000..d626f5a0 --- /dev/null +++ b/providers/src/openai_admin/v00.00.00000/services/costs.yaml @@ -0,0 +1,644 @@ +openapi: 3.1.0 +info: + title: costs API + description: openai_admin API + version: 2.3.0 +paths: + /organization/costs: + get: + security: + - AdminApiKeyAuth: [] + summary: Get costs details for the organization. + operationId: usage-costs + tags: + - Costs + parameters: + - name: start_time + in: query + description: Start time (Unix seconds) of the query time range, inclusive. + required: true + schema: + type: integer + - name: end_time + in: query + description: End time (Unix seconds) of the query time range, exclusive. + required: false + schema: + type: integer + - name: bucket_width + in: query + description: Width of each time bucket in response. Currently only `1d` is supported, default to `1d`. + required: false + schema: + type: string + enum: + - 1d + default: 1d + - name: project_ids + in: query + description: Return only costs for these projects. + required: false + schema: + type: array + items: + type: string + - name: api_key_ids + in: query + description: Return only costs for these API keys. + required: false + schema: + type: array + items: + type: string + - name: group_by + in: query + description: Group the costs by the specified fields. Support fields include `project_id`, `line_item`, `api_key_id` and any combination of them. + required: false + schema: + type: array + items: + type: string + enum: + - project_id + - line_item + - api_key_id + - name: limit + in: query + description: | + A limit on the number of buckets to be returned. Limit can range between 1 and 180, and the default is 7. + required: false + schema: + type: integer + default: 7 + - name: page + in: query + description: A cursor for use in pagination. Corresponding to the `next_page` field from the previous response. + schema: + type: string + responses: + '200': + description: Costs data retrieved successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/UsageResponse' + x-oaiMeta: + name: Costs + group: usage-costs + examples: + request: + curl: | + curl "https://api.openai.com/v1/organization/costs?start_time=1730419200&limit=1" \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const response = await client.admin.organization.usage.costs({ start_time: 0 }); + + console.log(response.data); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + response = client.admin.organization.usage.costs( + start_time=0, + ) + print(response.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tresponse, err := client.Admin.Organization.Usage.Costs(context.TODO(), openai.AdminOrganizationUsageCostsParams{\n\t\tStartTime: 0,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.usage.UsageCostsParams; + import com.openai.models.admin.organization.usage.UsageCostsResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UsageCostsParams params = UsageCostsParams.builder() + .startTime(0L) + .build(); + UsageCostsResponse response = client.admin().organization().usage().costs(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + response = openai.admin.organization.usage.costs(start_time: 0) + + puts(response) + response: | + { + "object": "page", + "data": [ + { + "object": "bucket", + "start_time": 1730419200, + "end_time": 1730505600, + "results": [ + { + "object": "organization.costs.result", + "amount": { + "value": 0.06, + "currency": "usd" + }, + "line_item": null, + "project_id": null, + "api_key_id": null, + "quantity": null + } + ] + } + ], + "has_more": false, + "next_page": null + } +components: + schemas: + UsageResponse: + type: object + properties: + object: + type: string + enum: + - page + x-stainless-const: true + data: + type: array + items: + $ref: '#/components/schemas/UsageTimeBucket' + has_more: + type: boolean + next_page: + type: string + required: + - object + - data + - has_more + - next_page + UsageTimeBucket: + type: object + properties: + object: + type: string + enum: + - bucket + x-stainless-const: true + start_time: + type: integer + end_time: + type: integer + results: + type: array + items: + oneOf: + - $ref: '#/components/schemas/UsageCompletionsResult' + - $ref: '#/components/schemas/UsageEmbeddingsResult' + - $ref: '#/components/schemas/UsageModerationsResult' + - $ref: '#/components/schemas/UsageImagesResult' + - $ref: '#/components/schemas/UsageAudioSpeechesResult' + - $ref: '#/components/schemas/UsageAudioTranscriptionsResult' + - $ref: '#/components/schemas/UsageVectorStoresResult' + - $ref: '#/components/schemas/UsageCodeInterpreterSessionsResult' + - $ref: '#/components/schemas/CostsResult' + discriminator: + propertyName: object + required: + - object + - start_time + - end_time + - results + UsageCompletionsResult: + type: object + description: The aggregated completions usage details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.usage.completions.result + x-stainless-const: true + input_tokens: + type: integer + description: The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens. + input_cached_tokens: + type: integer + description: The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens. + output_tokens: + type: integer + description: The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens. + input_audio_tokens: + type: integer + description: The aggregated number of audio input tokens used, including cached tokens. + output_audio_tokens: + type: integer + description: The aggregated number of audio output tokens used. + num_model_requests: + type: integer + description: The count of requests made to the model. + project_id: + type: string + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + user_id: + type: string + description: When `group_by=user_id`, this field provides the user ID of the grouped usage result. + api_key_id: + type: string + description: When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + model: + type: string + description: When `group_by=model`, this field provides the model name of the grouped usage result. + batch: + type: boolean + description: When `group_by=batch`, this field tells whether the grouped usage result is batch or not. + service_tier: + type: string + description: When `group_by=service_tier`, this field provides the service tier of the grouped usage result. + required: + - object + - input_tokens + - output_tokens + - num_model_requests + x-oaiMeta: + name: Completions usage object + example: | + { + "object": "organization.usage.completions.result", + "input_tokens": 5000, + "output_tokens": 1000, + "input_cached_tokens": 4000, + "input_audio_tokens": 300, + "output_audio_tokens": 200, + "num_model_requests": 5, + "project_id": "proj_abc", + "user_id": "user-abc", + "api_key_id": "key_abc", + "model": "gpt-4o-mini-2024-07-18", + "batch": false, + "service_tier": "default" + } + UsageEmbeddingsResult: + type: object + description: The aggregated embeddings usage details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.usage.embeddings.result + x-stainless-const: true + input_tokens: + type: integer + description: The aggregated number of input tokens used. + num_model_requests: + type: integer + description: The count of requests made to the model. + project_id: + type: string + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + user_id: + type: string + description: When `group_by=user_id`, this field provides the user ID of the grouped usage result. + api_key_id: + type: string + description: When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + model: + type: string + description: When `group_by=model`, this field provides the model name of the grouped usage result. + required: + - object + - input_tokens + - num_model_requests + x-oaiMeta: + name: Embeddings usage object + example: | + { + "object": "organization.usage.embeddings.result", + "input_tokens": 20, + "num_model_requests": 2, + "project_id": "proj_abc", + "user_id": "user-abc", + "api_key_id": "key_abc", + "model": "text-embedding-ada-002-v2" + } + UsageModerationsResult: + type: object + description: The aggregated moderations usage details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.usage.moderations.result + x-stainless-const: true + input_tokens: + type: integer + description: The aggregated number of input tokens used. + num_model_requests: + type: integer + description: The count of requests made to the model. + project_id: + type: string + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + user_id: + type: string + description: When `group_by=user_id`, this field provides the user ID of the grouped usage result. + api_key_id: + type: string + description: When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + model: + type: string + description: When `group_by=model`, this field provides the model name of the grouped usage result. + required: + - object + - input_tokens + - num_model_requests + x-oaiMeta: + name: Moderations usage object + example: | + { + "object": "organization.usage.moderations.result", + "input_tokens": 20, + "num_model_requests": 2, + "project_id": "proj_abc", + "user_id": "user-abc", + "api_key_id": "key_abc", + "model": "text-moderation" + } + UsageImagesResult: + type: object + description: The aggregated images usage details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.usage.images.result + x-stainless-const: true + images: + type: integer + description: The number of images processed. + num_model_requests: + type: integer + description: The count of requests made to the model. + source: + type: string + description: When `group_by=source`, this field provides the source of the grouped usage result, possible values are `image.generation`, `image.edit`, `image.variation`. + size: + type: string + description: When `group_by=size`, this field provides the image size of the grouped usage result. + project_id: + type: string + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + user_id: + type: string + description: When `group_by=user_id`, this field provides the user ID of the grouped usage result. + api_key_id: + type: string + description: When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + model: + type: string + description: When `group_by=model`, this field provides the model name of the grouped usage result. + required: + - object + - images + - num_model_requests + x-oaiMeta: + name: Images usage object + example: | + { + "object": "organization.usage.images.result", + "images": 2, + "num_model_requests": 2, + "size": "1024x1024", + "source": "image.generation", + "project_id": "proj_abc", + "user_id": "user-abc", + "api_key_id": "key_abc", + "model": "dall-e-3" + } + UsageAudioSpeechesResult: + type: object + description: The aggregated audio speeches usage details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.usage.audio_speeches.result + x-stainless-const: true + characters: + type: integer + description: The number of characters processed. + num_model_requests: + type: integer + description: The count of requests made to the model. + project_id: + type: string + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + user_id: + type: string + description: When `group_by=user_id`, this field provides the user ID of the grouped usage result. + api_key_id: + type: string + description: When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + model: + type: string + description: When `group_by=model`, this field provides the model name of the grouped usage result. + required: + - object + - characters + - num_model_requests + x-oaiMeta: + name: Audio speeches usage object + example: | + { + "object": "organization.usage.audio_speeches.result", + "characters": 45, + "num_model_requests": 1, + "project_id": "proj_abc", + "user_id": "user-abc", + "api_key_id": "key_abc", + "model": "tts-1" + } + UsageAudioTranscriptionsResult: + type: object + description: The aggregated audio transcriptions usage details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.usage.audio_transcriptions.result + x-stainless-const: true + seconds: + type: integer + format: int64 + description: The number of seconds processed. + num_model_requests: + type: integer + description: The count of requests made to the model. + project_id: + type: string + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + user_id: + type: string + description: When `group_by=user_id`, this field provides the user ID of the grouped usage result. + api_key_id: + type: string + description: When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + model: + type: string + description: When `group_by=model`, this field provides the model name of the grouped usage result. + required: + - object + - seconds + - num_model_requests + x-oaiMeta: + name: Audio transcriptions usage object + example: | + { + "object": "organization.usage.audio_transcriptions.result", + "seconds": 10, + "num_model_requests": 1, + "project_id": "proj_abc", + "user_id": "user-abc", + "api_key_id": "key_abc", + "model": "tts-1" + } + UsageVectorStoresResult: + type: object + description: The aggregated vector stores usage details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.usage.vector_stores.result + x-stainless-const: true + usage_bytes: + type: integer + description: The vector stores usage in bytes. + project_id: + type: string + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + required: + - object + - usage_bytes + x-oaiMeta: + name: Vector stores usage object + example: | + { + "object": "organization.usage.vector_stores.result", + "usage_bytes": 1024, + "project_id": "proj_abc" + } + UsageCodeInterpreterSessionsResult: + type: object + description: The aggregated code interpreter sessions usage details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.usage.code_interpreter_sessions.result + x-stainless-const: true + num_sessions: + type: integer + description: The number of code interpreter sessions. + project_id: + type: string + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + required: + - object + - num_sessions + x-oaiMeta: + name: Code interpreter sessions usage object + example: | + { + "object": "organization.usage.code_interpreter_sessions.result", + "num_sessions": 1, + "project_id": "proj_abc" + } + CostsResult: + type: object + description: The aggregated costs details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.costs.result + x-stainless-const: true + amount: + type: object + description: The monetary value in its associated currency. + properties: + value: + type: number + description: The numeric value of the cost. + currency: + type: string + description: Lowercase ISO-4217 currency e.g. "usd" + line_item: + type: string + description: When `group_by=line_item`, this field provides the line item of the grouped costs result. + project_id: + type: string + description: When `group_by=project_id`, this field provides the project ID of the grouped costs result. + api_key_id: + type: string + description: When `group_by=api_key_id`, this field provides the API Key ID of the grouped costs result. + quantity: + type: number + description: When `group_by=line_item`, this field provides the quantity of the grouped costs result. + required: + - object + x-oaiMeta: + name: Costs object + example: | + { + "object": "organization.costs.result", + "amount": { + "value": 0.06, + "currency": "usd" + }, + "line_item": "Image models", + "project_id": "proj_abc", + "quantity": 10000 + } + x-stackQL-resources: + costs: + id: openai_admin.costs.costs + name: costs + title: Costs + methods: + list: + operation: + $ref: '#/paths/~1organization~1costs/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/costs/methods/list' + insert: [] + update: [] + delete: [] + replace: [] +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: page + location: query + responseToken: + key: $.next_page + location: body diff --git a/providers/src/openai_admin/v00.00.00000/services/groups.yaml b/providers/src/openai_admin/v00.00.00000/services/groups.yaml new file mode 100644 index 00000000..af05c00f --- /dev/null +++ b/providers/src/openai_admin/v00.00.00000/services/groups.yaml @@ -0,0 +1,1761 @@ +openapi: 3.1.0 +info: + title: groups API + description: openai_admin API + version: 2.3.0 +paths: + /organization/groups: + get: + security: + - AdminApiKeyAuth: [] + summary: Lists all groups in the organization. + operationId: list-groups + tags: + - Groups + parameters: + - name: limit + in: query + description: | + A limit on the number of groups to be returned. Limit can range between 0 and 1000, and the default is 100. + required: false + schema: + type: integer + minimum: 0 + maximum: 1000 + default: 100 + - name: after + in: query + description: | + A cursor for use in pagination. `after` is a group ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with group_abc, your subsequent call can include `after=group_abc` in order to fetch the next page of the list. + required: false + schema: + type: string + - name: order + in: query + description: Specifies the sort order of the returned groups. + required: false + schema: + type: string + enum: + - asc + - desc + default: asc + responses: + '200': + description: Groups listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/GroupListResource' + x-oaiMeta: + name: List groups + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/groups?limit=20&order=asc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const group of client.admin.organization.groups.list()) { + console.log(group.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.groups.list() + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Groups.List(context.TODO(), openai.AdminOrganizationGroupListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.groups.GroupListPage; + import com.openai.models.admin.organization.groups.GroupListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + GroupListPage page = client.admin().organization().groups().list(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.groups.list + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "object": "group", + "id": "group_01J1F8ABCDXYZ", + "name": "Support Team", + "created_at": 1711471533, + "is_scim_managed": false + } + ], + "has_more": false, + "next": null + } + post: + security: + - AdminApiKeyAuth: [] + summary: Creates a new group in the organization. + operationId: create-group + tags: + - Groups + requestBody: + description: Parameters for the group you want to create. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateGroupBody' + responses: + '200': + description: Group created successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/GroupResponse' + x-oaiMeta: + name: Create group + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/organization/groups \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "Support Team" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const group = await client.admin.organization.groups.create({ name: 'x' }); + + console.log(group.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + group = client.admin.organization.groups.create( + name="x", + ) + print(group.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tgroup, err := client.Admin.Organization.Groups.New(context.TODO(), openai.AdminOrganizationGroupNewParams{\n\t\tName: \"x\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", group.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.groups.Group; + import com.openai.models.admin.organization.groups.GroupCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + GroupCreateParams params = GroupCreateParams.builder() + .name("x") + .build(); + Group group = client.admin().organization().groups().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + group = openai.admin.organization.groups.create(name: "x") + + puts(group) + response: | + { + "object": "group", + "id": "group_01J1F8ABCDXYZ", + "name": "Support Team", + "created_at": 1711471533, + "is_scim_managed": false + } + /organization/groups/{group_id}: + post: + security: + - AdminApiKeyAuth: [] + summary: Updates a group's information. + operationId: update-group + tags: + - Groups + parameters: + - name: group_id + in: path + description: The ID of the group to update. + required: true + schema: + type: string + requestBody: + description: New attributes to set on the group. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateGroupBody' + responses: + '200': + description: Group updated successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/GroupResourceWithSuccess' + x-oaiMeta: + name: Update group + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/organization/groups/group_01J1F8ABCDXYZ \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "Escalations" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const group = await client.admin.organization.groups.update('group_id', { name: 'x' }); + + console.log(group.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + group = client.admin.organization.groups.update( + group_id="group_id", + name="x", + ) + print(group.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tgroup, err := client.Admin.Organization.Groups.Update(\n\t\tcontext.TODO(),\n\t\t\"group_id\",\n\t\topenai.AdminOrganizationGroupUpdateParams{\n\t\t\tName: \"x\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", group.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.groups.GroupUpdateParams; + import com.openai.models.admin.organization.groups.GroupUpdateResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + GroupUpdateParams params = GroupUpdateParams.builder() + .groupId("group_id") + .name("x") + .build(); + GroupUpdateResponse group = client.admin().organization().groups().update(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + group = openai.admin.organization.groups.update("group_id", name: "x") + + puts(group) + response: | + { + "id": "group_01J1F8ABCDXYZ", + "name": "Escalations", + "created_at": 1711471533, + "is_scim_managed": false + } + delete: + security: + - AdminApiKeyAuth: [] + summary: Deletes a group from the organization. + operationId: delete-group + tags: + - Groups + parameters: + - name: group_id + in: path + description: The ID of the group to delete. + required: true + schema: + type: string + responses: + '200': + description: Group deleted successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/GroupDeletedResource' + x-oaiMeta: + name: Delete group + group: administration + examples: + request: + curl: | + curl -X DELETE https://api.openai.com/v1/organization/groups/group_01J1F8ABCDXYZ \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const group = await client.admin.organization.groups.delete('group_id'); + + console.log(group.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + group = client.admin.organization.groups.delete( + "group_id", + ) + print(group.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tgroup, err := client.Admin.Organization.Groups.Delete(context.TODO(), \"group_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", group.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.groups.GroupDeleteParams; + import com.openai.models.admin.organization.groups.GroupDeleteResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + GroupDeleteResponse group = client.admin().organization().groups().delete("group_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + group = openai.admin.organization.groups.delete("group_id") + + puts(group) + response: | + { + "object": "group.deleted", + "id": "group_01J1F8ABCDXYZ", + "deleted": true + } + /organization/groups/{group_id}/roles: + get: + security: + - AdminApiKeyAuth: [] + summary: Lists the organization roles assigned to a group within the organization. + operationId: list-group-role-assignments + tags: + - Group organization role assignments + parameters: + - name: group_id + in: path + description: The ID of the group whose organization role assignments you want to list. + required: true + schema: + type: string + - name: limit + in: query + description: A limit on the number of organization role assignments to return. + required: false + schema: + type: integer + minimum: 0 + maximum: 1000 + - name: after + in: query + description: Cursor for pagination. Provide the value from the previous response's `next` field to continue listing organization roles. + required: false + schema: + type: string + - name: order + in: query + description: Sort order for the returned organization roles. + required: false + schema: + type: string + enum: + - asc + - desc + responses: + '200': + description: Group organization role assignments listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/RoleListResource' + x-oaiMeta: + name: List group organization role assignments + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/groups/group_01J1F8ABCDXYZ/roles \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const roleListResponse of client.admin.organization.groups.roles.list('group_id')) { + console.log(roleListResponse.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.groups.roles.list( + group_id="group_id", + ) + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Groups.Roles.List(\n\t\tcontext.TODO(),\n\t\t\"group_id\",\n\t\topenai.AdminOrganizationGroupRoleListParams{},\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.groups.roles.RoleListPage; + import com.openai.models.admin.organization.groups.roles.RoleListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RoleListPage page = client.admin().organization().groups().roles().list("group_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.groups.roles.list("group_id") + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "id": "role_01J1F8ROLE01", + "name": "API Group Manager", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "resource_type": "api.organization", + "predefined_role": false, + "description": "Allows managing organization groups", + "created_at": 1711471533, + "updated_at": 1711472599, + "created_by": "user_abc123", + "created_by_user_obj": { + "id": "user_abc123", + "name": "Ada Lovelace", + "email": "ada@example.com" + }, + "metadata": {} + } + ], + "has_more": false, + "next": null + } + post: + security: + - AdminApiKeyAuth: [] + summary: Assigns an organization role to a group within the organization. + operationId: assign-group-role + tags: + - Group organization role assignments + parameters: + - name: group_id + in: path + description: The ID of the group that should receive the organization role. + required: true + schema: + type: string + requestBody: + description: Identifies the organization role to assign to the group. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PublicAssignOrganizationGroupRoleBody' + responses: + '200': + description: Organization role assigned to the group successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/GroupRoleAssignment' + x-oaiMeta: + name: Assign organization role to group + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/organization/groups/group_01J1F8ABCDXYZ/roles \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "role_id": "role_01J1F8ROLE01" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const role = await client.admin.organization.groups.roles.create('group_id', { + role_id: 'role_id', + }); + + console.log(role.group); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + role = client.admin.organization.groups.roles.create( + group_id="group_id", + role_id="role_id", + ) + print(role.group) + 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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\trole, err := client.Admin.Organization.Groups.Roles.New(\n\t\tcontext.TODO(),\n\t\t\"group_id\",\n\t\topenai.AdminOrganizationGroupRoleNewParams{\n\t\t\tRoleID: \"role_id\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", role.Group)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.groups.roles.RoleCreateParams; + import com.openai.models.admin.organization.groups.roles.RoleCreateResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RoleCreateParams params = RoleCreateParams.builder() + .groupId("group_id") + .roleId("role_id") + .build(); + RoleCreateResponse role = client.admin().organization().groups().roles().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + role = openai.admin.organization.groups.roles.create("group_id", role_id: "role_id") + + puts(role) + response: | + { + "object": "group.role", + "group": { + "object": "group", + "id": "group_01J1F8ABCDXYZ", + "name": "Support Team", + "created_at": 1711471533, + "scim_managed": false + }, + "role": { + "object": "role", + "id": "role_01J1F8ROLE01", + "name": "API Group Manager", + "description": "Allows managing organization groups", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "resource_type": "api.organization", + "predefined_role": false + } + } + /organization/groups/{group_id}/roles/{role_id}: + delete: + security: + - AdminApiKeyAuth: [] + summary: Unassigns an organization role from a group within the organization. + operationId: unassign-group-role + tags: + - Group organization role assignments + parameters: + - name: group_id + in: path + description: The ID of the group to modify. + required: true + schema: + type: string + - name: role_id + in: path + description: The ID of the organization role to remove from the group. + required: true + schema: + type: string + responses: + '200': + description: Organization role unassigned from the group successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/DeletedRoleAssignmentResource' + x-oaiMeta: + name: Unassign organization role from group + group: administration + examples: + request: + curl: | + curl -X DELETE https://api.openai.com/v1/organization/groups/group_01J1F8ABCDXYZ/roles/role_01J1F8ROLE01 \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const role = await client.admin.organization.groups.roles.delete('role_id', { + group_id: 'group_id', + }); + + console.log(role.deleted); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + role = client.admin.organization.groups.roles.delete( + role_id="role_id", + group_id="group_id", + ) + print(role.deleted) + 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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\trole, err := client.Admin.Organization.Groups.Roles.Delete(\n\t\tcontext.TODO(),\n\t\t\"group_id\",\n\t\t\"role_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", role.Deleted)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.groups.roles.RoleDeleteParams; + import com.openai.models.admin.organization.groups.roles.RoleDeleteResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RoleDeleteParams params = RoleDeleteParams.builder() + .groupId("group_id") + .roleId("role_id") + .build(); + RoleDeleteResponse role = client.admin().organization().groups().roles().delete(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + role = openai.admin.organization.groups.roles.delete("role_id", group_id: "group_id") + + puts(role) + response: | + { + "object": "group.role.deleted", + "deleted": true + } + /organization/groups/{group_id}/users: + get: + security: + - AdminApiKeyAuth: [] + summary: Lists the users assigned to a group. + operationId: list-group-users + tags: + - Group users + parameters: + - name: group_id + in: path + description: The ID of the group to inspect. + required: true + schema: + type: string + - name: limit + in: query + description: | + A limit on the number of users to be returned. Limit can range between 0 and 1000, and the default is 100. + required: false + schema: + type: integer + minimum: 0 + maximum: 1000 + default: 100 + - name: after + in: query + description: | + A cursor for use in pagination. Provide the ID of the last user from the previous list response to retrieve the next page. + required: false + schema: + type: string + - name: order + in: query + description: Specifies the sort order of users in the list. + required: false + schema: + type: string + enum: + - asc + - desc + default: desc + responses: + '200': + description: Group users listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/UserListResource' + x-oaiMeta: + name: List group users + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/groups/group_01J1F8ABCDXYZ/users?limit=20 \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const organizationGroupUser of client.admin.organization.groups.users.list('group_id')) { + console.log(organizationGroupUser.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.groups.users.list( + group_id="group_id", + ) + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Groups.Users.List(\n\t\tcontext.TODO(),\n\t\t\"group_id\",\n\t\topenai.AdminOrganizationGroupUserListParams{},\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.groups.users.UserListPage; + import com.openai.models.admin.organization.groups.users.UserListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UserListPage page = client.admin().organization().groups().users().list("group_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.groups.users.list("group_id") + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "id": "user_abc123", + "name": "Ada Lovelace", + "email": "ada@example.com" + } + ], + "has_more": false, + "next": null + } + post: + security: + - AdminApiKeyAuth: [] + summary: Adds a user to a group. + operationId: add-group-user + tags: + - Group users + parameters: + - name: group_id + in: path + description: The ID of the group to update. + required: true + schema: + type: string + requestBody: + description: Identifies the user that should be added to the group. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateGroupUserBody' + responses: + '200': + description: User added to the group successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/GroupUserAssignment' + x-oaiMeta: + name: Add group user + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/organization/groups/group_01J1F8ABCDXYZ/users \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "user_id": "user_abc123" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const user = await client.admin.organization.groups.users.create('group_id', { + user_id: 'user_id', + }); + + console.log(user.group_id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + user = client.admin.organization.groups.users.create( + group_id="group_id", + user_id="user_id", + ) + print(user.group_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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tuser, err := client.Admin.Organization.Groups.Users.New(\n\t\tcontext.TODO(),\n\t\t\"group_id\",\n\t\topenai.AdminOrganizationGroupUserNewParams{\n\t\t\tUserID: \"user_id\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", user.GroupID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.groups.users.UserCreateParams; + import com.openai.models.admin.organization.groups.users.UserCreateResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UserCreateParams params = UserCreateParams.builder() + .groupId("group_id") + .userId("user_id") + .build(); + UserCreateResponse user = client.admin().organization().groups().users().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + user = openai.admin.organization.groups.users.create("group_id", user_id: "user_id") + + puts(user) + response: | + { + "object": "group.user", + "user_id": "user_abc123", + "group_id": "group_01J1F8ABCDXYZ" + } + /organization/groups/{group_id}/users/{user_id}: + delete: + security: + - AdminApiKeyAuth: [] + summary: Removes a user from a group. + operationId: remove-group-user + tags: + - Group users + parameters: + - name: group_id + in: path + description: The ID of the group to update. + required: true + schema: + type: string + - name: user_id + in: path + description: The ID of the user to remove from the group. + required: true + schema: + type: string + responses: + '200': + description: User removed from the group successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/GroupUserDeletedResource' + x-oaiMeta: + name: Remove group user + group: administration + examples: + request: + curl: | + curl -X DELETE https://api.openai.com/v1/organization/groups/group_01J1F8ABCDXYZ/users/user_abc123 \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const user = await client.admin.organization.groups.users.delete('user_id', { + group_id: 'group_id', + }); + + console.log(user.deleted); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + user = client.admin.organization.groups.users.delete( + user_id="user_id", + group_id="group_id", + ) + print(user.deleted) + 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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tuser, err := client.Admin.Organization.Groups.Users.Delete(\n\t\tcontext.TODO(),\n\t\t\"group_id\",\n\t\t\"user_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", user.Deleted)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.groups.users.UserDeleteParams; + import com.openai.models.admin.organization.groups.users.UserDeleteResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UserDeleteParams params = UserDeleteParams.builder() + .groupId("group_id") + .userId("user_id") + .build(); + UserDeleteResponse user = client.admin().organization().groups().users().delete(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + user = openai.admin.organization.groups.users.delete("user_id", group_id: "group_id") + + puts(user) + response: | + { + "object": "group.user.deleted", + "deleted": true + } +components: + schemas: + GroupListResource: + type: object + description: Paginated list of organization groups. + properties: + object: + type: string + enum: + - list + description: Always `list`. + x-stainless-const: true + data: + type: array + description: Groups returned in the current page. + items: + $ref: '#/components/schemas/GroupResponse' + has_more: + type: boolean + description: Whether additional groups are available when paginating. + next: + description: Cursor to fetch the next page of results, or `null` if there are no more results. + type: string + required: + - object + - data + - has_more + - next + x-oaiMeta: + name: Group list + example: | + { + "object": "list", + "data": [ + { + "id": "group_01J1F8ABCDXYZ", + "name": "Support Team", + "created_at": 1711471533, + "is_scim_managed": false + }, + { + "id": "group_01J1F8PQRMNO", + "name": "Sales", + "created_at": 1711472599, + "is_scim_managed": true + } + ], + "has_more": false, + "next": null + } + CreateGroupBody: + type: object + description: Request payload for creating a new group in the organization. + properties: + name: + type: string + description: Human readable name for the group. + minLength: 1 + maxLength: 255 + required: + - name + x-oaiMeta: + example: | + { + "name": "Support Team" + } + GroupResponse: + type: object + description: Details about an organization group. + properties: + id: + type: string + description: Identifier for the group. + name: + type: string + description: Display name of the group. + created_at: + type: integer + format: unixtime + description: Unix timestamp (in seconds) when the group was created. + is_scim_managed: + type: boolean + description: Whether the group is managed through SCIM and controlled by your identity provider. + group_type: + type: string + description: The type of the group. + required: + - id + - name + - created_at + - is_scim_managed + - group_type + x-oaiMeta: + name: Group + example: | + { + "id": "group_01J1F8ABCDXYZ", + "name": "Support Team", + "created_at": 1711471533, + "is_scim_managed": false, + "group_type": "group" + } + UpdateGroupBody: + type: object + description: Request payload for updating the details of an existing group. + properties: + name: + type: string + description: New display name for the group. + minLength: 1 + maxLength: 255 + required: + - name + x-oaiMeta: + example: | + { + "name": "Escalations" + } + GroupResourceWithSuccess: + type: object + description: Response returned after updating a group. + properties: + id: + type: string + description: Identifier for the group. + name: + type: string + description: Updated display name for the group. + created_at: + type: integer + format: unixtime + description: Unix timestamp (in seconds) when the group was created. + is_scim_managed: + type: boolean + description: Whether the group is managed through SCIM and controlled by your identity provider. + required: + - id + - name + - created_at + - is_scim_managed + x-oaiMeta: + example: | + { + "id": "group_01J1F8ABCDXYZ", + "name": "Escalations", + "created_at": 1711471533, + "is_scim_managed": false + } + GroupDeletedResource: + type: object + description: Confirmation payload returned after deleting a group. + properties: + object: + type: string + enum: + - group.deleted + description: Always `group.deleted`. + x-stainless-const: true + id: + type: string + description: Identifier of the deleted group. + deleted: + type: boolean + description: Whether the group was deleted. + required: + - object + - id + - deleted + x-oaiMeta: + example: | + { + "object": "group.deleted", + "id": "group_01J1F8ABCDXYZ", + "deleted": true + } + RoleListResource: + type: object + description: Paginated list of roles assigned to a principal. + properties: + object: + type: string + enum: + - list + description: Always `list`. + x-stainless-const: true + data: + type: array + description: Role assignments returned in the current page. + items: + $ref: '#/components/schemas/AssignedRoleDetails' + has_more: + type: boolean + description: Whether additional assignments are available when paginating. + next: + description: Cursor to fetch the next page of results, or `null` when there are no more assignments. + type: string + required: + - object + - data + - has_more + - next + x-oaiMeta: + name: Assigned role list + example: | + { + "object": "list", + "data": [ + { + "id": "role_01J1F8ROLE01", + "name": "API Group Manager", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "resource_type": "api.organization", + "predefined_role": false, + "description": "Allows managing organization groups", + "created_at": 1711471533, + "updated_at": 1711472599, + "created_by": "user_abc123", + "created_by_user_obj": { + "id": "user_abc123", + "name": "Ada Lovelace", + "email": "ada@example.com" + }, + "metadata": {} + } + ], + "has_more": false, + "next": null + } + PublicAssignOrganizationGroupRoleBody: + type: object + description: Request payload for assigning a role to a group or user. + properties: + role_id: + type: string + description: Identifier of the role to assign. + required: + - role_id + x-oaiMeta: + example: | + { + "role_id": "role_01J1F8ROLE01" + } + GroupRoleAssignment: + type: object + description: Role assignment linking a group to a role. + properties: + object: + type: string + enum: + - group.role + description: Always `group.role`. + x-stainless-const: true + group: + $ref: '#/components/schemas/Group' + role: + $ref: '#/components/schemas/Role' + required: + - object + - group + - role + x-oaiMeta: + name: The group role object + example: | + { + "object": "group.role", + "group": { + "object": "group", + "id": "group_01J1F8ABCDXYZ", + "name": "Support Team", + "created_at": 1711471533, + "scim_managed": false + }, + "role": { + "object": "role", + "id": "role_01J1F8ROLE01", + "name": "API Group Manager", + "description": "Allows managing organization groups", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "resource_type": "api.organization", + "predefined_role": false + } + } + DeletedRoleAssignmentResource: + type: object + description: Confirmation payload returned after unassigning a role. + properties: + object: + type: string + description: Identifier for the deleted assignment, such as `group.role.deleted` or `user.role.deleted`. + deleted: + type: boolean + description: Whether the assignment was removed. + required: + - object + - deleted + x-oaiMeta: + name: Role assignment deletion confirmation + example: | + { + "object": "group.role.deleted", + "deleted": true + } + UserListResource: + type: object + description: Paginated list of user objects returned when inspecting group membership. + properties: + object: + type: string + enum: + - list + description: Always `list`. + x-stainless-const: true + data: + type: array + description: Users in the current page. + items: + $ref: '#/components/schemas/GroupUser' + has_more: + type: boolean + description: Whether more users are available when paginating. + next: + description: Cursor to fetch the next page of results, or `null` when no further users are available. + type: string + required: + - object + - data + - has_more + - next + x-oaiMeta: + name: Group user list + example: | + { + "object": "list", + "data": [ + { + "id": "user_abc123", + "name": "Ada Lovelace", + "email": "ada@example.com" + } + ], + "has_more": false, + "next": null + } + CreateGroupUserBody: + type: object + description: Request payload for adding a user to a group. + properties: + user_id: + type: string + description: Identifier of the user to add to the group. + required: + - user_id + x-oaiMeta: + example: | + { + "user_id": "user_abc123" + } + GroupUserAssignment: + type: object + description: Confirmation payload returned after adding a user to a group. + properties: + object: + type: string + enum: + - group.user + description: Always `group.user`. + x-stainless-const: true + user_id: + type: string + description: Identifier of the user that was added. + group_id: + type: string + description: Identifier of the group the user was added to. + required: + - object + - user_id + - group_id + x-oaiMeta: + name: The group user object + example: | + { + "object": "group.user", + "user_id": "user_abc123", + "group_id": "group_01J1F8ABCDXYZ" + } + GroupUserDeletedResource: + type: object + description: Confirmation payload returned after removing a user from a group. + properties: + object: + type: string + enum: + - group.user.deleted + description: Always `group.user.deleted`. + x-stainless-const: true + deleted: + type: boolean + description: Whether the group membership was removed. + required: + - object + - deleted + x-oaiMeta: + name: Group user deletion confirmation + example: | + { + "object": "group.user.deleted", + "deleted": true + } + AssignedRoleDetails: + type: object + description: Detailed information about a role assignment entry returned when listing assignments. + properties: + id: + type: string + description: Identifier for the role. + name: + type: string + description: Name of the role. + permissions: + type: array + description: Permissions associated with the role. + items: + type: string + resource_type: + type: string + description: Resource type the role applies to. + predefined_role: + type: boolean + description: Whether the role is predefined by OpenAI. + description: + description: Description of the role. + type: string + created_at: + description: When the role was created. + type: integer + format: unixtime + updated_at: + description: When the role was last updated. + type: integer + format: int64 + created_by: + description: Identifier of the actor who created the role. + type: string + created_by_user_obj: + description: User details for the actor that created the role, when available. + type: object + additionalProperties: true + metadata: + description: Arbitrary metadata stored on the role. + type: object + additionalProperties: true + required: + - id + - name + - permissions + - resource_type + - predefined_role + - description + - created_at + - updated_at + - created_by + - created_by_user_obj + - metadata + Group: + type: object + description: Summary information about a group returned in role assignment responses. + properties: + object: + type: string + enum: + - group + description: Always `group`. + x-stainless-const: true + id: + type: string + description: Identifier for the group. + name: + type: string + description: Display name of the group. + created_at: + type: integer + format: unixtime + description: Unix timestamp (in seconds) when the group was created. + scim_managed: + type: boolean + description: Whether the group is managed through SCIM. + required: + - object + - id + - name + - created_at + - scim_managed + x-oaiMeta: + name: The group object + example: | + { + "object": "group", + "id": "group_01J1F8ABCDXYZ", + "name": "Support Team", + "created_at": 1711471533, + "scim_managed": false + } + Role: + type: object + description: Details about a role that can be assigned through the public Roles API. + properties: + object: + type: string + enum: + - role + description: Always `role`. + x-stainless-const: true + id: + type: string + description: Identifier for the role. + name: + type: string + description: Unique name for the role. + description: + description: Optional description of the role. + type: string + permissions: + type: array + description: Permissions granted by the role. + items: + type: string + resource_type: + type: string + description: Resource type the role is bound to (for example `api.organization` or `api.project`). + predefined_role: + type: boolean + description: Whether the role is predefined and managed by OpenAI. + required: + - object + - id + - name + - description + - permissions + - resource_type + - predefined_role + x-oaiMeta: + name: The role object + example: | + { + "object": "role", + "id": "role_01J1F8ROLE01", + "name": "API Group Manager", + "description": "Allows managing organization groups", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "resource_type": "api.organization", + "predefined_role": false + } + GroupUser: + type: object + description: Represents an individual user returned when inspecting group membership. + properties: + id: + type: string + description: The identifier, which can be referenced in API endpoints + name: + type: string + description: The name of the user. + email: + description: The email address of the user. + type: string + required: + - id + - name + - email + x-stackQL-resources: + groups: + id: openai_admin.groups.groups + name: groups + title: Groups + methods: + list: + operation: + $ref: '#/paths/~1organization~1groups/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1groups/post' + response: + mediaType: application/json + openAPIDocKey: '200' + update: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1groups~1{group_id}/post' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1organization~1groups~1{group_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/groups/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/groups/methods/create' + update: + - $ref: '#/components/x-stackQL-resources/groups/methods/update' + delete: + - $ref: '#/components/x-stackQL-resources/groups/methods/delete' + replace: [] + role_assignments: + id: openai_admin.groups.role_assignments + name: role_assignments + title: Role Assignments + methods: + list: + operation: + $ref: '#/paths/~1organization~1groups~1{group_id}~1roles/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + assign: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1groups~1{group_id}~1roles/post' + response: + mediaType: application/json + openAPIDocKey: '200' + unassign: + operation: + $ref: '#/paths/~1organization~1groups~1{group_id}~1roles~1{role_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/role_assignments/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/role_assignments/methods/assign' + update: [] + delete: + - $ref: '#/components/x-stackQL-resources/role_assignments/methods/unassign' + replace: [] + users: + id: openai_admin.groups.users + name: users + title: Users + methods: + list: + operation: + $ref: '#/paths/~1organization~1groups~1{group_id}~1users/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + add: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1groups~1{group_id}~1users/post' + response: + mediaType: application/json + openAPIDocKey: '200' + remove: + operation: + $ref: '#/paths/~1organization~1groups~1{group_id}~1users~1{user_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/users/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/users/methods/add' + update: [] + delete: + - $ref: '#/components/x-stackQL-resources/users/methods/remove' + replace: [] +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.next + location: body diff --git a/providers/src/openai_admin/v00.00.00000/services/invites.yaml b/providers/src/openai_admin/v00.00.00000/services/invites.yaml new file mode 100644 index 00000000..72d79746 --- /dev/null +++ b/providers/src/openai_admin/v00.00.00000/services/invites.yaml @@ -0,0 +1,619 @@ +openapi: 3.1.0 +info: + title: invites API + description: openai_admin API + version: 2.3.0 +paths: + /organization/invites: + get: + security: + - AdminApiKeyAuth: [] + summary: Returns a list of invites in the organization. + operationId: list-invites + tags: + - Invites + parameters: + - name: limit + in: query + description: | + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + required: false + schema: + type: integer + default: 20 + - name: after + in: query + 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. + required: false + schema: + type: string + responses: + '200': + description: Invites listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/InviteListResponse' + x-oaiMeta: + name: List invites + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/invites?after=invite-abc&limit=20 \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const invite of client.admin.organization.invites.list()) { + console.log(invite.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.invites.list() + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Invites.List(context.TODO(), openai.AdminOrganizationInviteListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.invites.InviteListPage; + import com.openai.models.admin.organization.invites.InviteListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + InviteListPage page = client.admin().organization().invites().list(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.invites.list + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "object": "organization.invite", + "id": "invite-abc", + "email": "user@example.com", + "role": "owner", + "status": "accepted", + "created_at": 1711471533, + "expires_at": 1711471533, + "accepted_at": 1711471533 + } + ], + "first_id": "invite-abc", + "last_id": "invite-abc", + "has_more": false + } + post: + security: + - AdminApiKeyAuth: [] + summary: Create an invite for a user to the organization. The invite must be accepted by the user before they have access to the organization. + operationId: inviteUser + tags: + - Invites + requestBody: + description: The invite request payload. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/InviteRequest' + responses: + '200': + description: User invited successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/Invite' + x-oaiMeta: + name: Create invite + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/organization/invites \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "email": "anotheruser@example.com", + "role": "reader", + "projects": [ + { + "id": "project-xyz", + "role": "member" + }, + { + "id": "project-abc", + "role": "owner" + } + ] + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const invite = await client.admin.organization.invites.create({ email: 'email', role: 'reader' }); + + console.log(invite.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + invite = client.admin.organization.invites.create( + email="email", + role="reader", + ) + print(invite.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tinvite, err := client.Admin.Organization.Invites.New(context.TODO(), openai.AdminOrganizationInviteNewParams{\n\t\tEmail: \"email\",\n\t\tRole: openai.AdminOrganizationInviteNewParamsRoleReader,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", invite.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.invites.Invite; + import com.openai.models.admin.organization.invites.InviteCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + InviteCreateParams params = InviteCreateParams.builder() + .email("email") + .role(InviteCreateParams.Role.READER) + .build(); + Invite invite = client.admin().organization().invites().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + invite = openai.admin.organization.invites.create(email: "email", role: :reader) + + puts(invite) + response: | + { + "object": "organization.invite", + "id": "invite-def", + "email": "anotheruser@example.com", + "role": "reader", + "status": "pending", + "created_at": 1711471533, + "expires_at": 1711471533, + "accepted_at": null, + "projects": [ + { + "id": "project-xyz", + "role": "member" + }, + { + "id": "project-abc", + "role": "owner" + } + ] + } + /organization/invites/{invite_id}: + get: + security: + - AdminApiKeyAuth: [] + summary: Retrieves an invite. + operationId: retrieve-invite + tags: + - Invites + parameters: + - in: path + name: invite_id + required: true + schema: + type: string + description: The ID of the invite to retrieve. + responses: + '200': + description: Invite retrieved successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/Invite' + x-oaiMeta: + name: Retrieve invite + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/invites/invite-abc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const invite = await client.admin.organization.invites.retrieve('invite_id'); + + console.log(invite.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + invite = client.admin.organization.invites.retrieve( + "invite_id", + ) + print(invite.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tinvite, err := client.Admin.Organization.Invites.Get(context.TODO(), \"invite_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", invite.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.invites.Invite; + import com.openai.models.admin.organization.invites.InviteRetrieveParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Invite invite = client.admin().organization().invites().retrieve("invite_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + invite = openai.admin.organization.invites.retrieve("invite_id") + + puts(invite) + response: | + { + "object": "organization.invite", + "id": "invite-abc", + "email": "user@example.com", + "role": "owner", + "status": "accepted", + "created_at": 1711471533, + "expires_at": 1711471533, + "accepted_at": 1711471533 + } + delete: + security: + - AdminApiKeyAuth: [] + summary: Delete an invite. If the invite has already been accepted, it cannot be deleted. + operationId: delete-invite + tags: + - Invites + parameters: + - in: path + name: invite_id + required: true + schema: + type: string + description: The ID of the invite to delete. + responses: + '200': + description: Invite deleted successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/InviteDeleteResponse' + x-oaiMeta: + name: Delete invite + group: administration + examples: + request: + curl: | + curl -X DELETE https://api.openai.com/v1/organization/invites/invite-abc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const invite = await client.admin.organization.invites.delete('invite_id'); + + console.log(invite.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + invite = client.admin.organization.invites.delete( + "invite_id", + ) + print(invite.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tinvite, err := client.Admin.Organization.Invites.Delete(context.TODO(), \"invite_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", invite.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.invites.InviteDeleteParams; + import com.openai.models.admin.organization.invites.InviteDeleteResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + InviteDeleteResponse invite = client.admin().organization().invites().delete("invite_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + invite = openai.admin.organization.invites.delete("invite_id") + + puts(invite) + response: | + { + "object": "organization.invite.deleted", + "id": "invite-abc", + "deleted": true + } +components: + schemas: + InviteListResponse: + type: object + properties: + object: + type: string + enum: + - list + description: The object type, which is always `list` + x-stainless-const: true + data: + type: array + items: + $ref: '#/components/schemas/Invite' + first_id: + description: The first `invite_id` in the retrieved `list` + type: string + last_id: + description: The last `invite_id` in the retrieved `list` + type: string + has_more: + type: boolean + description: The `has_more` property is used for pagination to indicate there are additional results. + required: + - object + - data + - has_more + InviteRequest: + type: object + properties: + email: + type: string + description: Send an email to this address + role: + type: string + enum: + - reader + - owner + description: '`owner` or `reader`' + projects: + type: array + description: An array of projects to which membership is granted at the same time the org invite is accepted. If omitted, the user will be invited to the default project for compatibility with legacy behavior. + items: + type: object + properties: + id: + type: string + description: Project's public ID + role: + type: string + enum: + - member + - owner + description: Project membership role + required: + - id + - role + required: + - email + - role + Invite: + type: object + description: Represents an individual `invite` to the organization. + properties: + object: + type: string + enum: + - organization.invite + description: The object type, which is always `organization.invite` + x-stainless-const: true + id: + type: string + description: The identifier, which can be referenced in API endpoints + email: + type: string + description: The email address of the individual to whom the invite was sent + role: + type: string + enum: + - owner + - reader + description: '`owner` or `reader`' + status: + type: string + enum: + - accepted + - expired + - pending + description: '`accepted`,`expired`, or `pending`' + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the invite was sent. + expires_at: + description: The Unix timestamp (in seconds) of when the invite expires. + type: integer + format: unixtime + accepted_at: + description: The Unix timestamp (in seconds) of when the invite was accepted. + type: integer + format: unixtime + projects: + type: array + description: The projects that were granted membership upon acceptance of the invite. + items: + type: object + properties: + id: + type: string + description: Project's public ID + role: + type: string + enum: + - member + - owner + description: Project membership role + required: + - id + - role + required: + - object + - id + - email + - role + - status + - created_at + - projects + x-oaiMeta: + name: The invite object + example: | + { + "object": "organization.invite", + "id": "invite-abc", + "email": "user@example.com", + "role": "owner", + "status": "accepted", + "created_at": 1711471533, + "expires_at": 1711471533, + "accepted_at": 1711471533, + "projects": [ + { + "id": "project-xyz", + "role": "member" + } + ] + } + InviteDeleteResponse: + type: object + properties: + object: + type: string + enum: + - organization.invite.deleted + description: The object type, which is always `organization.invite.deleted` + x-stainless-const: true + id: + type: string + deleted: + type: boolean + required: + - object + - id + - deleted + x-stackQL-resources: + invites: + id: openai_admin.invites.invites + name: invites + title: Invites + methods: + list: + operation: + $ref: '#/paths/~1organization~1invites/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1invites/post' + response: + mediaType: application/json + openAPIDocKey: '200' + get: + operation: + $ref: '#/paths/~1organization~1invites~1{invite_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1organization~1invites~1{invite_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/invites/methods/get' + - $ref: '#/components/x-stackQL-resources/invites/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/invites/methods/create' + update: [] + delete: + - $ref: '#/components/x-stackQL-resources/invites/methods/delete' + replace: [] +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.last_id + location: body diff --git a/providers/src/openai_admin/v00.00.00000/services/projects.yaml b/providers/src/openai_admin/v00.00.00000/services/projects.yaml new file mode 100644 index 00000000..06200b29 --- /dev/null +++ b/providers/src/openai_admin/v00.00.00000/services/projects.yaml @@ -0,0 +1,4727 @@ +openapi: 3.1.0 +info: + title: projects API + description: openai_admin API + version: 2.3.0 +paths: + /organization/projects: + get: + summary: Returns a list of projects. + operationId: list-projects + security: + - AdminApiKeyAuth: [] + tags: + - Projects + parameters: + - name: limit + in: query + description: | + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + required: false + schema: + type: integer + default: 20 + - name: after + in: query + 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. + required: false + schema: + type: string + - name: include_archived + in: query + schema: + type: boolean + default: false + description: If `true` returns all projects including those that have been `archived`. Archived projects are not included by default. + responses: + '200': + description: Projects listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectListResponse' + x-oaiMeta: + name: List projects + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/projects?after=proj_abc&limit=20&include_archived=false \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const project of client.admin.organization.projects.list()) { + console.log(project.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.projects.list() + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Projects.List(context.TODO(), openai.AdminOrganizationProjectListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.ProjectListPage; + import com.openai.models.admin.organization.projects.ProjectListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ProjectListPage page = client.admin().organization().projects().list(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.projects.list + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "id": "proj_abc", + "object": "organization.project", + "name": "Project example", + "created_at": 1711471533, + "archived_at": null, + "status": "active" + } + ], + "first_id": "proj-abc", + "last_id": "proj-xyz", + "has_more": false + } + post: + summary: Create a new project in the organization. Projects can be created and archived, but cannot be deleted. + operationId: create-project + security: + - AdminApiKeyAuth: [] + tags: + - Projects + requestBody: + description: The project create request payload. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectCreateRequest' + responses: + '200': + description: Project created successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/Project' + x-oaiMeta: + name: Create project + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/organization/projects \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "Project ABC" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const project = await client.admin.organization.projects.create({ name: 'name' }); + + console.log(project.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + project = client.admin.organization.projects.create( + name="name", + ) + print(project.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tproject, err := client.Admin.Organization.Projects.New(context.TODO(), openai.AdminOrganizationProjectNewParams{\n\t\tName: \"name\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", project.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.Project; + import com.openai.models.admin.organization.projects.ProjectCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ProjectCreateParams params = ProjectCreateParams.builder() + .name("name") + .build(); + Project project = client.admin().organization().projects().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + project = openai.admin.organization.projects.create(name: "name") + + puts(project) + response: | + { + "id": "proj_abc", + "object": "organization.project", + "name": "Project ABC", + "created_at": 1711471533, + "archived_at": null, + "status": "active" + } + /organization/projects/{project_id}: + get: + summary: Retrieves a project. + operationId: retrieve-project + security: + - AdminApiKeyAuth: [] + tags: + - Projects + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + responses: + '200': + description: Project retrieved successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/Project' + x-oaiMeta: + name: Retrieve project + group: administration + description: Retrieve a project. + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/projects/proj_abc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const project = await client.admin.organization.projects.retrieve('project_id'); + + console.log(project.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + project = client.admin.organization.projects.retrieve( + "project_id", + ) + print(project.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tproject, err := client.Admin.Organization.Projects.Get(context.TODO(), \"project_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", project.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.Project; + import com.openai.models.admin.organization.projects.ProjectRetrieveParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Project project = client.admin().organization().projects().retrieve("project_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + project = openai.admin.organization.projects.retrieve("project_id") + + puts(project) + response: | + { + "id": "proj_abc", + "object": "organization.project", + "name": "Project example", + "created_at": 1711471533, + "archived_at": null, + "status": "active" + } + post: + summary: Modifies a project in the organization. + operationId: modify-project + security: + - AdminApiKeyAuth: [] + tags: + - Projects + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + requestBody: + description: The project update request payload. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectUpdateRequest' + responses: + '200': + description: Project updated successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/Project' + '400': + description: Error response when updating the default project. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + x-oaiMeta: + name: Modify project + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/organization/projects/proj_abc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "Project DEF" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const project = await client.admin.organization.projects.update('project_id'); + + console.log(project.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + project = client.admin.organization.projects.update( + project_id="project_id", + ) + print(project.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tproject, err := client.Admin.Organization.Projects.Update(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\topenai.AdminOrganizationProjectUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", project.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.Project; + import com.openai.models.admin.organization.projects.ProjectUpdateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Project project = client.admin().organization().projects().update("project_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + project = openai.admin.organization.projects.update("project_id") + + puts(project) + response: '' + /organization/projects/{project_id}/api_keys: + get: + security: + - AdminApiKeyAuth: [] + summary: Returns a list of API keys in the project. + operationId: list-project-api-keys + tags: + - Projects + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + - name: limit + in: query + description: | + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + required: false + schema: + type: integer + default: 20 + - name: after + in: query + 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. + required: false + schema: + type: string + responses: + '200': + description: Project API keys listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectApiKeyListResponse' + x-oaiMeta: + name: List project API keys + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/projects/proj_abc/api_keys?after=key_abc&limit=20 \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const projectAPIKey of client.admin.organization.projects.apiKeys.list('project_id')) { + console.log(projectAPIKey.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.projects.api_keys.list( + project_id="project_id", + ) + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Projects.APIKeys.List(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\topenai.AdminOrganizationProjectAPIKeyListParams{},\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.apikeys.ApiKeyListPage; + import com.openai.models.admin.organization.projects.apikeys.ApiKeyListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ApiKeyListPage page = client.admin().organization().projects().apiKeys().list("project_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.projects.api_keys.list("project_id") + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "object": "organization.project.api_key", + "redacted_value": "sk-abc...def", + "name": "My API Key", + "created_at": 1711471533, + "last_used_at": 1711471534, + "id": "key_abc", + "owner": { + "type": "user", + "user": { + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "created_at": 1711471533 + } + } + } + ], + "first_id": "key_abc", + "last_id": "key_xyz", + "has_more": false + } + /organization/projects/{project_id}/api_keys/{api_key_id}: + get: + security: + - AdminApiKeyAuth: [] + summary: Retrieves an API key in the project. + operationId: retrieve-project-api-key + tags: + - Projects + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + - name: api_key_id + in: path + description: The ID of the API key. + required: true + schema: + type: string + responses: + '200': + description: Project API key retrieved successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectApiKey' + x-oaiMeta: + name: Retrieve project API key + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/projects/proj_abc/api_keys/key_abc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const projectAPIKey = await client.admin.organization.projects.apiKeys.retrieve('api_key_id', { + project_id: 'project_id', + }); + + console.log(projectAPIKey.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + project_api_key = client.admin.organization.projects.api_keys.retrieve( + api_key_id="api_key_id", + project_id="project_id", + ) + print(project_api_key.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tprojectAPIKey, err := client.Admin.Organization.Projects.APIKeys.Get(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\t\"api_key_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", projectAPIKey.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.apikeys.ApiKeyRetrieveParams; + import com.openai.models.admin.organization.projects.apikeys.ProjectApiKey; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ApiKeyRetrieveParams params = ApiKeyRetrieveParams.builder() + .projectId("project_id") + .apiKeyId("api_key_id") + .build(); + ProjectApiKey projectApiKey = client.admin().organization().projects().apiKeys().retrieve(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + project_api_key = openai.admin.organization.projects.api_keys.retrieve("api_key_id", project_id: "project_id") + + puts(project_api_key) + response: | + { + "object": "organization.project.api_key", + "redacted_value": "sk-abc...def", + "name": "My API Key", + "created_at": 1711471533, + "last_used_at": 1711471534, + "id": "key_abc", + "owner": { + "type": "user", + "user": { + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "created_at": 1711471533 + } + } + } + delete: + security: + - AdminApiKeyAuth: [] + summary: | + Deletes an API key from the project. + + Returns confirmation of the key deletion, or an error if the key belonged to + a service account. + operationId: delete-project-api-key + tags: + - Projects + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + - name: api_key_id + in: path + description: The ID of the API key. + required: true + schema: + type: string + responses: + '200': + description: Project API key deleted successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectApiKeyDeleteResponse' + '400': + description: Error response for various conditions. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + x-oaiMeta: + name: Delete project API key + group: administration + examples: + request: + curl: | + curl -X DELETE https://api.openai.com/v1/organization/projects/proj_abc/api_keys/key_abc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const apiKey = await client.admin.organization.projects.apiKeys.delete('api_key_id', { + project_id: 'project_id', + }); + + console.log(apiKey.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + api_key = client.admin.organization.projects.api_keys.delete( + api_key_id="api_key_id", + project_id="project_id", + ) + print(api_key.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tapiKey, err := client.Admin.Organization.Projects.APIKeys.Delete(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\t\"api_key_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", apiKey.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.apikeys.ApiKeyDeleteParams; + import com.openai.models.admin.organization.projects.apikeys.ApiKeyDeleteResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ApiKeyDeleteParams params = ApiKeyDeleteParams.builder() + .projectId("project_id") + .apiKeyId("api_key_id") + .build(); + ApiKeyDeleteResponse apiKey = client.admin().organization().projects().apiKeys().delete(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + api_key = openai.admin.organization.projects.api_keys.delete("api_key_id", project_id: "project_id") + + puts(api_key) + response: | + { + "object": "organization.project.api_key.deleted", + "id": "key_abc", + "deleted": true + } + /organization/projects/{project_id}/archive: + post: + summary: Archives a project in the organization. Archived projects cannot be used or updated. + operationId: archive-project + security: + - AdminApiKeyAuth: [] + tags: + - Projects + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + responses: + '200': + description: Project archived successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/Project' + x-oaiMeta: + name: Archive project + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/organization/projects/proj_abc/archive \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const project = await client.admin.organization.projects.archive('project_id'); + + console.log(project.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + project = client.admin.organization.projects.archive( + "project_id", + ) + print(project.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tproject, err := client.Admin.Organization.Projects.Archive(context.TODO(), \"project_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", project.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.Project; + import com.openai.models.admin.organization.projects.ProjectArchiveParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Project project = client.admin().organization().projects().archive("project_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + project = openai.admin.organization.projects.archive("project_id") + + puts(project) + response: | + { + "id": "proj_abc", + "object": "organization.project", + "name": "Project DEF", + "created_at": 1711471533, + "archived_at": 1711471533, + "status": "archived" + } + /organization/projects/{project_id}/groups: + get: + security: + - AdminApiKeyAuth: [] + summary: Lists the groups that have access to a project. + operationId: list-project-groups + tags: + - Project groups + parameters: + - name: project_id + in: path + description: The ID of the project to inspect. + required: true + schema: + type: string + - name: limit + in: query + description: A limit on the number of project groups to return. Defaults to 20. + required: false + schema: + type: integer + minimum: 0 + maximum: 100 + default: 20 + - name: after + in: query + description: Cursor for pagination. Provide the ID of the last group from the previous response to fetch the next page. + required: false + schema: + type: string + - name: order + in: query + description: Sort order for the returned groups. + required: false + schema: + type: string + enum: + - asc + - desc + default: asc + responses: + '200': + description: Project groups listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectGroupListResource' + x-oaiMeta: + name: List project groups + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/projects/proj_abc123/groups?limit=20 \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const projectGroup of client.admin.organization.projects.groups.list('project_id')) { + console.log(projectGroup.group_id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.projects.groups.list( + project_id="project_id", + ) + page = page.data[0] + print(page.group_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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Projects.Groups.List(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\topenai.AdminOrganizationProjectGroupListParams{},\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.groups.GroupListPage; + import com.openai.models.admin.organization.projects.groups.GroupListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + GroupListPage page = client.admin().organization().projects().groups().list("project_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.projects.groups.list("project_id") + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "object": "project.group", + "project_id": "proj_abc123", + "group_id": "group_01J1F8ABCDXYZ", + "group_name": "Support Team", + "created_at": 1711471533 + } + ], + "has_more": false, + "next": null + } + post: + security: + - AdminApiKeyAuth: [] + summary: Grants a group access to a project. + operationId: add-project-group + tags: + - Project groups + parameters: + - name: project_id + in: path + description: The ID of the project to update. + required: true + schema: + type: string + requestBody: + description: Identifies the group and role to assign to the project. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/InviteProjectGroupBody' + responses: + '200': + description: Group granted access to the project successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectGroup' + x-oaiMeta: + name: Add project group + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/organization/projects/proj_abc123/groups \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "group_id": "group_01J1F8ABCDXYZ", + "role": "role_01J1F8PROJ" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const projectGroup = await client.admin.organization.projects.groups.create('project_id', { + group_id: 'group_id', + role: 'role', + }); + + console.log(projectGroup.group_id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + project_group = client.admin.organization.projects.groups.create( + project_id="project_id", + group_id="group_id", + role="role", + ) + print(project_group.group_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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tprojectGroup, err := client.Admin.Organization.Projects.Groups.New(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\topenai.AdminOrganizationProjectGroupNewParams{\n\t\t\tGroupID: \"group_id\",\n\t\t\tRole: \"role\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", projectGroup.GroupID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.groups.GroupCreateParams; + import com.openai.models.admin.organization.projects.groups.ProjectGroup; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + GroupCreateParams params = GroupCreateParams.builder() + .projectId("project_id") + .groupId("group_id") + .role("role") + .build(); + ProjectGroup projectGroup = client.admin().organization().projects().groups().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + project_group = openai.admin.organization.projects.groups.create("project_id", group_id: "group_id", role: "role") + + puts(project_group) + response: | + { + "object": "project.group", + "project_id": "proj_abc123", + "group_id": "group_01J1F8ABCDXYZ", + "group_name": "Support Team", + "created_at": 1711471533 + } + /organization/projects/{project_id}/groups/{group_id}: + delete: + security: + - AdminApiKeyAuth: [] + summary: Revokes a group's access to a project. + operationId: remove-project-group + tags: + - Project groups + parameters: + - name: project_id + in: path + description: The ID of the project to update. + required: true + schema: + type: string + - name: group_id + in: path + description: The ID of the group to remove from the project. + required: true + schema: + type: string + responses: + '200': + description: Group removed from the project successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectGroupDeletedResource' + x-oaiMeta: + name: Remove project group + group: administration + examples: + request: + curl: | + curl -X DELETE https://api.openai.com/v1/organization/projects/proj_abc123/groups/group_01J1F8ABCDXYZ \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const group = await client.admin.organization.projects.groups.delete('group_id', { + project_id: 'project_id', + }); + + console.log(group.deleted); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + group = client.admin.organization.projects.groups.delete( + group_id="group_id", + project_id="project_id", + ) + print(group.deleted) + 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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tgroup, err := client.Admin.Organization.Projects.Groups.Delete(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\t\"group_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", group.Deleted)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.groups.GroupDeleteParams; + import com.openai.models.admin.organization.projects.groups.GroupDeleteResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + GroupDeleteParams params = GroupDeleteParams.builder() + .projectId("project_id") + .groupId("group_id") + .build(); + GroupDeleteResponse group = client.admin().organization().projects().groups().delete(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + group = openai.admin.organization.projects.groups.delete("group_id", project_id: "project_id") + + puts(group) + response: | + { + "object": "project.group.deleted", + "deleted": true + } + /organization/projects/{project_id}/rate_limits: + get: + security: + - AdminApiKeyAuth: [] + summary: Returns the rate limits per model for a project. + operationId: list-project-rate-limits + tags: + - Projects + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + - name: limit + in: query + description: | + A limit on the number of objects to be returned. The default is 100. + required: false + schema: + type: integer + default: 100 + - name: after + in: query + 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. + required: false + schema: + type: string + - name: before + in: query + 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, beginning with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + required: false + schema: + type: string + responses: + '200': + description: Project rate limits listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectRateLimitListResponse' + x-oaiMeta: + name: List project rate limits + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/projects/proj_abc/rate_limits?after=rl_xxx&limit=20 \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const projectRateLimit of client.admin.organization.projects.rateLimits.listRateLimits( + 'project_id', + )) { + console.log(projectRateLimit.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.projects.rate_limits.list_rate_limits( + project_id="project_id", + ) + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Projects.RateLimits.ListRateLimits(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\topenai.AdminOrganizationProjectRateLimitListRateLimitsParams{},\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.ratelimits.RateLimitListRateLimitsPage; + import com.openai.models.admin.organization.projects.ratelimits.RateLimitListRateLimitsParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RateLimitListRateLimitsPage page = client.admin().organization().projects().rateLimits().listRateLimits("project_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.projects.rate_limits.list_rate_limits("project_id") + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "object": "project.rate_limit", + "id": "rl-ada", + "model": "ada", + "max_requests_per_1_minute": 600, + "max_tokens_per_1_minute": 150000, + "max_images_per_1_minute": 10 + } + ], + "first_id": "rl-ada", + "last_id": "rl-ada", + "has_more": false + } + error_response: | + { + "code": 404, + "message": "The project {project_id} was not found" + } + /organization/projects/{project_id}/rate_limits/{rate_limit_id}: + post: + security: + - AdminApiKeyAuth: [] + summary: Updates a project rate limit. + operationId: update-project-rate-limits + tags: + - Projects + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + - name: rate_limit_id + in: path + description: The ID of the rate limit. + required: true + schema: + type: string + requestBody: + description: The project rate limit update request payload. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectRateLimitUpdateRequest' + responses: + '200': + description: Project rate limit updated successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectRateLimit' + '400': + description: Error response for various conditions. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + x-oaiMeta: + name: Modify project rate limit + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/organization/projects/proj_abc/rate_limits/rl_xxx \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "max_requests_per_1_minute": 500 + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const projectRateLimit = await client.admin.organization.projects.rateLimits.updateRateLimit( + 'rate_limit_id', + { project_id: 'project_id' }, + ); + + console.log(projectRateLimit.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + project_rate_limit = client.admin.organization.projects.rate_limits.update_rate_limit( + rate_limit_id="rate_limit_id", + project_id="project_id", + ) + print(project_rate_limit.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tprojectRateLimit, err := client.Admin.Organization.Projects.RateLimits.UpdateRateLimit(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\t\"rate_limit_id\",\n\t\topenai.AdminOrganizationProjectRateLimitUpdateRateLimitParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", projectRateLimit.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.ratelimits.ProjectRateLimit; + import com.openai.models.admin.organization.projects.ratelimits.RateLimitUpdateRateLimitParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RateLimitUpdateRateLimitParams params = RateLimitUpdateRateLimitParams.builder() + .projectId("project_id") + .rateLimitId("rate_limit_id") + .build(); + ProjectRateLimit projectRateLimit = client.admin().organization().projects().rateLimits().updateRateLimit(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + project_rate_limit = openai.admin.organization.projects.rate_limits.update_rate_limit( + "rate_limit_id", + project_id: "project_id" + ) + + puts(project_rate_limit) + response: | + { + "object": "project.rate_limit", + "id": "rl-ada", + "model": "ada", + "max_requests_per_1_minute": 600, + "max_tokens_per_1_minute": 150000, + "max_images_per_1_minute": 10 + } + error_response: | + { + "code": 404, + "message": "The project {project_id} was not found" + } + /organization/projects/{project_id}/service_accounts: + get: + security: + - AdminApiKeyAuth: [] + summary: Returns a list of service accounts in the project. + operationId: list-project-service-accounts + tags: + - Projects + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + - name: limit + in: query + description: | + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + required: false + schema: + type: integer + default: 20 + - name: after + in: query + 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. + required: false + schema: + type: string + responses: + '200': + description: Project service accounts listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectServiceAccountListResponse' + '400': + description: Error response when project is archived. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + x-oaiMeta: + name: List project service accounts + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/projects/proj_abc/service_accounts?after=custom_id&limit=20 \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const projectServiceAccount of client.admin.organization.projects.serviceAccounts.list( + 'project_id', + )) { + console.log(projectServiceAccount.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.projects.service_accounts.list( + project_id="project_id", + ) + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Projects.ServiceAccounts.List(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\topenai.AdminOrganizationProjectServiceAccountListParams{},\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.serviceaccounts.ServiceAccountListPage; + import com.openai.models.admin.organization.projects.serviceaccounts.ServiceAccountListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ServiceAccountListPage page = client.admin().organization().projects().serviceAccounts().list("project_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.projects.service_accounts.list("project_id") + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "object": "organization.project.service_account", + "id": "svc_acct_abc", + "name": "Service Account", + "role": "owner", + "created_at": 1711471533 + } + ], + "first_id": "svc_acct_abc", + "last_id": "svc_acct_xyz", + "has_more": false + } + post: + security: + - AdminApiKeyAuth: [] + summary: Creates a new service account in the project. This also returns an unredacted API key for the service account. + operationId: create-project-service-account + tags: + - Projects + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + requestBody: + description: The project service account create request payload. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectServiceAccountCreateRequest' + responses: + '200': + description: Project service account created successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectServiceAccountCreateResponse' + '400': + description: Error response when project is archived. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + x-oaiMeta: + name: Create project service account + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/organization/projects/proj_abc/service_accounts \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "Production App" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const serviceAccount = await client.admin.organization.projects.serviceAccounts.create( + 'project_id', + { name: 'name' }, + ); + + console.log(serviceAccount.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + service_account = client.admin.organization.projects.service_accounts.create( + project_id="project_id", + name="name", + ) + print(service_account.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tserviceAccount, err := client.Admin.Organization.Projects.ServiceAccounts.New(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\topenai.AdminOrganizationProjectServiceAccountNewParams{\n\t\t\tName: \"name\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", serviceAccount.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.serviceaccounts.ServiceAccountCreateParams; + import com.openai.models.admin.organization.projects.serviceaccounts.ServiceAccountCreateResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ServiceAccountCreateParams params = ServiceAccountCreateParams.builder() + .projectId("project_id") + .name("name") + .build(); + ServiceAccountCreateResponse serviceAccount = client.admin().organization().projects().serviceAccounts().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + service_account = openai.admin.organization.projects.service_accounts.create("project_id", name: "name") + + puts(service_account) + response: | + { + "object": "organization.project.service_account", + "id": "svc_acct_abc", + "name": "Production App", + "role": "member", + "created_at": 1711471533, + "api_key": { + "object": "organization.project.service_account.api_key", + "value": "sk-abcdefghijklmnop123", + "name": "Secret Key", + "created_at": 1711471533, + "id": "key_abc" + } + } + /organization/projects/{project_id}/service_accounts/{service_account_id}: + get: + security: + - AdminApiKeyAuth: [] + summary: Retrieves a service account in the project. + operationId: retrieve-project-service-account + tags: + - Projects + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + - name: service_account_id + in: path + description: The ID of the service account. + required: true + schema: + type: string + responses: + '200': + description: Project service account retrieved successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectServiceAccount' + x-oaiMeta: + name: Retrieve project service account + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/projects/proj_abc/service_accounts/svc_acct_abc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const projectServiceAccount = await client.admin.organization.projects.serviceAccounts.retrieve( + 'service_account_id', + { project_id: 'project_id' }, + ); + + console.log(projectServiceAccount.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + project_service_account = client.admin.organization.projects.service_accounts.retrieve( + service_account_id="service_account_id", + project_id="project_id", + ) + print(project_service_account.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tprojectServiceAccount, err := client.Admin.Organization.Projects.ServiceAccounts.Get(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\t\"service_account_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", projectServiceAccount.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.serviceaccounts.ProjectServiceAccount; + import com.openai.models.admin.organization.projects.serviceaccounts.ServiceAccountRetrieveParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ServiceAccountRetrieveParams params = ServiceAccountRetrieveParams.builder() + .projectId("project_id") + .serviceAccountId("service_account_id") + .build(); + ProjectServiceAccount projectServiceAccount = client.admin().organization().projects().serviceAccounts().retrieve(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + project_service_account = openai.admin.organization.projects.service_accounts.retrieve( + "service_account_id", + project_id: "project_id" + ) + + puts(project_service_account) + response: | + { + "object": "organization.project.service_account", + "id": "svc_acct_abc", + "name": "Service Account", + "role": "owner", + "created_at": 1711471533 + } + delete: + security: + - AdminApiKeyAuth: [] + summary: | + Deletes a service account from the project. + + Returns confirmation of service account deletion, or an error if the project + is archived (archived projects have no service accounts). + operationId: delete-project-service-account + tags: + - Projects + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + - name: service_account_id + in: path + description: The ID of the service account. + required: true + schema: + type: string + responses: + '200': + description: Project service account deleted successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectServiceAccountDeleteResponse' + x-oaiMeta: + name: Delete project service account + group: administration + examples: + request: + curl: | + curl -X DELETE https://api.openai.com/v1/organization/projects/proj_abc/service_accounts/svc_acct_abc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const serviceAccount = await client.admin.organization.projects.serviceAccounts.delete( + 'service_account_id', + { project_id: 'project_id' }, + ); + + console.log(serviceAccount.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + service_account = client.admin.organization.projects.service_accounts.delete( + service_account_id="service_account_id", + project_id="project_id", + ) + print(service_account.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tserviceAccount, err := client.Admin.Organization.Projects.ServiceAccounts.Delete(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\t\"service_account_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", serviceAccount.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.serviceaccounts.ServiceAccountDeleteParams; + import com.openai.models.admin.organization.projects.serviceaccounts.ServiceAccountDeleteResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + ServiceAccountDeleteParams params = ServiceAccountDeleteParams.builder() + .projectId("project_id") + .serviceAccountId("service_account_id") + .build(); + ServiceAccountDeleteResponse serviceAccount = client.admin().organization().projects().serviceAccounts().delete(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + service_account = openai.admin.organization.projects.service_accounts.delete("service_account_id", project_id: "project_id") + + puts(service_account) + response: | + { + "object": "organization.project.service_account.deleted", + "id": "svc_acct_abc", + "deleted": true + } + /organization/projects/{project_id}/users: + get: + security: + - AdminApiKeyAuth: [] + summary: Returns a list of users in the project. + operationId: list-project-users + tags: + - Projects + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + - name: limit + in: query + description: | + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + required: false + schema: + type: integer + default: 20 + - name: after + in: query + 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. + required: false + schema: + type: string + responses: + '200': + description: Project users listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectUserListResponse' + '400': + description: Error response when project is archived. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + x-oaiMeta: + name: List project users + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/projects/proj_abc/users?after=user_abc&limit=20 \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const projectUser of client.admin.organization.projects.users.list('project_id')) { + console.log(projectUser.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.projects.users.list( + project_id="project_id", + ) + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Projects.Users.List(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\topenai.AdminOrganizationProjectUserListParams{},\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.users.UserListPage; + import com.openai.models.admin.organization.projects.users.UserListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UserListPage page = client.admin().organization().projects().users().list("project_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.projects.users.list("project_id") + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "object": "organization.project.user", + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } + ], + "first_id": "user-abc", + "last_id": "user-xyz", + "has_more": false + } + post: + security: + - AdminApiKeyAuth: [] + summary: Adds a user to the project. Users must already be members of the organization to be added to a project. + operationId: create-project-user + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + tags: + - Projects + requestBody: + description: The project user create request payload. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectUserCreateRequest' + responses: + '200': + description: User added to project successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectUser' + '400': + description: Error response for various conditions. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + x-oaiMeta: + name: Create project user + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/organization/projects/proj_abc/users \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "user_id": "user_abc", + "role": "member" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const projectUser = await client.admin.organization.projects.users.create('project_id', { + role: 'role', + }); + + console.log(projectUser.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + project_user = client.admin.organization.projects.users.create( + project_id="project_id", + role="role", + ) + print(project_user.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tprojectUser, err := client.Admin.Organization.Projects.Users.New(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\topenai.AdminOrganizationProjectUserNewParams{\n\t\t\tRole: \"role\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", projectUser.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.users.ProjectUser; + import com.openai.models.admin.organization.projects.users.UserCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UserCreateParams params = UserCreateParams.builder() + .projectId("project_id") + .role("role") + .build(); + ProjectUser projectUser = client.admin().organization().projects().users().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + project_user = openai.admin.organization.projects.users.create("project_id", role: "role") + + puts(project_user) + response: | + { + "object": "organization.project.user", + "id": "user_abc", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } + /organization/projects/{project_id}/users/{user_id}: + get: + security: + - AdminApiKeyAuth: [] + summary: Retrieves a user in the project. + operationId: retrieve-project-user + tags: + - Projects + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + - name: user_id + in: path + description: The ID of the user. + required: true + schema: + type: string + responses: + '200': + description: Project user retrieved successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectUser' + x-oaiMeta: + name: Retrieve project user + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/projects/proj_abc/users/user_abc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const projectUser = await client.admin.organization.projects.users.retrieve('user_id', { + project_id: 'project_id', + }); + + console.log(projectUser.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + project_user = client.admin.organization.projects.users.retrieve( + user_id="user_id", + project_id="project_id", + ) + print(project_user.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tprojectUser, err := client.Admin.Organization.Projects.Users.Get(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\t\"user_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", projectUser.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.users.ProjectUser; + import com.openai.models.admin.organization.projects.users.UserRetrieveParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UserRetrieveParams params = UserRetrieveParams.builder() + .projectId("project_id") + .userId("user_id") + .build(); + ProjectUser projectUser = client.admin().organization().projects().users().retrieve(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + project_user = openai.admin.organization.projects.users.retrieve("user_id", project_id: "project_id") + + puts(project_user) + response: | + { + "object": "organization.project.user", + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } + post: + security: + - AdminApiKeyAuth: [] + summary: Modifies a user's role in the project. + operationId: modify-project-user + tags: + - Projects + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + - name: user_id + in: path + description: The ID of the user. + required: true + schema: + type: string + requestBody: + description: The project user update request payload. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectUserUpdateRequest' + responses: + '200': + description: Project user's role updated successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectUser' + '400': + description: Error response for various conditions. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + x-oaiMeta: + name: Modify project user + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/organization/projects/proj_abc/users/user_abc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "role": "owner" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const projectUser = await client.admin.organization.projects.users.update('user_id', { + project_id: 'project_id', + }); + + console.log(projectUser.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + project_user = client.admin.organization.projects.users.update( + user_id="user_id", + project_id="project_id", + ) + print(project_user.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tprojectUser, err := client.Admin.Organization.Projects.Users.Update(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\t\"user_id\",\n\t\topenai.AdminOrganizationProjectUserUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", projectUser.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.users.ProjectUser; + import com.openai.models.admin.organization.projects.users.UserUpdateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UserUpdateParams params = UserUpdateParams.builder() + .projectId("project_id") + .userId("user_id") + .build(); + ProjectUser projectUser = client.admin().organization().projects().users().update(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + project_user = openai.admin.organization.projects.users.update("user_id", project_id: "project_id") + + puts(project_user) + response: | + { + "object": "organization.project.user", + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } + delete: + security: + - AdminApiKeyAuth: [] + summary: | + Deletes a user from the project. + + Returns confirmation of project user deletion, or an error if the project is + archived (archived projects have no users). + operationId: delete-project-user + tags: + - Projects + parameters: + - name: project_id + in: path + description: The ID of the project. + required: true + schema: + type: string + - name: user_id + in: path + description: The ID of the user. + required: true + schema: + type: string + responses: + '200': + description: Project user deleted successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectUserDeleteResponse' + '400': + description: Error response for various conditions. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + x-oaiMeta: + name: Delete project user + group: administration + examples: + request: + curl: | + curl -X DELETE https://api.openai.com/v1/organization/projects/proj_abc/users/user_abc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const user = await client.admin.organization.projects.users.delete('user_id', { + project_id: 'project_id', + }); + + console.log(user.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + user = client.admin.organization.projects.users.delete( + user_id="user_id", + project_id="project_id", + ) + print(user.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tuser, err := client.Admin.Organization.Projects.Users.Delete(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\t\"user_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", user.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.users.UserDeleteParams; + import com.openai.models.admin.organization.projects.users.UserDeleteResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UserDeleteParams params = UserDeleteParams.builder() + .projectId("project_id") + .userId("user_id") + .build(); + UserDeleteResponse user = client.admin().organization().projects().users().delete(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + user = openai.admin.organization.projects.users.delete("user_id", project_id: "project_id") + + puts(user) + response: | + { + "object": "organization.project.user.deleted", + "id": "user_abc", + "deleted": true + } + /projects/{project_id}/groups/{group_id}/roles: + get: + security: + - AdminApiKeyAuth: [] + summary: Lists the project roles assigned to a group within a project. + operationId: list-project-group-role-assignments + tags: + - Project group role assignments + parameters: + - name: project_id + in: path + description: The ID of the project to inspect. + required: true + schema: + type: string + - name: group_id + in: path + description: The ID of the group to inspect. + required: true + schema: + type: string + - name: limit + in: query + description: A limit on the number of project role assignments to return. + required: false + schema: + type: integer + minimum: 0 + maximum: 1000 + - name: after + in: query + description: Cursor for pagination. Provide the value from the previous response's `next` field to continue listing project roles. + required: false + schema: + type: string + - name: order + in: query + description: Sort order for the returned project roles. + required: false + schema: + type: string + enum: + - asc + - desc + responses: + '200': + description: Project group role assignments listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/RoleListResource' + x-oaiMeta: + name: List project group role assignments + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/projects/proj_abc123/groups/group_01J1F8ABCDXYZ/roles \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const roleListResponse of client.admin.organization.projects.groups.roles.list( + 'group_id', + { project_id: 'project_id' }, + )) { + console.log(roleListResponse.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.projects.groups.roles.list( + group_id="group_id", + project_id="project_id", + ) + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Projects.Groups.Roles.List(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\t\"group_id\",\n\t\topenai.AdminOrganizationProjectGroupRoleListParams{},\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.groups.roles.RoleListPage; + import com.openai.models.admin.organization.projects.groups.roles.RoleListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RoleListParams params = RoleListParams.builder() + .projectId("project_id") + .groupId("group_id") + .build(); + RoleListPage page = client.admin().organization().projects().groups().roles().list(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.projects.groups.roles.list("group_id", project_id: "project_id") + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "id": "role_01J1F8PROJ", + "name": "API Project Key Manager", + "permissions": [ + "api.organization.projects.api_keys.read", + "api.organization.projects.api_keys.write" + ], + "resource_type": "api.project", + "predefined_role": false, + "description": "Allows managing API keys for the project", + "created_at": 1711471533, + "updated_at": 1711472599, + "created_by": "user_abc123", + "created_by_user_obj": { + "id": "user_abc123", + "name": "Ada Lovelace", + "email": "ada@example.com" + }, + "metadata": {} + } + ], + "has_more": false, + "next": null + } + post: + security: + - AdminApiKeyAuth: [] + summary: Assigns a project role to a group within a project. + operationId: assign-project-group-role + tags: + - Project group role assignments + parameters: + - name: project_id + in: path + description: The ID of the project to update. + required: true + schema: + type: string + - name: group_id + in: path + description: The ID of the group that should receive the project role. + required: true + schema: + type: string + requestBody: + description: Identifies the project role to assign to the group. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PublicAssignOrganizationGroupRoleBody' + responses: + '200': + description: Project role assigned to the group successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/GroupRoleAssignment' + x-oaiMeta: + name: Assign project role to group + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/projects/proj_abc123/groups/group_01J1F8ABCDXYZ/roles \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "role_id": "role_01J1F8PROJ" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const role = await client.admin.organization.projects.groups.roles.create('group_id', { + project_id: 'project_id', + role_id: 'role_id', + }); + + console.log(role.group); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + role = client.admin.organization.projects.groups.roles.create( + group_id="group_id", + project_id="project_id", + role_id="role_id", + ) + print(role.group) + 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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\trole, err := client.Admin.Organization.Projects.Groups.Roles.New(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\t\"group_id\",\n\t\topenai.AdminOrganizationProjectGroupRoleNewParams{\n\t\t\tRoleID: \"role_id\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", role.Group)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.groups.roles.RoleCreateParams; + import com.openai.models.admin.organization.projects.groups.roles.RoleCreateResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RoleCreateParams params = RoleCreateParams.builder() + .projectId("project_id") + .groupId("group_id") + .roleId("role_id") + .build(); + RoleCreateResponse role = client.admin().organization().projects().groups().roles().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + role = openai.admin.organization.projects.groups.roles.create( + "group_id", + project_id: "project_id", + role_id: "role_id" + ) + + puts(role) + response: | + { + "object": "group.role", + "group": { + "object": "group", + "id": "group_01J1F8ABCDXYZ", + "name": "Support Team", + "created_at": 1711471533, + "scim_managed": false + }, + "role": { + "object": "role", + "id": "role_01J1F8PROJ", + "name": "API Project Key Manager", + "description": "Allows managing API keys for the project", + "permissions": [ + "api.organization.projects.api_keys.read", + "api.organization.projects.api_keys.write" + ], + "resource_type": "api.project", + "predefined_role": false + } + } + /projects/{project_id}/groups/{group_id}/roles/{role_id}: + delete: + security: + - AdminApiKeyAuth: [] + summary: Unassigns a project role from a group within a project. + operationId: unassign-project-group-role + tags: + - Project group role assignments + parameters: + - name: project_id + in: path + description: The ID of the project to modify. + required: true + schema: + type: string + - name: group_id + in: path + description: The ID of the group whose project role assignment should be removed. + required: true + schema: + type: string + - name: role_id + in: path + description: The ID of the project role to remove from the group. + required: true + schema: + type: string + responses: + '200': + description: Project role unassigned from the group successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/DeletedRoleAssignmentResource' + x-oaiMeta: + name: Unassign project role from group + group: administration + examples: + request: + curl: | + curl -X DELETE https://api.openai.com/v1/projects/proj_abc123/groups/group_01J1F8ABCDXYZ/roles/role_01J1F8PROJ \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const role = await client.admin.organization.projects.groups.roles.delete('role_id', { + project_id: 'project_id', + group_id: 'group_id', + }); + + console.log(role.deleted); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + role = client.admin.organization.projects.groups.roles.delete( + role_id="role_id", + project_id="project_id", + group_id="group_id", + ) + print(role.deleted) + 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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\trole, err := client.Admin.Organization.Projects.Groups.Roles.Delete(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\t\"group_id\",\n\t\t\"role_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", role.Deleted)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.groups.roles.RoleDeleteParams; + import com.openai.models.admin.organization.projects.groups.roles.RoleDeleteResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RoleDeleteParams params = RoleDeleteParams.builder() + .projectId("project_id") + .groupId("group_id") + .roleId("role_id") + .build(); + RoleDeleteResponse role = client.admin().organization().projects().groups().roles().delete(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + role = openai.admin.organization.projects.groups.roles.delete( + "role_id", + project_id: "project_id", + group_id: "group_id" + ) + + puts(role) + response: | + { + "object": "group.role.deleted", + "deleted": true + } + /projects/{project_id}/users/{user_id}/roles: + get: + security: + - AdminApiKeyAuth: [] + summary: Lists the project roles assigned to a user within a project. + operationId: list-project-user-role-assignments + tags: + - Project user role assignments + parameters: + - name: project_id + in: path + description: The ID of the project to inspect. + required: true + schema: + type: string + - name: user_id + in: path + description: The ID of the user to inspect. + required: true + schema: + type: string + - name: limit + in: query + description: A limit on the number of project role assignments to return. + required: false + schema: + type: integer + minimum: 0 + maximum: 1000 + - name: after + in: query + description: Cursor for pagination. Provide the value from the previous response's `next` field to continue listing project roles. + required: false + schema: + type: string + - name: order + in: query + description: Sort order for the returned project roles. + required: false + schema: + type: string + enum: + - asc + - desc + responses: + '200': + description: Project user role assignments listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/RoleListResource' + x-oaiMeta: + name: List project user role assignments + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/projects/proj_abc123/users/user_abc123/roles \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const roleListResponse of client.admin.organization.projects.users.roles.list( + 'user_id', + { project_id: 'project_id' }, + )) { + console.log(roleListResponse.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.projects.users.roles.list( + user_id="user_id", + project_id="project_id", + ) + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Projects.Users.Roles.List(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\t\"user_id\",\n\t\topenai.AdminOrganizationProjectUserRoleListParams{},\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.users.roles.RoleListPage; + import com.openai.models.admin.organization.projects.users.roles.RoleListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RoleListParams params = RoleListParams.builder() + .projectId("project_id") + .userId("user_id") + .build(); + RoleListPage page = client.admin().organization().projects().users().roles().list(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.projects.users.roles.list("user_id", project_id: "project_id") + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "id": "role_01J1F8PROJ", + "name": "API Project Key Manager", + "permissions": [ + "api.organization.projects.api_keys.read", + "api.organization.projects.api_keys.write" + ], + "resource_type": "api.project", + "predefined_role": false, + "description": "Allows managing API keys for the project", + "created_at": 1711471533, + "updated_at": 1711472599, + "created_by": "user_abc123", + "created_by_user_obj": { + "id": "user_abc123", + "name": "Ada Lovelace", + "email": "ada@example.com" + }, + "metadata": {} + } + ], + "has_more": false, + "next": null + } + post: + security: + - AdminApiKeyAuth: [] + summary: Assigns a project role to a user within a project. + operationId: assign-project-user-role + tags: + - Project user role assignments + parameters: + - name: project_id + in: path + description: The ID of the project to update. + required: true + schema: + type: string + - name: user_id + in: path + description: The ID of the user that should receive the project role. + required: true + schema: + type: string + requestBody: + description: Identifies the project role to assign to the user. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PublicAssignOrganizationGroupRoleBody' + responses: + '200': + description: Project role assigned to the user successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/UserRoleAssignment' + x-oaiMeta: + name: Assign project role to user + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/projects/proj_abc123/users/user_abc123/roles \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "role_id": "role_01J1F8PROJ" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const role = await client.admin.organization.projects.users.roles.create('user_id', { + project_id: 'project_id', + role_id: 'role_id', + }); + + console.log(role.object); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + role = client.admin.organization.projects.users.roles.create( + user_id="user_id", + project_id="project_id", + role_id="role_id", + ) + print(role.object) + 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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\trole, err := client.Admin.Organization.Projects.Users.Roles.New(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\t\"user_id\",\n\t\topenai.AdminOrganizationProjectUserRoleNewParams{\n\t\t\tRoleID: \"role_id\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", role.Object)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.users.roles.RoleCreateParams; + import com.openai.models.admin.organization.projects.users.roles.RoleCreateResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RoleCreateParams params = RoleCreateParams.builder() + .projectId("project_id") + .userId("user_id") + .roleId("role_id") + .build(); + RoleCreateResponse role = client.admin().organization().projects().users().roles().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + role = openai.admin.organization.projects.users.roles.create( + "user_id", + project_id: "project_id", + role_id: "role_id" + ) + + puts(role) + response: | + { + "object": "user.role", + "user": { + "object": "organization.user", + "id": "user_abc123", + "name": "Ada Lovelace", + "email": "ada@example.com", + "role": "owner", + "added_at": 1711470000 + }, + "role": { + "object": "role", + "id": "role_01J1F8PROJ", + "name": "API Project Key Manager", + "description": "Allows managing API keys for the project", + "permissions": [ + "api.organization.projects.api_keys.read", + "api.organization.projects.api_keys.write" + ], + "resource_type": "api.project", + "predefined_role": false + } + } + /projects/{project_id}/users/{user_id}/roles/{role_id}: + delete: + security: + - AdminApiKeyAuth: [] + summary: Unassigns a project role from a user within a project. + operationId: unassign-project-user-role + tags: + - Project user role assignments + parameters: + - name: project_id + in: path + description: The ID of the project to modify. + required: true + schema: + type: string + - name: user_id + in: path + description: The ID of the user whose project role assignment should be removed. + required: true + schema: + type: string + - name: role_id + in: path + description: The ID of the project role to remove from the user. + required: true + schema: + type: string + responses: + '200': + description: Project role unassigned from the user successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/DeletedRoleAssignmentResource' + x-oaiMeta: + name: Unassign project role from user + group: administration + examples: + request: + curl: | + curl -X DELETE https://api.openai.com/v1/projects/proj_abc123/users/user_abc123/roles/role_01J1F8PROJ \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const role = await client.admin.organization.projects.users.roles.delete('role_id', { + project_id: 'project_id', + user_id: 'user_id', + }); + + console.log(role.deleted); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + role = client.admin.organization.projects.users.roles.delete( + role_id="role_id", + project_id="project_id", + user_id="user_id", + ) + print(role.deleted) + 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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\trole, err := client.Admin.Organization.Projects.Users.Roles.Delete(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\t\"user_id\",\n\t\t\"role_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", role.Deleted)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.users.roles.RoleDeleteParams; + import com.openai.models.admin.organization.projects.users.roles.RoleDeleteResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RoleDeleteParams params = RoleDeleteParams.builder() + .projectId("project_id") + .userId("user_id") + .roleId("role_id") + .build(); + RoleDeleteResponse role = client.admin().organization().projects().users().roles().delete(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + role = openai.admin.organization.projects.users.roles.delete( + "role_id", + project_id: "project_id", + user_id: "user_id" + ) + + puts(role) + response: | + { + "object": "user.role.deleted", + "deleted": true + } +components: + schemas: + ProjectListResponse: + type: object + properties: + object: + type: string + enum: + - list + x-stainless-const: true + data: + type: array + items: + $ref: '#/components/schemas/Project' + first_id: + type: string + last_id: + type: string + has_more: + type: boolean + required: + - object + - data + - has_more + ProjectCreateRequest: + type: object + properties: + name: + type: string + description: The friendly name of the project, this name appears in reports. + geography: + description: Create the project with the specified data residency region. Your organization must have access to Data residency functionality in order to use. See [data residency controls](/docs/guides/your-data#data-residency-controls) to review the functionality and limitations of setting this field. + type: string + external_key_id: + description: External key ID to associate with the project. + type: string + required: + - name + Project: + type: object + description: Represents an individual project. + properties: + id: + type: string + description: The identifier, which can be referenced in API endpoints + object: + type: string + enum: + - organization.project + description: The object type, which is always `organization.project` + x-stainless-const: true + name: + description: The name of the project. This appears in reporting. + type: string + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the project was created. + archived_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the project was archived or `null`. + status: + description: '`active` or `archived`' + type: string + external_key_id: + description: The external key associated with the project. + type: string + required: + - id + - object + - created_at + x-oaiMeta: + name: The project object + example: | + { + "id": "proj_abc", + "object": "organization.project", + "name": "Project example", + "created_at": 1711471533, + "archived_at": null, + "status": "active", + "external_key_id": null + } + ProjectUpdateRequest: + type: object + properties: + name: + description: The updated name of the project, this name appears in reports. + type: string + external_key_id: + description: External key ID to associate with the project. + type: string + geography: + description: Geography for the project. + type: string + ErrorResponse: + type: object + properties: + error: + $ref: '#/components/schemas/Error' + required: + - error + ProjectApiKeyListResponse: + type: object + properties: + object: + type: string + enum: + - list + x-stainless-const: true + data: + type: array + items: + $ref: '#/components/schemas/ProjectApiKey' + first_id: + type: string + last_id: + type: string + has_more: + type: boolean + required: + - object + - data + - has_more + ProjectApiKey: + type: object + description: Represents an individual API key in a project. + properties: + object: + type: string + enum: + - organization.project.api_key + description: The object type, which is always `organization.project.api_key` + x-stainless-const: true + redacted_value: + type: string + description: The redacted value of the API key + name: + type: string + description: The name of the API key + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the API key was created + last_used_at: + description: The Unix timestamp (in seconds) of when the API key was last used. + type: integer + format: unixtime + id: + type: string + description: The identifier, which can be referenced in API endpoints + owner: + type: object + properties: + type: + type: string + enum: + - user + - service_account + description: '`user` or `service_account`' + user: + $ref: '#/components/schemas/ProjectApiKeyOwnerUser' + service_account: + $ref: '#/components/schemas/ProjectApiKeyOwnerServiceAccount' + required: + - object + - redacted_value + - name + - created_at + - last_used_at + - id + - owner + x-oaiMeta: + name: The project API key object + example: | + { + "object": "organization.project.api_key", + "redacted_value": "sk-abc...def", + "name": "My API Key", + "created_at": 1711471533, + "last_used_at": 1711471534, + "id": "key_abc", + "owner": { + "type": "user", + "user": { + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "created_at": 1711471533 + } + } + } + ProjectApiKeyDeleteResponse: + type: object + properties: + object: + type: string + enum: + - organization.project.api_key.deleted + x-stainless-const: true + id: + type: string + deleted: + type: boolean + required: + - object + - id + - deleted + ProjectGroupListResource: + type: object + description: Paginated list of groups that have access to a project. + properties: + object: + type: string + enum: + - list + description: Always `list`. + x-stainless-const: true + data: + type: array + description: Project group memberships returned in the current page. + items: + $ref: '#/components/schemas/ProjectGroup' + has_more: + type: boolean + description: Whether additional project group memberships are available. + next: + description: Cursor to fetch the next page of results, or `null` when there are no more results. + type: string + required: + - object + - data + - has_more + - next + x-oaiMeta: + name: Project group list + example: | + { + "object": "list", + "data": [ + { + "object": "project.group", + "project_id": "proj_abc123", + "group_id": "group_01J1F8ABCDXYZ", + "group_name": "Support Team", + "created_at": 1711471533 + } + ], + "has_more": false, + "next": null + } + InviteProjectGroupBody: + type: object + description: Request payload for granting a group access to a project. + properties: + group_id: + type: string + description: Identifier of the group to add to the project. + role: + type: string + description: Identifier of the project role to grant to the group. + required: + - group_id + - role + x-oaiMeta: + example: | + { + "group_id": "group_01J1F8ABCDXYZ", + "role": "role_01J1F8PROJ" + } + ProjectGroup: + type: object + description: Details about a group's membership in a project. + properties: + object: + type: string + enum: + - project.group + description: Always `project.group`. + x-stainless-const: true + project_id: + type: string + description: Identifier of the project. + group_id: + type: string + description: Identifier of the group that has access to the project. + group_name: + type: string + description: Display name of the group. + group_type: + type: string + description: The type of the group. + created_at: + type: integer + format: unixtime + description: Unix timestamp (in seconds) when the group was granted project access. + required: + - object + - project_id + - group_id + - group_name + - group_type + - created_at + x-oaiMeta: + name: The project group object + example: | + { + "object": "project.group", + "project_id": "proj_abc123", + "group_id": "group_01J1F8ABCDXYZ", + "group_name": "Support Team", + "group_type": "group", + "created_at": 1711471533 + } + ProjectGroupDeletedResource: + type: object + description: Confirmation payload returned after removing a group from a project. + properties: + object: + type: string + enum: + - project.group.deleted + description: Always `project.group.deleted`. + x-stainless-const: true + deleted: + type: boolean + description: Whether the group membership in the project was removed. + required: + - object + - deleted + x-oaiMeta: + name: Project group deletion confirmation + example: | + { + "object": "project.group.deleted", + "deleted": true + } + ProjectRateLimitListResponse: + type: object + properties: + object: + type: string + enum: + - list + x-stainless-const: true + data: + type: array + items: + $ref: '#/components/schemas/ProjectRateLimit' + first_id: + type: string + last_id: + type: string + has_more: + type: boolean + required: + - object + - data + - has_more + ProjectRateLimitUpdateRequest: + type: object + properties: + max_requests_per_1_minute: + type: integer + description: The maximum requests per minute. + max_tokens_per_1_minute: + type: integer + description: The maximum tokens per minute. + max_images_per_1_minute: + type: integer + description: The maximum images per minute. Only relevant for certain models. + max_audio_megabytes_per_1_minute: + type: integer + description: The maximum audio megabytes per minute. Only relevant for certain models. + max_requests_per_1_day: + type: integer + description: The maximum requests per day. Only relevant for certain models. + batch_1_day_max_input_tokens: + type: integer + description: The maximum batch input tokens per day. Only relevant for certain models. + ProjectRateLimit: + type: object + description: Represents a project rate limit config. + properties: + object: + type: string + enum: + - project.rate_limit + description: The object type, which is always `project.rate_limit` + x-stainless-const: true + id: + type: string + description: The identifier, which can be referenced in API endpoints. + model: + type: string + description: The model this rate limit applies to. + max_requests_per_1_minute: + type: integer + description: The maximum requests per minute. + max_tokens_per_1_minute: + type: integer + description: The maximum tokens per minute. + max_images_per_1_minute: + type: integer + description: The maximum images per minute. Only present for relevant models. + max_audio_megabytes_per_1_minute: + type: integer + description: The maximum audio megabytes per minute. Only present for relevant models. + max_requests_per_1_day: + type: integer + description: The maximum requests per day. Only present for relevant models. + batch_1_day_max_input_tokens: + type: integer + description: The maximum batch input tokens per day. Only present for relevant models. + required: + - object + - id + - model + - max_requests_per_1_minute + - max_tokens_per_1_minute + x-oaiMeta: + name: The project rate limit object + example: | + { + "object": "project.rate_limit", + "id": "rl_ada", + "model": "ada", + "max_requests_per_1_minute": 600, + "max_tokens_per_1_minute": 150000, + "max_images_per_1_minute": 10 + } + ProjectServiceAccountListResponse: + type: object + properties: + object: + type: string + enum: + - list + x-stainless-const: true + data: + type: array + items: + $ref: '#/components/schemas/ProjectServiceAccount' + first_id: + type: string + last_id: + type: string + has_more: + type: boolean + required: + - object + - data + - has_more + ProjectServiceAccountCreateRequest: + type: object + properties: + name: + type: string + description: The name of the service account being created. + required: + - name + ProjectServiceAccountCreateResponse: + type: object + properties: + object: + type: string + enum: + - organization.project.service_account + x-stainless-const: true + id: + type: string + name: + type: string + role: + type: string + enum: + - member + description: Service accounts can only have one role of type `member` + x-stainless-const: true + created_at: + type: integer + format: unixtime + api_key: + type: object + properties: + object: + type: string + enum: + - organization.project.service_account.api_key + description: The object type, which is always `organization.project.service_account.api_key` + x-stainless-const: true + value: + type: string + name: + type: string + created_at: + type: integer + format: unixtime + id: + type: string + required: + - object + - value + - name + - created_at + - id + required: + - object + - id + - name + - role + - created_at + - api_key + ProjectServiceAccount: + type: object + description: Represents an individual service account in a project. + properties: + object: + type: string + enum: + - organization.project.service_account + description: The object type, which is always `organization.project.service_account` + x-stainless-const: true + id: + type: string + description: The identifier, which can be referenced in API endpoints + name: + type: string + description: The name of the service account + role: + type: string + enum: + - owner + - member + description: '`owner` or `member`' + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the service account was created + required: + - object + - id + - name + - role + - created_at + x-oaiMeta: + name: The project service account object + example: | + { + "object": "organization.project.service_account", + "id": "svc_acct_abc", + "name": "Service Account", + "role": "owner", + "created_at": 1711471533 + } + ProjectServiceAccountDeleteResponse: + type: object + properties: + object: + type: string + enum: + - organization.project.service_account.deleted + x-stainless-const: true + id: + type: string + deleted: + type: boolean + required: + - object + - id + - deleted + ProjectUserListResponse: + type: object + properties: + object: + type: string + data: + type: array + items: + $ref: '#/components/schemas/ProjectUser' + first_id: + type: string + last_id: + type: string + has_more: + type: boolean + required: + - object + - data + - has_more + ProjectUserCreateRequest: + type: object + properties: + user_id: + description: The ID of the user. + type: string + email: + description: Email of the user to add. + type: string + role: + type: string + description: '`owner` or `member`' + required: + - role + ProjectUser: + type: object + description: Represents an individual user in a project. + properties: + object: + type: string + enum: + - organization.project.user + description: The object type, which is always `organization.project.user` + x-stainless-const: true + id: + type: string + description: The identifier, which can be referenced in API endpoints + name: + description: The name of the user + type: string + email: + description: The email address of the user + type: string + role: + type: string + description: '`owner` or `member`' + added_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the project was added. + required: + - object + - id + - role + - added_at + x-oaiMeta: + name: The project user object + example: | + { + "object": "organization.project.user", + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } + ProjectUserUpdateRequest: + type: object + properties: + role: + description: '`owner` or `member`' + type: string + ProjectUserDeleteResponse: + type: object + properties: + object: + type: string + enum: + - organization.project.user.deleted + x-stainless-const: true + id: + type: string + deleted: + type: boolean + required: + - object + - id + - deleted + RoleListResource: + type: object + description: Paginated list of roles assigned to a principal. + properties: + object: + type: string + enum: + - list + description: Always `list`. + x-stainless-const: true + data: + type: array + description: Role assignments returned in the current page. + items: + $ref: '#/components/schemas/AssignedRoleDetails' + has_more: + type: boolean + description: Whether additional assignments are available when paginating. + next: + description: Cursor to fetch the next page of results, or `null` when there are no more assignments. + type: string + required: + - object + - data + - has_more + - next + x-oaiMeta: + name: Assigned role list + example: | + { + "object": "list", + "data": [ + { + "id": "role_01J1F8ROLE01", + "name": "API Group Manager", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "resource_type": "api.organization", + "predefined_role": false, + "description": "Allows managing organization groups", + "created_at": 1711471533, + "updated_at": 1711472599, + "created_by": "user_abc123", + "created_by_user_obj": { + "id": "user_abc123", + "name": "Ada Lovelace", + "email": "ada@example.com" + }, + "metadata": {} + } + ], + "has_more": false, + "next": null + } + PublicAssignOrganizationGroupRoleBody: + type: object + description: Request payload for assigning a role to a group or user. + properties: + role_id: + type: string + description: Identifier of the role to assign. + required: + - role_id + x-oaiMeta: + example: | + { + "role_id": "role_01J1F8ROLE01" + } + GroupRoleAssignment: + type: object + description: Role assignment linking a group to a role. + properties: + object: + type: string + enum: + - group.role + description: Always `group.role`. + x-stainless-const: true + group: + $ref: '#/components/schemas/Group' + role: + $ref: '#/components/schemas/Role' + required: + - object + - group + - role + x-oaiMeta: + name: The group role object + example: | + { + "object": "group.role", + "group": { + "object": "group", + "id": "group_01J1F8ABCDXYZ", + "name": "Support Team", + "created_at": 1711471533, + "scim_managed": false + }, + "role": { + "object": "role", + "id": "role_01J1F8ROLE01", + "name": "API Group Manager", + "description": "Allows managing organization groups", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "resource_type": "api.organization", + "predefined_role": false + } + } + DeletedRoleAssignmentResource: + type: object + description: Confirmation payload returned after unassigning a role. + properties: + object: + type: string + description: Identifier for the deleted assignment, such as `group.role.deleted` or `user.role.deleted`. + deleted: + type: boolean + description: Whether the assignment was removed. + required: + - object + - deleted + x-oaiMeta: + name: Role assignment deletion confirmation + example: | + { + "object": "group.role.deleted", + "deleted": true + } + UserRoleAssignment: + type: object + description: Role assignment linking a user to a role. + properties: + object: + type: string + enum: + - user.role + description: Always `user.role`. + x-stainless-const: true + user: + $ref: '#/components/schemas/User' + role: + $ref: '#/components/schemas/Role' + required: + - object + - user + - role + x-oaiMeta: + name: The user role object + example: | + { + "object": "user.role", + "user": { + "object": "organization.user", + "id": "user_abc123", + "name": "Ada Lovelace", + "email": "ada@example.com", + "role": "owner", + "added_at": 1711470000 + }, + "role": { + "object": "role", + "id": "role_01J1F8ROLE01", + "name": "API Group Manager", + "description": "Allows managing organization groups", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "resource_type": "api.organization", + "predefined_role": false + } + } + Error: + type: object + properties: + code: + type: string + message: + type: string + param: + type: string + type: + type: string + required: + - type + - message + - param + - code + ProjectApiKeyOwnerUser: + type: object + description: The user that owns a project API key. + properties: + id: + type: string + description: The identifier, which can be referenced in API endpoints + email: + type: string + description: The email address of the user. + name: + type: string + description: The name of the user. + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the user was created. + role: + type: string + description: The user's project role. + required: + - id + - email + - name + - created_at + - role + ProjectApiKeyOwnerServiceAccount: + type: object + description: The service account that owns a project API key. + properties: + id: + type: string + description: The identifier, which can be referenced in API endpoints + name: + type: string + description: The name of the service account. + created_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the service account was created. + role: + type: string + description: The service account's project role. + required: + - id + - name + - created_at + - role + ProjectServiceAccountApiKey: + type: object + properties: + object: + type: string + enum: + - organization.project.service_account.api_key + description: The object type, which is always `organization.project.service_account.api_key` + x-stainless-const: true + value: + type: string + name: + type: string + created_at: + type: integer + format: unixtime + id: + type: string + required: + - object + - value + - name + - created_at + - id + AssignedRoleDetails: + type: object + description: Detailed information about a role assignment entry returned when listing assignments. + properties: + id: + type: string + description: Identifier for the role. + name: + type: string + description: Name of the role. + permissions: + type: array + description: Permissions associated with the role. + items: + type: string + resource_type: + type: string + description: Resource type the role applies to. + predefined_role: + type: boolean + description: Whether the role is predefined by OpenAI. + description: + description: Description of the role. + type: string + created_at: + description: When the role was created. + type: integer + format: unixtime + updated_at: + description: When the role was last updated. + type: integer + format: int64 + created_by: + description: Identifier of the actor who created the role. + type: string + created_by_user_obj: + description: User details for the actor that created the role, when available. + type: object + additionalProperties: true + metadata: + description: Arbitrary metadata stored on the role. + type: object + additionalProperties: true + required: + - id + - name + - permissions + - resource_type + - predefined_role + - description + - created_at + - updated_at + - created_by + - created_by_user_obj + - metadata + Group: + type: object + description: Summary information about a group returned in role assignment responses. + properties: + object: + type: string + enum: + - group + description: Always `group`. + x-stainless-const: true + id: + type: string + description: Identifier for the group. + name: + type: string + description: Display name of the group. + created_at: + type: integer + format: unixtime + description: Unix timestamp (in seconds) when the group was created. + scim_managed: + type: boolean + description: Whether the group is managed through SCIM. + required: + - object + - id + - name + - created_at + - scim_managed + x-oaiMeta: + name: The group object + example: | + { + "object": "group", + "id": "group_01J1F8ABCDXYZ", + "name": "Support Team", + "created_at": 1711471533, + "scim_managed": false + } + Role: + type: object + description: Details about a role that can be assigned through the public Roles API. + properties: + object: + type: string + enum: + - role + description: Always `role`. + x-stainless-const: true + id: + type: string + description: Identifier for the role. + name: + type: string + description: Unique name for the role. + description: + description: Optional description of the role. + type: string + permissions: + type: array + description: Permissions granted by the role. + items: + type: string + resource_type: + type: string + description: Resource type the role is bound to (for example `api.organization` or `api.project`). + predefined_role: + type: boolean + description: Whether the role is predefined and managed by OpenAI. + required: + - object + - id + - name + - description + - permissions + - resource_type + - predefined_role + x-oaiMeta: + name: The role object + example: | + { + "object": "role", + "id": "role_01J1F8ROLE01", + "name": "API Group Manager", + "description": "Allows managing organization groups", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "resource_type": "api.organization", + "predefined_role": false + } + User: + type: object + description: Represents an individual `user` within an organization. + properties: + object: + type: string + enum: + - organization.user + description: The object type, which is always `organization.user` + x-stainless-const: true + id: + type: string + description: The identifier, which can be referenced in API endpoints + name: + description: The name of the user + type: string + email: + description: The email address of the user + type: string + role: + description: '`owner` or `reader`' + type: string + added_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the user was added. + is_default: + type: boolean + description: Whether this is the organization's default user. + created: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the user was created. + user: + type: object + description: Nested user details. + properties: + object: + type: string + enum: + - user + x-stainless-const: true + id: + type: string + email: + anyOf: + - type: string + - type: 'null' + name: + anyOf: + - type: string + - type: 'null' + picture: + anyOf: + - type: string + - type: 'null' + enabled: + anyOf: + - type: boolean + - type: 'null' + banned: + anyOf: + - type: boolean + - type: 'null' + banned_at: + anyOf: + - type: integer + format: unixtime + - type: 'null' + required: + - object + - id + is_service_account: + type: boolean + description: Whether the user is a service account. + is_scale_tier_authorized_purchaser: + description: Whether the user is an authorized purchaser for Scale Tier. + type: boolean + is_scim_managed: + type: boolean + description: Whether the user is managed through SCIM. + api_key_last_used_at: + description: The Unix timestamp (in seconds) of the user's last API key usage. + type: integer + format: unixtime + technical_level: + description: The technical level metadata for the user. + type: string + developer_persona: + description: The developer persona metadata for the user. + type: string + projects: + description: Projects associated with the user, if included. + type: object + properties: + object: + type: string + enum: + - list + x-stainless-const: true + data: + type: array + items: + type: object + properties: + id: + anyOf: + - type: string + - type: 'null' + name: + anyOf: + - type: string + - type: 'null' + role: + anyOf: + - type: string + - type: 'null' + required: + - object + - data + required: + - object + - id + - added_at + x-oaiMeta: + name: The user object + example: | + { + "object": "organization.user", + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } + StackqlExecResult: + type: object + description: Synthetic dispatch-result envelope for EXEC-only methods (see post_process.mjs). + properties: + result: + type: string + description: Raw response payload. + items: + type: array + items: + type: string + x-stackQL-resources: + projects: + id: openai_admin.projects.projects + name: projects + title: Projects + methods: + list: + operation: + $ref: '#/paths/~1organization~1projects/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1projects/post' + response: + mediaType: application/json + openAPIDocKey: '200' + get: + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + update: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}/post' + response: + mediaType: application/json + openAPIDocKey: '200' + archive: + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1archive/post' + response: + mediaType: application/json + openAPIDocKey: '200' + schema_override: + $ref: '#/components/schemas/StackqlExecResult' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/projects/methods/get' + - $ref: '#/components/x-stackQL-resources/projects/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/projects/methods/create' + update: + - $ref: '#/components/x-stackQL-resources/projects/methods/update' + delete: [] + replace: [] + api_keys: + id: openai_admin.projects.api_keys + name: api_keys + title: Api Keys + methods: + list: + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1api_keys/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + get: + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1api_keys~1{api_key_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1api_keys~1{api_key_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/api_keys/methods/get' + - $ref: '#/components/x-stackQL-resources/api_keys/methods/list' + insert: [] + update: [] + delete: + - $ref: '#/components/x-stackQL-resources/api_keys/methods/delete' + replace: [] + groups: + id: openai_admin.projects.groups + name: groups + title: Groups + methods: + list: + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1groups/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.next + location: body + add: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1groups/post' + response: + mediaType: application/json + openAPIDocKey: '200' + remove: + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1groups~1{group_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/groups/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/groups/methods/add' + update: [] + delete: + - $ref: '#/components/x-stackQL-resources/groups/methods/remove' + replace: [] + rate_limits: + id: openai_admin.projects.rate_limits + name: rate_limits + title: Rate Limits + methods: + list: + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1rate_limits/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + update: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1rate_limits~1{rate_limit_id}/post' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/rate_limits/methods/list' + insert: [] + update: + - $ref: '#/components/x-stackQL-resources/rate_limits/methods/update' + delete: [] + replace: [] + service_accounts: + id: openai_admin.projects.service_accounts + name: service_accounts + title: Service Accounts + methods: + list: + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1service_accounts/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1service_accounts/post' + response: + mediaType: application/json + openAPIDocKey: '200' + get: + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1service_accounts~1{service_account_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1service_accounts~1{service_account_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/service_accounts/methods/get' + - $ref: '#/components/x-stackQL-resources/service_accounts/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/service_accounts/methods/create' + update: [] + delete: + - $ref: '#/components/x-stackQL-resources/service_accounts/methods/delete' + replace: [] + users: + id: openai_admin.projects.users + name: users + title: Users + methods: + list: + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1users/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1users/post' + response: + mediaType: application/json + openAPIDocKey: '200' + get: + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1users~1{user_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + update: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1users~1{user_id}/post' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1organization~1projects~1{project_id}~1users~1{user_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/users/methods/get' + - $ref: '#/components/x-stackQL-resources/users/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/users/methods/create' + update: + - $ref: '#/components/x-stackQL-resources/users/methods/update' + delete: + - $ref: '#/components/x-stackQL-resources/users/methods/delete' + replace: [] + group_role_assignments: + id: openai_admin.projects.group_role_assignments + name: group_role_assignments + title: Group Role Assignments + methods: + list: + operation: + $ref: '#/paths/~1projects~1{project_id}~1groups~1{group_id}~1roles/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.next + location: body + assign: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1projects~1{project_id}~1groups~1{group_id}~1roles/post' + response: + mediaType: application/json + openAPIDocKey: '200' + unassign: + operation: + $ref: '#/paths/~1projects~1{project_id}~1groups~1{group_id}~1roles~1{role_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/group_role_assignments/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/group_role_assignments/methods/assign' + update: [] + delete: + - $ref: '#/components/x-stackQL-resources/group_role_assignments/methods/unassign' + replace: [] + user_role_assignments: + id: openai_admin.projects.user_role_assignments + name: user_role_assignments + title: User Role Assignments + methods: + list: + operation: + $ref: '#/paths/~1projects~1{project_id}~1users~1{user_id}~1roles/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.next + location: body + assign: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1projects~1{project_id}~1users~1{user_id}~1roles/post' + response: + mediaType: application/json + openAPIDocKey: '200' + unassign: + operation: + $ref: '#/paths/~1projects~1{project_id}~1users~1{user_id}~1roles~1{role_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/user_role_assignments/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/user_role_assignments/methods/assign' + update: [] + delete: + - $ref: '#/components/x-stackQL-resources/user_role_assignments/methods/unassign' + replace: [] +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.last_id + location: body diff --git a/providers/src/openai_admin/v00.00.00000/services/roles.yaml b/providers/src/openai_admin/v00.00.00000/services/roles.yaml new file mode 100644 index 00000000..f955a087 --- /dev/null +++ b/providers/src/openai_admin/v00.00.00000/services/roles.yaml @@ -0,0 +1,1164 @@ +openapi: 3.1.0 +info: + title: roles API + description: openai_admin API + version: 2.3.0 +paths: + /organization/roles: + get: + security: + - AdminApiKeyAuth: [] + summary: Lists the roles configured for the organization. + operationId: list-roles + tags: + - Roles + parameters: + - name: limit + in: query + description: A limit on the number of roles to return. Defaults to 1000. + required: false + schema: + type: integer + minimum: 0 + maximum: 1000 + default: 1000 + - name: after + in: query + description: Cursor for pagination. Provide the value from the previous response's `next` field to continue listing roles. + required: false + schema: + type: string + - name: order + in: query + description: Sort order for the returned roles. + required: false + schema: + type: string + enum: + - asc + - desc + default: asc + responses: + '200': + description: Roles listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/PublicRoleListResource' + x-oaiMeta: + name: List organization roles + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/roles?limit=20 \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const role of client.admin.organization.roles.list()) { + console.log(role.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.roles.list() + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Roles.List(context.TODO(), openai.AdminOrganizationRoleListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.roles.RoleListPage; + import com.openai.models.admin.organization.roles.RoleListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RoleListPage page = client.admin().organization().roles().list(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.roles.list + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "object": "role", + "id": "role_01J1F8ROLE01", + "name": "API Group Manager", + "description": "Allows managing organization groups", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "resource_type": "api.organization", + "predefined_role": false + } + ], + "has_more": false, + "next": null + } + post: + security: + - AdminApiKeyAuth: [] + summary: Creates a custom role for the organization. + operationId: create-role + tags: + - Roles + requestBody: + description: Parameters for the role you want to create. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PublicCreateOrganizationRoleBody' + responses: + '200': + description: Role created successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/Role' + x-oaiMeta: + name: Create organization role + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/organization/roles \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "role_name": "API Group Manager", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "description": "Allows managing organization groups" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const role = await client.admin.organization.roles.create({ + permissions: ['string'], + role_name: 'role_name', + }); + + console.log(role.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + role = client.admin.organization.roles.create( + permissions=["string"], + role_name="role_name", + ) + print(role.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\trole, err := client.Admin.Organization.Roles.New(context.TODO(), openai.AdminOrganizationRoleNewParams{\n\t\tPermissions: []string{\"string\"},\n\t\tRoleName: \"role_name\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", role.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.roles.Role; + import com.openai.models.admin.organization.roles.RoleCreateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RoleCreateParams params = RoleCreateParams.builder() + .addPermission("string") + .roleName("role_name") + .build(); + Role role = client.admin().organization().roles().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + role = openai.admin.organization.roles.create(permissions: ["string"], role_name: "role_name") + + puts(role) + response: | + { + "object": "role", + "id": "role_01J1F8ROLE01", + "name": "API Group Manager", + "description": "Allows managing organization groups", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "resource_type": "api.organization", + "predefined_role": false + } + /organization/roles/{role_id}: + post: + security: + - AdminApiKeyAuth: [] + summary: Updates an existing organization role. + operationId: update-role + tags: + - Roles + parameters: + - name: role_id + in: path + description: The ID of the role to update. + required: true + schema: + type: string + requestBody: + description: Fields to update on the role. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PublicUpdateOrganizationRoleBody' + responses: + '200': + description: Role updated successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/Role' + x-oaiMeta: + name: Update organization role + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/organization/roles/role_01J1F8ROLE01 \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "role_name": "API Group Manager", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "description": "Allows managing organization groups" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const role = await client.admin.organization.roles.update('role_id'); + + console.log(role.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + role = client.admin.organization.roles.update( + role_id="role_id", + ) + print(role.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\trole, err := client.Admin.Organization.Roles.Update(\n\t\tcontext.TODO(),\n\t\t\"role_id\",\n\t\topenai.AdminOrganizationRoleUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", role.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.roles.Role; + import com.openai.models.admin.organization.roles.RoleUpdateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + Role role = client.admin().organization().roles().update("role_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + role = openai.admin.organization.roles.update("role_id") + + puts(role) + response: | + { + "object": "role", + "id": "role_01J1F8ROLE01", + "name": "API Group Manager", + "description": "Allows managing organization groups", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "resource_type": "api.organization", + "predefined_role": false + } + delete: + security: + - AdminApiKeyAuth: [] + summary: Deletes a custom role from the organization. + operationId: delete-role + tags: + - Roles + parameters: + - name: role_id + in: path + description: The ID of the role to delete. + required: true + schema: + type: string + responses: + '200': + description: Role deleted successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/RoleDeletedResource' + x-oaiMeta: + name: Delete organization role + group: administration + examples: + request: + curl: | + curl -X DELETE https://api.openai.com/v1/organization/roles/role_01J1F8ROLE01 \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const role = await client.admin.organization.roles.delete('role_id'); + + console.log(role.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + role = client.admin.organization.roles.delete( + "role_id", + ) + print(role.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\trole, err := client.Admin.Organization.Roles.Delete(context.TODO(), \"role_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", role.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.roles.RoleDeleteParams; + import com.openai.models.admin.organization.roles.RoleDeleteResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RoleDeleteResponse role = client.admin().organization().roles().delete("role_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + role = openai.admin.organization.roles.delete("role_id") + + puts(role) + response: | + { + "object": "role.deleted", + "id": "role_01J1F8ROLE01", + "deleted": true + } + /projects/{project_id}/roles: + get: + security: + - AdminApiKeyAuth: [] + summary: Lists the roles configured for a project. + operationId: list-project-roles + tags: + - Roles + parameters: + - name: project_id + in: path + description: The ID of the project to inspect. + required: true + schema: + type: string + - name: limit + in: query + description: A limit on the number of roles to return. Defaults to 1000. + required: false + schema: + type: integer + minimum: 0 + maximum: 1000 + default: 1000 + - name: after + in: query + description: Cursor for pagination. Provide the value from the previous response's `next` field to continue listing roles. + required: false + schema: + type: string + - name: order + in: query + description: Sort order for the returned roles. + required: false + schema: + type: string + enum: + - asc + - desc + default: asc + responses: + '200': + description: Project roles listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/PublicRoleListResource' + x-oaiMeta: + name: List project roles + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/projects/proj_abc123/roles?limit=20 \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const role of client.admin.organization.projects.roles.list('project_id')) { + console.log(role.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.projects.roles.list( + project_id="project_id", + ) + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Projects.Roles.List(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\topenai.AdminOrganizationProjectRoleListParams{},\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.roles.RoleListPage; + import com.openai.models.admin.organization.projects.roles.RoleListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RoleListPage page = client.admin().organization().projects().roles().list("project_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.projects.roles.list("project_id") + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "object": "role", + "id": "role_01J1F8PROJ", + "name": "API Project Key Manager", + "description": "Allows managing API keys for the project", + "permissions": [ + "api.organization.projects.api_keys.read", + "api.organization.projects.api_keys.write" + ], + "resource_type": "api.project", + "predefined_role": false + } + ], + "has_more": false, + "next": null + } + post: + security: + - AdminApiKeyAuth: [] + summary: Creates a custom role for a project. + operationId: create-project-role + tags: + - Roles + parameters: + - name: project_id + in: path + description: The ID of the project to update. + required: true + schema: + type: string + requestBody: + description: Parameters for the project role you want to create. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PublicCreateOrganizationRoleBody' + responses: + '200': + description: Project role created successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/Role' + x-oaiMeta: + name: Create project role + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/projects/proj_abc123/roles \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "role_name": "API Project Key Manager", + "permissions": [ + "api.organization.projects.api_keys.read", + "api.organization.projects.api_keys.write" + ], + "description": "Allows managing API keys for the project" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const role = await client.admin.organization.projects.roles.create('project_id', { + permissions: ['string'], + role_name: 'role_name', + }); + + console.log(role.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + role = client.admin.organization.projects.roles.create( + project_id="project_id", + permissions=["string"], + role_name="role_name", + ) + print(role.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\trole, err := client.Admin.Organization.Projects.Roles.New(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\topenai.AdminOrganizationProjectRoleNewParams{\n\t\t\tPermissions: []string{\"string\"},\n\t\t\tRoleName: \"role_name\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", role.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.roles.RoleCreateParams; + import com.openai.models.admin.organization.roles.Role; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RoleCreateParams params = RoleCreateParams.builder() + .projectId("project_id") + .addPermission("string") + .roleName("role_name") + .build(); + Role role = client.admin().organization().projects().roles().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + role = openai.admin.organization.projects.roles.create( + "project_id", + permissions: ["string"], + role_name: "role_name" + ) + + puts(role) + response: | + { + "object": "role", + "id": "role_01J1F8PROJ", + "name": "API Project Key Manager", + "description": "Allows managing API keys for the project", + "permissions": [ + "api.organization.projects.api_keys.read", + "api.organization.projects.api_keys.write" + ], + "resource_type": "api.project", + "predefined_role": false + } + /projects/{project_id}/roles/{role_id}: + post: + security: + - AdminApiKeyAuth: [] + summary: Updates an existing project role. + operationId: update-project-role + tags: + - Roles + parameters: + - name: project_id + in: path + description: The ID of the project to update. + required: true + schema: + type: string + - name: role_id + in: path + description: The ID of the role to update. + required: true + schema: + type: string + requestBody: + description: Fields to update on the project role. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PublicUpdateOrganizationRoleBody' + responses: + '200': + description: Project role updated successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/Role' + x-oaiMeta: + name: Update project role + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/projects/proj_abc123/roles/role_01J1F8PROJ \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "role_name": "API Project Key Manager", + "permissions": [ + "api.organization.projects.api_keys.read", + "api.organization.projects.api_keys.write" + ], + "description": "Allows managing API keys for the project" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const role = await client.admin.organization.projects.roles.update('role_id', { + project_id: 'project_id', + }); + + console.log(role.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + role = client.admin.organization.projects.roles.update( + role_id="role_id", + project_id="project_id", + ) + print(role.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\trole, err := client.Admin.Organization.Projects.Roles.Update(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\t\"role_id\",\n\t\topenai.AdminOrganizationProjectRoleUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", role.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.roles.RoleUpdateParams; + import com.openai.models.admin.organization.roles.Role; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RoleUpdateParams params = RoleUpdateParams.builder() + .projectId("project_id") + .roleId("role_id") + .build(); + Role role = client.admin().organization().projects().roles().update(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + role = openai.admin.organization.projects.roles.update("role_id", project_id: "project_id") + + puts(role) + response: | + { + "object": "role", + "id": "role_01J1F8PROJ", + "name": "API Project Key Manager", + "description": "Allows managing API keys for the project", + "permissions": [ + "api.organization.projects.api_keys.read", + "api.organization.projects.api_keys.write" + ], + "resource_type": "api.project", + "predefined_role": false + } + delete: + security: + - AdminApiKeyAuth: [] + summary: Deletes a custom role from a project. + operationId: delete-project-role + tags: + - Roles + parameters: + - name: project_id + in: path + description: The ID of the project to update. + required: true + schema: + type: string + - name: role_id + in: path + description: The ID of the role to delete. + required: true + schema: + type: string + responses: + '200': + description: Project role deleted successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/RoleDeletedResource' + x-oaiMeta: + name: Delete project role + group: administration + examples: + request: + curl: | + curl -X DELETE https://api.openai.com/v1/projects/proj_abc123/roles/role_01J1F8PROJ \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const role = await client.admin.organization.projects.roles.delete('role_id', { + project_id: 'project_id', + }); + + console.log(role.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + role = client.admin.organization.projects.roles.delete( + role_id="role_id", + project_id="project_id", + ) + print(role.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\trole, err := client.Admin.Organization.Projects.Roles.Delete(\n\t\tcontext.TODO(),\n\t\t\"project_id\",\n\t\t\"role_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", role.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.projects.roles.RoleDeleteParams; + import com.openai.models.admin.organization.projects.roles.RoleDeleteResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RoleDeleteParams params = RoleDeleteParams.builder() + .projectId("project_id") + .roleId("role_id") + .build(); + RoleDeleteResponse role = client.admin().organization().projects().roles().delete(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + role = openai.admin.organization.projects.roles.delete("role_id", project_id: "project_id") + + puts(role) + response: | + { + "object": "role.deleted", + "id": "role_01J1F8PROJ", + "deleted": true + } +components: + schemas: + PublicRoleListResource: + type: object + description: Paginated list of roles available on an organization or project. + properties: + object: + type: string + enum: + - list + description: Always `list`. + x-stainless-const: true + data: + type: array + description: Roles returned in the current page. + items: + $ref: '#/components/schemas/Role' + has_more: + type: boolean + description: Whether more roles are available when paginating. + next: + description: Cursor to fetch the next page of results, or `null` when there are no additional roles. + type: string + required: + - object + - data + - has_more + - next + x-oaiMeta: + name: Role list + example: | + { + "object": "list", + "data": [ + { + "object": "role", + "id": "role_01J1F8ROLE01", + "name": "API Group Manager", + "description": "Allows managing organization groups", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "resource_type": "api.organization", + "predefined_role": false + } + ], + "has_more": false, + "next": null + } + PublicCreateOrganizationRoleBody: + type: object + description: Request payload for creating a custom role. + properties: + role_name: + type: string + description: Unique name for the role. + permissions: + type: array + description: Permissions to grant to the role. + items: + type: string + description: + description: Optional description of the role. + type: string + required: + - role_name + - permissions + x-oaiMeta: + example: | + { + "role_name": "API Group Manager", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "description": "Allows managing organization groups" + } + Role: + type: object + description: Details about a role that can be assigned through the public Roles API. + properties: + object: + type: string + enum: + - role + description: Always `role`. + x-stainless-const: true + id: + type: string + description: Identifier for the role. + name: + type: string + description: Unique name for the role. + description: + description: Optional description of the role. + type: string + permissions: + type: array + description: Permissions granted by the role. + items: + type: string + resource_type: + type: string + description: Resource type the role is bound to (for example `api.organization` or `api.project`). + predefined_role: + type: boolean + description: Whether the role is predefined and managed by OpenAI. + required: + - object + - id + - name + - description + - permissions + - resource_type + - predefined_role + x-oaiMeta: + name: The role object + example: | + { + "object": "role", + "id": "role_01J1F8ROLE01", + "name": "API Group Manager", + "description": "Allows managing organization groups", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "resource_type": "api.organization", + "predefined_role": false + } + PublicUpdateOrganizationRoleBody: + type: object + description: Request payload for updating an existing role. + properties: + permissions: + description: Updated set of permissions for the role. + type: array + items: + type: string + description: + description: New description for the role. + type: string + role_name: + description: New name for the role. + type: string + x-oaiMeta: + example: | + { + "role_name": "API Group Manager", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "description": "Allows managing organization groups" + } + RoleDeletedResource: + type: object + description: Confirmation payload returned after deleting a role. + properties: + object: + type: string + enum: + - role.deleted + description: Always `role.deleted`. + x-stainless-const: true + id: + type: string + description: Identifier of the deleted role. + deleted: + type: boolean + description: Whether the role was deleted. + required: + - object + - id + - deleted + x-oaiMeta: + name: Role deletion confirmation + example: | + { + "object": "role.deleted", + "id": "role_01J1F8ROLE01", + "deleted": true + } + x-stackQL-resources: + roles: + id: openai_admin.roles.roles + name: roles + title: Roles + methods: + list: + operation: + $ref: '#/paths/~1organization~1roles/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1roles/post' + response: + mediaType: application/json + openAPIDocKey: '200' + update: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1roles~1{role_id}/post' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1organization~1roles~1{role_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/roles/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/roles/methods/create' + update: + - $ref: '#/components/x-stackQL-resources/roles/methods/update' + delete: + - $ref: '#/components/x-stackQL-resources/roles/methods/delete' + replace: [] + project_roles: + id: openai_admin.roles.project_roles + name: project_roles + title: Project Roles + methods: + list: + operation: + $ref: '#/paths/~1projects~1{project_id}~1roles/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + create: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1projects~1{project_id}~1roles/post' + response: + mediaType: application/json + openAPIDocKey: '200' + update: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1projects~1{project_id}~1roles~1{role_id}/post' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1projects~1{project_id}~1roles~1{role_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/project_roles/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/project_roles/methods/create' + update: + - $ref: '#/components/x-stackQL-resources/project_roles/methods/update' + delete: + - $ref: '#/components/x-stackQL-resources/project_roles/methods/delete' + replace: [] +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.next + location: body diff --git a/providers/src/openai_admin/v00.00.00000/services/usage.yaml b/providers/src/openai_admin/v00.00.00000/services/usage.yaml new file mode 100644 index 00000000..fe82d003 --- /dev/null +++ b/providers/src/openai_admin/v00.00.00000/services/usage.yaml @@ -0,0 +1,2053 @@ +openapi: 3.1.0 +info: + title: usage API + description: openai_admin API + version: 2.3.0 +paths: + /organization/usage/audio_speeches: + get: + security: + - AdminApiKeyAuth: [] + summary: Get audio speeches usage details for the organization. + operationId: usage-audio-speeches + tags: + - Usage + parameters: + - name: start_time + in: query + description: Start time (Unix seconds) of the query time range, inclusive. + required: true + schema: + type: integer + - name: end_time + in: query + description: End time (Unix seconds) of the query time range, exclusive. + required: false + schema: + type: integer + - name: bucket_width + in: query + description: Width of each time bucket in response. Currently `1m`, `1h` and `1d` are supported, default to `1d`. + required: false + schema: + type: string + enum: + - 1m + - 1h + - 1d + default: 1d + - name: project_ids + in: query + description: Return only usage for these projects. + required: false + schema: + type: array + items: + type: string + - name: user_ids + in: query + description: Return only usage for these users. + required: false + schema: + type: array + items: + type: string + - name: api_key_ids + in: query + description: Return only usage for these API keys. + required: false + schema: + type: array + items: + type: string + - name: models + in: query + description: Return only usage for these models. + required: false + schema: + type: array + items: + type: string + - name: group_by + in: query + description: Group the usage data by the specified fields. Support fields include `project_id`, `user_id`, `api_key_id`, `model` or any combination of them. + required: false + schema: + type: array + items: + type: string + enum: + - project_id + - user_id + - api_key_id + - model + - name: limit + in: query + description: | + Specifies the number of buckets to return. + - `bucket_width=1d`: default: 7, max: 31 + - `bucket_width=1h`: default: 24, max: 168 + - `bucket_width=1m`: default: 60, max: 1440 + required: false + schema: + type: integer + - name: page + in: query + description: A cursor for use in pagination. Corresponding to the `next_page` field from the previous response. + schema: + type: string + responses: + '200': + description: Usage data retrieved successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/UsageResponse' + x-oaiMeta: + name: Audio speeches + group: usage-audio-speeches + examples: + request: + curl: | + curl "https://api.openai.com/v1/organization/usage/audio_speeches?start_time=1730419200&limit=1" \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const response = await client.admin.organization.usage.audioSpeeches({ start_time: 0 }); + + console.log(response.data); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + response = client.admin.organization.usage.audio_speeches( + start_time=0, + ) + print(response.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tresponse, err := client.Admin.Organization.Usage.AudioSpeeches(context.TODO(), openai.AdminOrganizationUsageAudioSpeechesParams{\n\t\tStartTime: 0,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.usage.UsageAudioSpeechesParams; + import com.openai.models.admin.organization.usage.UsageAudioSpeechesResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UsageAudioSpeechesParams params = UsageAudioSpeechesParams.builder() + .startTime(0L) + .build(); + UsageAudioSpeechesResponse response = client.admin().organization().usage().audioSpeeches(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + response = openai.admin.organization.usage.audio_speeches(start_time: 0) + + puts(response) + response: | + { + "object": "page", + "data": [ + { + "object": "bucket", + "start_time": 1730419200, + "end_time": 1730505600, + "results": [ + { + "object": "organization.usage.audio_speeches.result", + "characters": 45, + "num_model_requests": 1, + "project_id": null, + "user_id": null, + "api_key_id": null, + "model": null + } + ] + } + ], + "has_more": false, + "next_page": null + } + /organization/usage/audio_transcriptions: + get: + security: + - AdminApiKeyAuth: [] + summary: Get audio transcriptions usage details for the organization. + operationId: usage-audio-transcriptions + tags: + - Usage + parameters: + - name: start_time + in: query + description: Start time (Unix seconds) of the query time range, inclusive. + required: true + schema: + type: integer + - name: end_time + in: query + description: End time (Unix seconds) of the query time range, exclusive. + required: false + schema: + type: integer + - name: bucket_width + in: query + description: Width of each time bucket in response. Currently `1m`, `1h` and `1d` are supported, default to `1d`. + required: false + schema: + type: string + enum: + - 1m + - 1h + - 1d + default: 1d + - name: project_ids + in: query + description: Return only usage for these projects. + required: false + schema: + type: array + items: + type: string + - name: user_ids + in: query + description: Return only usage for these users. + required: false + schema: + type: array + items: + type: string + - name: api_key_ids + in: query + description: Return only usage for these API keys. + required: false + schema: + type: array + items: + type: string + - name: models + in: query + description: Return only usage for these models. + required: false + schema: + type: array + items: + type: string + - name: group_by + in: query + description: Group the usage data by the specified fields. Support fields include `project_id`, `user_id`, `api_key_id`, `model` or any combination of them. + required: false + schema: + type: array + items: + type: string + enum: + - project_id + - user_id + - api_key_id + - model + - name: limit + in: query + description: | + Specifies the number of buckets to return. + - `bucket_width=1d`: default: 7, max: 31 + - `bucket_width=1h`: default: 24, max: 168 + - `bucket_width=1m`: default: 60, max: 1440 + required: false + schema: + type: integer + - name: page + in: query + description: A cursor for use in pagination. Corresponding to the `next_page` field from the previous response. + schema: + type: string + responses: + '200': + description: Usage data retrieved successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/UsageResponse' + x-oaiMeta: + name: Audio transcriptions + group: usage-audio-transcriptions + examples: + request: + curl: | + curl "https://api.openai.com/v1/organization/usage/audio_transcriptions?start_time=1730419200&limit=1" \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const response = await client.admin.organization.usage.audioTranscriptions({ start_time: 0 }); + + console.log(response.data); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + response = client.admin.organization.usage.audio_transcriptions( + start_time=0, + ) + print(response.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tresponse, err := client.Admin.Organization.Usage.AudioTranscriptions(context.TODO(), openai.AdminOrganizationUsageAudioTranscriptionsParams{\n\t\tStartTime: 0,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.usage.UsageAudioTranscriptionsParams; + import com.openai.models.admin.organization.usage.UsageAudioTranscriptionsResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UsageAudioTranscriptionsParams params = UsageAudioTranscriptionsParams.builder() + .startTime(0L) + .build(); + UsageAudioTranscriptionsResponse response = client.admin().organization().usage().audioTranscriptions(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + response = openai.admin.organization.usage.audio_transcriptions(start_time: 0) + + puts(response) + response: | + { + "object": "page", + "data": [ + { + "object": "bucket", + "start_time": 1730419200, + "end_time": 1730505600, + "results": [ + { + "object": "organization.usage.audio_transcriptions.result", + "seconds": 20, + "num_model_requests": 1, + "project_id": null, + "user_id": null, + "api_key_id": null, + "model": null + } + ] + } + ], + "has_more": false, + "next_page": null + } + /organization/usage/code_interpreter_sessions: + get: + security: + - AdminApiKeyAuth: [] + summary: Get code interpreter sessions usage details for the organization. + operationId: usage-code-interpreter-sessions + tags: + - Usage + parameters: + - name: start_time + in: query + description: Start time (Unix seconds) of the query time range, inclusive. + required: true + schema: + type: integer + - name: end_time + in: query + description: End time (Unix seconds) of the query time range, exclusive. + required: false + schema: + type: integer + - name: bucket_width + in: query + description: Width of each time bucket in response. Currently `1m`, `1h` and `1d` are supported, default to `1d`. + required: false + schema: + type: string + enum: + - 1m + - 1h + - 1d + default: 1d + - name: project_ids + in: query + description: Return only usage for these projects. + required: false + schema: + type: array + items: + type: string + - name: group_by + in: query + description: Group the usage data by the specified fields. Support fields include `project_id`. + required: false + schema: + type: array + items: + type: string + enum: + - project_id + - name: limit + in: query + description: | + Specifies the number of buckets to return. + - `bucket_width=1d`: default: 7, max: 31 + - `bucket_width=1h`: default: 24, max: 168 + - `bucket_width=1m`: default: 60, max: 1440 + required: false + schema: + type: integer + - name: page + in: query + description: A cursor for use in pagination. Corresponding to the `next_page` field from the previous response. + schema: + type: string + responses: + '200': + description: Usage data retrieved successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/UsageResponse' + x-oaiMeta: + name: Code interpreter sessions + group: usage-code-interpreter-sessions + examples: + request: + curl: | + curl "https://api.openai.com/v1/organization/usage/code_interpreter_sessions?start_time=1730419200&limit=1" \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const response = await client.admin.organization.usage.codeInterpreterSessions({ start_time: 0 }); + + console.log(response.data); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + response = client.admin.organization.usage.code_interpreter_sessions( + start_time=0, + ) + print(response.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tresponse, err := client.Admin.Organization.Usage.CodeInterpreterSessions(context.TODO(), openai.AdminOrganizationUsageCodeInterpreterSessionsParams{\n\t\tStartTime: 0,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.usage.UsageCodeInterpreterSessionsParams; + import com.openai.models.admin.organization.usage.UsageCodeInterpreterSessionsResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UsageCodeInterpreterSessionsParams params = UsageCodeInterpreterSessionsParams.builder() + .startTime(0L) + .build(); + UsageCodeInterpreterSessionsResponse response = client.admin().organization().usage().codeInterpreterSessions(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + response = openai.admin.organization.usage.code_interpreter_sessions(start_time: 0) + + puts(response) + response: | + { + "object": "page", + "data": [ + { + "object": "bucket", + "start_time": 1730419200, + "end_time": 1730505600, + "results": [ + { + "object": "organization.usage.code_interpreter_sessions.result", + "num_sessions": 1, + "project_id": null + } + ] + } + ], + "has_more": false, + "next_page": null + } + /organization/usage/completions: + get: + security: + - AdminApiKeyAuth: [] + summary: Get completions usage details for the organization. + operationId: usage-completions + tags: + - Usage + parameters: + - name: start_time + in: query + description: Start time (Unix seconds) of the query time range, inclusive. + required: true + schema: + type: integer + - name: end_time + in: query + description: End time (Unix seconds) of the query time range, exclusive. + required: false + schema: + type: integer + - name: bucket_width + in: query + description: Width of each time bucket in response. Currently `1m`, `1h` and `1d` are supported, default to `1d`. + required: false + schema: + type: string + enum: + - 1m + - 1h + - 1d + default: 1d + - name: project_ids + in: query + description: Return only usage for these projects. + required: false + schema: + type: array + items: + type: string + - name: user_ids + in: query + description: Return only usage for these users. + required: false + schema: + type: array + items: + type: string + - name: api_key_ids + in: query + description: Return only usage for these API keys. + required: false + schema: + type: array + items: + type: string + - name: models + in: query + description: Return only usage for these models. + required: false + schema: + type: array + items: + type: string + - name: batch + in: query + description: | + If `true`, return batch jobs only. If `false`, return non-batch jobs only. By default, return both. + required: false + schema: + type: boolean + - name: group_by + in: query + description: Group the usage data by the specified fields. Support fields include `project_id`, `user_id`, `api_key_id`, `model`, `batch`, `service_tier` or any combination of them. + required: false + schema: + type: array + items: + type: string + enum: + - project_id + - user_id + - api_key_id + - model + - batch + - service_tier + - name: limit + in: query + description: | + Specifies the number of buckets to return. + - `bucket_width=1d`: default: 7, max: 31 + - `bucket_width=1h`: default: 24, max: 168 + - `bucket_width=1m`: default: 60, max: 1440 + required: false + schema: + type: integer + - name: page + in: query + description: A cursor for use in pagination. Corresponding to the `next_page` field from the previous response. + schema: + type: string + responses: + '200': + description: Usage data retrieved successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/UsageResponse' + x-oaiMeta: + name: Completions + group: usage-completions + examples: + request: + curl: | + curl "https://api.openai.com/v1/organization/usage/completions?start_time=1730419200&limit=1" \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const response = await client.admin.organization.usage.completions({ start_time: 0 }); + + console.log(response.data); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + response = client.admin.organization.usage.completions( + start_time=0, + ) + print(response.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tresponse, err := client.Admin.Organization.Usage.Completions(context.TODO(), openai.AdminOrganizationUsageCompletionsParams{\n\t\tStartTime: 0,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.usage.UsageCompletionsParams; + import com.openai.models.admin.organization.usage.UsageCompletionsResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UsageCompletionsParams params = UsageCompletionsParams.builder() + .startTime(0L) + .build(); + UsageCompletionsResponse response = client.admin().organization().usage().completions(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + response = openai.admin.organization.usage.completions(start_time: 0) + + puts(response) + response: | + { + "object": "page", + "data": [ + { + "object": "bucket", + "start_time": 1730419200, + "end_time": 1730505600, + "results": [ + { + "object": "organization.usage.completions.result", + "input_tokens": 1000, + "output_tokens": 500, + "input_cached_tokens": 800, + "input_audio_tokens": 0, + "output_audio_tokens": 0, + "num_model_requests": 5, + "project_id": null, + "user_id": null, + "api_key_id": null, + "model": null, + "batch": null, + "service_tier": null + } + ] + } + ], + "has_more": true, + "next_page": "page_AAAAAGdGxdEiJdKOAAAAAGcqsYA=" + } + /organization/usage/embeddings: + get: + security: + - AdminApiKeyAuth: [] + summary: Get embeddings usage details for the organization. + operationId: usage-embeddings + tags: + - Usage + parameters: + - name: start_time + in: query + description: Start time (Unix seconds) of the query time range, inclusive. + required: true + schema: + type: integer + - name: end_time + in: query + description: End time (Unix seconds) of the query time range, exclusive. + required: false + schema: + type: integer + - name: bucket_width + in: query + description: Width of each time bucket in response. Currently `1m`, `1h` and `1d` are supported, default to `1d`. + required: false + schema: + type: string + enum: + - 1m + - 1h + - 1d + default: 1d + - name: project_ids + in: query + description: Return only usage for these projects. + required: false + schema: + type: array + items: + type: string + - name: user_ids + in: query + description: Return only usage for these users. + required: false + schema: + type: array + items: + type: string + - name: api_key_ids + in: query + description: Return only usage for these API keys. + required: false + schema: + type: array + items: + type: string + - name: models + in: query + description: Return only usage for these models. + required: false + schema: + type: array + items: + type: string + - name: group_by + in: query + description: Group the usage data by the specified fields. Support fields include `project_id`, `user_id`, `api_key_id`, `model` or any combination of them. + required: false + schema: + type: array + items: + type: string + enum: + - project_id + - user_id + - api_key_id + - model + - name: limit + in: query + description: | + Specifies the number of buckets to return. + - `bucket_width=1d`: default: 7, max: 31 + - `bucket_width=1h`: default: 24, max: 168 + - `bucket_width=1m`: default: 60, max: 1440 + required: false + schema: + type: integer + - name: page + in: query + description: A cursor for use in pagination. Corresponding to the `next_page` field from the previous response. + schema: + type: string + responses: + '200': + description: Usage data retrieved successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/UsageResponse' + x-oaiMeta: + name: Embeddings + group: usage-embeddings + examples: + request: + curl: | + curl "https://api.openai.com/v1/organization/usage/embeddings?start_time=1730419200&limit=1" \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const response = await client.admin.organization.usage.embeddings({ start_time: 0 }); + + console.log(response.data); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + response = client.admin.organization.usage.embeddings( + start_time=0, + ) + print(response.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tresponse, err := client.Admin.Organization.Usage.Embeddings(context.TODO(), openai.AdminOrganizationUsageEmbeddingsParams{\n\t\tStartTime: 0,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.usage.UsageEmbeddingsParams; + import com.openai.models.admin.organization.usage.UsageEmbeddingsResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UsageEmbeddingsParams params = UsageEmbeddingsParams.builder() + .startTime(0L) + .build(); + UsageEmbeddingsResponse response = client.admin().organization().usage().embeddings(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + response = openai.admin.organization.usage.embeddings(start_time: 0) + + puts(response) + response: | + { + "object": "page", + "data": [ + { + "object": "bucket", + "start_time": 1730419200, + "end_time": 1730505600, + "results": [ + { + "object": "organization.usage.embeddings.result", + "input_tokens": 16, + "num_model_requests": 2, + "project_id": null, + "user_id": null, + "api_key_id": null, + "model": null + } + ] + } + ], + "has_more": false, + "next_page": null + } + /organization/usage/images: + get: + security: + - AdminApiKeyAuth: [] + summary: Get images usage details for the organization. + operationId: usage-images + tags: + - Usage + parameters: + - name: start_time + in: query + description: Start time (Unix seconds) of the query time range, inclusive. + required: true + schema: + type: integer + - name: end_time + in: query + description: End time (Unix seconds) of the query time range, exclusive. + required: false + schema: + type: integer + - name: bucket_width + in: query + description: Width of each time bucket in response. Currently `1m`, `1h` and `1d` are supported, default to `1d`. + required: false + schema: + type: string + enum: + - 1m + - 1h + - 1d + default: 1d + - name: sources + in: query + description: Return only usages for these sources. Possible values are `image.generation`, `image.edit`, `image.variation` or any combination of them. + required: false + schema: + type: array + items: + type: string + enum: + - image.generation + - image.edit + - image.variation + - name: sizes + in: query + description: Return only usages for these image sizes. Possible values are `256x256`, `512x512`, `1024x1024`, `1792x1792`, `1024x1792` or any combination of them. + required: false + schema: + type: array + items: + type: string + enum: + - 256x256 + - 512x512 + - 1024x1024 + - 1792x1792 + - 1024x1792 + - name: project_ids + in: query + description: Return only usage for these projects. + required: false + schema: + type: array + items: + type: string + - name: user_ids + in: query + description: Return only usage for these users. + required: false + schema: + type: array + items: + type: string + - name: api_key_ids + in: query + description: Return only usage for these API keys. + required: false + schema: + type: array + items: + type: string + - name: models + in: query + description: Return only usage for these models. + required: false + schema: + type: array + items: + type: string + - name: group_by + in: query + description: Group the usage data by the specified fields. Support fields include `project_id`, `user_id`, `api_key_id`, `model`, `size`, `source` or any combination of them. + required: false + schema: + type: array + items: + type: string + enum: + - project_id + - user_id + - api_key_id + - model + - size + - source + - name: limit + in: query + description: | + Specifies the number of buckets to return. + - `bucket_width=1d`: default: 7, max: 31 + - `bucket_width=1h`: default: 24, max: 168 + - `bucket_width=1m`: default: 60, max: 1440 + required: false + schema: + type: integer + - name: page + in: query + description: A cursor for use in pagination. Corresponding to the `next_page` field from the previous response. + schema: + type: string + responses: + '200': + description: Usage data retrieved successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/UsageResponse' + x-oaiMeta: + name: Images + group: usage-images + examples: + request: + curl: | + curl "https://api.openai.com/v1/organization/usage/images?start_time=1730419200&limit=1" \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const response = await client.admin.organization.usage.images({ start_time: 0 }); + + console.log(response.data); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + response = client.admin.organization.usage.images( + start_time=0, + ) + print(response.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tresponse, err := client.Admin.Organization.Usage.Images(context.TODO(), openai.AdminOrganizationUsageImagesParams{\n\t\tStartTime: 0,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.usage.UsageImagesParams; + import com.openai.models.admin.organization.usage.UsageImagesResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UsageImagesParams params = UsageImagesParams.builder() + .startTime(0L) + .build(); + UsageImagesResponse response = client.admin().organization().usage().images(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + response = openai.admin.organization.usage.images(start_time: 0) + + puts(response) + response: | + { + "object": "page", + "data": [ + { + "object": "bucket", + "start_time": 1730419200, + "end_time": 1730505600, + "results": [ + { + "object": "organization.usage.images.result", + "images": 2, + "num_model_requests": 2, + "size": null, + "source": null, + "project_id": null, + "user_id": null, + "api_key_id": null, + "model": null + } + ] + } + ], + "has_more": false, + "next_page": null + } + /organization/usage/moderations: + get: + security: + - AdminApiKeyAuth: [] + summary: Get moderations usage details for the organization. + operationId: usage-moderations + tags: + - Usage + parameters: + - name: start_time + in: query + description: Start time (Unix seconds) of the query time range, inclusive. + required: true + schema: + type: integer + - name: end_time + in: query + description: End time (Unix seconds) of the query time range, exclusive. + required: false + schema: + type: integer + - name: bucket_width + in: query + description: Width of each time bucket in response. Currently `1m`, `1h` and `1d` are supported, default to `1d`. + required: false + schema: + type: string + enum: + - 1m + - 1h + - 1d + default: 1d + - name: project_ids + in: query + description: Return only usage for these projects. + required: false + schema: + type: array + items: + type: string + - name: user_ids + in: query + description: Return only usage for these users. + required: false + schema: + type: array + items: + type: string + - name: api_key_ids + in: query + description: Return only usage for these API keys. + required: false + schema: + type: array + items: + type: string + - name: models + in: query + description: Return only usage for these models. + required: false + schema: + type: array + items: + type: string + - name: group_by + in: query + description: Group the usage data by the specified fields. Support fields include `project_id`, `user_id`, `api_key_id`, `model` or any combination of them. + required: false + schema: + type: array + items: + type: string + enum: + - project_id + - user_id + - api_key_id + - model + - name: limit + in: query + description: | + Specifies the number of buckets to return. + - `bucket_width=1d`: default: 7, max: 31 + - `bucket_width=1h`: default: 24, max: 168 + - `bucket_width=1m`: default: 60, max: 1440 + required: false + schema: + type: integer + - name: page + in: query + description: A cursor for use in pagination. Corresponding to the `next_page` field from the previous response. + schema: + type: string + responses: + '200': + description: Usage data retrieved successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/UsageResponse' + x-oaiMeta: + name: Moderations + group: usage-moderations + examples: + request: + curl: | + curl "https://api.openai.com/v1/organization/usage/moderations?start_time=1730419200&limit=1" \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const response = await client.admin.organization.usage.moderations({ start_time: 0 }); + + console.log(response.data); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + response = client.admin.organization.usage.moderations( + start_time=0, + ) + print(response.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tresponse, err := client.Admin.Organization.Usage.Moderations(context.TODO(), openai.AdminOrganizationUsageModerationsParams{\n\t\tStartTime: 0,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.usage.UsageModerationsParams; + import com.openai.models.admin.organization.usage.UsageModerationsResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UsageModerationsParams params = UsageModerationsParams.builder() + .startTime(0L) + .build(); + UsageModerationsResponse response = client.admin().organization().usage().moderations(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + response = openai.admin.organization.usage.moderations(start_time: 0) + + puts(response) + response: | + { + "object": "page", + "data": [ + { + "object": "bucket", + "start_time": 1730419200, + "end_time": 1730505600, + "results": [ + { + "object": "organization.usage.moderations.result", + "input_tokens": 16, + "num_model_requests": 2, + "project_id": null, + "user_id": null, + "api_key_id": null, + "model": null + } + ] + } + ], + "has_more": false, + "next_page": null + } + /organization/usage/vector_stores: + get: + security: + - AdminApiKeyAuth: [] + summary: Get vector stores usage details for the organization. + operationId: usage-vector-stores + tags: + - Usage + parameters: + - name: start_time + in: query + description: Start time (Unix seconds) of the query time range, inclusive. + required: true + schema: + type: integer + - name: end_time + in: query + description: End time (Unix seconds) of the query time range, exclusive. + required: false + schema: + type: integer + - name: bucket_width + in: query + description: Width of each time bucket in response. Currently `1m`, `1h` and `1d` are supported, default to `1d`. + required: false + schema: + type: string + enum: + - 1m + - 1h + - 1d + default: 1d + - name: project_ids + in: query + description: Return only usage for these projects. + required: false + schema: + type: array + items: + type: string + - name: group_by + in: query + description: Group the usage data by the specified fields. Support fields include `project_id`. + required: false + schema: + type: array + items: + type: string + enum: + - project_id + - name: limit + in: query + description: | + Specifies the number of buckets to return. + - `bucket_width=1d`: default: 7, max: 31 + - `bucket_width=1h`: default: 24, max: 168 + - `bucket_width=1m`: default: 60, max: 1440 + required: false + schema: + type: integer + - name: page + in: query + description: A cursor for use in pagination. Corresponding to the `next_page` field from the previous response. + schema: + type: string + responses: + '200': + description: Usage data retrieved successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/UsageResponse' + x-oaiMeta: + name: Vector stores + group: usage-vector-stores + examples: + request: + curl: | + curl "https://api.openai.com/v1/organization/usage/vector_stores?start_time=1730419200&limit=1" \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const response = await client.admin.organization.usage.vectorStores({ start_time: 0 }); + + console.log(response.data); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + response = client.admin.organization.usage.vector_stores( + start_time=0, + ) + print(response.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tresponse, err := client.Admin.Organization.Usage.VectorStores(context.TODO(), openai.AdminOrganizationUsageVectorStoresParams{\n\t\tStartTime: 0,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.usage.UsageVectorStoresParams; + import com.openai.models.admin.organization.usage.UsageVectorStoresResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UsageVectorStoresParams params = UsageVectorStoresParams.builder() + .startTime(0L) + .build(); + UsageVectorStoresResponse response = client.admin().organization().usage().vectorStores(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + response = openai.admin.organization.usage.vector_stores(start_time: 0) + + puts(response) + response: | + { + "object": "page", + "data": [ + { + "object": "bucket", + "start_time": 1730419200, + "end_time": 1730505600, + "results": [ + { + "object": "organization.usage.vector_stores.result", + "usage_bytes": 1024, + "project_id": null + } + ] + } + ], + "has_more": false, + "next_page": null + } +components: + schemas: + UsageResponse: + type: object + properties: + object: + type: string + enum: + - page + x-stainless-const: true + data: + type: array + items: + $ref: '#/components/schemas/UsageTimeBucket' + has_more: + type: boolean + next_page: + type: string + required: + - object + - data + - has_more + - next_page + UsageTimeBucket: + type: object + properties: + object: + type: string + enum: + - bucket + x-stainless-const: true + start_time: + type: integer + end_time: + type: integer + results: + type: array + items: + oneOf: + - $ref: '#/components/schemas/UsageCompletionsResult' + - $ref: '#/components/schemas/UsageEmbeddingsResult' + - $ref: '#/components/schemas/UsageModerationsResult' + - $ref: '#/components/schemas/UsageImagesResult' + - $ref: '#/components/schemas/UsageAudioSpeechesResult' + - $ref: '#/components/schemas/UsageAudioTranscriptionsResult' + - $ref: '#/components/schemas/UsageVectorStoresResult' + - $ref: '#/components/schemas/UsageCodeInterpreterSessionsResult' + - $ref: '#/components/schemas/CostsResult' + discriminator: + propertyName: object + required: + - object + - start_time + - end_time + - results + UsageCompletionsResult: + type: object + description: The aggregated completions usage details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.usage.completions.result + x-stainless-const: true + input_tokens: + type: integer + description: The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens. + input_cached_tokens: + type: integer + description: The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens. + output_tokens: + type: integer + description: The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens. + input_audio_tokens: + type: integer + description: The aggregated number of audio input tokens used, including cached tokens. + output_audio_tokens: + type: integer + description: The aggregated number of audio output tokens used. + num_model_requests: + type: integer + description: The count of requests made to the model. + project_id: + type: string + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + user_id: + type: string + description: When `group_by=user_id`, this field provides the user ID of the grouped usage result. + api_key_id: + type: string + description: When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + model: + type: string + description: When `group_by=model`, this field provides the model name of the grouped usage result. + batch: + type: boolean + description: When `group_by=batch`, this field tells whether the grouped usage result is batch or not. + service_tier: + type: string + description: When `group_by=service_tier`, this field provides the service tier of the grouped usage result. + required: + - object + - input_tokens + - output_tokens + - num_model_requests + x-oaiMeta: + name: Completions usage object + example: | + { + "object": "organization.usage.completions.result", + "input_tokens": 5000, + "output_tokens": 1000, + "input_cached_tokens": 4000, + "input_audio_tokens": 300, + "output_audio_tokens": 200, + "num_model_requests": 5, + "project_id": "proj_abc", + "user_id": "user-abc", + "api_key_id": "key_abc", + "model": "gpt-4o-mini-2024-07-18", + "batch": false, + "service_tier": "default" + } + UsageEmbeddingsResult: + type: object + description: The aggregated embeddings usage details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.usage.embeddings.result + x-stainless-const: true + input_tokens: + type: integer + description: The aggregated number of input tokens used. + num_model_requests: + type: integer + description: The count of requests made to the model. + project_id: + type: string + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + user_id: + type: string + description: When `group_by=user_id`, this field provides the user ID of the grouped usage result. + api_key_id: + type: string + description: When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + model: + type: string + description: When `group_by=model`, this field provides the model name of the grouped usage result. + required: + - object + - input_tokens + - num_model_requests + x-oaiMeta: + name: Embeddings usage object + example: | + { + "object": "organization.usage.embeddings.result", + "input_tokens": 20, + "num_model_requests": 2, + "project_id": "proj_abc", + "user_id": "user-abc", + "api_key_id": "key_abc", + "model": "text-embedding-ada-002-v2" + } + UsageModerationsResult: + type: object + description: The aggregated moderations usage details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.usage.moderations.result + x-stainless-const: true + input_tokens: + type: integer + description: The aggregated number of input tokens used. + num_model_requests: + type: integer + description: The count of requests made to the model. + project_id: + type: string + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + user_id: + type: string + description: When `group_by=user_id`, this field provides the user ID of the grouped usage result. + api_key_id: + type: string + description: When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + model: + type: string + description: When `group_by=model`, this field provides the model name of the grouped usage result. + required: + - object + - input_tokens + - num_model_requests + x-oaiMeta: + name: Moderations usage object + example: | + { + "object": "organization.usage.moderations.result", + "input_tokens": 20, + "num_model_requests": 2, + "project_id": "proj_abc", + "user_id": "user-abc", + "api_key_id": "key_abc", + "model": "text-moderation" + } + UsageImagesResult: + type: object + description: The aggregated images usage details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.usage.images.result + x-stainless-const: true + images: + type: integer + description: The number of images processed. + num_model_requests: + type: integer + description: The count of requests made to the model. + source: + type: string + description: When `group_by=source`, this field provides the source of the grouped usage result, possible values are `image.generation`, `image.edit`, `image.variation`. + size: + type: string + description: When `group_by=size`, this field provides the image size of the grouped usage result. + project_id: + type: string + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + user_id: + type: string + description: When `group_by=user_id`, this field provides the user ID of the grouped usage result. + api_key_id: + type: string + description: When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + model: + type: string + description: When `group_by=model`, this field provides the model name of the grouped usage result. + required: + - object + - images + - num_model_requests + x-oaiMeta: + name: Images usage object + example: | + { + "object": "organization.usage.images.result", + "images": 2, + "num_model_requests": 2, + "size": "1024x1024", + "source": "image.generation", + "project_id": "proj_abc", + "user_id": "user-abc", + "api_key_id": "key_abc", + "model": "dall-e-3" + } + UsageAudioSpeechesResult: + type: object + description: The aggregated audio speeches usage details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.usage.audio_speeches.result + x-stainless-const: true + characters: + type: integer + description: The number of characters processed. + num_model_requests: + type: integer + description: The count of requests made to the model. + project_id: + type: string + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + user_id: + type: string + description: When `group_by=user_id`, this field provides the user ID of the grouped usage result. + api_key_id: + type: string + description: When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + model: + type: string + description: When `group_by=model`, this field provides the model name of the grouped usage result. + required: + - object + - characters + - num_model_requests + x-oaiMeta: + name: Audio speeches usage object + example: | + { + "object": "organization.usage.audio_speeches.result", + "characters": 45, + "num_model_requests": 1, + "project_id": "proj_abc", + "user_id": "user-abc", + "api_key_id": "key_abc", + "model": "tts-1" + } + UsageAudioTranscriptionsResult: + type: object + description: The aggregated audio transcriptions usage details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.usage.audio_transcriptions.result + x-stainless-const: true + seconds: + type: integer + format: int64 + description: The number of seconds processed. + num_model_requests: + type: integer + description: The count of requests made to the model. + project_id: + type: string + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + user_id: + type: string + description: When `group_by=user_id`, this field provides the user ID of the grouped usage result. + api_key_id: + type: string + description: When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + model: + type: string + description: When `group_by=model`, this field provides the model name of the grouped usage result. + required: + - object + - seconds + - num_model_requests + x-oaiMeta: + name: Audio transcriptions usage object + example: | + { + "object": "organization.usage.audio_transcriptions.result", + "seconds": 10, + "num_model_requests": 1, + "project_id": "proj_abc", + "user_id": "user-abc", + "api_key_id": "key_abc", + "model": "tts-1" + } + UsageVectorStoresResult: + type: object + description: The aggregated vector stores usage details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.usage.vector_stores.result + x-stainless-const: true + usage_bytes: + type: integer + description: The vector stores usage in bytes. + project_id: + type: string + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + required: + - object + - usage_bytes + x-oaiMeta: + name: Vector stores usage object + example: | + { + "object": "organization.usage.vector_stores.result", + "usage_bytes": 1024, + "project_id": "proj_abc" + } + UsageCodeInterpreterSessionsResult: + type: object + description: The aggregated code interpreter sessions usage details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.usage.code_interpreter_sessions.result + x-stainless-const: true + num_sessions: + type: integer + description: The number of code interpreter sessions. + project_id: + type: string + description: When `group_by=project_id`, this field provides the project ID of the grouped usage result. + required: + - object + - num_sessions + x-oaiMeta: + name: Code interpreter sessions usage object + example: | + { + "object": "organization.usage.code_interpreter_sessions.result", + "num_sessions": 1, + "project_id": "proj_abc" + } + CostsResult: + type: object + description: The aggregated costs details of the specific time bucket. + properties: + object: + type: string + enum: + - organization.costs.result + x-stainless-const: true + amount: + type: object + description: The monetary value in its associated currency. + properties: + value: + type: number + description: The numeric value of the cost. + currency: + type: string + description: Lowercase ISO-4217 currency e.g. "usd" + line_item: + type: string + description: When `group_by=line_item`, this field provides the line item of the grouped costs result. + project_id: + type: string + description: When `group_by=project_id`, this field provides the project ID of the grouped costs result. + api_key_id: + type: string + description: When `group_by=api_key_id`, this field provides the API Key ID of the grouped costs result. + quantity: + type: number + description: When `group_by=line_item`, this field provides the quantity of the grouped costs result. + required: + - object + x-oaiMeta: + name: Costs object + example: | + { + "object": "organization.costs.result", + "amount": { + "value": 0.06, + "currency": "usd" + }, + "line_item": "Image models", + "project_id": "proj_abc", + "quantity": 10000 + } + x-stackQL-resources: + audio_speeches: + id: openai_admin.usage.audio_speeches + name: audio_speeches + title: Audio Speeches + methods: + list: + operation: + $ref: '#/paths/~1organization~1usage~1audio_speeches/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/audio_speeches/methods/list' + insert: [] + update: [] + delete: [] + replace: [] + audio_transcriptions: + id: openai_admin.usage.audio_transcriptions + name: audio_transcriptions + title: Audio Transcriptions + methods: + list: + operation: + $ref: '#/paths/~1organization~1usage~1audio_transcriptions/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/audio_transcriptions/methods/list' + insert: [] + update: [] + delete: [] + replace: [] + code_interpreter_sessions: + id: openai_admin.usage.code_interpreter_sessions + name: code_interpreter_sessions + title: Code Interpreter Sessions + methods: + list: + operation: + $ref: '#/paths/~1organization~1usage~1code_interpreter_sessions/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/code_interpreter_sessions/methods/list' + insert: [] + update: [] + delete: [] + replace: [] + completions: + id: openai_admin.usage.completions + name: completions + title: Completions + methods: + list: + operation: + $ref: '#/paths/~1organization~1usage~1completions/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/completions/methods/list' + insert: [] + update: [] + delete: [] + replace: [] + embeddings: + id: openai_admin.usage.embeddings + name: embeddings + title: Embeddings + methods: + list: + operation: + $ref: '#/paths/~1organization~1usage~1embeddings/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/embeddings/methods/list' + insert: [] + update: [] + delete: [] + replace: [] + images: + id: openai_admin.usage.images + name: images + title: Images + methods: + list: + operation: + $ref: '#/paths/~1organization~1usage~1images/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/images/methods/list' + insert: [] + update: [] + delete: [] + replace: [] + moderations: + id: openai_admin.usage.moderations + name: moderations + title: Moderations + methods: + list: + operation: + $ref: '#/paths/~1organization~1usage~1moderations/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/moderations/methods/list' + insert: [] + update: [] + delete: [] + replace: [] + vector_stores: + id: openai_admin.usage.vector_stores + name: vector_stores + title: Vector Stores + methods: + list: + operation: + $ref: '#/paths/~1organization~1usage~1vector_stores/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/vector_stores/methods/list' + insert: [] + update: [] + delete: [] + replace: [] +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: page + location: query + responseToken: + key: $.next_page + location: body diff --git a/providers/src/openai_admin/v00.00.00000/services/users.yaml b/providers/src/openai_admin/v00.00.00000/services/users.yaml new file mode 100644 index 00000000..7bb4e3ec --- /dev/null +++ b/providers/src/openai_admin/v00.00.00000/services/users.yaml @@ -0,0 +1,1255 @@ +openapi: 3.1.0 +info: + title: users API + description: openai_admin API + version: 2.3.0 +paths: + /organization/users: + get: + security: + - AdminApiKeyAuth: [] + summary: Lists all of the users in the organization. + operationId: list-users + tags: + - Users + parameters: + - name: limit + in: query + description: | + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + required: false + schema: + type: integer + default: 20 + - name: after + in: query + 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. + required: false + schema: + type: string + - name: emails + in: query + description: Filter by the email address of users. + required: false + schema: + type: array + items: + type: string + responses: + '200': + description: Users listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/UserListResponse' + x-oaiMeta: + name: List users + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/users?after=user_abc&limit=20 \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const organizationUser of client.admin.organization.users.list()) { + console.log(organizationUser.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.users.list() + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Users.List(context.TODO(), openai.AdminOrganizationUserListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.users.UserListPage; + import com.openai.models.admin.organization.users.UserListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UserListPage page = client.admin().organization().users().list(); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.users.list + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "object": "organization.user", + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } + ], + "first_id": "user-abc", + "last_id": "user-xyz", + "has_more": false + } + /organization/users/{user_id}: + get: + security: + - AdminApiKeyAuth: [] + summary: Retrieves a user by their identifier. + operationId: retrieve-user + tags: + - Users + parameters: + - name: user_id + in: path + description: The ID of the user. + required: true + schema: + type: string + responses: + '200': + description: User retrieved successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/User' + x-oaiMeta: + name: Retrieve user + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/users/user_abc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const organizationUser = await client.admin.organization.users.retrieve('user_id'); + + console.log(organizationUser.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + organization_user = client.admin.organization.users.retrieve( + "user_id", + ) + print(organization_user.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\torganizationUser, err := client.Admin.Organization.Users.Get(context.TODO(), \"user_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", organizationUser.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.users.OrganizationUser; + import com.openai.models.admin.organization.users.UserRetrieveParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + OrganizationUser organizationUser = client.admin().organization().users().retrieve("user_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + organization_user = openai.admin.organization.users.retrieve("user_id") + + puts(organization_user) + response: | + { + "object": "organization.user", + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } + post: + security: + - AdminApiKeyAuth: [] + summary: Modifies a user's role in the organization. + operationId: modify-user + tags: + - Users + parameters: + - name: user_id + in: path + description: The ID of the user. + required: true + schema: + type: string + requestBody: + description: The new user role to modify. This must be one of `owner` or `member`. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UserRoleUpdateRequest' + responses: + '200': + description: User role updated successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/User' + x-oaiMeta: + name: Modify user + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/organization/users/user_abc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "role": "owner" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const organizationUser = await client.admin.organization.users.update('user_id'); + + console.log(organizationUser.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + organization_user = client.admin.organization.users.update( + user_id="user_id", + ) + print(organization_user.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\torganizationUser, err := client.Admin.Organization.Users.Update(\n\t\tcontext.TODO(),\n\t\t\"user_id\",\n\t\topenai.AdminOrganizationUserUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", organizationUser.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.users.OrganizationUser; + import com.openai.models.admin.organization.users.UserUpdateParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + OrganizationUser organizationUser = client.admin().organization().users().update("user_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + organization_user = openai.admin.organization.users.update("user_id") + + puts(organization_user) + response: | + { + "object": "organization.user", + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } + delete: + security: + - AdminApiKeyAuth: [] + summary: Deletes a user from the organization. + operationId: delete-user + tags: + - Users + parameters: + - name: user_id + in: path + description: The ID of the user. + required: true + schema: + type: string + responses: + '200': + description: User deleted successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/UserDeleteResponse' + x-oaiMeta: + name: Delete user + group: administration + examples: + request: + curl: | + curl -X DELETE https://api.openai.com/v1/organization/users/user_abc \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const user = await client.admin.organization.users.delete('user_id'); + + console.log(user.id); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + user = client.admin.organization.users.delete( + "user_id", + ) + print(user.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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tuser, err := client.Admin.Organization.Users.Delete(context.TODO(), \"user_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", user.ID)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.users.UserDeleteParams; + import com.openai.models.admin.organization.users.UserDeleteResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + UserDeleteResponse user = client.admin().organization().users().delete("user_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + user = openai.admin.organization.users.delete("user_id") + + puts(user) + response: | + { + "object": "organization.user.deleted", + "id": "user_abc", + "deleted": true + } + /organization/users/{user_id}/roles: + get: + security: + - AdminApiKeyAuth: [] + summary: Lists the organization roles assigned to a user within the organization. + operationId: list-user-role-assignments + tags: + - User organization role assignments + parameters: + - name: user_id + in: path + description: The ID of the user to inspect. + required: true + schema: + type: string + - name: limit + in: query + description: A limit on the number of organization role assignments to return. + required: false + schema: + type: integer + minimum: 0 + maximum: 1000 + - name: after + in: query + description: Cursor for pagination. Provide the value from the previous response's `next` field to continue listing organization roles. + required: false + schema: + type: string + - name: order + in: query + description: Sort order for the returned organization roles. + required: false + schema: + type: string + enum: + - asc + - desc + responses: + '200': + description: User organization role assignments listed successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/RoleListResource' + x-oaiMeta: + name: List user organization role assignments + group: administration + examples: + request: + curl: | + curl https://api.openai.com/v1/organization/users/user_abc123/roles \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + // Automatically fetches more pages as needed. + for await (const roleListResponse of client.admin.organization.users.roles.list('user_id')) { + console.log(roleListResponse.id); + } + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + page = client.admin.organization.users.roles.list( + user_id="user_id", + ) + page = page.data[0] + print(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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tpage, err := client.Admin.Organization.Users.Roles.List(\n\t\tcontext.TODO(),\n\t\t\"user_id\",\n\t\topenai.AdminOrganizationUserRoleListParams{},\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; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.users.roles.RoleListPage; + import com.openai.models.admin.organization.users.roles.RoleListParams; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RoleListPage page = client.admin().organization().users().roles().list("user_id"); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + page = openai.admin.organization.users.roles.list("user_id") + + puts(page) + response: | + { + "object": "list", + "data": [ + { + "id": "role_01J1F8ROLE01", + "name": "API Group Manager", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "resource_type": "api.organization", + "predefined_role": false, + "description": "Allows managing organization groups", + "created_at": 1711471533, + "updated_at": 1711472599, + "created_by": "user_abc123", + "created_by_user_obj": { + "id": "user_abc123", + "name": "Ada Lovelace", + "email": "ada@example.com" + }, + "metadata": {} + } + ], + "has_more": false, + "next": null + } + post: + security: + - AdminApiKeyAuth: [] + summary: Assigns an organization role to a user within the organization. + operationId: assign-user-role + tags: + - User organization role assignments + parameters: + - name: user_id + in: path + description: The ID of the user that should receive the organization role. + required: true + schema: + type: string + requestBody: + description: Identifies the organization role to assign to the user. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PublicAssignOrganizationGroupRoleBody' + responses: + '200': + description: Organization role assigned to the user successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/UserRoleAssignment' + x-oaiMeta: + name: Assign organization role to user + group: administration + examples: + request: + curl: | + curl -X POST https://api.openai.com/v1/organization/users/user_abc123/roles \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "role_id": "role_01J1F8ROLE01" + }' + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const role = await client.admin.organization.users.roles.create('user_id', { role_id: 'role_id' }); + + console.log(role.object); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + role = client.admin.organization.users.roles.create( + user_id="user_id", + role_id="role_id", + ) + print(role.object) + 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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\trole, err := client.Admin.Organization.Users.Roles.New(\n\t\tcontext.TODO(),\n\t\t\"user_id\",\n\t\topenai.AdminOrganizationUserRoleNewParams{\n\t\t\tRoleID: \"role_id\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", role.Object)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.users.roles.RoleCreateParams; + import com.openai.models.admin.organization.users.roles.RoleCreateResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RoleCreateParams params = RoleCreateParams.builder() + .userId("user_id") + .roleId("role_id") + .build(); + RoleCreateResponse role = client.admin().organization().users().roles().create(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + role = openai.admin.organization.users.roles.create("user_id", role_id: "role_id") + + puts(role) + response: | + { + "object": "user.role", + "user": { + "object": "organization.user", + "id": "user_abc123", + "name": "Ada Lovelace", + "email": "ada@example.com", + "role": "owner", + "added_at": 1711470000 + }, + "role": { + "object": "role", + "id": "role_01J1F8ROLE01", + "name": "API Group Manager", + "description": "Allows managing organization groups", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "resource_type": "api.organization", + "predefined_role": false + } + } + /organization/users/{user_id}/roles/{role_id}: + delete: + security: + - AdminApiKeyAuth: [] + summary: Unassigns an organization role from a user within the organization. + operationId: unassign-user-role + tags: + - User organization role assignments + parameters: + - name: user_id + in: path + description: The ID of the user to modify. + required: true + schema: + type: string + - name: role_id + in: path + description: The ID of the organization role to remove from the user. + required: true + schema: + type: string + responses: + '200': + description: Organization role unassigned from the user successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/DeletedRoleAssignmentResource' + x-oaiMeta: + name: Unassign organization role from user + group: administration + examples: + request: + curl: | + curl -X DELETE https://api.openai.com/v1/organization/users/user_abc123/roles/role_01J1F8ROLE01 \ + -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \ + -H "Content-Type: application/json" + node.js: |- + import OpenAI from 'openai'; + + const client = new OpenAI({ + adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted + }); + + const role = await client.admin.organization.users.roles.delete('role_id', { user_id: 'user_id' }); + + console.log(role.deleted); + python: |- + import os + from openai import OpenAI + + client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted + ) + role = client.admin.organization.users.roles.delete( + role_id="role_id", + user_id="user_id", + ) + print(role.deleted) + 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.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\trole, err := client.Admin.Organization.Users.Roles.Delete(\n\t\tcontext.TODO(),\n\t\t\"user_id\",\n\t\t\"role_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", role.Deleted)\n}\n" + java: |- + package com.openai.example; + + import com.openai.client.OpenAIClient; + import com.openai.client.okhttp.OpenAIOkHttpClient; + import com.openai.models.admin.organization.users.roles.RoleDeleteParams; + import com.openai.models.admin.organization.users.roles.RoleDeleteResponse; + + public final class Main { + private Main() {} + + public static void main(String[] args) { + OpenAIClient client = OpenAIOkHttpClient.fromEnv(); + + RoleDeleteParams params = RoleDeleteParams.builder() + .userId("user_id") + .roleId("role_id") + .build(); + RoleDeleteResponse role = client.admin().organization().users().roles().delete(params); + } + } + ruby: |- + require "openai" + + openai = OpenAI::Client.new(admin_api_key: "My Admin API Key") + + role = openai.admin.organization.users.roles.delete("role_id", user_id: "user_id") + + puts(role) + response: | + { + "object": "user.role.deleted", + "deleted": true + } +components: + schemas: + UserListResponse: + type: object + properties: + object: + type: string + enum: + - list + x-stainless-const: true + data: + type: array + items: + $ref: '#/components/schemas/User' + first_id: + type: string + last_id: + type: string + has_more: + type: boolean + required: + - object + - data + - has_more + User: + type: object + description: Represents an individual `user` within an organization. + properties: + object: + type: string + enum: + - organization.user + description: The object type, which is always `organization.user` + x-stainless-const: true + id: + type: string + description: The identifier, which can be referenced in API endpoints + name: + description: The name of the user + type: string + email: + description: The email address of the user + type: string + role: + description: '`owner` or `reader`' + type: string + added_at: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the user was added. + is_default: + type: boolean + description: Whether this is the organization's default user. + created: + type: integer + format: unixtime + description: The Unix timestamp (in seconds) of when the user was created. + user: + type: object + description: Nested user details. + properties: + object: + type: string + enum: + - user + x-stainless-const: true + id: + type: string + email: + anyOf: + - type: string + - type: 'null' + name: + anyOf: + - type: string + - type: 'null' + picture: + anyOf: + - type: string + - type: 'null' + enabled: + anyOf: + - type: boolean + - type: 'null' + banned: + anyOf: + - type: boolean + - type: 'null' + banned_at: + anyOf: + - type: integer + format: unixtime + - type: 'null' + required: + - object + - id + is_service_account: + type: boolean + description: Whether the user is a service account. + is_scale_tier_authorized_purchaser: + description: Whether the user is an authorized purchaser for Scale Tier. + type: boolean + is_scim_managed: + type: boolean + description: Whether the user is managed through SCIM. + api_key_last_used_at: + description: The Unix timestamp (in seconds) of the user's last API key usage. + type: integer + format: unixtime + technical_level: + description: The technical level metadata for the user. + type: string + developer_persona: + description: The developer persona metadata for the user. + type: string + projects: + description: Projects associated with the user, if included. + type: object + properties: + object: + type: string + enum: + - list + x-stainless-const: true + data: + type: array + items: + type: object + properties: + id: + anyOf: + - type: string + - type: 'null' + name: + anyOf: + - type: string + - type: 'null' + role: + anyOf: + - type: string + - type: 'null' + required: + - object + - data + required: + - object + - id + - added_at + x-oaiMeta: + name: The user object + example: | + { + "object": "organization.user", + "id": "user_abc", + "name": "First Last", + "email": "user@example.com", + "role": "owner", + "added_at": 1711471533 + } + UserRoleUpdateRequest: + type: object + properties: + role: + description: '`owner` or `reader`' + type: string + role_id: + description: Role ID to assign to the user. + type: string + technical_level: + description: Technical level metadata. + type: string + developer_persona: + description: Developer persona metadata. + type: string + UserDeleteResponse: + type: object + properties: + object: + type: string + enum: + - organization.user.deleted + x-stainless-const: true + id: + type: string + deleted: + type: boolean + required: + - object + - id + - deleted + RoleListResource: + type: object + description: Paginated list of roles assigned to a principal. + properties: + object: + type: string + enum: + - list + description: Always `list`. + x-stainless-const: true + data: + type: array + description: Role assignments returned in the current page. + items: + $ref: '#/components/schemas/AssignedRoleDetails' + has_more: + type: boolean + description: Whether additional assignments are available when paginating. + next: + description: Cursor to fetch the next page of results, or `null` when there are no more assignments. + type: string + required: + - object + - data + - has_more + - next + x-oaiMeta: + name: Assigned role list + example: | + { + "object": "list", + "data": [ + { + "id": "role_01J1F8ROLE01", + "name": "API Group Manager", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "resource_type": "api.organization", + "predefined_role": false, + "description": "Allows managing organization groups", + "created_at": 1711471533, + "updated_at": 1711472599, + "created_by": "user_abc123", + "created_by_user_obj": { + "id": "user_abc123", + "name": "Ada Lovelace", + "email": "ada@example.com" + }, + "metadata": {} + } + ], + "has_more": false, + "next": null + } + PublicAssignOrganizationGroupRoleBody: + type: object + description: Request payload for assigning a role to a group or user. + properties: + role_id: + type: string + description: Identifier of the role to assign. + required: + - role_id + x-oaiMeta: + example: | + { + "role_id": "role_01J1F8ROLE01" + } + UserRoleAssignment: + type: object + description: Role assignment linking a user to a role. + properties: + object: + type: string + enum: + - user.role + description: Always `user.role`. + x-stainless-const: true + user: + $ref: '#/components/schemas/User' + role: + $ref: '#/components/schemas/Role' + required: + - object + - user + - role + x-oaiMeta: + name: The user role object + example: | + { + "object": "user.role", + "user": { + "object": "organization.user", + "id": "user_abc123", + "name": "Ada Lovelace", + "email": "ada@example.com", + "role": "owner", + "added_at": 1711470000 + }, + "role": { + "object": "role", + "id": "role_01J1F8ROLE01", + "name": "API Group Manager", + "description": "Allows managing organization groups", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "resource_type": "api.organization", + "predefined_role": false + } + } + DeletedRoleAssignmentResource: + type: object + description: Confirmation payload returned after unassigning a role. + properties: + object: + type: string + description: Identifier for the deleted assignment, such as `group.role.deleted` or `user.role.deleted`. + deleted: + type: boolean + description: Whether the assignment was removed. + required: + - object + - deleted + x-oaiMeta: + name: Role assignment deletion confirmation + example: | + { + "object": "group.role.deleted", + "deleted": true + } + AssignedRoleDetails: + type: object + description: Detailed information about a role assignment entry returned when listing assignments. + properties: + id: + type: string + description: Identifier for the role. + name: + type: string + description: Name of the role. + permissions: + type: array + description: Permissions associated with the role. + items: + type: string + resource_type: + type: string + description: Resource type the role applies to. + predefined_role: + type: boolean + description: Whether the role is predefined by OpenAI. + description: + description: Description of the role. + type: string + created_at: + description: When the role was created. + type: integer + format: unixtime + updated_at: + description: When the role was last updated. + type: integer + format: int64 + created_by: + description: Identifier of the actor who created the role. + type: string + created_by_user_obj: + description: User details for the actor that created the role, when available. + type: object + additionalProperties: true + metadata: + description: Arbitrary metadata stored on the role. + type: object + additionalProperties: true + required: + - id + - name + - permissions + - resource_type + - predefined_role + - description + - created_at + - updated_at + - created_by + - created_by_user_obj + - metadata + Role: + type: object + description: Details about a role that can be assigned through the public Roles API. + properties: + object: + type: string + enum: + - role + description: Always `role`. + x-stainless-const: true + id: + type: string + description: Identifier for the role. + name: + type: string + description: Unique name for the role. + description: + description: Optional description of the role. + type: string + permissions: + type: array + description: Permissions granted by the role. + items: + type: string + resource_type: + type: string + description: Resource type the role is bound to (for example `api.organization` or `api.project`). + predefined_role: + type: boolean + description: Whether the role is predefined and managed by OpenAI. + required: + - object + - id + - name + - description + - permissions + - resource_type + - predefined_role + x-oaiMeta: + name: The role object + example: | + { + "object": "role", + "id": "role_01J1F8ROLE01", + "name": "API Group Manager", + "description": "Allows managing organization groups", + "permissions": [ + "api.groups.read", + "api.groups.write" + ], + "resource_type": "api.organization", + "predefined_role": false + } + x-stackQL-resources: + users: + id: openai_admin.users.users + name: users + title: Users + methods: + list: + operation: + $ref: '#/paths/~1organization~1users/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + get: + operation: + $ref: '#/paths/~1organization~1users~1{user_id}/get' + response: + mediaType: application/json + openAPIDocKey: '200' + update: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1users~1{user_id}/post' + response: + mediaType: application/json + openAPIDocKey: '200' + delete: + operation: + $ref: '#/paths/~1organization~1users~1{user_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/users/methods/get' + - $ref: '#/components/x-stackQL-resources/users/methods/list' + insert: [] + update: + - $ref: '#/components/x-stackQL-resources/users/methods/update' + delete: + - $ref: '#/components/x-stackQL-resources/users/methods/delete' + replace: [] + role_assignments: + id: openai_admin.users.role_assignments + name: role_assignments + title: Role Assignments + methods: + list: + operation: + $ref: '#/paths/~1organization~1users~1{user_id}~1roles/get' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: $.data + config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.next + location: body + assign: + config: + requestBodyTranslate: + algorithm: naive + operation: + $ref: '#/paths/~1organization~1users~1{user_id}~1roles/post' + response: + mediaType: application/json + openAPIDocKey: '200' + unassign: + operation: + $ref: '#/paths/~1organization~1users~1{user_id}~1roles~1{role_id}/delete' + response: + mediaType: application/json + openAPIDocKey: '200' + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/role_assignments/methods/list' + insert: + - $ref: '#/components/x-stackQL-resources/role_assignments/methods/assign' + update: [] + delete: + - $ref: '#/components/x-stackQL-resources/role_assignments/methods/unassign' + replace: [] +servers: + - url: https://api.openai.com/v1 +x-stackQL-config: + pagination: + requestToken: + key: after + location: query + responseToken: + key: $.last_id + location: body