diff --git a/.github/workflows/mintlify-update.yml b/.github/workflows/mintlify-update.yml new file mode 100644 index 00000000..1e4ed663 --- /dev/null +++ b/.github/workflows/mintlify-update.yml @@ -0,0 +1,17 @@ +name: Trigger Mintlify Update + +on: + push: + branches: + - master + +jobs: + trigger-update: + runs-on: ubuntu-latest + + steps: + - name: Trigger Mintlify Update + run: | + curl --request POST \ + --url https://api.mintlify.com/v1/project/update/${{ secrets.MINTLIFY_PROJECT_ID }} \ + --header 'Authorization: Bearer ${{ secrets.MINTLIFY_TOKEN }}' diff --git a/README.md b/README.md index 04bcd9be..5191825a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# OpenAPI spec for the OpenAI API +# OpenAPI spec for the Portkey API -This repository contains an [OpenAPI](https://www.openapis.org/) specification for the [OpenAI API](https://platform.openai.com/docs/api-reference). +This repository contains an [OpenAPI](https://www.openapis.org/) specification for the [Portkey API](https://portkey.ai/docs/api-reference). diff --git a/backups/11-06-24.yaml b/backups/11-06-24.yaml new file mode 100644 index 00000000..f271d25f --- /dev/null +++ b/backups/11-06-24.yaml @@ -0,0 +1,13833 @@ +openapi: 3.0.0 +info: + title: Portkey API + description: The Portkey REST API. Please see https://portkey.ai/docs/api-reference for more details. + version: "2.0.0" + termsOfService: https://portkey.ai/terms + contact: + name: Portkey Developer Forum + url: https://portkey.ai/community + license: + name: MIT + url: https://github.com/Portkey-AI/portkey-openapi/blob/master/LICENSE +servers: + - url: https://api.portkey.ai/v1 +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: 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 a input text, outputs if the model classifies it as potentially harmful. +paths: + # Note: When adding an endpoint, make sure you also add it in the `groups` section, in the end of this file, + # under the appropriate group + /chat/completions: + post: + operationId: createChatCompletion + tags: + - Chat + summary: Creates a model response for the given chat conversation. + 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](https://platform.openai.com/docs/api-reference/chat/object) object, or a streamed sequence of [chat completion chunk](https://platform.openai.com/docs/api-reference/chat/streaming) objects if the request is streamed. + path: create + examples: + - title: Default + request: + curl: | + curl https://api.portkey.ai/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: &chat_completion_example | + { + "id": "chatcmpl-123", + "object": "chat.completion", + "created": 1677652288, + "model": "gpt-3.5-turbo-0125", + "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 + } + } + - title: Image input + request: + curl: | + curl https://api.portkey.ai/v1/chat/completions \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "model": "gpt-4-turbo", + "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-4-turbo", + messages=[ + { + "role": "user", + "content": [ + {"type": "text", "text": "What's in this image?"}, + { + "type": "image_url", + "image_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-4-turbo", + messages: [ + { + role: "user", + content: [ + { type: "text", text: "What's in this image?" }, + { + type: "image_url", + image_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: &chat_completion_image_example | + { + "id": "chatcmpl-123", + "object": "chat.completion", + "created": 1677652288, + "model": "gpt-3.5-turbo-0125", + "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 + } + } + - title: Streaming + request: + curl: | + curl https://api.portkey.ai/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: &chat_completion_chunk_example | + {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-3.5-turbo-0125", "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-3.5-turbo-0125", "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-3.5-turbo-0125", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + - title: Functions + request: + curl: | + curl https://api.portkey.ai/v1/chat/completions \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "model": "gpt-4-turbo", + "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-4-turbo", + messages: messages, + tools: tools, + tool_choice: "auto", + }); + + console.log(response); + } + + main(); + response: &chat_completion_function_example | + { + "id": "chatcmpl-abc123", + "object": "chat.completion", + "created": 1699896916, + "model": "gpt-3.5-turbo-0125", + "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 + } + } + - title: Logprobs + request: + curl: | + curl https://api.portkey.ai/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-3.5-turbo-0125", + "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 + }, + "system_fingerprint": null + } + + /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](https://platform.openai.com/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.portkey.ai/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.portkey.ai/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", + } + + /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](https://platform.openai.com/docs/api-reference/images/object) objects. + examples: + request: + curl: | + curl https://api.portkey.ai/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/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](https://platform.openai.com/docs/api-reference/images/object) objects. + examples: + request: + curl: | + curl https://api.portkey.ai/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/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](https://platform.openai.com/docs/api-reference/images/object) objects. + examples: + request: + curl: | + curl https://api.portkey.ai/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://..." + } + ] + } + + /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](https://platform.openai.com/docs/api-reference/embeddings/object) objects. + examples: + request: + curl: | + curl https://api.portkey.ai/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 + } + } + + /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.portkey.ai/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](https://platform.openai.com/docs/api-reference/audio/json-object) or a [verbose transcription object](https://platform.openai.com/docs/api-reference/audio/verbose-json-object). + examples: + - title: Default + request: + curl: | + curl https://api.portkey.ai/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: &basic_transcription_response_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." + } + - title: Word timestamps + request: + curl: | + curl https://api.portkey.ai/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.portkey.ai/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: &verbose_transcription_response_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 + }, + ... + ] + } + /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.portkey.ai/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?" + } + + /files: + get: + operationId: listFiles + tags: + - Files + summary: Returns a list of files that belong to the user's organization. + parameters: + - in: query + name: purpose + required: false + schema: + type: string + description: Only return files with the given purpose. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ListFilesResponse" + x-oaiMeta: + name: List files + group: files + returns: A list of [File](https://platform.openai.com/docs/api-reference/files/object) objects. + examples: + request: + curl: | + curl https://api.portkey.ai/v1/files \ + -H "Authorization: Bearer $OPENAI_API_KEY" + python: | + from openai import OpenAI + client = OpenAI() + + client.files.list() + node.js: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const list = await openai.files.list(); + + for await (const file of list) { + console.log(file); + } + } + + main(); + response: | + { + "data": [ + { + "id": "file-abc123", + "object": "file", + "bytes": 175, + "created_at": 1613677385, + "filename": "salesOverview.pdf", + "purpose": "assistants", + }, + { + "id": "file-abc123", + "object": "file", + "bytes": 140, + "created_at": 1613779121, + "filename": "puppy.jsonl", + "purpose": "fine-tune", + } + ], + "object": "list" + } + 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. + + The Assistants API supports files up to 2 million tokens and of specific file types. See the [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) for details. + + The Fine-tuning API only supports `.jsonl` files. The input also has certain required formats for fine-tuning [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input) models. + + The Batch API only supports `.jsonl` files up to 100 MB in size. The input also has a specific required [format](https://platform.openai.com/docs/api-reference/batch/request-input). + + Please [contact OpenAI](https://help.openai.com/) if you need to increase these storage limits. + requestBody: + required: true + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/CreateFileRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/OpenAIFile" + x-oaiMeta: + name: Upload file + group: files + returns: The uploaded [File](https://platform.openai.com/docs/api-reference/files/object) object. + examples: + request: + curl: | + curl https://api.portkey.ai/v1/files \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -F purpose="fine-tune" \ + -F file="@mydata.jsonl" + python: | + from openai import OpenAI + client = OpenAI() + + client.files.create( + file=open("mydata.jsonl", "rb"), + purpose="fine-tune" + ) + node.js: |- + import fs from "fs"; + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const file = await openai.files.create({ + file: fs.createReadStream("mydata.jsonl"), + purpose: "fine-tune", + }); + + console.log(file); + } + + main(); + response: | + { + "id": "file-abc123", + "object": "file", + "bytes": 120000, + "created_at": 1677610602, + "filename": "mydata.jsonl", + "purpose": "fine-tune", + } + /files/{file_id}: + delete: + operationId: deleteFile + tags: + - Files + summary: Delete a 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: + $ref: "#/components/schemas/DeleteFileResponse" + x-oaiMeta: + name: Delete file + group: files + returns: Deletion status. + examples: + request: + curl: | + curl https://api.portkey.ai/v1/files/file-abc123 \ + -X DELETE \ + -H "Authorization: Bearer $OPENAI_API_KEY" + python: | + from openai import OpenAI + client = OpenAI() + + client.files.delete("file-abc123") + node.js: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const file = await openai.files.del("file-abc123"); + + console.log(file); + } + + main(); + response: | + { + "id": "file-abc123", + "object": "file", + "deleted": true + } + get: + operationId: retrieveFile + tags: + - Files + summary: Returns information about a specific 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: + $ref: "#/components/schemas/OpenAIFile" + x-oaiMeta: + name: Retrieve file + group: files + returns: The [File](https://platform.openai.com/docs/api-reference/files/object) object matching the specified ID. + examples: + request: + curl: | + curl https://api.portkey.ai/v1/files/file-abc123 \ + -H "Authorization: Bearer $OPENAI_API_KEY" + python: | + from openai import OpenAI + client = OpenAI() + + client.files.retrieve("file-abc123") + node.js: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const file = await openai.files.retrieve("file-abc123"); + + console.log(file); + } + + main(); + response: | + { + "id": "file-abc123", + "object": "file", + "bytes": 120000, + "created_at": 1677610602, + "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 + x-oaiMeta: + name: Retrieve file content + group: files + returns: The file content. + examples: + request: + curl: | + curl https://api.portkey.ai/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(); + + /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](https://platform.openai.com/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](https://platform.openai.com/docs/api-reference/fine-tuning/object) object. + examples: + - title: Default + request: + curl: | + curl https://api.portkey.ai/v1/fine_tuning/jobs \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "training_file": "file-BK7bzQj3FfZFXr7DbL6xJwfo", + "model": "gpt-3.5-turbo" + }' + python: | + from openai import OpenAI + client = OpenAI() + + client.fine_tuning.jobs.create( + training_file="file-abc123", + model="gpt-3.5-turbo" + ) + 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-3.5-turbo-0125", + "created_at": 1614807352, + "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.portkey.ai/v1/fine_tuning/jobs \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "training_file": "file-abc123", + "model": "gpt-3.5-turbo", + "hyperparameters": { + "n_epochs": 2 + } + }' + python: | + from openai import OpenAI + client = OpenAI() + + client.fine_tuning.jobs.create( + training_file="file-abc123", + model="gpt-3.5-turbo", + hyperparameters={ + "n_epochs":2 + } + ) + node.js: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const fineTune = await openai.fineTuning.jobs.create({ + training_file: "file-abc123", + model: "gpt-3.5-turbo", + hyperparameters: { n_epochs: 2 } + }); + + console.log(fineTune); + } + + main(); + response: | + { + "object": "fine_tuning.job", + "id": "ftjob-abc123", + "model": "gpt-3.5-turbo-0125", + "created_at": 1614807352, + "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.portkey.ai/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-3.5-turbo" + }' + python: | + from openai import OpenAI + client = OpenAI() + + client.fine_tuning.jobs.create( + training_file="file-abc123", + validation_file="file-def456", + model="gpt-3.5-turbo" + ) + node.js: | + 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(); + response: | + { + "object": "fine_tuning.job", + "id": "ftjob-abc123", + "model": "gpt-3.5-turbo-0125", + "created_at": 1614807352, + "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.portkey.ai/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-3.5-turbo", + "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-3.5-turbo-0125", + "created_at": 1614807352, + "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" + x-oaiMeta: + name: List fine-tuning jobs + group: fine-tuning + returns: A list of paginated [fine-tuning job](https://platform.openai.com/docs/api-reference/fine-tuning/object) objects. + examples: + request: + curl: | + curl https://api.portkey.ai/v1/fine_tuning/jobs?limit=2 \ + -H "Authorization: Bearer $OPENAI_API_KEY" + python: | + from openai import OpenAI + client = OpenAI() + + client.fine_tuning.jobs.list() + node.js: |- + 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(); + 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](https://platform.openai.com/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" + x-oaiMeta: + name: Retrieve fine-tuning job + group: fine-tuning + returns: The [fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning/object) object with the given ID. + examples: + request: + curl: | + curl https://api.portkey.ai/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F \ + -H "Authorization: Bearer $OPENAI_API_KEY" + python: | + from openai import OpenAI + client = OpenAI() + + client.fine_tuning.jobs.retrieve("ftjob-abc123") + node.js: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const fineTune = await openai.fineTuning.jobs.retrieve("ftjob-abc123"); + + console.log(fineTune); + } + + main(); + response: &fine_tuning_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 + } + /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.portkey.ai/v1/fine_tuning/jobs/ftjob-abc123/events \ + -H "Authorization: Bearer $OPENAI_API_KEY" + python: | + from openai import OpenAI + client = OpenAI() + + client.fine_tuning.jobs.list_events( + fine_tuning_job_id="ftjob-abc123", + limit=2 + ) + node.js: |- + 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(); + response: | + { + "object": "list", + "data": [ + { + "object": "fine_tuning.job.event", + "id": "ft-event-ddTJfwuMVpfLXseO0Am0Gqjm", + "created_at": 1692407401, + "level": "info", + "message": "Fine tuning job successfully completed", + "data": null, + "type": "message" + }, + { + "object": "fine_tuning.job.event", + "id": "ft-event-tyiGuB72evQncpH87xe505Sv", + "created_at": 1692407400, + "level": "info", + "message": "New fine-tuned model created: ft:gpt-3.5-turbo:openai::7p4lURel", + "data": null, + "type": "message" + } + ], + "has_more": true + } + /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. + 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](https://platform.openai.com/docs/api-reference/fine-tuning/object) object. + examples: + request: + curl: | + curl -X POST https://api.portkey.ai/v1/fine_tuning/jobs/ftjob-abc123/cancel \ + -H "Authorization: Bearer $OPENAI_API_KEY" + python: | + from openai import OpenAI + client = OpenAI() + + client.fine_tuning.jobs.cancel("ftjob-abc123") + node.js: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const fineTune = await openai.fineTuning.jobs.cancel("ftjob-abc123"); + + console.log(fineTune); + } + main(); + response: | + { + "object": "fine_tuning.job", + "id": "ftjob-abc123", + "model": "gpt-3.5-turbo-0125", + "created_at": 1689376978, + "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](https://platform.openai.com/docs/api-reference/fine-tuning/checkpoint-object) for a fine-tuning job. + examples: + request: + curl: | + curl https://api.portkey.ai/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": 1519129973, + "fine_tuned_model_checkpoint": "ft:gpt-3.5-turbo-0125: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": 1519129833, + "fine_tuned_model_checkpoint": "ft:gpt-3.5-turbo-0125: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 + } + + /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. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ListModelsResponse" + x-oaiMeta: + name: List models + group: models + returns: A list of [model](https://platform.openai.com/docs/api-reference/models/object) objects. + examples: + request: + curl: | + curl https://api.portkey.ai/v1/models \ + -H "Authorization: Bearer $OPENAI_API_KEY" + python: | + from openai import OpenAI + client = OpenAI() + + client.models.list() + node.js: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const list = await openai.models.list(); + + for await (const model of list) { + console.log(model); + } + } + main(); + response: | + { + "object": "list", + "data": [ + { + "id": "model-id-0", + "object": "model", + "created": 1686935002, + "owned_by": "organization-owner" + }, + { + "id": "model-id-1", + "object": "model", + "created": 1686935002, + "owned_by": "organization-owner", + }, + { + "id": "model-id-2", + "object": "model", + "created": 1686935002, + "owned_by": "openai" + }, + ], + "object": "list" + } + /models/{model}: + get: + operationId: retrieveModel + tags: + - Models + summary: Retrieves a model instance, providing basic information about the model such as the owner and permissioning. + parameters: + - in: path + name: model + required: true + schema: + type: string + # ideally this will be an actual ID, so this will always work from browser + example: gpt-3.5-turbo + description: The ID of the model to use for this request + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/Model" + x-oaiMeta: + name: Retrieve model + group: models + returns: The [model](https://platform.openai.com/docs/api-reference/models/object) object matching the specified ID. + examples: + request: + curl: | + curl https://api.portkey.ai/v1/models/VAR_model_id \ + -H "Authorization: Bearer $OPENAI_API_KEY" + python: | + from openai import OpenAI + client = OpenAI() + + client.models.retrieve("VAR_model_id") + node.js: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const model = await openai.models.retrieve("VAR_model_id"); + + console.log(model); + } + + main(); + response: &retrieve_model_response | + { + "id": "VAR_model_id", + "object": "model", + "created": 1686935002, + "owned_by": "openai" + } + delete: + operationId: deleteModel + tags: + - Models + 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-3.5-turbo:acemeco:suffix:abc123 + description: The model to delete + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/DeleteModelResponse" + x-oaiMeta: + name: Delete a fine-tuned model + group: models + returns: Deletion status. + examples: + request: + curl: | + curl https://api.portkey.ai/v1/models/ft:gpt-3.5-turbo:acemeco:suffix:abc123 \ + -X DELETE \ + -H "Authorization: Bearer $OPENAI_API_KEY" + python: | + from openai import OpenAI + client = OpenAI() + + client.models.delete("ft:gpt-3.5-turbo:acemeco:suffix:abc123") + node.js: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const model = await openai.models.del("ft:gpt-3.5-turbo:acemeco:suffix:abc123"); + + console.log(model); + } + main(); + response: | + { + "id": "ft:gpt-3.5-turbo:acemeco:suffix:abc123", + "object": "model", + "deleted": true + } + + /moderations: + post: + operationId: createModeration + tags: + - Moderations + summary: Classifies if text is potentially harmful. + 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](https://platform.openai.com/docs/api-reference/moderations/object) object. + examples: + request: + curl: | + curl https://api.portkey.ai/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: &moderation_example | + { + "id": "modr-XXXXX", + "model": "text-moderation-005", + "results": [ + { + "flagged": true, + "categories": { + "sexual": false, + "hate": false, + "harassment": false, + "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": 1.2282071e-06, + "hate": 0.010696256, + "harassment": 0.29842457, + "self-harm": 1.5236925e-08, + "sexual/minors": 5.7246268e-08, + "hate/threatening": 0.0060676364, + "violence/graphic": 4.435014e-06, + "self-harm/intent": 8.098441e-10, + "self-harm/instructions": 2.8498655e-11, + "harassment/threatening": 0.63055265, + "violence": 0.99011886, + } + } + ] + } + + /assistants: + get: + operationId: listAssistants + tags: + - Assistants + summary: Returns a list of assistants. + parameters: + - name: limit + in: query + description: &pagination_limit_param_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: &pagination_order_param_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: &pagination_after_param_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: &pagination_before_param_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](https://platform.openai.com/docs/api-reference/assistants/object) objects. + examples: + request: + curl: | + curl "https://api.portkey.ai/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() + + my_assistants = client.beta.assistants.list( + order="desc", + limit="20", + ) + print(my_assistants.data) + node.js: |- + 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(); + response: &list_assistants_example | + { + "object": "list", + "data": [ + { + "id": "asst_abc123", + "object": "assistant", + "created_at": 1698982736, + "name": "Coding Tutor", + "description": null, + "model": "gpt-4-turbo", + "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-4-turbo", + "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-4-turbo", + "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. + 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](https://platform.openai.com/docs/api-reference/assistants/object) object. + examples: + - title: Code Interpreter + request: + curl: | + curl "https://api.portkey.ai/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-4-turbo" + }' + + python: | + 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-4-turbo", + ) + print(my_assistant) + node.js: |- + 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-4-turbo", + }); + + console.log(myAssistant); + } + + main(); + response: &create_assistants_example | + { + "id": "asst_abc123", + "object": "assistant", + "created_at": 1698984975, + "name": "Math Tutor", + "description": null, + "model": "gpt-4-turbo", + "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.portkey.ai/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-4-turbo" + }' + python: | + 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-4-turbo" + ) + print(my_assistant) + node.js: |- + 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-4-turbo" + }); + + console.log(myAssistant); + } + + main(); + response: | + { + "id": "asst_abc123", + "object": "assistant", + "created_at": 1699009403, + "name": "HR Helper", + "description": null, + "model": "gpt-4-turbo", + "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}: + get: + operationId: getAssistant + tags: + - Assistants + summary: Retrieves an assistant. + parameters: + - in: path + name: assistant_id + required: true + schema: + type: string + description: The ID of the assistant to retrieve. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/AssistantObject" + x-oaiMeta: + name: Retrieve assistant + group: assistants + beta: true + returns: The [assistant](https://platform.openai.com/docs/api-reference/assistants/object) object matching the specified ID. + examples: + request: + curl: | + curl https://api.portkey.ai/v1/assistants/asst_abc123 \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "OpenAI-Beta: assistants=v2" + python: | + from openai import OpenAI + client = OpenAI() + + my_assistant = client.beta.assistants.retrieve("asst_abc123") + print(my_assistant) + node.js: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const myAssistant = await openai.beta.assistants.retrieve( + "asst_abc123" + ); + + console.log(myAssistant); + } + + main(); + response: | + { + "id": "asst_abc123", + "object": "assistant", + "created_at": 1699009709, + "name": "HR Helper", + "description": null, + "model": "gpt-4-turbo", + "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. + parameters: + - in: path + name: assistant_id + required: true + schema: + type: string + description: The ID of the assistant to modify. + 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: Modify assistant + group: assistants + beta: true + returns: The modified [assistant](https://platform.openai.com/docs/api-reference/assistants/object) object. + examples: + request: + curl: | + curl https://api.portkey.ai/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-4-turbo" + }' + python: | + 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-4-turbo" + ) + + print(my_updated_assistant) + node.js: |- + 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-4-turbo" + } + ); + + console.log(myUpdatedAssistant); + } + + main(); + response: | + { + "id": "asst_123", + "object": "assistant", + "created_at": 1699009709, + "name": "HR Helper", + "description": null, + "model": "gpt-4-turbo", + "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.portkey.ai/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](https://platform.openai.com/docs/api-reference/threads) object. + examples: + - title: Empty + request: + curl: | + curl https://api.portkey.ai/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.portkey.ai/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." + }, + ] + ) + + print(message_thread) + node.js: |- + 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(); + response: | + { + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, + "metadata": {}, + "tool_resources": {} + } + + /threads/{thread_id}: + get: + operationId: getThread + tags: + - Assistants + summary: Retrieves a thread. + parameters: + - in: path + name: thread_id + required: true + schema: + type: string + description: The ID of the thread to retrieve. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ThreadObject" + x-oaiMeta: + name: Retrieve thread + group: threads + beta: true + returns: The [thread](https://platform.openai.com/docs/api-reference/threads/object) object matching the specified ID. + examples: + request: + curl: | + curl https://api.portkey.ai/v1/threads/thread_abc123 \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "OpenAI-Beta: assistants=v2" + python: | + from openai import OpenAI + client = OpenAI() + + my_thread = client.beta.threads.retrieve("thread_abc123") + print(my_thread) + node.js: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const myThread = await openai.beta.threads.retrieve( + "thread_abc123" + ); + + console.log(myThread); + } + + main(); + response: | + { + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, + "metadata": {}, + "tool_resources": { + "code_interpreter": { + "file_ids": [] + } + } + } + post: + operationId: modifyThread + tags: + - Assistants + summary: Modifies a thread. + 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. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/ModifyThreadRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ThreadObject" + x-oaiMeta: + name: Modify thread + group: threads + beta: true + returns: The modified [thread](https://platform.openai.com/docs/api-reference/threads/object) object matching the specified ID. + examples: + request: + curl: | + curl https://api.portkey.ai/v1/threads/thread_abc123 \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "metadata": { + "modified": "true", + "user": "abc123" + } + }' + python: | + from openai import OpenAI + client = OpenAI() + + my_updated_thread = client.beta.threads.update( + "thread_abc123", + metadata={ + "modified": "true", + "user": "abc123" + } + ) + print(my_updated_thread) + node.js: |- + 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" }, + } + ); + + console.log(updatedThread); + } + + main(); + response: | + { + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, + "metadata": { + "modified": "true", + "user": "abc123" + }, + "tool_resources": {} + } + delete: + operationId: deleteThread + tags: + - Assistants + summary: Delete a thread. + parameters: + - in: path + name: thread_id + required: true + schema: + type: string + description: The ID of the thread to delete. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/DeleteThreadResponse" + x-oaiMeta: + name: Delete thread + group: threads + beta: true + returns: Deletion status + examples: + request: + curl: | + curl https://api.portkey.ai/v1/threads/thread_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.threads.delete("thread_abc123") + print(response) + node.js: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const response = await openai.beta.threads.del("thread_abc123"); + + console.log(response); + } + main(); + response: | + { + "id": "thread_abc123", + "object": "thread.deleted", + "deleted": 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](https://platform.openai.com/docs/api-reference/threads) the messages belong to. + - name: limit + in: query + description: *pagination_limit_param_description + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: *pagination_order_param_description + schema: + type: string + default: desc + enum: ["asc", "desc"] + - name: after + in: query + description: *pagination_after_param_description + schema: + type: string + - name: before + in: query + description: *pagination_before_param_description + schema: + type: string + - name: run_id + in: query + description: | + Filter messages by the run ID that generated them. + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ListMessagesResponse" + x-oaiMeta: + name: List messages + group: threads + beta: true + returns: A list of [message](https://platform.openai.com/docs/api-reference/messages) objects. + examples: + request: + curl: | + curl https://api.portkey.ai/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() + + thread_messages = client.beta.threads.messages.list("thread_abc123") + print(thread_messages.data) + node.js: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const threadMessages = await openai.beta.threads.messages.list( + "thread_abc123" + ); + + console.log(threadMessages.data); + } + + 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": [ + { + "type": "text", + "text": { + "value": "How does AI work? Explain it in simple terms.", + "annotations": [] + } + } + ], + "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 + } + 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](https://platform.openai.com/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](https://platform.openai.com/docs/api-reference/messages/object) object. + examples: + request: + curl: | + curl https://api.portkey.ai/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"; + + 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." } + ); + + 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": [] + } + } + ], + "attachments": [], + "metadata": {} + } + + /threads/{thread_id}/messages/{message_id}: + get: + operationId: getMessage + tags: + - Assistants + summary: Retrieve a message. + parameters: + - in: path + name: thread_id + required: true + schema: + type: string + description: The ID of the [thread](https://platform.openai.com/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. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/MessageObject" + x-oaiMeta: + name: Retrieve message + group: threads + beta: true + returns: The [message](https://platform.openai.com/docs/api-reference/threads/messages/object) object matching the specified ID. + examples: + request: + curl: | + curl https://api.portkey.ai/v1/threads/thread_abc123/messages/msg_abc123 \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "OpenAI-Beta: assistants=v2" + python: | + from openai import OpenAI + client = OpenAI() + + message = client.beta.threads.messages.retrieve( + message_id="msg_abc123", + thread_id="thread_abc123", + ) + print(message) + node.js: |- + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const message = await openai.beta.threads.messages.retrieve( + "thread_abc123", + "msg_abc123" + ); + + console.log(message); + } + + main(); + 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": [] + } + } + ], + "attachments": [], + "metadata": {} + } + post: + operationId: modifyMessage + tags: + - Assistants + summary: Modifies 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 modify. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/ModifyMessageRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/MessageObject" + x-oaiMeta: + name: Modify message + group: threads + beta: true + returns: The modified [message](https://platform.openai.com/docs/api-reference/threads/messages/object) object. + examples: + request: + curl: | + curl https://api.portkey.ai/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: | + 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", + }, + ) + print(message) + node.js: |- + 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", + }, + } + }' + 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" + } + } + 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. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/DeleteMessageResponse" + x-oaiMeta: + name: Delete message + group: threads + beta: true + returns: Deletion status + examples: + request: + curl: | + curl -X DELETE https://api.portkey.ai/v1/threads/thread_abc123/messages/msg_abc123 \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "OpenAI-Beta: assistants=v2" + python: | + 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"; + + const openai = new OpenAI(); + + async function main() { + const deletedMessage = await openai.beta.threads.messages.del( + "thread_abc123", + "msg_abc123" + ); + + console.log(deletedMessage); + } + response: | + { + "id": "msg_abc123", + "object": "thread.message.deleted", + "deleted": 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: Create thread and run + group: threads + beta: true + returns: A [run](https://platform.openai.com/docs/api-reference/runs/object) object. + examples: + - title: Default + request: + curl: | + curl https://api.portkey.ai/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() + + run = client.beta.threads.create_and_run( + assistant_id="asst_abc123", + thread={ + "messages": [ + {"role": "user", "content": "Explain deep learning to a 5 year old."} + ] + } + ) + + print(run) + node.js: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + 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(); + 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-4-turbo", + "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.portkey.ai/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() + + stream = client.beta.threads.create_and_run( + assistant_id="asst_123", + thread={ + "messages": [ + {"role": "user", "content": "Hello"} + ] + }, + stream=True + ) + + for event in stream: + print(event) + node.js: | + 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(); + 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-4-turbo","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-4-turbo","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-4-turbo","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 + 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 + {"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-4-turbo","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.portkey.ai/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"] + } + } + } + ], + "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"], + }, + } + } + ] + + 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 + ) + + for event in stream: + print(event) + node.js: | + import OpenAI from "openai"; + + 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"], + }, + } + } + ]; + + 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); + } + } + + 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-4-turbo","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-4-turbo","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-4-turbo","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-4-turbo","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}/runs: + get: + operationId: listRuns + tags: + - Assistants + summary: Returns a list of runs belonging to a thread. + parameters: + - name: thread_id + in: path + required: true + schema: + type: string + description: The ID of the thread the run belongs to. + - name: limit + in: query + description: *pagination_limit_param_description + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: *pagination_order_param_description + schema: + type: string + default: desc + enum: ["asc", "desc"] + - name: after + in: query + description: *pagination_after_param_description + schema: + type: string + - name: before + in: query + description: *pagination_before_param_description + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ListRunsResponse" + x-oaiMeta: + name: List runs + group: threads + beta: true + returns: A list of [run](https://platform.openai.com/docs/api-reference/runs/object) objects. + examples: + request: + curl: | + curl https://api.portkey.ai/v1/threads/thread_abc123/runs \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + python: | + from openai import OpenAI + client = OpenAI() + + runs = client.beta.threads.runs.list( + "thread_abc123" + ) + + print(runs) + node.js: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const runs = await openai.beta.threads.runs.list( + "thread_abc123" + ); + + console.log(runs); + } + + main(); + 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-4-turbo", + "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-4-turbo", + "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 + } + post: + operationId: createRun + tags: + - Assistants + summary: Create a run. + parameters: + - in: path + name: thread_id + required: true + schema: + type: string + description: The ID of the thread to run. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CreateRunRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/RunObject" + x-oaiMeta: + name: Create run + group: threads + beta: true + returns: A [run](https://platform.openai.com/docs/api-reference/runs/object) object. + examples: + - title: Default + request: + curl: | + curl https://api.portkey.ai/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: | + from openai import OpenAI + client = OpenAI() + + run = client.beta.threads.runs.create( + thread_id="thread_abc123", + assistant_id="asst_abc123" + ) + + print(run) + node.js: | + 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" } + ); + + console.log(run); + } + + main(); + response: &run_object_example | + { + "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-4-turbo", + "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.portkey.ai/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: | + from openai import OpenAI + client = OpenAI() + + stream = client.beta.threads.runs.create( + thread_id="thread_123", + assistant_id="asst_123", + stream=True + ) + + for event in stream: + print(event) + node.js: | + 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(); + 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-4-turbo","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-4-turbo","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-4-turbo","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-4-turbo","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.portkey.ai/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"], + }, + } + } + ] + + 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"; + + 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"], + }, + } + } + ]; + + 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); + } + } + + 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-4-turbo","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-4-turbo","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-4-turbo","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-4-turbo","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] + + /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](https://platform.openai.com/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" + x-oaiMeta: + name: Retrieve run + group: threads + beta: true + returns: The [run](https://platform.openai.com/docs/api-reference/runs/object) object matching the specified ID. + examples: + request: + curl: | + curl https://api.portkey.ai/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" + ); + + 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-4-turbo", + "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](https://platform.openai.com/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 + content: + application/json: + schema: + $ref: "#/components/schemas/ModifyRunRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/RunObject" + x-oaiMeta: + name: Modify run + group: threads + beta: true + returns: The modified [run](https://platform.openai.com/docs/api-reference/runs/object) object matching the specified ID. + examples: + request: + curl: | + curl https://api.portkey.ai/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-4-turbo", + "instructions": null, + "incomplete_details": null, + "tools": [ + { + "type": "code_interpreter" + } + ], + "tool_resources": { + "code_interpreter": { + "file_ids": [ + "file-abc123", + "file-abc456" + ] + } + }, + "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}/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](https://platform.openai.com/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](https://platform.openai.com/docs/api-reference/runs/object) object matching the specified ID. + examples: + - title: Default + request: + curl: | + curl https://api.portkey.ai/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." + } + ] + ) + + print(run) + node.js: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + 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); + } + + 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-4-turbo", + "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.portkey.ai/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() + + 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 + ) + + for event in stream: + print(event) + node.js: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + 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.", + }, + ], + } + ); + + for await (const event of stream) { + console.log(event); + } + } + + 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}} + + 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-4-turbo","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-4-turbo","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 + 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.delta + data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"The","annotations":[]}}]}} + + 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_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" weather"}}]}} + + ... + + event: thread.message.delta + data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" sunny"}}]}} + + event: thread.message.delta + data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"."}}]}} + + 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":{}} + + 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-4-turbo","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] + + /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](https://platform.openai.com/docs/api-reference/runs/object) object matching the specified ID. + examples: + request: + curl: | + curl https://api.portkey.ai/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" + ) + + print(run) + node.js: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + async function main() { + const run = await openai.beta.threads.runs.cancel( + "thread_abc123", + "run_abc123" + ); + + console.log(run); + } + + 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-4-turbo", + "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: *pagination_limit_param_description + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: *pagination_order_param_description + schema: + type: string + default: desc + enum: ["asc", "desc"] + - name: after + in: query + description: *pagination_after_param_description + schema: + type: string + - name: before + in: query + description: *pagination_before_param_description + schema: + type: string + 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](https://platform.openai.com/docs/api-reference/runs/step-object) objects. + examples: + request: + curl: | + curl https://api.portkey.ai/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. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/RunStepObject" + x-oaiMeta: + name: Retrieve run step + group: threads + beta: true + returns: The [run step](https://platform.openai.com/docs/api-reference/runs/step-object) object matching the specified ID. + examples: + request: + curl: | + curl https://api.portkey.ai/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); + } + + main(); + response: &run_step_object_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 + } + } + + /vector_stores: + get: + operationId: listVectorStores + tags: + - Vector Stores + summary: Returns a list of vector stores. + parameters: + - name: limit + in: query + description: *pagination_limit_param_description + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: *pagination_order_param_description + schema: + type: string + default: desc + enum: ["asc", "desc"] + - name: after + in: query + description: *pagination_after_param_description + schema: + type: string + - name: before + in: query + description: *pagination_before_param_description + 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](https://platform.openai.com/docs/api-reference/vector-stores/object) objects. + examples: + request: + curl: | + curl https://api.portkey.ai/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 + } + post: + operationId: createVectorStore + tags: + - Vector Stores + summary: Create a vector store. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CreateVectorStoreRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/VectorStoreObject" + x-oaiMeta: + name: Create vector store + group: vector_stores + beta: true + returns: A [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) object. + examples: + request: + curl: | + curl https://api.portkey.ai/v1/vector_stores \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + -d '{ + "name": "Support FAQ" + }' + python: | + from openai import OpenAI + client = OpenAI() + + vector_store = client.beta.vector_stores.create( + name="Support FAQ" + ) + print(vector_store) + node.js: | + import OpenAI from "openai"; + const openai = new OpenAI(); + + async function main() { + const vectorStore = await openai.beta.vectorStores.create({ + name: "Support FAQ" + }); + console.log(vectorStore); + } + + main(); + response: | + { + "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 + } + } + + /vector_stores/{vector_store_id}: + get: + operationId: getVectorStore + tags: + - Vector Stores + summary: Retrieves a vector store. + parameters: + - in: path + name: vector_store_id + required: true + schema: + type: string + description: The ID of the vector store to retrieve. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/VectorStoreObject" + x-oaiMeta: + name: Retrieve vector store + group: vector_stores + beta: true + returns: The [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) object matching the specified ID. + examples: + request: + curl: | + curl https://api.portkey.ai/v1/vector_stores/vs_abc123 \ + -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 = client.beta.vector_stores.retrieve( + vector_store_id="vs_abc123" + ) + print(vector_store) + node.js: | + import OpenAI from "openai"; + const openai = new OpenAI(); + + async function main() { + const vectorStore = await openai.beta.vectorStores.retrieve( + "vs_abc123" + ); + console.log(vectorStore); + } + + main(); + response: | + { + "id": "vs_abc123", + "object": "vector_store", + "created_at": 1699061776 + } + post: + operationId: modifyVectorStore + tags: + - Vector Stores + summary: Modifies a vector store. + parameters: + - in: path + name: vector_store_id + required: true + schema: + type: string + description: The ID of the vector store to modify. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateVectorStoreRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/VectorStoreObject" + x-oaiMeta: + name: Modify vector store + group: vector_stores + beta: true + returns: The modified [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) object. + examples: + request: + curl: | + curl https://api.portkey.ai/v1/vector_stores/vs_abc123 \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + -d '{ + "name": "Support FAQ" + }' + python: | + from openai import OpenAI + client = OpenAI() + + vector_store = client.beta.vector_stores.update( + vector_store_id="vs_abc123", + name="Support FAQ" + ) + print(vector_store) + node.js: | + import OpenAI from "openai"; + const openai = new OpenAI(); + + async function main() { + const vectorStore = await openai.beta.vectorStores.update( + "vs_abc123", + { + name: "Support FAQ" + } + ); + console.log(vectorStore); + } + + main(); + response: | + { + "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 + } + } + + delete: + operationId: deleteVectorStore + tags: + - Vector Stores + summary: Delete a vector store. + parameters: + - in: path + name: vector_store_id + required: true + schema: + type: string + description: The ID of the vector store to delete. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/DeleteVectorStoreResponse" + x-oaiMeta: + name: Delete vector store + group: vector_stores + beta: true + returns: Deletion status + examples: + request: + curl: | + curl https://api.portkey.ai/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 + } + + /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: *pagination_limit_param_description + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: *pagination_order_param_description + schema: + type: string + default: desc + enum: ["asc", "desc"] + - name: after + in: query + description: *pagination_after_param_description + schema: + type: string + - name: before + in: query + description: *pagination_before_param_description + 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](https://platform.openai.com/docs/api-reference/vector-stores-files/file-object) objects. + examples: + request: + curl: | + curl https://api.portkey.ai/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(); + + async function main() { + const vectorStoreFiles = await openai.beta.vectorStores.files.list( + "vs_abc123" + ); + console.log(vectorStoreFiles); + } + + 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](https://platform.openai.com/docs/api-reference/files) to a [vector store](https://platform.openai.com/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](https://platform.openai.com/docs/api-reference/vector-stores-files/file-object) object. + examples: + request: + curl: | + curl https://api.portkey.ai/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() + + 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(); + + async function main() { + const myVectorStoreFile = await openai.beta.vectorStores.files.create( + "vs_abc123", + { + file_id: "file-abc123" + } + ); + console.log(myVectorStoreFile); + } + + 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](https://platform.openai.com/docs/api-reference/vector-stores-files/file-object) object. + examples: + request: + curl: | + curl https://api.portkey.ai/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() + + 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(); + + async function main() { + const vectorStoreFile = await openai.beta.vectorStores.files.retrieve( + "vs_abc123", + "file-abc123" + ); + console.log(vectorStoreFile); + } + + 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](https://platform.openai.com/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.portkey.ai/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() + + 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(); + + async function main() { + const deletedVectorStoreFile = await openai.beta.vectorStores.files.del( + "vs_abc123", + "file-abc123" + ); + console.log(deletedVectorStoreFile); + } + + main(); + response: | + { + id: "file-abc123", + object: "vector_store.file.deleted", + deleted: true + } + + /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" + x-oaiMeta: + name: Create vector store file batch + group: vector_stores + beta: true + returns: A [vector store file batch](https://platform.openai.com/docs/api-reference/vector-stores-file-batches/batch-object) object. + examples: + request: + curl: | + curl https://api.portkey.ai/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, + } + } + + /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" + x-oaiMeta: + name: Retrieve vector store file batch + group: vector_stores + beta: true + returns: The [vector store file batch](https://platform.openai.com/docs/api-reference/vector-stores-file-batches/batch-object) object. + examples: + request: + curl: | + curl https://api.portkey.ai/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() + + 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(); + + async function main() { + const vectorStoreFileBatch = await openai.beta.vectorStores.fileBatches.retrieve( + "vs_abc123", + "vsfb_abc123" + ); + console.log(vectorStoreFileBatch); + } + + 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.portkey.ai/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() + + 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(); + + async function main() { + const deletedVectorStoreFileBatch = await openai.vector_stores.fileBatches.cancel( + "vs_abc123", + "vsfb_abc123" + ); + console.log(deletedVectorStoreFileBatch); + } + + 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: *pagination_limit_param_description + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: *pagination_order_param_description + schema: + type: string + default: desc + enum: ["asc", "desc"] + - name: after + in: query + description: *pagination_after_param_description + schema: + type: string + - name: before + in: query + description: *pagination_before_param_description + 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 in a batch + group: vector_stores + beta: true + returns: A list of [vector store file](https://platform.openai.com/docs/api-reference/vector-stores-files/file-object) objects. + examples: + request: + curl: | + curl https://api.portkey.ai/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() + + 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(); + + async function main() { + const vectorStoreFiles = await openai.beta.vectorStores.fileBatches.listFiles( + "vs_abc123", + "vsfb_abc123" + ); + console.log(vectorStoreFiles); + } + + 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 + } + + /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](https://platform.openai.com/docs/api-reference/files/create) for how to upload a file. + + Your input file must be formatted as a [JSONL file](https://platform.openai.com/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](https://platform.openai.com/docs/api-reference/batch/object) object. + examples: + request: + curl: | + curl https://api.portkey.ai/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: *pagination_after_param_description + - name: limit + in: query + description: *pagination_limit_param_description + 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](https://platform.openai.com/docs/api-reference/batch/object) objects. + examples: + request: + curl: | + curl https://api.portkey.ai/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](https://platform.openai.com/docs/api-reference/batch/object) object matching the specified ID. + examples: + request: + curl: | + curl https://api.portkey.ai/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: &batch_object | + { + "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](https://platform.openai.com/docs/api-reference/batch/object) object matching the specified ID. + examples: + request: + curl: | + curl https://api.portkey.ai/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", + } + } + +components: + securitySchemes: + ApiKeyAuth: + type: http + scheme: "bearer" + + schemas: + 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 + ErrorResponse: + type: object + properties: + error: + $ref: "#/components/schemas/Error" + required: + - error + + ListModelsResponse: + type: object + properties: + object: + type: string + enum: [list] + data: + type: array + items: + $ref: "#/components/schemas/Model" + required: + - object + - data + DeleteModelResponse: + type: object + properties: + id: + type: string + deleted: + type: boolean + object: + type: string + required: + - id + - object + - deleted + + CreateCompletionRequest: + type: object + properties: + model: + description: &model_description | + ID of the model to use. You can use the [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](https://platform.openai.com/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: &completions_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: &completions_best_of_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: &completions_echo_description > + Echo back the prompt in addition to the completion + frequency_penalty: + type: number + default: 0 + minimum: -2 + maximum: 2 + nullable: true + description: &completions_frequency_penalty_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.](https://platform.openai.com/docs/guides/text-generation/parameter-details) + logit_bias: &completions_logit_bias + type: object + x-oaiTypeLabel: map + default: null + nullable: true + additionalProperties: + type: integer + description: &completions_logit_bias_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](https://platform.openai.com/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: &completions_logprobs_configuration + type: integer + minimum: 0 + maximum: 5 + default: null + nullable: true + description: &completions_logprobs_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: &completions_max_tokens_description | + The maximum number of [tokens](https://platform.openai.com/tokenizer?view=bpe) 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: &completions_completions_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: &completions_presence_penalty_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.](https://platform.openai.com/docs/guides/text-generation/parameter-details) + seed: &completions_seed_param + type: integer + minimum: -9223372036854775808 + maximum: 9223372036854775807 + 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: &completions_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: "\n" + 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-UShttps://platform.openai.com/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: &completions_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. + + 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: &completions_top_p_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: &end_user_param_configuration + type: string + example: user-1234 + description: | + A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](https://platform.openai.com/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: &completion_finish_reason_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 + } + } + + ChatCompletionRequestMessageContentPart: + oneOf: + - $ref: "#/components/schemas/ChatCompletionRequestMessageContentPartText" + - $ref: "#/components/schemas/ChatCompletionRequestMessageContentPartImage" + x-oaiExpandable: true + + ChatCompletionRequestMessageContentPartImage: + type: object + title: Image content part + 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](https://platform.openai.com/docs/guides/vision/low-or-high-fidelity-image-understanding). + enum: ["auto", "low", "high"] + default: "auto" + required: + - url + required: + - type + - image_url + + ChatCompletionRequestMessageContentPartText: + type: object + title: Text content part + properties: + type: + type: string + enum: ["text"] + description: The type of the content part. + text: + type: string + description: The text content. + required: + - type + - text + + 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 + + ChatCompletionRequestSystemMessage: + type: object + title: System message + properties: + content: + description: The contents of the system message. + type: string + 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, each can be of type `text` or `image_url` when passing in images. You can pass multiple images by adding multiple `image_url` content parts. Image input is only supported when using the `gpt-4-visual-preview` model. + title: Array of content parts + items: + $ref: "#/components/schemas/ChatCompletionRequestMessageContentPart" + 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: + nullable: true + type: string + description: | + The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified. + 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. + 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 + + # TODO(apeng): This is only because we don't support tools yet. Use allOf once we do. + FineTuneChatCompletionRequestAssistantMessage: + type: object + title: Assistant message + properties: + content: + nullable: true + type: string + description: | + The contents of the assistant message. Required unless `function_call` is specified. + 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. + function_call: + type: object + description: 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 + weight: + type: integer + enum: [0, 1] + description: "Controls whether the assistant message is trained against (0 or 1)" + 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: + type: string + 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 + + # TODO(apeng): This is only because we don't support tools yet. Add back deprecated once we do. + FineTuneChatCompletionRequestFunctionMessage: + allOf: + - type: object + title: Function message + deprecated: false + - $ref: "#/components/schemas/ChatCompletionRequestFunctionMessage" + + FunctionParameters: + type: object + description: "The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. \n\nOmitting `parameters` defines a function with an empty parameter list." + additionalProperties: true + + 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 + + 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 + + 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 + + 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" + required: + - name + + 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 + + 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 + + ParallelToolCalls: + description: Whether to enable [parallel function calling](https://platform.openai.com/docs/guides/function-calling/parallel-function-calling) during tool use. + type: boolean + default: true + + ChatCompletionMessageToolCalls: + type: array + description: The tool calls generated by the model, such as function calls. + items: + $ref: "#/components/schemas/ChatCompletionMessageToolCall" + + ChatCompletionMessageToolCall: + type: object + properties: + # TODO: index included when streaming + 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 + + ChatCompletionMessageToolCallChunk: + type: object + properties: + index: + type: integer + 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 + 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: + - index + + # Note, this isn't referenced anywhere, but is kept as a convenience to record all possible roles in one place. + ChatCompletionRole: + type: string + description: The role of the author of a message + enum: + - system + - user + - assistant + - tool + - function + + 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. + + ChatCompletionResponseMessage: + type: object + description: A chat completion message generated by the model. + properties: + content: + type: string + description: The contents of the message. + 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 + required: + - role + - content + + ChatCompletionStreamResponseDelta: + type: object + description: A chat completion delta generated by streamed model responses. + properties: + content: + type: string + description: The contents of the chunk message. + nullable: true + function_call: + deprecated: true + type: object + 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. + tool_calls: + type: array + items: + $ref: "#/components/schemas/ChatCompletionMessageToolCallChunk" + role: + type: string + enum: ["system", "user", "assistant", "tool"] + description: The role of the author of this message. + + CreateChatCompletionRequest: + type: object + properties: + messages: + description: A list of messages comprising the conversation so far. [Example Python code](https://cookbook.openai.com/examples/how_to_format_inputs_to_chatgpt_models). + type: array + minItems: 1 + items: + $ref: "#/components/schemas/ChatCompletionRequestMessage" + model: + description: ID of the model to use. See the [model endpoint compatibility](https://platform.openai.com/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API. + example: "gpt-4-turbo" + anyOf: + - type: string + - type: string + enum: + [ + "gpt-4o", + "gpt-4o-2024-05-13", + "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 + frequency_penalty: + type: number + default: 0 + minimum: -2 + maximum: 2 + nullable: true + description: *completions_frequency_penalty_description + 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](https://platform.openai.com/tokenizer?view=bpe) that can be generated in the chat completion. + + The total length of input tokens and generated tokens is limited by the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. + 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. + presence_penalty: + type: number + default: 0 + minimum: -2 + maximum: 2 + nullable: true + description: *completions_presence_penalty_description + response_format: + type: object + description: | + An object specifying the format that the model must output. Compatible with [GPT-4 Turbo](https://platform.openai.com/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_object" }` enables JSON mode, which guarantees 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. + properties: + type: + type: string + enum: ["text", "json_object"] + example: "json_object" + default: "text" + description: Must be one of `text` or `json_object`. + seed: + type: integer + minimum: -9223372036854775808 + maximum: 9223372036854775807 + 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 + 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-UShttps://platform.openai.com/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: *completions_temperature_description + top_p: + type: number + minimum: 0 + maximum: 1 + default: 1 + example: 1 + nullable: true + description: *completions_top_p_description + 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: *end_user_param_configuration + 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: &chat_completion_finish_reason_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: &chat_completion_response_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 + required: + - content + 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. + 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: *chat_completion_example + + CreateChatCompletionFunctionResponse: + 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: + &chat_completion_function_finish_reason_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, or `function_call` if the model called a function. + enum: + ["stop", "length", "function_call", "content_filter"] + index: + type: integer + description: The index of the choice in the list of choices. + message: + $ref: "#/components/schemas/ChatCompletionResponseMessage" + 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. + 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: *chat_completion_function_example + + ChatCompletionTokenLogprob: + type: object + properties: + token: &chat_completion_response_logprobs_token + description: The token. + type: string + logprob: &chat_completion_response_logprobs_token_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: &chat_completion_response_logprobs_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: *chat_completion_response_logprobs_token + logprob: *chat_completion_response_logprobs_token_logprob + bytes: *chat_completion_response_logprobs_bytes + required: + - token + - logprob + - bytes + required: + - token + - logprob + - bytes + - top_logprobs + + 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 + + CreateChatCompletionStreamResponse: + type: object + description: Represents a streamed chunk of a chat completion response returned by model, based on the provided input. + properties: + id: + type: string + description: A unique identifier for the chat completion. Each chunk has the same ID. + choices: + type: array + description: | + A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the + last chunk if you set `stream_options: {"include_usage": true}`. + items: + type: object + required: + - delta + - finish_reason + - index + properties: + delta: + $ref: "#/components/schemas/ChatCompletionStreamResponseDelta" + logprobs: *chat_completion_response_logprobs + finish_reason: + type: string + description: *chat_completion_finish_reason_description + enum: + [ + "stop", + "length", + "tool_calls", + "content_filter", + "function_call", + ] + nullable: true + index: + type: integer + description: The index of the choice in the list of choices. + created: + type: integer + description: The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp. + model: + type: string + description: The model to generate the 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 `chat.completion.chunk`. + enum: [chat.completion.chunk] + usage: + type: object + description: | + An optional field that will only be present when you set `stream_options: {"include_usage": true}` in your request. + When present, it contains a null value except for the last chunk which contains the token usage statistics for the entire 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). + required: + - prompt_tokens + - completion_tokens + - total_tokens + required: + - choices + - created + - id + - model + - object + x-oaiMeta: + name: The chat completion chunk object + group: chat + example: *chat_completion_chunk_example + + CreateChatCompletionImageResponse: + type: object + description: Represents a streamed chunk of a chat completion response returned by model, based on the provided input. + x-oaiMeta: + name: The chat completion chunk object + group: chat + example: *chat_completion_image_example + + 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: &images_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: &images_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: &images_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: *end_user_param_configuration + required: + - prompt + + 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 Portkey 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": "..." + } + + 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: &dalle2_images_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: *images_response_format + user: *end_user_param_configuration + required: + - prompt + - image + + 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: *images_n + response_format: *images_response_format + size: *dalle2_images_size + user: *end_user_param_configuration + required: + - image + + CreateModerationRequest: + type: object + properties: + input: + description: The input text to classify + oneOf: + - type: string + default: "" + example: "I want to kill them." + - type: array + items: + type: string + default: "" + example: "I want to kill them." + model: + description: | + Two content moderations models are available: `text-moderation-stable` and `text-moderation-latest`. + + The default is `text-moderation-latest` which will be automatically upgraded over time. This ensures you are always using our most accurate model. If you use `text-moderation-stable`, we will provide advanced notice before updating the model. Accuracy of `text-moderation-stable` may be slightly lower than for `text-moderation-latest`. + nullable: false + default: "text-moderation-latest" + example: "text-moderation-stable" + anyOf: + - type: string + - type: string + enum: ["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. + 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 + - 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'. + 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 + - self-harm + - self-harm/intent + - self-harm/instructions + - sexual + - sexual/minors + - violence + - violence/graphic + required: + - flagged + - categories + - category_scores + required: + - id + - model + - results + x-oaiMeta: + name: The moderation object + example: *moderation_example + + ListFilesResponse: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/OpenAIFile" + object: + type: string + enum: [list] + required: + - object + - data + + 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](https://platform.openai.com/docs/api-reference/assistants) and [Message](https://platform.openai.com/docs/api-reference/messages) files, "vision" for Assistants image file inputs, "batch" for [Batch API](https://platform.openai.com/docs/guides/batch), and "fine-tune" for [Fine-tuning](https://platform.openai.com/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 + + CreateFineTuningJobRequest: + type: object + properties: + model: + description: | + The name of the model to fine-tune. You can select one of the + [supported models](https://platform.openai.com/docs/guides/fine-tuning/what-models-can-be-fine-tuned). + example: "gpt-3.5-turbo" + anyOf: + - type: string + - type: string + enum: ["babbage-002", "davinci-002", "gpt-3.5-turbo"] + x-oaiTypeLabel: string + training_file: + description: | + The ID of an uploaded file that contains training data. + + See [upload file](https://platform.openai.com/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](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input) format. + + See the [fine-tuning guide](https://platform.openai.com/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 18 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-3.5-turbo:openai:custom-model-name:7p4lURel`. + type: string + minLength: 1 + maxLength: 40 + 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](https://platform.openai.com/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: + type: + description: | + The type of integration to enable. Currently, only "wandb" (Weights and Biases) is supported. + oneOf: + - type: string + 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" + + 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. + If a seed is not specified, one will be generated for you. + type: integer + nullable: true + minimum: 0 + maximum: 2147483647 + example: 42 + required: + - model + - training_file + + ListFineTuningJobEventsResponse: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/FineTuningJobEvent" + object: + type: string + enum: [list] + required: + - object + - data + + 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 + + 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: *model_description + 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: *end_user_param_configuration + 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 + + 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](https://platform.openai.com/docs/guides/speech-to-text/prompting) should match the audio language. + type: string + response_format: + description: | + The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`. + type: string + enum: + - json + - text + - srt + - verbose_json + - vtt + default: json + 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 + + # Note: This does not currently support the non-default response format types. + 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: *basic_transcription_response_example + + 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 + + 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] + + 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: *verbose_transcription_response_example + + 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](https://platform.openai.com/docs/guides/speech-to-text/prompting) should be in English. + type: string + response_format: + description: | + The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`. + type: string + default: json + 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 + + # Note: This does not currently support the non-default response format types. + 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] + + CreateSpeechRequest: + type: object + additionalProperties: false + properties: + model: + description: | + One of the available [TTS models](https://platform.openai.com/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](https://platform.openai.com/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.0 + minimum: 0.25 + maximum: 4.0 + required: + - model + - input + - voice + + 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: *retrieve_model_response + + 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", + } + 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](https://platform.openai.com/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 + } + + FineTuningJob: + type: object + title: FineTuningJob + 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. + created_at: + type: integer + 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. + properties: + code: + type: string + description: A machine-readable error code. + message: + 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 + 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. + 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. + hyperparameters: + type: object + description: The hyperparameters used for the fine-tuning job. See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning) for more details. + properties: + n_epochs: + oneOf: + - type: string + enum: [auto] + - 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". + enum: [fine_tuning.job] + 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](https://platform.openai.com/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`. + enum: + [ + "validating_files", + "queued", + "running", + "succeeded", + "failed", + "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. + training_file: + type: string + description: The file ID used for training. You can retrieve the training data with the [Files API](https://platform.openai.com/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](https://platform.openai.com/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: *fine_tuning_example + + 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" + + FineTuningJobEvent: + 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" + } + + 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] + required: + - created_at + - fine_tuning_job_id + - fine_tuned_model_checkpoint + - id + - metrics + - object + - step_number + x-oaiMeta: + 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-3.5-turbo-0125: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 + } + + FinetuneChatRequestInput: + type: object + description: The per-line training example of a fine-tuning input file for chat models + properties: + messages: + type: array + minItems: 1 + items: + oneOf: + - $ref: "#/components/schemas/ChatCompletionRequestSystemMessage" + - $ref: "#/components/schemas/ChatCompletionRequestUserMessage" + - $ref: "#/components/schemas/FineTuneChatCompletionRequestAssistantMessage" + - $ref: "#/components/schemas/FineTuneChatCompletionRequestFunctionMessage" + x-oaiExpandable: true + functions: + description: + A list of functions the model may generate JSON inputs for. + type: array + minItems: 1 + maxItems: 128 + items: + $ref: "#/components/schemas/ChatCompletionFunctions" + x-oaiMeta: + name: Training format for chat models + example: | + {"messages":[{"role":"user","content":"What is the weather in San Francisco?"},{"role":"assistant","function_call":{"name":"get_current_weather","arguments":"{\"location\": \"San Francisco, USA\", \"format\": \"celsius\"}"}}],"functions":[{"name":"get_current_weather","description":"Get the current weather","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and country, eg. San Francisco, USA"},"format":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location","format"]}}]} + + FinetuneCompletionRequestInput: + type: object + description: The per-line training example of a fine-tuning input file for completions models + properties: + prompt: + type: string + description: The input prompt for this training example. + completion: + type: string + description: The desired completion for this training example. + x-oaiMeta: + name: Training format for completions models + example: | + {"prompt": "What is the answer to 2+2", "completion": "4"} + + 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). + required: + - prompt_tokens + - completion_tokens + - total_tokens + + 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 + + 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 + + AssistantsApiResponseFormatOption: + description: | + Specifies the format that the model must output. Compatible with [GPT-4o](https://platform.openai.com/docs/models/gpt-4o), [GPT-4 Turbo](https://platform.openai.com/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_object" }` enables JSON mode, which guarantees 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: + - type: string + description: > + `auto` is the default value + enum: [none, auto] + - $ref: "#/components/schemas/AssistantsApiResponseFormat" + x-oaiExpandable: true + + AssistantsApiResponseFormat: + type: object + description: | + An object describing the expected output of the model. If `json_object` only `function` type `tools` are allowed to be passed to the Run. If `text` the model can return text or any value needed. + properties: + type: + type: string + enum: ["text", "json_object"] + example: "json_object" + default: "text" + description: Must be one of `text` or `json_object`. + + 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: &assistant_name_param_description | + The name of the assistant. The maximum length is 256 characters. + type: string + maxLength: 256 + nullable: true + description: + description: &assistant_description_param_description | + The description of the assistant. The maximum length is 512 characters. + type: string + maxLength: 512 + nullable: true + model: + description: *model_description + type: string + instructions: + description: &assistant_instructions_param_description | + The system instructions that the assistant uses. The maximum length is 256,000 characters. + type: string + maxLength: 256000 + nullable: true + tools: + description: &assistant_tools_param_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](https://platform.openai.com/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](https://platform.openai.com/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: &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 maxium of 512 characters long. + type: object + x-oaiTypeLabel: map + nullable: true + temperature: + description: &run_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: &run_top_p_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 + x-oaiMeta: + name: The assistant object + beta: true + example: *create_assistants_example + + CreateAssistantRequest: + type: object + additionalProperties: false + properties: + model: + description: *model_description + example: "gpt-4-turbo" + anyOf: + - type: string + - type: string + enum: + [ + "gpt-4o", + "gpt-4o-2024-05-13", + "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: *assistant_name_param_description + type: string + nullable: true + maxLength: 256 + description: + description: *assistant_description_param_description + type: string + nullable: true + maxLength: 512 + instructions: + description: *assistant_instructions_param_description + type: string + nullable: true + maxLength: 256000 + tools: + description: *assistant_tools_param_description + 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](https://platform.openai.com/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](https://platform.openai.com/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](https://platform.openai.com/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](https://platform.openai.com/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: + # Ideally we'd reuse the chunking strategy schema here, but it doesn't expand properly + 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 maxium of 512 characters long. + x-oaiTypeLabel: map + oneOf: + - required: [vector_store_ids] + - required: [vector_stores] + nullable: true + metadata: + description: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: true + temperature: + description: &run_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: &run_top_p_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: + - model + + ModifyAssistantRequest: + type: object + additionalProperties: false + properties: + model: + description: *model_description + anyOf: + - type: string + name: + description: *assistant_name_param_description + type: string + nullable: true + maxLength: 256 + description: + description: *assistant_description_param_description + type: string + nullable: true + maxLength: 512 + instructions: + description: *assistant_instructions_param_description + type: string + nullable: true + maxLength: 256000 + tools: + description: *assistant_tools_param_description + 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](https://platform.openai.com/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](https://platform.openai.com/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: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: true + temperature: + description: *run_temperature_description + 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: &run_top_p_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 + + 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: *list_assistants_example + + 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. + + Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/number-of-chunks-returned) for more information. + required: + - type + + AssistantToolsFileSearchTypeOnly: + type: object + title: FileSearch tool + properties: + type: + type: string + description: "The type of tool being defined: `file_search`" + enum: ["file_search"] + 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 + + 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 + + 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 + + RunObject: + type: object + title: A run on a thread + description: Represents an execution run on a [thread](https://platform.openai.com/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](https://platform.openai.com/docs/api-reference/threads) that was executed on as a part of this run. + type: string + assistant_id: + description: The ID of the [assistant](https://platform.openai.com/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](https://platform.openai.com/docs/api-reference/assistants) used for this run. + type: string + instructions: + description: The instructions that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. + type: string + tools: + description: The list of tools that the [assistant](https://platform.openai.com/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: *metadata_description + 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 + x-oaiMeta: + name: The run object + 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-4-turbo", + "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 + } + CreateRunRequest: + type: object + additionalProperties: false + properties: + assistant_id: + description: The ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to execute this run. + type: string + model: + description: The ID of the [Model](https://platform.openai.com/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-4-turbo" + anyOf: + - type: string + - type: string + enum: + [ + "gpt-4o", + "gpt-4o-2024-05-13", + "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](https://platform.openai.com/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: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: true + temperature: + type: number + minimum: 0 + maximum: 2 + default: 1 + example: 1 + nullable: true + description: *run_temperature_description + top_p: + type: number + minimum: 0 + maximum: 1 + default: 1 + example: 1 + nullable: true + description: &run_top_p_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: + - thread_id + - assistant_id + 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 + ModifyRunRequest: + type: object + additionalProperties: false + properties: + metadata: + description: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: true + 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 + + 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](https://platform.openai.com/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 + + CreateThreadAndRunRequest: + type: object + additionalProperties: false + properties: + assistant_id: + description: The ID of the [assistant](https://platform.openai.com/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](https://platform.openai.com/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-4-turbo" + anyOf: + - type: string + - type: string + enum: + [ + "gpt-4o", + "gpt-4o-2024-05-13", + "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](https://platform.openai.com/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](https://platform.openai.com/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: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: true + temperature: + type: number + minimum: 0 + maximum: 2 + default: 1 + example: 1 + nullable: true + description: *run_temperature_description + top_p: + type: number + minimum: 0 + maximum: 1 + default: 1 + example: 1 + nullable: true + description: *run_top_p_description + 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: + - thread_id + - assistant_id + + ThreadObject: + type: object + title: Thread + description: Represents a thread that contains [messages](https://platform.openai.com/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](https://platform.openai.com/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](https://platform.openai.com/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: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: true + 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": {} + } + + CreateThreadRequest: + type: object + additionalProperties: false + properties: + messages: + description: A list of [messages](https://platform.openai.com/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](https://platform.openai.com/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](https://platform.openai.com/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](https://platform.openai.com/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](https://platform.openai.com/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: + # Ideally we'd reuse the chunking strategy schema here, but it doesn't expand properly + 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 maxium of 512 characters long. + x-oaiTypeLabel: map + x-oaiExpandable: true + oneOf: + - required: [vector_store_ids] + - required: [vector_stores] + nullable: true + metadata: + description: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: 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](https://platform.openai.com/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](https://platform.openai.com/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: *metadata_description + 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 + + ListThreadsResponse: + properties: + object: + type: string + example: "list" + data: + type: array + items: + $ref: "#/components/schemas/ThreadObject" + 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 + + MessageObject: + type: object + title: The message object + description: Represents a message within a [thread](https://platform.openai.com/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](https://platform.openai.com/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" + x-oaiExpandable: true + assistant_id: + description: If applicable, the ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) that authored this message. + type: string + nullable: true + run_id: + description: The ID of the [run](https://platform.openai.com/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: *metadata_description + 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": {} + } + + MessageDeltaObject: + type: object + title: Message delta object + description: | + Represents a message delta i.e. any changed fields on a message during streaming. + properties: + id: + description: The identifier of the message, which can be referenced in API endpoints. + type: string + object: + description: The object type, which is always `thread.message.delta`. + type: string + enum: ["thread.message.delta"] + delta: + description: The delta containing the fields that have changed on the Message. + type: object + properties: + 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/MessageDeltaContentImageFileObject" + - $ref: "#/components/schemas/MessageDeltaContentTextObject" + - $ref: "#/components/schemas/MessageDeltaContentImageUrlObject" + x-oaiExpandable: true + required: + - id + - object + - delta + x-oaiMeta: + name: The message delta object + beta: true + example: | + { + "id": "msg_123", + "object": "thread.message.delta", + "delta": { + "content": [ + { + "index": 0, + "type": "text", + "text": { "value": "Hello", "annotations": [] } + } + ] + } + } + + 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. + 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](https://platform.openai.com/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: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: true + + ModifyMessageRequest: + type: object + additionalProperties: false + properties: + metadata: + description: *metadata_description + 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 + + 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 + + MessageContentImageFileObject: + title: Image file + type: object + description: References an image [File](https://platform.openai.com/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](https://platform.openai.com/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 + + MessageDeltaContentImageFileObject: + title: Image file + type: object + description: References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + properties: + index: + type: integer + description: The index of the content part in the message. + type: + description: Always `image_file`. + type: string + enum: ["image_file"] + image_file: + type: object + properties: + file_id: + description: The [File](https://platform.openai.com/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: + - index + - type + + 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 + + MessageDeltaContentImageUrlObject: + title: Image URL + type: object + description: References an image URL in the content of a message. + properties: + index: + type: integer + description: The index of the content part in the message. + type: + description: Always `image_url`. + type: string + enum: ["image_url"] + image_url: + type: object + properties: + url: + description: "The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp." + type: string + detail: + type: string + description: Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. + enum: ["auto", "low", "high"] + default: "auto" + required: + - index + - 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"] + 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 + + 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 + + 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 + quote: + description: The specific quote in the file. + type: string + required: + - file_id + - quote + 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 + + MessageDeltaContentTextObject: + title: Text + type: object + description: The text content that is part of a message. + properties: + index: + type: integer + description: The index of the content part in the message. + 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/MessageDeltaContentTextAnnotationsFileCitationObject" + - $ref: "#/components/schemas/MessageDeltaContentTextAnnotationsFilePathObject" + x-oaiExpandable: true + required: + - index + - type + + MessageDeltaContentTextAnnotationsFileCitationObject: + 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: + index: + type: integer + description: The index of the annotation in the text content part. + 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 + quote: + description: The specific quote in the file. + type: string + start_index: + type: integer + minimum: 0 + end_index: + type: integer + minimum: 0 + required: + - index + - type + + MessageDeltaContentTextAnnotationsFilePathObject: + 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: + index: + type: integer + description: The index of the annotation in the text content part. + 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 + start_index: + type: integer + minimum: 0 + end_index: + type: integer + minimum: 0 + required: + - index + - type + + 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](https://platform.openai.com/docs/api-reference/assistants) associated with the run step. + type: string + thread_id: + description: The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) that was run. + type: string + run_id: + description: The ID of the [run](https://platform.openai.com/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: *metadata_description + 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: *run_step_object_example + + RunStepDeltaObject: + type: object + title: Run step delta object + description: | + Represents a run step delta i.e. any changed fields on a run step during streaming. + 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.delta`. + type: string + enum: ["thread.run.step.delta"] + delta: + description: The delta containing the fields that have changed on the run step. + type: object + properties: + step_details: + type: object + description: The details of the run step. + oneOf: + - $ref: "#/components/schemas/RunStepDeltaStepDetailsMessageCreationObject" + - $ref: "#/components/schemas/RunStepDeltaStepDetailsToolCallsObject" + x-oaiExpandable: true + required: + - id + - object + - delta + x-oaiMeta: + name: The run step delta object + beta: true + example: | + { + "id": "step_123", + "object": "thread.run.step.delta", + "delta": { + "step_details": { + "type": "tool_calls", + "tool_calls": [ + { + "index": 0, + "id": "call_123", + "type": "code_interpreter", + "code_interpreter": { "input": "", "outputs": [] } + } + ] + } + } + } + + 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 + + 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 + + RunStepDeltaStepDetailsMessageCreationObject: + 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: + - type + + 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 + + RunStepDeltaStepDetailsToolCallsObject: + 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/RunStepDeltaStepDetailsToolCallsCodeObject" + - $ref: "#/components/schemas/RunStepDeltaStepDetailsToolCallsFileSearchObject" + - $ref: "#/components/schemas/RunStepDeltaStepDetailsToolCallsFunctionObject" + x-oaiExpandable: true + required: + - type + + 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 + + RunStepDeltaStepDetailsToolCallsCodeObject: + title: Code interpreter tool call + type: object + description: Details of the Code Interpreter tool call the run step was involved in. + properties: + index: + type: integer + description: The index of the tool call in the tool calls array. + 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. + 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/RunStepDeltaStepDetailsToolCallsCodeOutputLogsObject" + - $ref: "#/components/schemas/RunStepDeltaStepDetailsToolCallsCodeOutputImageObject" + x-oaiExpandable: true + required: + - index + - type + + 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 + + RunStepDeltaStepDetailsToolCallsCodeOutputLogsObject: + title: Code interpreter log output + type: object + description: Text output from the Code Interpreter tool call as part of a run step. + properties: + index: + type: integer + description: The index of the output in the outputs array. + type: + description: Always `logs`. + type: string + enum: ["logs"] + logs: + type: string + description: The text output from the Code Interpreter tool call. + required: + - index + - type + + 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](https://platform.openai.com/docs/api-reference/files) ID of the image. + type: string + required: + - file_id + required: + - type + - image + + RunStepDeltaStepDetailsToolCallsCodeOutputImageObject: + title: Code interpreter image output + type: object + properties: + index: + type: integer + description: The index of the output in the outputs array. + type: + description: Always `image`. + type: string + enum: ["image"] + image: + type: object + properties: + file_id: + description: The [file](https://platform.openai.com/docs/api-reference/files) ID of the image. + type: string + required: + - index + - type + + 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 + required: + - id + - type + - file_search + + RunStepDeltaStepDetailsToolCallsFileSearchObject: + title: File search tool call + type: object + properties: + index: + type: integer + description: The index of the tool call in the tool calls array. + 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 + required: + - index + - 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](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs) yet. + nullable: true + required: + - name + - arguments + - output + required: + - id + - type + - function + + RunStepDeltaStepDetailsToolCallsFunctionObject: + type: object + title: Function tool call + properties: + index: + type: integer + description: The index of the tool call in the tool calls array. + 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](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs) yet. + nullable: true + required: + - index + - type + + 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 + + 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: *metadata_description + 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 + } + + CreateVectorStoreRequest: + type: object + additionalProperties: false + properties: + file_ids: + description: A list of [File](https://platform.openai.com/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: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: true + + 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: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: true + + 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 + + DeleteVectorStoreResponse: + type: object + properties: + id: + type: string + deleted: + type: boolean + object: + type: string + enum: [vector_store.deleted] + required: + - id + - object + - deleted + + 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](https://platform.openai.com/docs/api-reference/vector-stores/object) that the [File](https://platform.openai.com/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: + [ + "internal_error", + "file_not_found", + "parsing_error", + "unhandled_mime_type", + ] + 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 + 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 + } + } + } + + 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 + + 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 + + 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 + + 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 + + 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 + + CreateVectorStoreFileRequest: + type: object + additionalProperties: false + properties: + file_id: + description: A [File](https://platform.openai.com/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 + + 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 + + DeleteVectorStoreFileResponse: + type: object + properties: + id: + type: string + deleted: + type: boolean + object: + type: string + enum: [vector_store.file.deleted] + required: + - id + - object + - deleted + + 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](https://platform.openai.com/docs/api-reference/vector-stores/object) that the [File](https://platform.openai.com/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 + } + } + + CreateVectorStoreFileBatchRequest: + type: object + additionalProperties: false + properties: + file_ids: + description: A list of [File](https://platform.openai.com/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: + type: string + chunking_strategy: + $ref: "#/components/schemas/ChunkingStrategyRequestParam" + required: + - file_ids + + AssistantStreamEvent: + description: | + Represents an event emitted when streaming a Run. + + Each event in a server-sent events stream has an `event` and `data` property: + + ``` + event: thread.created + data: {"id": "thread_123", "object": "thread", ...} + ``` + + We emit events whenever a new object is created, transitions to a new state, or is being + streamed in parts (deltas). For example, we emit `thread.run.created` when a new run + is created, `thread.run.completed` when a run completes, and so on. When an Assistant chooses + to create a message during a run, we emit a `thread.message.created event`, a + `thread.message.in_progress` event, many `thread.message.delta` events, and finally a + `thread.message.completed` event. + + We may add additional events over time, so we recommend handling unknown events gracefully + in your code. See the [Assistants API quickstart](https://platform.openai.com/docs/assistants/overview) to learn how to + integrate the Assistants API with streaming. + oneOf: + - $ref: "#/components/schemas/ThreadStreamEvent" + - $ref: "#/components/schemas/RunStreamEvent" + - $ref: "#/components/schemas/RunStepStreamEvent" + - $ref: "#/components/schemas/MessageStreamEvent" + - $ref: "#/components/schemas/ErrorEvent" + - $ref: "#/components/schemas/DoneEvent" + x-oaiMeta: + name: Assistant stream events + beta: true + + ThreadStreamEvent: + oneOf: + - type: object + properties: + event: + type: string + enum: ["thread.created"] + data: + $ref: "#/components/schemas/ThreadObject" + required: + - event + - data + description: Occurs when a new [thread](https://platform.openai.com/docs/api-reference/threads/object) is created. + x-oaiMeta: + dataDescription: "`data` is a [thread](https://platform.openai.com/docs/api-reference/threads/object)" + + RunStreamEvent: + oneOf: + - type: object + properties: + event: + type: string + enum: ["thread.run.created"] + data: + $ref: "#/components/schemas/RunObject" + required: + - event + - data + description: Occurs when a new [run](https://platform.openai.com/docs/api-reference/runs/object) is created. + x-oaiMeta: + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.queued"] + data: + $ref: "#/components/schemas/RunObject" + required: + - event + - data + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `queued` status. + x-oaiMeta: + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.in_progress"] + data: + $ref: "#/components/schemas/RunObject" + required: + - event + - data + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to an `in_progress` status. + x-oaiMeta: + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.requires_action"] + data: + $ref: "#/components/schemas/RunObject" + required: + - event + - data + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `requires_action` status. + x-oaiMeta: + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.completed"] + data: + $ref: "#/components/schemas/RunObject" + required: + - event + - data + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) is completed. + x-oaiMeta: + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" + - type: object + properties: + event: + type: string + enum: [ "thread.run.incomplete" ] + data: + $ref: "#/components/schemas/RunObject" + required: + - event + - data + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) ends with status `incomplete`. + x-oaiMeta: + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.failed"] + data: + $ref: "#/components/schemas/RunObject" + required: + - event + - data + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) fails. + x-oaiMeta: + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.cancelling"] + data: + $ref: "#/components/schemas/RunObject" + required: + - event + - data + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `cancelling` status. + x-oaiMeta: + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.cancelled"] + data: + $ref: "#/components/schemas/RunObject" + required: + - event + - data + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) is cancelled. + x-oaiMeta: + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.expired"] + data: + $ref: "#/components/schemas/RunObject" + required: + - event + - data + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) expires. + x-oaiMeta: + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" + + RunStepStreamEvent: + oneOf: + - type: object + properties: + event: + type: string + enum: ["thread.run.step.created"] + data: + $ref: "#/components/schemas/RunStepObject" + required: + - event + - data + description: Occurs when a [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is created. + x-oaiMeta: + dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.step.in_progress"] + data: + $ref: "#/components/schemas/RunStepObject" + required: + - event + - data + description: Occurs when a [run step](https://platform.openai.com/docs/api-reference/runs/step-object) moves to an `in_progress` state. + x-oaiMeta: + dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.step.delta"] + data: + $ref: "#/components/schemas/RunStepDeltaObject" + required: + - event + - data + description: Occurs when parts of a [run step](https://platform.openai.com/docs/api-reference/runs/step-object) are being streamed. + x-oaiMeta: + dataDescription: "`data` is a [run step delta](https://platform.openai.com/docs/api-reference/assistants-streaming/run-step-delta-object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.step.completed"] + data: + $ref: "#/components/schemas/RunStepObject" + required: + - event + - data + description: Occurs when a [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is completed. + x-oaiMeta: + dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.step.failed"] + data: + $ref: "#/components/schemas/RunStepObject" + required: + - event + - data + description: Occurs when a [run step](https://platform.openai.com/docs/api-reference/runs/step-object) fails. + x-oaiMeta: + dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.step.cancelled"] + data: + $ref: "#/components/schemas/RunStepObject" + required: + - event + - data + description: Occurs when a [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is cancelled. + x-oaiMeta: + dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.step.expired"] + data: + $ref: "#/components/schemas/RunStepObject" + required: + - event + - data + description: Occurs when a [run step](https://platform.openai.com/docs/api-reference/runs/step-object) expires. + x-oaiMeta: + dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" + + MessageStreamEvent: + oneOf: + - type: object + properties: + event: + type: string + enum: ["thread.message.created"] + data: + $ref: "#/components/schemas/MessageObject" + required: + - event + - data + description: Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) is created. + x-oaiMeta: + dataDescription: "`data` is a [message](https://platform.openai.com/docs/api-reference/messages/object)" + - type: object + properties: + event: + type: string + enum: ["thread.message.in_progress"] + data: + $ref: "#/components/schemas/MessageObject" + required: + - event + - data + description: Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) moves to an `in_progress` state. + x-oaiMeta: + dataDescription: "`data` is a [message](https://platform.openai.com/docs/api-reference/messages/object)" + - type: object + properties: + event: + type: string + enum: ["thread.message.delta"] + data: + $ref: "#/components/schemas/MessageDeltaObject" + required: + - event + - data + description: Occurs when parts of a [Message](https://platform.openai.com/docs/api-reference/messages/object) are being streamed. + x-oaiMeta: + dataDescription: "`data` is a [message delta](https://platform.openai.com/docs/api-reference/assistants-streaming/message-delta-object)" + - type: object + properties: + event: + type: string + enum: ["thread.message.completed"] + data: + $ref: "#/components/schemas/MessageObject" + required: + - event + - data + description: Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) is completed. + x-oaiMeta: + dataDescription: "`data` is a [message](https://platform.openai.com/docs/api-reference/messages/object)" + - type: object + properties: + event: + type: string + enum: ["thread.message.incomplete"] + data: + $ref: "#/components/schemas/MessageObject" + required: + - event + - data + description: Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) ends before it is completed. + x-oaiMeta: + dataDescription: "`data` is a [message](https://platform.openai.com/docs/api-reference/messages/object)" + + ErrorEvent: + type: object + properties: + event: + type: string + enum: ["error"] + data: + $ref: "#/components/schemas/Error" + required: + - event + - data + description: Occurs when an [error](https://platform.openai.com/docs/guides/error-codes/api-errors) occurs. This can happen due to an internal server error or a timeout. + x-oaiMeta: + dataDescription: "`data` is an [error](https://platform.openai.com/docs/guides/error-codes/api-errors)" + + DoneEvent: + type: object + properties: + event: + type: string + enum: ["done"] + data: + type: string + enum: ["[DONE]"] + required: + - event + - data + description: Occurs when a stream ends. + x-oaiMeta: + dataDescription: "`data` is `[DONE]`" + + 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 Portkey 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: *metadata_description + 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: *batch_object + + BatchRequestInput: + type: object + description: The per-line object of the batch input file + properties: + custom_id: + type: string + description: A developer-provided per-request id that will be used to match outputs to inputs. Must be unique for each request in a batch. + method: + type: string + enum: ["POST"] + description: The HTTP method to be used for the request. Currently only `POST` is supported. + url: + type: string + description: The Portkey API relative URL to be used for the request. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. + x-oaiMeta: + name: The request input object + example: | + {"custom_id": "request-1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is 2+2?"}]}} + + BatchRequestOutput: + type: object + description: The per-line object of the batch output and error files + properties: + id: + type: string + custom_id: + type: string + description: A developer-provided per-request id that will be used to match outputs to inputs. + response: + type: object + nullable: true + properties: + status_code: + type: integer + description: The HTTP status code of the response + request_id: + type: string + description: An unique identifier for the provider API request. Please include this request ID when contacting your provider support. + body: + type: object + x-oaiTypeLabel: map + description: The JSON body of the response + error: + type: object + nullable: true + description: For requests that failed with a non-HTTP error, this will contain more information on the cause of the failure. + properties: + code: + type: string + description: A machine-readable error code. + message: + type: string + description: A human-readable error message. + x-oaiMeta: + name: The request output object + example: | + {"id": "batch_req_wnaDys", "custom_id": "request-2", "response": {"status_code": 200, "request_id": "req_c187b3", "body": {"id": "chatcmpl-9758Iw", "object": "chat.completion", "created": 1711475054, "model": "gpt-3.5-turbo", "choices": [{"index": 0, "message": {"role": "assistant", "content": "2 + 2 equals 4."}, "finish_reason": "stop"}], "usage": {"prompt_tokens": 24, "completion_tokens": 15, "total_tokens": 39}, "system_fingerprint": null}}, "error": null} + + 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 + +security: + - ApiKeyAuth: [] + +x-oaiMeta: + navigationGroups: + - id: endpoints + title: Endpoints + - id: assistants + title: Assistants + - id: legacy + title: Legacy + groups: + # > General Notes + # The `groups` section is used to generate the API reference pages and navigation, in the same + # order listed below. Additionally, each `group` can have a list of `sections`, each of which + # will become a navigation subroute and subsection under the group. Each section has: + # - `type`: Currently, either an `endpoint` or `object`, depending on how the section needs to + # be rendered + # - `key`: The reference key that can be used to lookup the section definition + # - `path`: The path (url) of the section, which is used to generate the navigation link. + # + # > The `object` sections maps to a schema component and the following fields are read for rendering + # - `x-oaiMeta.name`: The name of the object, which will become the section title + # - `x-oaiMeta.example`: The example object, which will be used to generate the example sample (always JSON) + # - `description`: The description of the object, which will be used to generate the section description + # + # > The `endpoint` section maps to an operation path and the following fields are read for rendering: + # - `x-oaiMeta.name`: The name of the endpoint, which will become the section title + # - `x-oaiMeta.examples`: The endpoint examples, which can be an object (meaning a single variation, most + # endpoints, or an array of objects, meaning multiple variations, e.g. the + # chat completion and completion endpoints, with streamed and non-streamed examples. + # - `x-oaiMeta.returns`: text describing what the endpoint returns. + # - `summary`: The summary of the endpoint, which will be used to generate the section description + - id: audio + title: Audio + description: | + Learn how to turn audio into text or text into audio. + + Related guide: [Speech to text](https://platform.openai.com/docs/guides/speech-to-text) + navigationGroup: endpoints + sections: + - type: endpoint + key: createSpeech + path: createSpeech + - type: endpoint + key: createTranscription + path: createTranscription + - type: endpoint + key: createTranslation + path: createTranslation + - type: object + key: CreateTranscriptionResponseJson + path: json-object + - type: object + key: CreateTranscriptionResponseVerboseJson + path: verbose-json-object + - id: chat + title: Chat + description: | + Given a list of messages comprising a conversation, the model will return a response. + + Related guide: [Chat Completions](https://platform.openai.com/docs/guides/text-generation) + navigationGroup: endpoints + sections: + - type: endpoint + key: createChatCompletion + path: create + - type: object + key: CreateChatCompletionResponse + path: object + - type: object + key: CreateChatCompletionStreamResponse + path: streaming + - id: embeddings + title: Embeddings + description: | + Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. + + Related guide: [Embeddings](https://platform.openai.com/docs/guides/embeddings) + navigationGroup: endpoints + sections: + - type: endpoint + key: createEmbedding + path: create + - type: object + key: Embedding + path: object + - id: fine-tuning + title: Fine-tuning + description: | + Manage fine-tuning jobs to tailor a model to your specific training data. + + Related guide: [Fine-tune models](https://platform.openai.com/docs/guides/fine-tuning) + navigationGroup: endpoints + sections: + - type: endpoint + key: createFineTuningJob + path: create + - type: endpoint + key: listPaginatedFineTuningJobs + path: list + - type: endpoint + key: listFineTuningEvents + path: list-events + - type: endpoint + key: listFineTuningJobCheckpoints + path: list-checkpoints + - type: endpoint + key: retrieveFineTuningJob + path: retrieve + - type: endpoint + key: cancelFineTuningJob + path: cancel + - type: object + key: FinetuneChatRequestInput + path: chat-input + - type: object + key: FinetuneCompletionRequestInput + path: completions-input + - type: object + key: FineTuningJob + path: object + - type: object + key: FineTuningJobEvent + path: event-object + - type: object + key: FineTuningJobCheckpoint + path: checkpoint-object + - id: batch + title: Batch + description: | + Create large batches of API requests for asynchronous processing. The Batch API returns completions within 24 hours for a 50% discount. + + Related guide: [Batch](https://platform.openai.com/docs/guides/batch) + navigationGroup: endpoints + sections: + - type: endpoint + key: createBatch + path: create + - type: endpoint + key: retrieveBatch + path: retrieve + - type: endpoint + key: cancelBatch + path: cancel + - type: endpoint + key: listBatches + path: list + - type: object + key: Batch + path: object + - type: object + key: BatchRequestInput + path: request-input + - type: object + key: BatchRequestOutput + path: request-output + - id: files + title: Files + description: | + Files are used to upload documents that can be used with features like [Assistants](https://platform.openai.com/docs/api-reference/assistants), [Fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning), and [Batch API](https://platform.openai.com/docs/guides/batch). + navigationGroup: endpoints + sections: + - type: endpoint + key: createFile + path: create + - type: endpoint + key: listFiles + path: list + - type: endpoint + key: retrieveFile + path: retrieve + - type: endpoint + key: deleteFile + path: delete + - type: endpoint + key: downloadFile + path: retrieve-contents + - type: object + key: OpenAIFile + path: object + - id: images + title: Images + description: | + Given a prompt and/or an input image, the model will generate a new image. + + Related guide: [Image generation](https://platform.openai.com/docs/guides/images) + navigationGroup: endpoints + sections: + - type: endpoint + key: createImage + path: create + - type: endpoint + key: createImageEdit + path: createEdit + - type: endpoint + key: createImageVariation + path: createVariation + - type: object + key: Image + path: object + - id: models + title: Models + description: | + List and describe the various models available in the API. You can refer to the [Models](https://platform.openai.com/docs/models) documentation to understand what models are available and the differences between them. + navigationGroup: endpoints + sections: + - type: endpoint + key: listModels + path: list + - type: endpoint + key: retrieveModel + path: retrieve + - type: endpoint + key: deleteModel + path: delete + - type: object + key: Model + path: object + - id: moderations + title: Moderations + description: | + Given some input text, outputs if the model classifies it as potentially harmful across several categories. + + Related guide: [Moderations](https://platform.openai.com/docs/guides/moderation) + navigationGroup: endpoints + sections: + - type: endpoint + key: createModeration + path: create + - type: object + key: CreateModerationResponse + path: object + - id: assistants + title: Assistants + beta: true + description: | + Build assistants that can call models and use tools to perform tasks. + + [Get started with the Assistants API](https://platform.openai.com/docs/assistants) + navigationGroup: assistants + sections: + - type: endpoint + key: createAssistant + path: createAssistant + - type: endpoint + key: listAssistants + path: listAssistants + - type: endpoint + key: getAssistant + path: getAssistant + - type: endpoint + key: modifyAssistant + path: modifyAssistant + - type: endpoint + key: deleteAssistant + path: deleteAssistant + - type: object + key: AssistantObject + path: object + - id: threads + title: Threads + beta: true + description: | + Create threads that assistants can interact with. + + Related guide: [Assistants](https://platform.openai.com/docs/assistants/overview) + navigationGroup: assistants + sections: + - type: endpoint + key: createThread + path: createThread + - type: endpoint + key: getThread + path: getThread + - type: endpoint + key: modifyThread + path: modifyThread + - type: endpoint + key: deleteThread + path: deleteThread + - type: object + key: ThreadObject + path: object + - id: messages + title: Messages + beta: true + description: | + Create messages within threads + + Related guide: [Assistants](https://platform.openai.com/docs/assistants/overview) + navigationGroup: assistants + sections: + - type: endpoint + key: createMessage + path: createMessage + - type: endpoint + key: listMessages + path: listMessages + - type: endpoint + key: getMessage + path: getMessage + - type: endpoint + key: modifyMessage + path: modifyMessage + - type: endpoint + key: deleteMessage + path: deleteMessage + - type: object + key: MessageObject + path: object + - id: runs + title: Runs + beta: true + description: | + Represents an execution run on a thread. + + Related guide: [Assistants](https://platform.openai.com/docs/assistants/overview) + navigationGroup: assistants + sections: + - type: endpoint + key: createRun + path: createRun + - type: endpoint + key: createThreadAndRun + path: createThreadAndRun + - type: endpoint + key: listRuns + path: listRuns + - type: endpoint + key: getRun + path: getRun + - type: endpoint + key: modifyRun + path: modifyRun + - type: endpoint + key: submitToolOuputsToRun + path: submitToolOutputs + - type: endpoint + key: cancelRun + path: cancelRun + - type: object + key: RunObject + path: object + - id: run-steps + title: Run Steps + beta: true + description: | + Represents the steps (model and tool calls) taken during the run. + + Related guide: [Assistants](https://platform.openai.com/docs/assistants/overview) + navigationGroup: assistants + sections: + - type: endpoint + key: listRunSteps + path: listRunSteps + - type: endpoint + key: getRunStep + path: getRunStep + - type: object + key: RunStepObject + path: step-object + - id: vector-stores + title: Vector Stores + beta: true + description: | + Vector stores are used to store files for use by the `file_search` tool. + + Related guide: [File Search](https://platform.openai.com/docs/assistants/tools/file-search) + navigationGroup: assistants + sections: + - type: endpoint + key: createVectorStore + path: create + - type: endpoint + key: listVectorStores + path: list + - type: endpoint + key: getVectorStore + path: retrieve + - type: endpoint + key: modifyVectorStore + path: modify + - type: endpoint + key: deleteVectorStore + path: delete + - type: object + key: VectorStoreObject + path: object + - id: vector-stores-files + title: Vector Store Files + beta: true + description: | + Vector store files represent files inside a vector store. + + Related guide: [File Search](https://platform.openai.com/docs/assistants/tools/file-search) + navigationGroup: assistants + sections: + - type: endpoint + key: createVectorStoreFile + path: createFile + - type: endpoint + key: listVectorStoreFiles + path: listFiles + - type: endpoint + key: getVectorStoreFile + path: getFile + - type: endpoint + key: deleteVectorStoreFile + path: deleteFile + - type: object + key: VectorStoreFileObject + path: file-object + - id: vector-stores-file-batches + title: Vector Store File Batches + beta: true + description: | + Vector store file batches represent operations to add multiple files to a vector store. + + Related guide: [File Search](https://platform.openai.com/docs/assistants/tools/file-search) + navigationGroup: assistants + sections: + - type: endpoint + key: createVectorStoreFileBatch + path: createBatch + - type: endpoint + key: getVectorStoreFileBatch + path: getBatch + - type: endpoint + key: cancelVectorStoreFileBatch + path: cancelBatch + - type: endpoint + key: listFilesInVectorStoreBatch + path: listBatchFiles + - type: object + key: VectorStoreFileBatchObject + path: batch-object + - id: assistants-streaming + title: Streaming + beta: true + description: | + Stream the result of executing a Run or resuming a Run after submitting tool outputs. + + You can stream events from the [Create Thread and Run](https://platform.openai.com/docs/api-reference/runs/createThreadAndRun), + [Create Run](https://platform.openai.com/docs/api-reference/runs/createRun), and [Submit Tool Outputs](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs) + endpoints by passing `"stream": true`. The response will be a [Server-Sent events](https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events) stream. + + Our Node and Python SDKs provide helpful utilities to make streaming easy. Reference the + [Assistants API quickstart](https://platform.openai.com/docs/assistants/overview) to learn more. + navigationGroup: assistants + sections: + - type: object + key: MessageDeltaObject + path: message-delta-object + - type: object + key: RunStepDeltaObject + path: run-step-delta-object + - type: object + key: AssistantStreamEvent + path: events + - id: completions + title: Completions + legacy: true + navigationGroup: legacy + description: | + Given a prompt, the model will return one or more predicted completions along with the probabilities of alternative tokens at each position. Most developer should use our [Chat Completions API](https://platform.openai.com/docs/guides/text-generation/text-generation-models) to leverage our best and newest models. + sections: + - type: endpoint + key: createCompletion + path: create + - type: object + key: CreateCompletionResponse + path: object diff --git a/openapi.yaml b/openapi.yaml index 68154fa8..16afcecb 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1,13833 +1,37172 @@ openapi: 3.0.0 info: - title: OpenAI API - description: The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details. - version: "2.0.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 -servers: - - url: https://api.openai.com/v1 -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: 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 a input text, outputs if the model classifies it as potentially harmful. -paths: - # Note: When adding an endpoint, make sure you also add it in the `groups` section, in the end of this file, - # under the appropriate group - /chat/completions: - post: - operationId: createChatCompletion - tags: - - Chat - summary: Creates a model response for the given chat conversation. - 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: &chat_completion_example | - { - "id": "chatcmpl-123", - "object": "chat.completion", - "created": 1677652288, - "model": "gpt-3.5-turbo-0125", - "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 - } - } - - 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-4-turbo", - "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-4-turbo", - messages=[ - { - "role": "user", - "content": [ - {"type": "text", "text": "What's in this image?"}, - { - "type": "image_url", - "image_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-4-turbo", - messages: [ - { - role: "user", - content: [ - { type: "text", text: "What's in this image?" }, - { - type: "image_url", - image_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: &chat_completion_image_example | - { - "id": "chatcmpl-123", - "object": "chat.completion", - "created": 1677652288, - "model": "gpt-3.5-turbo-0125", - "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 - } - } - - 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: &chat_completion_chunk_example | - {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-3.5-turbo-0125", "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-3.5-turbo-0125", "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-3.5-turbo-0125", "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-4-turbo", - "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-4-turbo", - messages: messages, - tools: tools, - tool_choice: "auto", - }); - - console.log(response); - } - - main(); - response: &chat_completion_function_example | - { - "id": "chatcmpl-abc123", - "object": "chat.completion", - "created": 1699896916, - "model": "gpt-3.5-turbo-0125", - "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 - } - } - - 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-3.5-turbo-0125", - "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 - }, - "system_fingerprint": null - } - - /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", - } - - /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/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/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://..." - } - ] - } - - /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 - } - } - - /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: &basic_transcription_response_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." - } - - 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: &verbose_transcription_response_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 - }, - ... - ] - } - /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?" - } - - /files: - get: - operationId: listFiles - tags: - - Files - summary: Returns a list of files that belong to the user's organization. - parameters: - - in: query - name: purpose - required: false - schema: - type: string - description: Only return files with the given purpose. - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/ListFilesResponse" - 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: | - from openai import OpenAI - client = OpenAI() - - client.files.list() - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const list = await openai.files.list(); - - for await (const file of list) { - console.log(file); - } - } - - main(); - response: | - { - "data": [ - { - "id": "file-abc123", - "object": "file", - "bytes": 175, - "created_at": 1613677385, - "filename": "salesOverview.pdf", - "purpose": "assistants", - }, - { - "id": "file-abc123", - "object": "file", - "bytes": 140, - "created_at": 1613779121, - "filename": "puppy.jsonl", - "purpose": "fine-tune", - } - ], - "object": "list" - } - 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. - - 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 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. - requestBody: - required: true - content: - multipart/form-data: - schema: - $ref: "#/components/schemas/CreateFileRequest" - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/OpenAIFile" - x-oaiMeta: - name: Upload file - group: files - returns: The uploaded [File](/docs/api-reference/files/object) object. - examples: - request: - curl: | - curl https://api.openai.com/v1/files \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -F purpose="fine-tune" \ - -F file="@mydata.jsonl" - python: | - from openai import OpenAI - client = OpenAI() - - client.files.create( - file=open("mydata.jsonl", "rb"), - purpose="fine-tune" - ) - node.js: |- - import fs from "fs"; - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const file = await openai.files.create({ - file: fs.createReadStream("mydata.jsonl"), - purpose: "fine-tune", - }); - - console.log(file); - } - - main(); - response: | - { - "id": "file-abc123", - "object": "file", - "bytes": 120000, - "created_at": 1677610602, - "filename": "mydata.jsonl", - "purpose": "fine-tune", - } - /files/{file_id}: - delete: - operationId: deleteFile - tags: - - Files - summary: Delete a 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: - $ref: "#/components/schemas/DeleteFileResponse" - 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: | - from openai import OpenAI - client = OpenAI() - - client.files.delete("file-abc123") - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const file = await openai.files.del("file-abc123"); - - console.log(file); - } - - main(); - response: | - { - "id": "file-abc123", - "object": "file", - "deleted": true - } - get: - operationId: retrieveFile - tags: - - Files - summary: Returns information about a specific 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: - $ref: "#/components/schemas/OpenAIFile" - 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: | - from openai import OpenAI - client = OpenAI() - - client.files.retrieve("file-abc123") - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const file = await openai.files.retrieve("file-abc123"); - - console.log(file); - } - - main(); - response: | - { - "id": "file-abc123", - "object": "file", - "bytes": 120000, - "created_at": 1677610602, - "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 - 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(); - - /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-3.5-turbo" - }' - python: | - from openai import OpenAI - client = OpenAI() - - client.fine_tuning.jobs.create( - training_file="file-abc123", - model="gpt-3.5-turbo" - ) - 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-3.5-turbo-0125", - "created_at": 1614807352, - "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-3.5-turbo", - "hyperparameters": { - "n_epochs": 2 - } - }' - python: | - from openai import OpenAI - client = OpenAI() - - client.fine_tuning.jobs.create( - training_file="file-abc123", - model="gpt-3.5-turbo", - hyperparameters={ - "n_epochs":2 - } - ) - node.js: | - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const fineTune = await openai.fineTuning.jobs.create({ - training_file: "file-abc123", - model: "gpt-3.5-turbo", - hyperparameters: { n_epochs: 2 } - }); - - console.log(fineTune); - } - - main(); - response: | - { - "object": "fine_tuning.job", - "id": "ftjob-abc123", - "model": "gpt-3.5-turbo-0125", - "created_at": 1614807352, - "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-3.5-turbo" - }' - python: | - from openai import OpenAI - client = OpenAI() - - client.fine_tuning.jobs.create( - training_file="file-abc123", - validation_file="file-def456", - model="gpt-3.5-turbo" - ) - node.js: | - 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(); - response: | - { - "object": "fine_tuning.job", - "id": "ftjob-abc123", - "model": "gpt-3.5-turbo-0125", - "created_at": 1614807352, - "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-3.5-turbo", - "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-3.5-turbo-0125", - "created_at": 1614807352, - "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" - 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() - - client.fine_tuning.jobs.list() - node.js: |- - 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(); - 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" - 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() - - client.fine_tuning.jobs.retrieve("ftjob-abc123") - node.js: | - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const fineTune = await openai.fineTuning.jobs.retrieve("ftjob-abc123"); - - console.log(fineTune); - } - - main(); - response: &fine_tuning_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 - } - /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() - - client.fine_tuning.jobs.list_events( - fine_tuning_job_id="ftjob-abc123", - limit=2 - ) - node.js: |- - 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(); - response: | - { - "object": "list", - "data": [ - { - "object": "fine_tuning.job.event", - "id": "ft-event-ddTJfwuMVpfLXseO0Am0Gqjm", - "created_at": 1692407401, - "level": "info", - "message": "Fine tuning job successfully completed", - "data": null, - "type": "message" - }, - { - "object": "fine_tuning.job.event", - "id": "ft-event-tyiGuB72evQncpH87xe505Sv", - "created_at": 1692407400, - "level": "info", - "message": "New fine-tuned model created: ft:gpt-3.5-turbo:openai::7p4lURel", - "data": null, - "type": "message" - } - ], - "has_more": true - } - /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. - 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() - - client.fine_tuning.jobs.cancel("ftjob-abc123") - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const fineTune = await openai.fineTuning.jobs.cancel("ftjob-abc123"); - - console.log(fineTune); - } - main(); - response: | - { - "object": "fine_tuning.job", - "id": "ftjob-abc123", - "model": "gpt-3.5-turbo-0125", - "created_at": 1689376978, - "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": 1519129973, - "fine_tuned_model_checkpoint": "ft:gpt-3.5-turbo-0125: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": 1519129833, - "fine_tuned_model_checkpoint": "ft:gpt-3.5-turbo-0125: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 - } - - /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. - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/ListModelsResponse" - 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: | - from openai import OpenAI - client = OpenAI() - - client.models.list() - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const list = await openai.models.list(); - - for await (const model of list) { - console.log(model); - } - } - main(); - response: | - { - "object": "list", - "data": [ - { - "id": "model-id-0", - "object": "model", - "created": 1686935002, - "owned_by": "organization-owner" - }, - { - "id": "model-id-1", - "object": "model", - "created": 1686935002, - "owned_by": "organization-owner", - }, - { - "id": "model-id-2", - "object": "model", - "created": 1686935002, - "owned_by": "openai" - }, - ], - "object": "list" - } - /models/{model}: - get: - operationId: retrieveModel - tags: - - Models - summary: Retrieves a model instance, providing basic information about the model such as the owner and permissioning. - parameters: - - in: path - name: model - required: true - schema: - type: string - # ideally this will be an actual ID, so this will always work from browser - example: gpt-3.5-turbo - description: The ID of the model to use for this request - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/Model" - 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 \ - -H "Authorization: Bearer $OPENAI_API_KEY" - python: | - from openai import OpenAI - client = OpenAI() - - client.models.retrieve("VAR_model_id") - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const model = await openai.models.retrieve("VAR_model_id"); - - console.log(model); - } - - main(); - response: &retrieve_model_response | - { - "id": "VAR_model_id", - "object": "model", - "created": 1686935002, - "owned_by": "openai" - } - delete: - operationId: deleteModel - tags: - - Models - 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-3.5-turbo:acemeco:suffix:abc123 - description: The model to delete - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/DeleteModelResponse" - 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-3.5-turbo:acemeco:suffix:abc123 \ - -X DELETE \ - -H "Authorization: Bearer $OPENAI_API_KEY" - python: | - from openai import OpenAI - client = OpenAI() - - client.models.delete("ft:gpt-3.5-turbo:acemeco:suffix:abc123") - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const model = await openai.models.del("ft:gpt-3.5-turbo:acemeco:suffix:abc123"); - - console.log(model); - } - main(); - response: | - { - "id": "ft:gpt-3.5-turbo:acemeco:suffix:abc123", - "object": "model", - "deleted": true - } - - /moderations: - post: - operationId: createModeration - tags: - - Moderations - summary: Classifies if text is potentially harmful. - 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: - 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: &moderation_example | - { - "id": "modr-XXXXX", - "model": "text-moderation-005", - "results": [ - { - "flagged": true, - "categories": { - "sexual": false, - "hate": false, - "harassment": false, - "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": 1.2282071e-06, - "hate": 0.010696256, - "harassment": 0.29842457, - "self-harm": 1.5236925e-08, - "sexual/minors": 5.7246268e-08, - "hate/threatening": 0.0060676364, - "violence/graphic": 4.435014e-06, - "self-harm/intent": 8.098441e-10, - "self-harm/instructions": 2.8498655e-11, - "harassment/threatening": 0.63055265, - "violence": 0.99011886, - } - } - ] - } - - /assistants: - get: - operationId: listAssistants - tags: - - Assistants - summary: Returns a list of assistants. - parameters: - - name: limit - in: query - description: &pagination_limit_param_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: &pagination_order_param_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: &pagination_after_param_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: &pagination_before_param_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() - - my_assistants = client.beta.assistants.list( - order="desc", - limit="20", - ) - print(my_assistants.data) - node.js: |- - 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(); - response: &list_assistants_example | - { - "object": "list", - "data": [ - { - "id": "asst_abc123", - "object": "assistant", - "created_at": 1698982736, - "name": "Coding Tutor", - "description": null, - "model": "gpt-4-turbo", - "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-4-turbo", - "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-4-turbo", - "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. - 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 - 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-4-turbo" - }' - - python: | - 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-4-turbo", - ) - print(my_assistant) - node.js: |- - 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-4-turbo", - }); - - console.log(myAssistant); - } - - main(); - response: &create_assistants_example | - { - "id": "asst_abc123", - "object": "assistant", - "created_at": 1698984975, - "name": "Math Tutor", - "description": null, - "model": "gpt-4-turbo", - "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-4-turbo" - }' - python: | - 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-4-turbo" - ) - print(my_assistant) - node.js: |- - 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-4-turbo" - }); - - console.log(myAssistant); - } - - main(); - response: | - { - "id": "asst_abc123", - "object": "assistant", - "created_at": 1699009403, - "name": "HR Helper", - "description": null, - "model": "gpt-4-turbo", - "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}: - get: - operationId: getAssistant - tags: - - Assistants - summary: Retrieves an assistant. - parameters: - - in: path - name: assistant_id - required: true - schema: - type: string - description: The ID of the assistant to retrieve. - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/AssistantObject" - x-oaiMeta: - name: Retrieve assistant - group: assistants - 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 \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from openai import OpenAI - client = OpenAI() - - my_assistant = client.beta.assistants.retrieve("asst_abc123") - print(my_assistant) - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const myAssistant = await openai.beta.assistants.retrieve( - "asst_abc123" - ); - - console.log(myAssistant); - } - - main(); - response: | - { - "id": "asst_abc123", - "object": "assistant", - "created_at": 1699009709, - "name": "HR Helper", - "description": null, - "model": "gpt-4-turbo", - "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. - parameters: - - in: path - name: assistant_id - required: true - schema: - type: string - description: The ID of the assistant to modify. - 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: Modify assistant - group: assistants - beta: true - returns: The modified [assistant](/docs/api-reference/assistants/object) object. - 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-4-turbo" - }' - python: | - 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-4-turbo" - ) - - print(my_updated_assistant) - node.js: |- - 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-4-turbo" - } - ); - - console.log(myUpdatedAssistant); - } - - main(); - response: | - { - "id": "asst_123", - "object": "assistant", - "created_at": 1699009709, - "name": "HR Helper", - "description": null, - "model": "gpt-4-turbo", - "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." - }, - ] - ) - - print(message_thread) - node.js: |- - 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(); - response: | - { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699014083, - "metadata": {}, - "tool_resources": {} - } - - /threads/{thread_id}: - get: - operationId: getThread - tags: - - Assistants - summary: Retrieves a thread. - parameters: - - in: path - name: thread_id - required: true - schema: - type: string - description: The ID of the thread to retrieve. - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/ThreadObject" - x-oaiMeta: - name: Retrieve thread - 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 \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from openai import OpenAI - client = OpenAI() - - my_thread = client.beta.threads.retrieve("thread_abc123") - print(my_thread) - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const myThread = await openai.beta.threads.retrieve( - "thread_abc123" - ); - - console.log(myThread); - } - - main(); - response: | - { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699014083, - "metadata": {}, - "tool_resources": { - "code_interpreter": { - "file_ids": [] - } - } - } - post: - operationId: modifyThread - tags: - - Assistants - summary: Modifies a thread. - 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. - requestBody: - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/ModifyThreadRequest" - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/ThreadObject" - x-oaiMeta: - name: Modify thread - 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 \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "OpenAI-Beta: assistants=v2" \ - -d '{ - "metadata": { - "modified": "true", - "user": "abc123" - } - }' - python: | - from openai import OpenAI - client = OpenAI() - - my_updated_thread = client.beta.threads.update( - "thread_abc123", - metadata={ - "modified": "true", - "user": "abc123" - } - ) - print(my_updated_thread) - node.js: |- - 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" }, - } - ); - - console.log(updatedThread); - } - - main(); - response: | - { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699014083, - "metadata": { - "modified": "true", - "user": "abc123" - }, - "tool_resources": {} - } - delete: - operationId: deleteThread - tags: - - Assistants - summary: Delete a thread. - parameters: - - in: path - name: thread_id - required: true - schema: - type: string - description: The ID of the thread to delete. - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/DeleteThreadResponse" - x-oaiMeta: - name: Delete thread - group: threads - beta: true - returns: Deletion status - examples: - 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: | - from openai import OpenAI - client = OpenAI() - - response = client.beta.threads.delete("thread_abc123") - print(response) - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const response = await openai.beta.threads.del("thread_abc123"); - - console.log(response); - } - main(); - response: | - { - "id": "thread_abc123", - "object": "thread.deleted", - "deleted": 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: *pagination_limit_param_description - required: false - schema: - type: integer - default: 20 - - name: order - in: query - description: *pagination_order_param_description - schema: - type: string - default: desc - enum: ["asc", "desc"] - - name: after - in: query - description: *pagination_after_param_description - schema: - type: string - - name: before - in: query - description: *pagination_before_param_description - schema: - type: string - - name: run_id - in: query - description: | - Filter messages by the run ID that generated them. - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/ListMessagesResponse" - x-oaiMeta: - name: List messages - 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() - - thread_messages = client.beta.threads.messages.list("thread_abc123") - print(thread_messages.data) - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const threadMessages = await openai.beta.threads.messages.list( - "thread_abc123" - ); - - console.log(threadMessages.data); - } - - 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": [ - { - "type": "text", - "text": { - "value": "How does AI work? Explain it in simple terms.", - "annotations": [] - } - } - ], - "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 - } - 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"; - - 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." } - ); - - 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": [] - } - } - ], - "attachments": [], - "metadata": {} - } - - /threads/{thread_id}/messages/{message_id}: - get: - operationId: getMessage - tags: - - Assistants - summary: Retrieve a message. - 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. - - in: path - name: message_id - required: true - schema: - type: string - description: The ID of the message to retrieve. - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/MessageObject" - x-oaiMeta: - name: Retrieve message - group: threads - beta: true - returns: The [message](/docs/api-reference/threads/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" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from openai import OpenAI - client = OpenAI() - - message = client.beta.threads.messages.retrieve( - message_id="msg_abc123", - thread_id="thread_abc123", - ) - print(message) - node.js: |- - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const message = await openai.beta.threads.messages.retrieve( - "thread_abc123", - "msg_abc123" - ); - - console.log(message); - } - - main(); - 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": [] - } - } - ], - "attachments": [], - "metadata": {} - } - post: - operationId: modifyMessage - tags: - - Assistants - summary: Modifies 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 modify. - requestBody: - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/ModifyMessageRequest" - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/MessageObject" - x-oaiMeta: - name: Modify message - group: threads - beta: true - returns: The modified [message](/docs/api-reference/threads/messages/object) object. - 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: | - 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", - }, - ) - print(message) - node.js: |- - 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", - }, - } - }' - 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" - } - } - 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. - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/DeleteMessageResponse" - x-oaiMeta: - name: Delete message - 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" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "OpenAI-Beta: assistants=v2" - python: | - 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"; - - const openai = new OpenAI(); - - async function main() { - const deletedMessage = await openai.beta.threads.messages.del( - "thread_abc123", - "msg_abc123" - ); - - console.log(deletedMessage); - } - response: | - { - "id": "msg_abc123", - "object": "thread.message.deleted", - "deleted": 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: Create thread and 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/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() - - run = client.beta.threads.create_and_run( - assistant_id="asst_abc123", - thread={ - "messages": [ - {"role": "user", "content": "Explain deep learning to a 5 year old."} - ] - } - ) - - print(run) - node.js: | - import OpenAI from "openai"; - - const openai = new OpenAI(); - - 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(); - 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-4-turbo", - "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/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() - - stream = client.beta.threads.create_and_run( - assistant_id="asst_123", - thread={ - "messages": [ - {"role": "user", "content": "Hello"} - ] - }, - stream=True - ) - - for event in stream: - print(event) - node.js: | - 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(); - 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-4-turbo","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-4-turbo","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-4-turbo","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 - 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 - {"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-4-turbo","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/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"] - } - } - } - ], - "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"], - }, - } - } - ] - - 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 - ) - - for event in stream: - print(event) - node.js: | - import OpenAI from "openai"; - - 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"], - }, - } - } - ]; - - 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); - } - } - - 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-4-turbo","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-4-turbo","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-4-turbo","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-4-turbo","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}/runs: - get: - operationId: listRuns - tags: - - Assistants - summary: Returns a list of runs belonging to a thread. - parameters: - - name: thread_id - in: path - required: true - schema: - type: string - description: The ID of the thread the run belongs to. - - name: limit - in: query - description: *pagination_limit_param_description - required: false - schema: - type: integer - default: 20 - - name: order - in: query - description: *pagination_order_param_description - schema: - type: string - default: desc - enum: ["asc", "desc"] - - name: after - in: query - description: *pagination_after_param_description - schema: - type: string - - name: before - in: query - description: *pagination_before_param_description - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/ListRunsResponse" - x-oaiMeta: - name: List runs - 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 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from openai import OpenAI - client = OpenAI() - - runs = client.beta.threads.runs.list( - "thread_abc123" - ) - - print(runs) - node.js: | - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const runs = await openai.beta.threads.runs.list( - "thread_abc123" - ); - - console.log(runs); - } - - main(); - 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-4-turbo", - "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-4-turbo", - "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 - } - post: - operationId: createRun - tags: - - Assistants - summary: Create a run. - parameters: - - in: path - name: thread_id - required: true - schema: - type: string - description: The ID of the thread to run. - requestBody: - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/CreateRunRequest" - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/RunObject" - x-oaiMeta: - name: Create 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 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" \ - -d '{ - "assistant_id": "asst_abc123" - }' - python: | - from openai import OpenAI - client = OpenAI() - - run = client.beta.threads.runs.create( - thread_id="thread_abc123", - assistant_id="asst_abc123" - ) - - print(run) - node.js: | - 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" } - ); - - console.log(run); - } - - main(); - response: &run_object_example | - { - "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-4-turbo", - "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: | - from openai import OpenAI - client = OpenAI() - - stream = client.beta.threads.runs.create( - thread_id="thread_123", - assistant_id="asst_123", - stream=True - ) - - for event in stream: - print(event) - node.js: | - 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(); - 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-4-turbo","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-4-turbo","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-4-turbo","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-4-turbo","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: | - 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"], - }, - } - } - ] - - 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"; - - 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"], - }, - } - } - ]; - - 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); - } - } - - 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-4-turbo","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-4-turbo","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-4-turbo","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-4-turbo","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] - - /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" - x-oaiMeta: - name: Retrieve run - group: threads - 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" - ); - - 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-4-turbo", - "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 - content: - application/json: - schema: - $ref: "#/components/schemas/ModifyRunRequest" - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/RunObject" - x-oaiMeta: - name: Modify 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 \ - -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-4-turbo", - "instructions": null, - "incomplete_details": null, - "tools": [ - { - "type": "code_interpreter" - } - ], - "tool_resources": { - "code_interpreter": { - "file_ids": [ - "file-abc123", - "file-abc456" - ] - } - }, - "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}/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." - } - ] - ) - - print(run) - node.js: | - import OpenAI from "openai"; - - const openai = new OpenAI(); - - 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); - } - - 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-4-turbo", - "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() - - 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 - ) - - for event in stream: - print(event) - node.js: | - import OpenAI from "openai"; - - const openai = new OpenAI(); - - 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.", - }, - ], - } - ); - - for await (const event of stream) { - console.log(event); - } - } - - 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}} - - 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-4-turbo","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-4-turbo","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 - 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.delta - data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"The","annotations":[]}}]}} - - 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_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" weather"}}]}} - - ... - - event: thread.message.delta - data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" sunny"}}]}} - - event: thread.message.delta - data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"."}}]}} - - 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":{}} - - 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-4-turbo","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] - - /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" - ) - - print(run) - node.js: | - import OpenAI from "openai"; - - const openai = new OpenAI(); - - async function main() { - const run = await openai.beta.threads.runs.cancel( - "thread_abc123", - "run_abc123" - ); - - console.log(run); - } - - 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-4-turbo", - "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: *pagination_limit_param_description - required: false - schema: - type: integer - default: 20 - - name: order - in: query - description: *pagination_order_param_description - schema: - type: string - default: desc - enum: ["asc", "desc"] - - name: after - in: query - description: *pagination_after_param_description - schema: - type: string - - name: before - in: query - description: *pagination_before_param_description - schema: - type: string - 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/runs/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. - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/RunStepObject" - x-oaiMeta: - name: Retrieve run step - group: threads - beta: true - returns: The [run step](/docs/api-reference/runs/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); - } - - main(); - response: &run_step_object_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 - } - } - - /vector_stores: - get: - operationId: listVectorStores - tags: - - Vector Stores - summary: Returns a list of vector stores. - parameters: - - name: limit - in: query - description: *pagination_limit_param_description - required: false - schema: - type: integer - default: 20 - - name: order - in: query - description: *pagination_order_param_description - schema: - type: string - default: desc - enum: ["asc", "desc"] - - name: after - in: query - description: *pagination_after_param_description - schema: - type: string - - name: before - in: query - description: *pagination_before_param_description - 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 - } - post: - operationId: createVectorStore - tags: - - Vector Stores - summary: Create a vector store. - requestBody: - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/CreateVectorStoreRequest" - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/VectorStoreObject" - 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" - -d '{ - "name": "Support FAQ" - }' - python: | - from openai import OpenAI - client = OpenAI() - - vector_store = client.beta.vector_stores.create( - name="Support FAQ" - ) - print(vector_store) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); - - async function main() { - const vectorStore = await openai.beta.vectorStores.create({ - name: "Support FAQ" - }); - console.log(vectorStore); - } - - main(); - response: | - { - "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 - } - } - - /vector_stores/{vector_store_id}: - get: - operationId: getVectorStore - tags: - - Vector Stores - summary: Retrieves a vector store. - parameters: - - in: path - name: vector_store_id - required: true - schema: - type: string - description: The ID of the vector store to retrieve. - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/VectorStoreObject" - 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: | - 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" - python: | - from openai import OpenAI - client = OpenAI() - - vector_store = client.beta.vector_stores.retrieve( - vector_store_id="vs_abc123" - ) - print(vector_store) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); - - async function main() { - const vectorStore = await openai.beta.vectorStores.retrieve( - "vs_abc123" - ); - console.log(vectorStore); - } - - main(); - response: | - { - "id": "vs_abc123", - "object": "vector_store", - "created_at": 1699061776 - } - post: - operationId: modifyVectorStore - tags: - - Vector Stores - summary: Modifies a vector store. - parameters: - - in: path - name: vector_store_id - required: true - schema: - type: string - description: The ID of the vector store to modify. - requestBody: - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/UpdateVectorStoreRequest" - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/VectorStoreObject" - 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: | - 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" - -d '{ - "name": "Support FAQ" - }' - python: | - from openai import OpenAI - client = OpenAI() - - vector_store = client.beta.vector_stores.update( - vector_store_id="vs_abc123", - name="Support FAQ" - ) - print(vector_store) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); - - async function main() { - const vectorStore = await openai.beta.vectorStores.update( - "vs_abc123", - { - name: "Support FAQ" - } - ); - console.log(vectorStore); - } - - main(); - response: | - { - "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 - } - } - - delete: - operationId: deleteVectorStore - tags: - - Vector Stores - summary: Delete a vector store. - parameters: - - in: path - name: vector_store_id - required: true - schema: - type: string - description: The ID of the vector store to delete. - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/DeleteVectorStoreResponse" - x-oaiMeta: - name: Delete vector store - group: vector_stores - 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 - } - - /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: *pagination_limit_param_description - required: false - schema: - type: integer - default: 20 - - name: order - in: query - description: *pagination_order_param_description - schema: - type: string - default: desc - enum: ["asc", "desc"] - - name: after - in: query - description: *pagination_after_param_description - schema: - type: string - - name: before - in: query - description: *pagination_before_param_description - 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(); - - async function main() { - const vectorStoreFiles = await openai.beta.vectorStores.files.list( - "vs_abc123" - ); - console.log(vectorStoreFiles); - } - - 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() - - 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(); - - async function main() { - const myVectorStoreFile = await openai.beta.vectorStores.files.create( - "vs_abc123", - { - file_id: "file-abc123" - } - ); - console.log(myVectorStoreFile); - } - - 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() - - 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(); - - async function main() { - const vectorStoreFile = await openai.beta.vectorStores.files.retrieve( - "vs_abc123", - "file-abc123" - ); - console.log(vectorStoreFile); - } - - 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() - - 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(); - - async function main() { - const deletedVectorStoreFile = await openai.beta.vectorStores.files.del( - "vs_abc123", - "file-abc123" - ); - console.log(deletedVectorStoreFile); - } - - main(); - response: | - { - id: "file-abc123", - object: "vector_store.file.deleted", - deleted: true - } - - /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" - x-oaiMeta: - name: Create vector store file batch - group: vector_stores - 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, - } - } - - /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" - 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() - - 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(); - - async function main() { - const vectorStoreFileBatch = await openai.beta.vectorStores.fileBatches.retrieve( - "vs_abc123", - "vsfb_abc123" - ); - console.log(vectorStoreFileBatch); - } - - 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() - - 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(); - - async function main() { - const deletedVectorStoreFileBatch = await openai.vector_stores.fileBatches.cancel( - "vs_abc123", - "vsfb_abc123" - ); - console.log(deletedVectorStoreFileBatch); - } - - 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: *pagination_limit_param_description - required: false - schema: - type: integer - default: 20 - - name: order - in: query - description: *pagination_order_param_description - schema: - type: string - default: desc - enum: ["asc", "desc"] - - name: after - in: query - description: *pagination_after_param_description - schema: - type: string - - name: before - in: query - description: *pagination_before_param_description - 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 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() - - 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(); - - async function main() { - const vectorStoreFiles = await openai.beta.vectorStores.fileBatches.listFiles( - "vs_abc123", - "vsfb_abc123" - ); - console.log(vectorStoreFiles); - } - - 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 - } - - /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: *pagination_after_param_description - - name: limit - in: query - description: *pagination_limit_param_description - 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: &batch_object | - { - "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", - } - } - -components: - securitySchemes: - ApiKeyAuth: - type: http - scheme: "bearer" - - schemas: - 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 - ErrorResponse: - type: object - properties: - error: - $ref: "#/components/schemas/Error" - required: - - error - - ListModelsResponse: - type: object - properties: - object: - type: string - enum: [list] - data: - type: array - items: - $ref: "#/components/schemas/Model" - required: - - object - - data - DeleteModelResponse: - type: object - properties: - id: - type: string - deleted: - type: boolean - object: - type: string - required: - - id - - object - - deleted - - CreateCompletionRequest: - type: object - properties: - model: - description: &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: &completions_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: &completions_best_of_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: &completions_echo_description > - Echo back the prompt in addition to the completion - frequency_penalty: - type: number - default: 0 - minimum: -2 - maximum: 2 - nullable: true - description: &completions_frequency_penalty_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: &completions_logit_bias - type: object - x-oaiTypeLabel: map - default: null - nullable: true - additionalProperties: - type: integer - description: &completions_logit_bias_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: &completions_logprobs_configuration - type: integer - minimum: 0 - maximum: 5 - default: null - nullable: true - description: &completions_logprobs_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: &completions_max_tokens_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: &completions_completions_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: &completions_presence_penalty_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: &completions_seed_param - type: integer - minimum: -9223372036854775808 - maximum: 9223372036854775807 - 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: &completions_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: "\n" - 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: &completions_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. - - 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: &completions_top_p_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: &end_user_param_configuration - 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: &completion_finish_reason_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 - } - } - - ChatCompletionRequestMessageContentPart: - oneOf: - - $ref: "#/components/schemas/ChatCompletionRequestMessageContentPartText" - - $ref: "#/components/schemas/ChatCompletionRequestMessageContentPartImage" - x-oaiExpandable: true - - ChatCompletionRequestMessageContentPartImage: - type: object - title: Image content part - 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 - - ChatCompletionRequestMessageContentPartText: - type: object - title: Text content part - properties: - type: - type: string - enum: ["text"] - description: The type of the content part. - text: - type: string - description: The text content. - required: - - type - - text - - 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 - - ChatCompletionRequestSystemMessage: - type: object - title: System message - properties: - content: - description: The contents of the system message. - type: string - 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, each can be of type `text` or `image_url` when passing in images. You can pass multiple images by adding multiple `image_url` content parts. Image input is only supported when using the `gpt-4-visual-preview` model. - title: Array of content parts - items: - $ref: "#/components/schemas/ChatCompletionRequestMessageContentPart" - 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: - nullable: true - type: string - description: | - The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified. - 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. - 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 - - # TODO(apeng): This is only because we don't support tools yet. Use allOf once we do. - FineTuneChatCompletionRequestAssistantMessage: - type: object - title: Assistant message - properties: - content: - nullable: true - type: string - description: | - The contents of the assistant message. Required unless `function_call` is specified. - 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. - function_call: - type: object - description: 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 - weight: - type: integer - enum: [0, 1] - description: "Controls whether the assistant message is trained against (0 or 1)" - 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: - type: string - 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 - - # TODO(apeng): This is only because we don't support tools yet. Add back deprecated once we do. - FineTuneChatCompletionRequestFunctionMessage: - allOf: - - type: object - title: Function message - deprecated: false - - $ref: "#/components/schemas/ChatCompletionRequestFunctionMessage" - - 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. \n\nOmitting `parameters` defines a function with an empty parameter list." - additionalProperties: true - - 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 - - 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 - - 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 - - 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" - required: - - name - - 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 - - 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 - - ParallelToolCalls: - description: Whether to enable [parallel function calling](/docs/guides/function-calling/parallel-function-calling) during tool use. - type: boolean - default: true - - ChatCompletionMessageToolCalls: - type: array - description: The tool calls generated by the model, such as function calls. - items: - $ref: "#/components/schemas/ChatCompletionMessageToolCall" - - ChatCompletionMessageToolCall: - type: object - properties: - # TODO: index included when streaming - 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 - - ChatCompletionMessageToolCallChunk: - type: object - properties: - index: - type: integer - 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 - 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: - - index - - # Note, this isn't referenced anywhere, but is kept as a convenience to record all possible roles in one place. - ChatCompletionRole: - type: string - description: The role of the author of a message - enum: - - system - - user - - assistant - - tool - - function - - 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. - - ChatCompletionResponseMessage: - type: object - description: A chat completion message generated by the model. - properties: - content: - type: string - description: The contents of the message. - 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 - required: - - role - - content - - ChatCompletionStreamResponseDelta: - type: object - description: A chat completion delta generated by streamed model responses. - properties: - content: - type: string - description: The contents of the chunk message. - nullable: true - function_call: - deprecated: true - type: object - 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. - tool_calls: - type: array - items: - $ref: "#/components/schemas/ChatCompletionMessageToolCallChunk" - role: - type: string - enum: ["system", "user", "assistant", "tool"] - description: The role of the author of this message. - - CreateChatCompletionRequest: - type: object - properties: - messages: - description: A list of messages comprising the conversation so far. [Example Python code](https://cookbook.openai.com/examples/how_to_format_inputs_to_chatgpt_models). - 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-4-turbo" - anyOf: - - type: string - - type: string - enum: - [ - "gpt-4o", - "gpt-4o-2024-05-13", - "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 - frequency_penalty: - type: number - default: 0 - minimum: -2 - maximum: 2 - nullable: true - description: *completions_frequency_penalty_description - 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. - - The total length of input tokens and generated tokens is limited by the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. - 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. - presence_penalty: - type: number - default: 0 - minimum: -2 - maximum: 2 - nullable: true - description: *completions_presence_penalty_description - response_format: - type: object - description: | - An object specifying the format that the model must output. Compatible with [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_object" }` enables JSON mode, which guarantees 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. - properties: - type: - type: string - enum: ["text", "json_object"] - example: "json_object" - default: "text" - description: Must be one of `text` or `json_object`. - seed: - type: integer - minimum: -9223372036854775808 - maximum: 9223372036854775807 - 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 - 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: *completions_temperature_description - top_p: - type: number - minimum: 0 - maximum: 1 - default: 1 - example: 1 - nullable: true - description: *completions_top_p_description - 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: *end_user_param_configuration - 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: &chat_completion_finish_reason_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: &chat_completion_response_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 - required: - - content - 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. - 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: *chat_completion_example - - CreateChatCompletionFunctionResponse: - 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: - &chat_completion_function_finish_reason_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, or `function_call` if the model called a function. - enum: - ["stop", "length", "function_call", "content_filter"] - index: - type: integer - description: The index of the choice in the list of choices. - message: - $ref: "#/components/schemas/ChatCompletionResponseMessage" - 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. - 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: *chat_completion_function_example - - ChatCompletionTokenLogprob: - type: object - properties: - token: &chat_completion_response_logprobs_token - description: The token. - type: string - logprob: &chat_completion_response_logprobs_token_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: &chat_completion_response_logprobs_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: *chat_completion_response_logprobs_token - logprob: *chat_completion_response_logprobs_token_logprob - bytes: *chat_completion_response_logprobs_bytes - required: - - token - - logprob - - bytes - required: - - token - - logprob - - bytes - - top_logprobs - - 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 - - CreateChatCompletionStreamResponse: - type: object - description: Represents a streamed chunk of a chat completion response returned by model, based on the provided input. - properties: - id: - type: string - description: A unique identifier for the chat completion. Each chunk has the same ID. - choices: - type: array - description: | - A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the - last chunk if you set `stream_options: {"include_usage": true}`. - items: - type: object - required: - - delta - - finish_reason - - index - properties: - delta: - $ref: "#/components/schemas/ChatCompletionStreamResponseDelta" - logprobs: *chat_completion_response_logprobs - finish_reason: - type: string - description: *chat_completion_finish_reason_description - enum: - [ - "stop", - "length", - "tool_calls", - "content_filter", - "function_call", - ] - nullable: true - index: - type: integer - description: The index of the choice in the list of choices. - created: - type: integer - description: The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp. - model: - type: string - description: The model to generate the 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 `chat.completion.chunk`. - enum: [chat.completion.chunk] - usage: - type: object - description: | - An optional field that will only be present when you set `stream_options: {"include_usage": true}` in your request. - When present, it contains a null value except for the last chunk which contains the token usage statistics for the entire 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). - required: - - prompt_tokens - - completion_tokens - - total_tokens - required: - - choices - - created - - id - - model - - object - x-oaiMeta: - name: The chat completion chunk object - group: chat - example: *chat_completion_chunk_example - - CreateChatCompletionImageResponse: - type: object - description: Represents a streamed chunk of a chat completion response returned by model, based on the provided input. - x-oaiMeta: - name: The chat completion chunk object - group: chat - example: *chat_completion_image_example - - 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: &images_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: &images_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: &images_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: *end_user_param_configuration - required: - - prompt - - 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": "..." - } - - 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: &dalle2_images_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: *images_response_format - user: *end_user_param_configuration - required: - - prompt - - image - - 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: *images_n - response_format: *images_response_format - size: *dalle2_images_size - user: *end_user_param_configuration - required: - - image - - CreateModerationRequest: - type: object - properties: - input: - description: The input text to classify - oneOf: - - type: string - default: "" - example: "I want to kill them." - - type: array - items: - type: string - default: "" - example: "I want to kill them." - model: - description: | - Two content moderations models are available: `text-moderation-stable` and `text-moderation-latest`. - - The default is `text-moderation-latest` which will be automatically upgraded over time. This ensures you are always using our most accurate model. If you use `text-moderation-stable`, we will provide advanced notice before updating the model. Accuracy of `text-moderation-stable` may be slightly lower than for `text-moderation-latest`. - nullable: false - default: "text-moderation-latest" - example: "text-moderation-stable" - anyOf: - - type: string - - type: string - enum: ["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. - 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 - - 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'. - 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 - - self-harm - - self-harm/intent - - self-harm/instructions - - sexual - - sexual/minors - - violence - - violence/graphic - required: - - flagged - - categories - - category_scores - required: - - id - - model - - results - x-oaiMeta: - name: The moderation object - example: *moderation_example - - ListFilesResponse: - type: object - properties: - data: - type: array - items: - $ref: "#/components/schemas/OpenAIFile" - object: - type: string - enum: [list] - required: - - object - - data - - 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 - - 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/what-models-can-be-fine-tuned). - example: "gpt-3.5-turbo" - anyOf: - - type: string - - type: string - enum: ["babbage-002", "davinci-002", "gpt-3.5-turbo"] - x-oaiTypeLabel: string - 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) 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 18 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-3.5-turbo:openai:custom-model-name:7p4lURel`. - type: string - minLength: 1 - maxLength: 40 - 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/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: - type: - description: | - The type of integration to enable. Currently, only "wandb" (Weights and Biases) is supported. - oneOf: - - type: string - 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" - - 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. - If a seed is not specified, one will be generated for you. - type: integer - nullable: true - minimum: 0 - maximum: 2147483647 - example: 42 - required: - - model - - training_file - - ListFineTuningJobEventsResponse: - type: object - properties: - data: - type: array - items: - $ref: "#/components/schemas/FineTuningJobEvent" - object: - type: string - enum: [list] - required: - - object - - data - - 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 - - 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: *model_description - 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: *end_user_param_configuration - 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 - - 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: - description: | - The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`. - type: string - enum: - - json - - text - - srt - - verbose_json - - vtt - default: json - 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 - - # Note: This does not currently support the non-default response format types. - 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: *basic_transcription_response_example - - 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 - - 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] - - 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: *verbose_transcription_response_example - - 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: - description: | - The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`. - type: string - default: json - 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 - - # Note: This does not currently support the non-default response format types. - 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] - - 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.0 - minimum: 0.25 - maximum: 4.0 - required: - - model - - input - - voice - - 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: *retrieve_model_response - - 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", - } - 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 - } - - FineTuningJob: - type: object - title: FineTuningJob - 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. - created_at: - type: integer - 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. - properties: - code: - type: string - description: A machine-readable error code. - message: - 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 - 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. - 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. - hyperparameters: - type: object - description: The hyperparameters used for the fine-tuning job. See the [fine-tuning guide](/docs/guides/fine-tuning) for more details. - properties: - n_epochs: - oneOf: - - type: string - enum: [auto] - - 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". - enum: [fine_tuning.job] - 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). - 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`. - enum: - [ - "validating_files", - "queued", - "running", - "succeeded", - "failed", - "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. - 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). - 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). - 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: *fine_tuning_example - - 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" - - FineTuningJobEvent: - 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" - } - - 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] - required: - - created_at - - fine_tuning_job_id - - fine_tuned_model_checkpoint - - id - - metrics - - object - - step_number - x-oaiMeta: - 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-3.5-turbo-0125: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 - } - - FinetuneChatRequestInput: - type: object - description: The per-line training example of a fine-tuning input file for chat models - properties: - messages: - type: array - minItems: 1 - items: - oneOf: - - $ref: "#/components/schemas/ChatCompletionRequestSystemMessage" - - $ref: "#/components/schemas/ChatCompletionRequestUserMessage" - - $ref: "#/components/schemas/FineTuneChatCompletionRequestAssistantMessage" - - $ref: "#/components/schemas/FineTuneChatCompletionRequestFunctionMessage" - x-oaiExpandable: true - functions: - description: - A list of functions the model may generate JSON inputs for. - type: array - minItems: 1 - maxItems: 128 - items: - $ref: "#/components/schemas/ChatCompletionFunctions" - x-oaiMeta: - name: Training format for chat models - example: | - {"messages":[{"role":"user","content":"What is the weather in San Francisco?"},{"role":"assistant","function_call":{"name":"get_current_weather","arguments":"{\"location\": \"San Francisco, USA\", \"format\": \"celsius\"}"}}],"functions":[{"name":"get_current_weather","description":"Get the current weather","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and country, eg. San Francisco, USA"},"format":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location","format"]}}]} - - FinetuneCompletionRequestInput: - type: object - description: The per-line training example of a fine-tuning input file for completions models - properties: - prompt: - type: string - description: The input prompt for this training example. - completion: - type: string - description: The desired completion for this training example. - x-oaiMeta: - name: Training format for completions models - example: | - {"prompt": "What is the answer to 2+2", "completion": "4"} - - 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). - required: - - prompt_tokens - - completion_tokens - - total_tokens - - 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 - - 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 - - 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`. + title: Portkey API + description: The Portkey REST API. Please see https://portkey.ai/docs/api-reference for more details. + version: "2.0.0" + termsOfService: https://portkey.ai/terms + contact: + name: Portkey Developer Forum + url: https://portkey.wiki/community + license: + name: MIT + url: https://github.com/Portkey-AI/portkey-openapi/blob/master/LICENSE +x-server-groups: + ControlPlaneServers: &ControlPlaneServers + - url: https://api.portkey.ai/v1 + description: Portkey API Public Endpoint + - url: SELF_HOSTED_CONTROL_PLANE_URL + description: Self-Hosted Control Plane URL + + DataPlaneServers: &DataPlaneServers + - url: https://api.portkey.ai/v1 + description: Portkey API Public Endpoint + - url: SELF_HOSTED_GATEWAY_URL + description: Self-Hosted Gateway URL + + PublicServers: &PublicServers + - url: https://api.portkey.ai + description: Portkey Public API (no auth required) + +x-mint: + mcp: + enabled: true + name: Portkey MCP + description: Official MCP Server for Portkey Docs & APIs - Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. +servers: + - url: https://api.portkey.ai/v1 + description: Portkey API Public Endpoint - **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: [none, auto] - - $ref: "#/components/schemas/AssistantsApiResponseFormat" - x-oaiExpandable: true +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: Realtime + description: WebSocket proxy for provider Realtime APIs + - name: Collections + description: Create, List, Retrieve, Update, and Delete collections of prompts. + - name: Labels + description: Create, List, Retrieve, Update, and Delete labels. + - name: Prompt Collections + description: Create, List, Retrieve, Update, and Delete prompt collections. + - name: PromptPartials + description: Create, List, Retrieve, Update, and Delete prompt partials. + - name: Prompts + description: Given a prompt template ID and variables, will run the saved prompt template and return a response. + - name: Guardrails + description: Create, List, Retrieve, Update, and Delete prompt Guardrails. + - 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: 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 a input text, outputs if the model classifies it as potentially harmful. + - name: Configs + description: Create, List, Retrieve, and Update your Portkey Configs. + - name: Feedback + description: Send and Update any feedback. + - name: Logs + description: Custom Logger to add external logs to Portkey. + - name: Integrations + description: Create, List, Retrieve, Update, and Delete your Portkey Integrations. + - name: Integrations > Workspaces + description: Manage workspace access for your Portkey Integrations. + - name: Integrations > Models + description: Manage model access for your Portkey Integrations. + - name: Providers + description: Create, List, Retrieve, Update, and Delete your Portkey Providers. + - name: Virtual-keys + description: Create, List, Retrieve, Update, and Delete your Portkey Virtual keys. + - name: Users + description: Create and manage users. + - name: User-invites + description: Create and manage user invites. + - name: Workspaces + description: Create and manage workspaces. + - name: Workspaces > Members + description: Create and manage workspace members. + - name: MCP Integrations + description: Create, List, Retrieve, Update, and Delete MCP Integrations. + - name: MCP Integrations > Workspaces + description: Manage workspace access for MCP Integrations. + - name: MCP Integrations > Capabilities + description: List and manage capabilities for MCP Integrations. + - name: MCP Integrations > Metadata + description: Get MCP Integration metadata and sync info. + - name: MCP Servers + description: Create, List, Retrieve, Update, and Delete MCP Servers (workspace instances of MCP Integrations). + - name: MCP Servers > Capabilities + description: List and manage capabilities for MCP Servers. + - name: MCP Servers > User Access + description: List and manage user access for MCP Servers. + - name: Api-Keys + description: Create, List, Retrieve, Update, and Delete your Portkey API keys. + - name: Logs Export + description: Exports logs service. + - name: Audit Logs + description: Get audit logs for your Portkey account. + - name: Analytics + description: Get analytics over different data points like requests, costs, tokens, etc. + - name: Analytics > Graphs + description: Get data points for graphical representation. + - name: Analytics > Summary + description: Get overall summary for the selected time bucket. + - name: Analytics > Groups + description: Get grouped metrics for the selected time bucket. + - name: Usage Limits Policies + description: Manage usage limits policies to control total usage over time + - name: Rate Limits Policies + description: Manage rate limits policies to control request or token rates + - name: Model Pricing + description: Model pricing configurations for 2300+ LLMs across 40+ providers + - name: Secret-References + description: Create, List, Retrieve, Update, and Delete secret references to external secret managers. - AssistantsApiResponseFormat: - type: object - description: | - An object describing the expected output of the model. If `json_object` only `function` type `tools` are allowed to be passed to the Run. If `text` the model can return text or any value needed. - properties: - type: - type: string - enum: ["text", "json_object"] - example: "json_object" - default: "text" - description: Must be one of `text` or `json_object`. - 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: &assistant_name_param_description | - The name of the assistant. The maximum length is 256 characters. - type: string - maxLength: 256 - nullable: true - description: - description: &assistant_description_param_description | - The description of the assistant. The maximum length is 512 characters. - type: string - maxLength: 512 - nullable: true - model: - description: *model_description - type: string - instructions: - description: &assistant_instructions_param_description | - The system instructions that the assistant uses. The maximum length is 256,000 characters. - type: string - maxLength: 256000 - nullable: true - tools: - description: &assistant_tools_param_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: [] +paths: + # Note: When adding an endpoint, make sure you also add it in the `groups` section, in the end of this file, + # under the appropriate group + /chat/completions: + servers: *DataPlaneServers + post: + operationId: createChatCompletion + tags: + - Chat + summary: Chat + parameters: + - $ref: "#/components/parameters/PortkeyTraceId" + - $ref: "#/components/parameters/PortkeySpanId" + - $ref: "#/components/parameters/PortkeyParentSpanId" + - $ref: "#/components/parameters/PortkeySpanName" + - $ref: "#/components/parameters/PortkeyMetadata" + - $ref: "#/components/parameters/PortkeyCacheNamespace" + - $ref: "#/components/parameters/PortkeyCacheForceRefresh" + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CreateChatCompletionRequest" + + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/CreateChatCompletionResponse" + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: cURL + label: Default + source: | + curl https://api.portkey.ai/v1/chat/completions \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -d '{ + "model": "gpt-4o", + "messages": [ + { + "role": "system", + "content": "You are a helpful assistant." + }, + { + "role": "user", + "content": "Hello!" + } + ] + }' + - lang: cURL + label: Self-Hosted + source: | + curl SELF_HOSTED_GATEWAY_URL/chat/completions \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -d '{ + "model": "gpt-4o", + "messages": [ + { + "role": "system", + "content": "You are a helpful assistant." + }, + { + "role": "user", + "content": "Hello!" + } + ] + }' + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + response = portkey.chat.completions.create( + model="gpt-4o", + messages=[ + {"role": "system", "content": "You are a helpful assistant."}, + {"role": "user", "content": "Hello!"} + ] + ) + + print(response.choices[0].message) + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key = "PORTKEY_API_KEY", + base_url = "SELF_HOSTED_GATEWAY_URL", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + response = portkey.chat.completions.create( + model="gpt-4o", + messages=[ + {"role": "system", "content": "You are a helpful assistant."}, + {"role": "user", "content": "Hello!"} + ] + ) + + print(response.choices[0].message) + - lang: javascript + label: Default + source: | + import Portkey from 'portkey-ai'; + + const portkey = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const response = await portkey.chat.completions.create({ + messages: [{ role: "system", content: "You are a helpful assistant." }], + model: "gpt-4o", + }); + + console.log(response.choices[0]); + } + + main(); + - lang: javascript + label: Self-Hosted + source: | + import Portkey from 'portkey-ai'; + + const portkey = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL' + }); + + async function main() { + const response = await portkey.chat.completions.create({ + messages: [{ role: "system", content: "You are a helpful assistant." }], + model: "gpt-4o", + }); + + console.log(response.choices[0]); + } + + main(); + + /realtime: + servers: *DataPlaneServers + get: + operationId: connectRealtime + tags: + - Realtime + summary: Realtime + description: "Connect to the Realtime API endpoint." + parameters: + - $ref: "#/components/parameters/PortkeyTraceId" + - $ref: "#/components/parameters/PortkeySpanId" + - $ref: "#/components/parameters/PortkeyParentSpanId" + - $ref: "#/components/parameters/PortkeySpanName" + - $ref: "#/components/parameters/PortkeyMetadata" + - $ref: "#/components/parameters/PortkeyCacheNamespace" + - $ref: "#/components/parameters/PortkeyCacheForceRefresh" + - name: model + in: query + required: false + schema: + type: string + description: Often required for OpenAI-style realtime; other query params pass through unchanged. + responses: + "101": + description: WebSocket upgrade. + default: + description: Error + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + x-code-samples: + - lang: cURL + label: Default + source: | + curl -sS -D - -o /dev/null \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + "https://api.portkey.ai/v1/realtime?model=gpt-4o-realtime-preview" + - lang: cURL + label: Self-Hosted + source: | + curl -sS -D - -o /dev/null \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + "SELF_HOSTED_GATEWAY_URL/realtime?model=gpt-4o-realtime-preview" + - lang: javascript + label: Default + source: | + import WebSocket from 'ws'; + + const ws = new WebSocket( + 'wss://api.portkey.ai/v1/realtime?model=gpt-4o-realtime-preview', + { + headers: { + 'x-portkey-api-key': process.env.PORTKEY_API_KEY, + 'x-portkey-virtual-key': process.env.PORTKEY_PROVIDER_VIRTUAL_KEY, + }, + } + ); + - lang: javascript + label: Self-Hosted + source: | + import WebSocket from 'ws'; + + const u = new URL(process.env.SELF_HOSTED_GATEWAY_URL); + u.protocol = u.protocol === 'https:' ? 'wss:' : 'ws:'; + u.pathname = `${u.pathname.replace(/\/$/, '')}/realtime`; + u.searchParams.set('model', 'gpt-4o-realtime-preview'); + new WebSocket(u.toString(), { + headers: { + 'x-portkey-api-key': process.env.PORTKEY_API_KEY, + 'x-portkey-virtual-key': process.env.PORTKEY_PROVIDER_VIRTUAL_KEY, + }, + }); + - lang: python + label: Default + source: | + import os + import asyncio + import websockets + + async def main(): + uri = "wss://api.portkey.ai/v1/realtime?model=gpt-4o-realtime-preview" + headers = { + "x-portkey-api-key": os.environ["PORTKEY_API_KEY"], + "x-portkey-virtual-key": os.environ["PORTKEY_PROVIDER_VIRTUAL_KEY"], + } + async with websockets.connect(uri, extra_headers=headers): + pass + + asyncio.run(main()) + - lang: python + label: Self-Hosted + source: | + import os + import asyncio + from urllib.parse import urlparse, urlunparse + import websockets + + async def main(): + p = urlparse(os.environ["SELF_HOSTED_GATEWAY_URL"]) + scheme = "wss" if p.scheme == "https" else "ws" + path = p.path.rstrip("/") + "/realtime" + uri = urlunparse((scheme, p.netloc, path, "", "model=gpt-4o-realtime-preview", "")) + headers = { + "x-portkey-api-key": os.environ["PORTKEY_API_KEY"], + "x-portkey-virtual-key": os.environ["PORTKEY_PROVIDER_VIRTUAL_KEY"], + } + async with websockets.connect(uri, extra_headers=headers): + pass + + asyncio.run(main()) + + /completions: + servers: *DataPlaneServers + post: + operationId: createCompletion + tags: + - Completions + summary: Completions + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CreateCompletionRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/CreateCompletionResponse" + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + label: Default + source: | + curl https://api.portkey.ai/v1/completions \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -d '{ + "model": "gpt-3.5-turbo-instruct", + "prompt": "Say this is a test", + "max_tokens": 7, + "temperature": 0 + }' + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + response = portkey.completions.create( + model="gpt-3.5-turbo-instruct", + prompt="Say this is a test", + max_tokens=7, + temperature=0 + ) + + print(response) + - lang: javascript + label: Default + source: | + import Portkey from 'portkey-ai'; + + const portkey = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const response = await portkey.completions.create({ + model: "gpt-3.5-turbo-instruct", + prompt: "Say this is a test.", + max_tokens: 7, + temperature: 0, + }); + + console.log(response); + } + + main(); + - lang: javascript + label: Self-Hosted + source: | + import Portkey from 'portkey-ai'; + + const portkey = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL' + }); + + async function main() { + const response = await client.completions.create({ + model: "gpt-3.5-turbo-instruct", + prompt: "Say this is a test.", + max_tokens: 7, + temperature: 0, + }); + + console.log(response); + } + + main(); + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY", + base_url = "SELF_HOSTED_GATEWAY_URL" + ) + + response = portkey.completions.create( + model="gpt-3.5-turbo-instruct", + prompt="Say this is a test", + max_tokens=7, + temperature=0 + ) + + print(response) + - lang: curl + label: Self-Hosted + source: | + curl https://SELF_HOSTED_GATEWAY_URL/completions \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -d '{ + "model": "gpt-3.5-turbo-instruct", + "prompt": "Say this is a test", + "max_tokens": 7, + "temperature": 0 + }' + + /collections: + servers: *ControlPlaneServers + post: + summary: Create a new collection + description: Creates a new collection in the specified workspace + tags: + - Collections + security: + - Portkey-Key: [] + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + workspace_id: + type: string + description: ID or slug of the workspace + name: + type: string + description: Name of the collection + parent_collection_id: + type: string + description: ID or slug of the parent collection (optional) + required: + - name + responses: + '200': + description: Collection created successfully + content: + application/json: + schema: + type: object + properties: + id: + type: string + format: uuid + description: ID of the created collection + slug: + type: string + description: Slug of the created collection + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Workspace or parent collection not found + '500': + description: Server error + + get: + summary: List collections + description: Lists all collections in the specified workspace + tags: + - Collections + security: + - Portkey-Key: [] + parameters: + - name: workspace_id + in: query + required: true + schema: + type: string + description: ID or slug of the workspace + - name: current_page + in: query + required: false + schema: + type: integer + minimum: 0 + description: Page number for pagination (0-indexed) + - name: page_size + in: query + required: false + schema: + type: integer + minimum: 1 + description: Number of items per page + - name: search + in: query + required: false + schema: + type: string + description: Search query to filter collections by name + responses: + '200': + description: List of collections + content: + application/json: + schema: + type: object + properties: + total: + type: integer + description: Total number of collections matching the criteria + data: 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: &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 maxium of 512 characters long. - type: object - x-oaiTypeLabel: map - nullable: true - temperature: - description: &run_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: &run_top_p_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 + $ref: '#/components/schemas/CollectionWithDetails' + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Workspace not found + '500': + description: Server error + + /collections/{collectionId}: + servers: *ControlPlaneServers + parameters: + - name: collectionId + in: path + required: true + schema: + type: string + description: ID or slug of the collection + + get: + summary: Get collection details + description: Retrieves details of a specific collection + tags: + - Collections + security: + - Portkey-Key: [] + responses: + '200': + description: Collection details + content: + application/json: + schema: + $ref: '#/components/schemas/CollectionWithChildCollections' + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Collection not found + '500': + description: Server error + + put: + summary: Update collection + description: Updates a collection's details + security: + - Portkey-Key: [] + tags: + - Collections + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + name: + type: string + description: New name for the collection + required: - name - - description - - model - - instructions - - tools - - metadata - x-oaiMeta: - name: The assistant object - beta: true - example: *create_assistants_example - - CreateAssistantRequest: - type: object - additionalProperties: false - properties: - model: - description: *model_description - example: "gpt-4-turbo" - anyOf: - - type: string - - type: string - enum: - [ - "gpt-4o", - "gpt-4o-2024-05-13", - "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 + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + example: {} + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Collection not found + '500': + description: Server error + + delete: + summary: Delete collection + description: Deletes a collection + security: + - Portkey-Key: [] + tags: + - Collections + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + example: {} + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Collection not found or trying to delete default collection + '500': + description: Server error + + /labels: + servers: *ControlPlaneServers + post: + summary: Create a new label + description: Creates a new label in the system + operationId: createLabel + security: + - Portkey-Key: [] + tags: + - Labels + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateLabelRequest' + responses: + '200': + description: Label created successfully + content: + application/json: + schema: + $ref: '#/components/schemas/CreateLabelResponse' + '400': + description: Invalid request + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '401': + description: Unauthorized + '403': + description: Forbidden + '500': + description: Server error + + get: + summary: List labels + description: Returns a list of labels based on filters + operationId: listLabels + security: + - Portkey-Key: [] + tags: + - Labels + parameters: + - name: organisation_id + in: query + schema: + type: string + format: uuid + description: ID of the organisation + - name: workspace_id + in: query + schema: + type: string + description: ID or slug of the workspace + - name: search + in: query + schema: + type: string + description: Search query to filter labels by name + - name: current_page + in: query + schema: + type: integer + minimum: 0 + description: Page number for pagination + - name: page_size + in: query + schema: + type: integer + minimum: 1 + description: Number of items per page + responses: + '200': + description: List of labels + content: + application/json: + schema: + $ref: '#/components/schemas/ListLabelsResponse' + '400': + description: Invalid request + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '401': + description: Unauthorized + '403': + description: Forbidden + '500': + description: Server error + + /labels/{labelId}: + servers: *ControlPlaneServers + get: + summary: Get a label by ID + description: Returns a specific label by its ID + operationId: getLabel + security: + - Portkey-Key: [] + tags: + - Labels + parameters: + - name: labelId + in: path + required: true + schema: + type: string + format: uuid + description: ID of the label to retrieve + - name: organisation_id + in: query + schema: + type: string + format: uuid + description: ID of the organisation + - name: workspace_id + in: query + schema: + type: string + description: ID or slug of the workspace + responses: + '200': + description: Label details + content: + application/json: + schema: + $ref: '#/components/schemas/Label' + '400': + description: Invalid request + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Label not found + '500': + description: Server error + + put: + summary: Update a label + description: Updates an existing label + operationId: updateLabel + security: + - Portkey-Key: [] + tags: + - Labels + parameters: + - name: labelId + in: path + required: true + schema: + type: string + format: uuid + description: ID of the label to update + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateLabelRequest' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + example: {} + '400': + description: Invalid request + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Label not found + '500': + description: Server error + + delete: + summary: Delete a label + description: Deletes a label + operationId: deleteLabel + security: + - Portkey-Key: [] + tags: + - Labels + parameters: + - name: labelId + in: path + required: true + schema: + type: string + format: uuid + description: ID of the label to delete + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + example: {} + '400': + description: Invalid request + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Label not found + '500': + description: Server err + + /prompts: + servers: *ControlPlaneServers + post: + summary: Create a new prompt + operationId: createPrompt + tags: + - Prompts + security: + - Portkey-Key: [] + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - name + - collection_id + - string + - parameters + - virtual_key + properties: name: - description: *assistant_name_param_description - type: string - nullable: true - maxLength: 256 - description: - description: *assistant_description_param_description - type: string - nullable: true - maxLength: 512 - instructions: - description: *assistant_instructions_param_description - type: string - nullable: true - maxLength: 256000 + type: string + collection_id: + type: string + description: UUID or slug of the collection + string: + type: string + description: Prompt template in string format + parameters: + type: object + description: Parameters for the prompt + functions: + type: array + description: Functions for the prompt + items: + type: object tools: - description: *assistant_tools_param_description - default: [] + type: array + description: Tools for the prompt + items: + type: object + tool_choice: + type: object + description: Tool Choice for the prompt + model: + type: string + description: The model to use for the prompt + virtual_key: + type: string + description: The virtual key to use for the prompt + version_description: + type: string + description: The description of the prompt version + template_metadata: + type: object + description: Metadata for the prompt + responses: + '200': + description: Prompt created successfully + content: + application/json: + schema: + type: object + properties: + id: + type: string + format: uuid + slug: + type: string + version_id: + type: string + format: uuid + object: + type: string + enum: ['prompt'] + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '500': + description: Server error + + get: + summary: List prompts + operationId: listPrompts + tags: + - Prompts + security: + - Portkey-Key: [] + parameters: + - name: collection_id + in: query + schema: + type: string + - name: workspace_id + in: query + schema: + type: string + - name: current_page + in: query + schema: + type: integer + - name: page_size + in: query + schema: + type: integer + - name: search + in: query + schema: + type: string + responses: + '200': + description: List of prompts + content: + application/json: + schema: + type: object + properties: + data: type: array - maxItems: 128 items: - oneOf: - - $ref: "#/components/schemas/AssistantToolsCode" - - $ref: "#/components/schemas/AssistantToolsFileSearch" - - $ref: "#/components/schemas/AssistantToolsFunction" - x-oaiExpandable: true - tool_resources: + $ref: '#/components/schemas/PromptSummary' + total: + type: integer + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '500': + description: Server error + + /prompts/{promptId}: + servers: *ControlPlaneServers + get: + summary: Get a prompt by ID or slug + operationId: getPrompt + tags: + - Prompts + security: + - Portkey-Key: [] + parameters: + - name: promptId + in: path + required: true + schema: + type: string + responses: + '200': + description: Prompt details + content: + application/json: + schema: + $ref: '#/components/schemas/Prompt' + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Prompt not found + '500': + description: Server error + + put: + summary: Update a prompt + description: | + Update a prompt's metadata and/or create a new version with updated template content. + + **Partial version updates:** Set `patch: true` to perform a partial update of version fields (`string`, `parameters`, `model`, `virtual_key`, `version_description`, `functions`, `tools`, `tool_choice`, `is_raw_template`, `prompt_metadata`). When enabled, any version fields omitted from the request are backfilled from the current latest version, allowing you to update only the fields you need. When `patch` is omitted or `false`, all version fields must be provided together (original strict validation). + + **Metadata-only updates:** Fields like `name`, `collection_id`, `version_description`, and `virtual_key` can always be updated independently without affecting versioning. + operationId: updatePrompt + tags: + - Prompts + security: + - Portkey-Key: [] + parameters: + - name: promptId + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + patch: + type: boolean + description: | + When `true`, enables partial version updates. Missing version fields (`string`, `parameters`, `model`) are backfilled from the current latest version, so you only need to provide the fields you want to change. When `false` or omitted, the original strict validation is preserved for backward compatibility. + name: + type: string + collection_id: + type: string + string: + type: string + description: The prompt template string. When `patch` is `true`, this field is optional and will be inherited from the current latest version if omitted. + parameters: + type: object + description: Model parameters (e.g. temperature, max_tokens). When `patch` is `true`, this field is optional and will be inherited from the current latest version if omitted. + model: + type: string + description: The model identifier. When `patch` is `true`, this field is optional and will be inherited from the current latest version if omitted. + virtual_key: + type: string + description: The virtual key to associate with this version. When `patch` is `true`, this field is optional and will be inherited from the current latest version if omitted. + version_description: + type: string + description: A human-readable description for this version. When `patch` is `true`, this field is optional and will be inherited from the current latest version if omitted. + functions: + type: array + items: 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: - # Ideally we'd reuse the chunking strategy schema here, but it doesn't expand properly - 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 maxium of 512 characters long. - x-oaiTypeLabel: map - oneOf: - - required: [vector_store_ids] - - required: [vector_stores] - nullable: true - metadata: - description: *metadata_description + description: Function definitions available to the model. When `patch` is `true`, this field is optional and will be inherited from the current latest version if omitted. + tools: + type: array + items: type: object - x-oaiTypeLabel: map - nullable: true - temperature: - description: &run_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: &run_top_p_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: - - model - - ModifyAssistantRequest: - type: object - additionalProperties: false - properties: - model: - description: *model_description - anyOf: - - type: string + description: Tool definitions available to the model. When `patch` is `true`, this field is optional and will be inherited from the current latest version if omitted. + tool_choice: + type: object + description: Controls which tool the model uses. When `patch` is `true`, this field is optional and will be inherited from the current latest version if omitted. + is_raw_template: + type: integer + enum: [0, 1] + description: Whether the template string is raw (1) or processed (0). When `patch` is `true`, this field is optional and will be inherited from the current latest version if omitted. + prompt_metadata: + type: object + description: Additional metadata for the prompt version. When `patch` is `true`, this field is optional and will be inherited from the current latest version if omitted. + responses: + '200': + description: Prompt updated successfully + content: + application/json: + schema: + type: object + properties: + id: + type: string + format: uuid + slug: + type: string + prompt_version_id: + type: string + format: uuid + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Prompt not found + '500': + description: Server error + + delete: + summary: Delete a prompt + operationId: deletePrompt + tags: + - Prompts + security: + - Portkey-Key: [] + parameters: + - name: promptId + in: path + required: true + schema: + type: string + responses: + '200': + description: Prompt deleted successfully + content: + application/json: + schema: + type: object + properties: {} + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Prompt not found + '500': + description: Server error + + /prompts/{promptId}/versions: + servers: *ControlPlaneServers + get: + summary: Get all versions of a prompt + operationId: getPromptVersions + tags: + - Prompts + security: + - Portkey-Key: [] + parameters: + - name: promptId + in: path + required: true + schema: + type: string + responses: + '200': + description: List of prompt versions + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/PromptVersionSummary' + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Prompt not found + '500': + description: Server error + + /prompts/{promptId}/versions/{versionId}: + servers: *ControlPlaneServers + get: + summary: Get a specific version of a prompt + operationId: getPromptByVersion + tags: + - Prompts + security: + - Portkey-Key: [] + parameters: + - name: promptId + in: path + required: true + schema: + type: string + - name: versionId + in: path + required: true + schema: + type: string + format: uuid + responses: + '200': + description: Prompt version details + content: + application/json: + schema: + $ref: '#/components/schemas/Prompt' + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Prompt version not found + '500': + description: Server error + + put: + summary: Update a specific version of a prompt + description: | + Updates metadata for a specific prompt version. **This endpoint only supports updating the `label_id` field.** + + Prompt versions are immutable — their `string`, `parameters`, and `model` content cannot be changed after creation. To update prompt content, use `PUT /prompts/{promptId}` which creates a new version with the updated content. + operationId: updatePromptVersion + tags: + - Prompts + security: + - Portkey-Key: [] + parameters: + - name: promptId + in: path + required: true + schema: + type: string + - name: versionId + in: path + required: true + schema: + type: string + format: uuid + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + label_id: + type: string + format: uuid + description: The label to assign to this version. + responses: + '200': + description: Prompt version updated successfully + content: + application/json: + schema: + type: object + properties: {} + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Prompt version not found + '500': + description: Server error + + /prompts/{promptId}/makeDefault: + servers: *ControlPlaneServers + put: + summary: Set a version as the default for a prompt + operationId: updatePromptDefault + tags: + - Prompts + security: + - Portkey-Key: [] + parameters: + - name: promptId + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - version + properties: + version: + type: number + description: Version Number to set as default + responses: + '200': + description: Default version set successfully + content: + application/json: + schema: + type: object + properties: {} + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Prompt or version not found + '500': + description: Server error + + /prompts/partials: + servers: *ControlPlaneServers + post: + summary: Create a new prompt partial + operationId: createPromptPartial + tags: + - PromptPartials + security: + - Portkey-Key: [] + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - name + - string + properties: + workspace_id: + type: string + description: Required for Admin keys name: - description: *assistant_name_param_description - type: string - nullable: true - maxLength: 256 + type: string + string: + type: string + description: Prompt partial template in string format + version_description: + type: string + responses: + '200': + description: Prompt partial created successfully + content: + application/json: + schema: + type: object + properties: + id: + type: string + format: uuid + slug: + type: string + version_id: + type: string + format: uuid + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '500': + description: Server error + + get: + summary: List prompt partials + operationId: listPromptPartials + tags: + - PromptPartials + security: + - Portkey-Key: [] + parameters: + - name: collection_id + in: query + schema: + type: string + responses: + '200': + description: List of prompt partials + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/PromptPartialSummary' + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Not found + '500': + description: Server error + + /prompts/partials/{promptPartialId}: + servers: *ControlPlaneServers + get: + summary: Get a prompt partial by ID or slug + operationId: getPromptPartial + tags: + - PromptPartials + security: + - Portkey-Key: [] + parameters: + - name: promptPartialId + in: path + required: true + schema: + type: string + responses: + '200': + description: Prompt partial details + content: + application/json: + schema: + $ref: '#/components/schemas/PromptPartial' + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Prompt partial not found + '500': + description: Server error + + put: + summary: Update a prompt partial + operationId: updatePromptPartial + tags: + - PromptPartials + security: + - Portkey-Key: [] + parameters: + - name: promptPartialId + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + name: + type: string + string: + type: string description: - description: *assistant_description_param_description - type: string - nullable: true - maxLength: 512 + type: string + status: + type: string + responses: + '200': + description: Prompt partial updated successfully + content: + application/json: + schema: + type: object + properties: + prompt_partial_version_id: + type: string + format: uuid + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Prompt partial not found + '500': + description: Server error + + delete: + summary: Delete a prompt partial + operationId: deletePromptPartial + tags: + - PromptPartials + security: + - Portkey-Key: [] + parameters: + - name: promptPartialId + in: path + required: true + schema: + type: string + responses: + '200': + description: Prompt partial deleted successfully + content: + application/json: + schema: + type: object + properties: {} + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Prompt partial not found + '500': + description: Server error + + /prompts/partials/{promptPartialId}/versions: + servers: *ControlPlaneServers + get: + summary: Get all versions of a prompt partial + operationId: getPromptPartialVersions + tags: + - PromptPartials + security: + - Portkey-Key: [] + parameters: + - name: promptPartialId + in: path + required: true + schema: + type: string + responses: + '200': + description: List of prompt partial versions + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/PromptPartialVersion' + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Prompt partial not found + '500': + description: Server error + + /prompts/partials/{promptPartialId}/makeDefault: + servers: *ControlPlaneServers + put: + summary: Set a version as the default for a prompt partial + operationId: updatePromptPartialDefault + tags: + - PromptPartials + security: + - Portkey-Key: [] + parameters: + - name: promptPartialId + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - version + properties: + version: + type: number + description: Version Number to set as default + responses: + '200': + description: Default version set successfully + content: + application/json: + schema: + type: object + properties: {} + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Prompt partial or version not found + '500': + description: Server error + + /prompts/{promptId}/completions: + servers: *DataPlaneServers + post: + operationId: createPromptCompletion + tags: + - Prompts + summary: Prompts Completions + description: | + Execute your saved prompt templates on Portkey + parameters: + - in: path + name: promptId + required: true + schema: + type: string + description: The unique identifier of the prompt template to use + requestBody: + required: true + content: + application/json: + schema: + allOf: + - type: object + required: + - variables + description: | + Note: Although hyperparameters are shown grouped here (like messages, max_tokens, temperature, etc.), they should only be passed at the root level, alongside 'variables' and 'stream'. + properties: + variables: + type: object + description: Variables to substitute in the prompt template + stream: + type: boolean + default: False + description: "Default: False. Set to True if you want to stream the response" + hyperparameters: + oneOf: + - title: Chat Completions + $ref: "#/components/schemas/CreateChatCompletionRequest" + - title: Completions + $ref: "#/components/schemas/CreateCompletionRequest" + description: | + **Note**: All hyperparameters are optional. Pass them at the root level, and not nested under `hyperparameters`. Their grouping here is for educational purposes only. + + responses: + "200": + description: Successful completion response + content: + application/json: + schema: + type: object + properties: + status: + type: string + description: Response status + headers: + type: object + description: Response headers + body: + oneOf: + - title: Chat Completions + $ref: "#/components/schemas/CreateChatCompletionResponse" + - title: Completions + $ref: "#/components/schemas/CreateCompletionResponse" + + x-code-samples: + - lang: cURL + label: Default + source: | + curl -X POST "https://api.portkey.ai/v1/prompts/YOUR_PROMPT_ID/completions" \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -d '{ + "variables": { + "user_input": "Hello world" + }, + "max_tokens": 250, + "presence_penalty": 0.2 + }' + - lang: Python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key="PORTKEY_API_KEY" + ) + + completion = client.prompts.completions.create( + prompt_id="YOUR_PROMPT_ID", + variables={ + "user_input": "Hello world" + }, + max_tokens=250, + presence_penalty=0.2 + ) + + print(completion) + + - lang: JavaScript + label: Default + source: | + import Portkey from 'portkey-ai'; + + const portkey = new Portkey({ + apiKey: 'PORTKEY_API_KEY' + }); + + const completion = await portkey.prompts.completions.create({ + promptId: "YOUR_PROMPT_ID", + variables: { + user_input: "Hello world" + }, + max_tokens: 250, + presence_penalty: 0.2 + }); + + console.log(completion); + - lang: curl + label: Self-Hosted + source: | + curl -X POST "SELF_HOSTED_GATEWAY_URL/prompts/YOUR_PROMPT_ID/completions" \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -d '{ + "variables": { + "user_input": "Hello world" + }, + "max_tokens": 250, + "presence_penalty": 0.2 + }' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_GATEWAY_URL" + ) + + completion = client.prompts.completions.create( + prompt_id="YOUR_PROMPT_ID", + variables={ + "user_input": "Hello world" + }, + max_tokens=250, + presence_penalty=0.2 + ) + + print(completion) + - lang: javascript + label: Self-Hosted + source: | + import Portkey from 'portkey-ai'; + + const portkey = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + baseURL: 'SELF_HOSTED_GATEWAY_URL' + }); + + const completion = await portkey.prompts.completions.create({ + promptId: "YOUR_PROMPT_ID", + variables: { + user_input: "Hello world" + }, + max_tokens: 250, + presence_penalty: 0.2 + }); + + console.log(completion); + + /prompts/{promptId}/render: + servers: *DataPlaneServers + post: + operationId: createPromptRender + tags: + - Prompts + summary: Prompts Render + description: | + Renders a prompt template with its variable values filled in + parameters: + - in: path + name: promptId + required: true + schema: + type: string + description: The unique identifier of the prompt template to render + requestBody: + required: true + content: + application/json: + schema: + allOf: + - type: object + required: + - variables + description: | + Note: Although hyperparameters are shown grouped here (like messages, max_tokens, temperature, etc.), they should only be passed at the root level, alongside 'variables' and 'stream'. + properties: + variables: + type: object + description: Variables to substitute in the prompt template + hyperparameters: + oneOf: + - title: Chat Completions + $ref: "#/components/schemas/CreateChatCompletionRequest" + - title: Completions + $ref: "#/components/schemas/CreateCompletionRequest" + description: | + **Note**: All hyperparameters are optional. Pass them at the root level, and not nested under `hyperparameters`. Their grouping here is for educational purposes only. + + responses: + "200": + description: Successful rendered prompt + content: + application/json: + schema: + $ref: "#/components/schemas/PromptRenderResponse" + + x-code-samples: + - lang: "cURL" + label: Default + source: | + curl -X POST "https://api.portkey.ai/v1/prompts/YOUR_PROMPT_ID/render" \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -d '{ + "variables": { + "user_input": "Hello world" + }, + "max_tokens": 250, + "presence_penalty": 0.2 + }' + - lang: Python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key="PORTKEY_API_KEY" + ) + + completion = client.prompts.render( + prompt_id="YOUR_PROMPT_ID", + variables={ + "user_input": "Hello world" + }, + max_tokens=250, + presence_penalty=0.2 + ) + + print(completion) + + - lang: "JavaScript" + label: Default + source: | + import Portkey from 'portkey-ai'; + + const portkey = new Portkey({ + apiKey: 'PORTKEY_API_KEY' + }); + + const completion = await portkey.prompts.render({ + promptId: "YOUR_PROMPT_ID", + variables: { + user_input: "Hello world" + }, + max_tokens: 250, + presence_penalty: 0.2 + }); + + console.log(completion); + - lang: "cURL" + label: Self-Hosted + source: | + curl -X POST "SELF_HOSTED_GATEWAY_URL/prompts/YOUR_PROMPT_ID/render" \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -d '{ + "variables": { + "user_input": "Hello world" + }, + "max_tokens": 250, + "presence_penalty": 0.2 + }' + - lang: Python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_GATEWAY_URL" + ) + + completion = client.prompts.render( + prompt_id="YOUR_PROMPT_ID", + variables={ + "user_input": "Hello world" + }, + max_tokens=250, + presence_penalty=0.2 + ) + + print(completion) + + - lang: "JavaScript" + label: Self-Hosted + source: | + import Portkey from 'portkey-ai'; + + const portkey = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL' + }); + + const completion = await portkey.prompts.render({ + promptId: "YOUR_PROMPT_ID", + variables: { + user_input: "Hello world" + }, + max_tokens: 250, + presence_penalty: 0.2 + }); + + console.log(completion); + + /guardrails: + post: + summary: Create a new guardrail + description: Creates a new guardrail with specified checks and actions + operationId: createGuardrail + tags: + - Guardrails + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateGuardrailRequest' + examples: + # BASIC CATEGORY EXAMPLES + jwt_authentication: + summary: "[BASIC] JWT Token Validation" + value: + name: "JWT Authentication Guard" + organisation_id: "550e8400-e29b-41d4-a716-446655440001" + checks: + - id: "default.jwt" + parameters: + jwksUri: "https://example.com/.well-known/jwks.json" + headerKey: "Authorization" + algorithms: ["RS256"] + cacheMaxAge: 86400 + clockTolerance: 5 + maxTokenAge: "1d" + actions: + onFail: "block" + message: "Invalid JWT token" + + model_whitelist: + summary: "[BASIC] Model Whitelist Control" + value: + name: "Allowed Models Only" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "default.modelWhitelist" + parameters: + models: ["gpt-4", "gpt-3.5-turbo", "claude-3-sonnet", "claude-3-haiku"] + actions: + onFail: "block" + message: "Model not in approved whitelist" + + allowed_request_types: + summary: "[BASIC] Restrict to Chat and Embed Only" + value: + name: "Restrict to Chat and Embed Only" + checks: + - id: "default.allowedRequestTypes" + parameters: + allowedTypes: ["chatComplete", "embed"] + actions: + on_fail: "deny" + on_success: "continue" + + case_validation: + summary: "[BASIC] Case Validation Checks" + value: + name: "Text Case Validation" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "default.isAllLowerCase" + - id: "default.alluppercase" + parameters: + not: true + actions: + onFail: "log" + message: "Text case validation failed" + + content_regex: + summary: "[BASIC] Regex Pattern Matching" + value: + name: "Content Pattern Validation" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "default.regexMatch" + parameters: + rule: "\\b(inappropriate|banned|harmful|offensive)\\b" + not: false + - id: "default.endsWith" + parameters: + suffix: "." + not: false + actions: + onFail: "block" + message: "Content violates pattern rules" + + length_controls: + summary: "[BASIC] Content Length Controls" + value: + name: "Content Length Validation" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "default.wordCount" + parameters: + minWords: 5 + maxWords: 500 + not: false + - id: "default.sentenceCount" + parameters: + minSentences: 1 + maxSentences: 20 + not: false + - id: "default.characterCount" + parameters: + minCharacters: 10 + maxCharacters: 4000 + not: false + actions: + onFail: "block" + message: "Content length out of bounds" + + json_validation: + summary: "[BASIC] JSON Structure Validation" + value: + name: "JSON Response Validation" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "default.jsonSchema" + parameters: + schema: + type: "object" + properties: + result: + type: "string" + confidence: + type: "number" + minimum: 0 + maximum: 1 + metadata: + type: "object" + required: ["result"] + not: false + - id: "default.jsonKeys" + parameters: + keys: ["result", "timestamp", "id"] + operator: "all" + actions: + onFail: "block" + message: "Response does not match expected format" + + content_analysis: + summary: "[BASIC] Content Analysis Checks" + value: + name: "Content Quality Checks" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "default.contains" + parameters: + words: ["please", "thank you", "help"] + operator: "any" + - id: "default.validUrls" + parameters: + onlyDNS: true + not: false + - id: "default.containsCode" + parameters: + format: "SQL" + not: true + actions: + onFail: "warn" + message: "Content quality check failed" + + webhook_integration: + summary: "[BASIC] Custom Webhook Validation" + value: + name: "External Validation Service" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "default.webhook" + parameters: + webhookURL: "https://api.example.com/validate-content" + headers: + "Authorization": "Bearer token123" + "Content-Type": "application/json" + "X-API-Version": "v1" + timeout: 5000 + failOnError: true + actions: + onFail: "block" + message: "External validation failed" + + metadata_validation: + summary: "[BASIC] Required Metadata Keys" + value: + name: "Metadata Requirement Check" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "default.requiredMetadataKeys" + parameters: + metadataKeys: ["user_id", "session_id", "request_type"] + operator: "all" + actions: + onFail: "block" + message: "Required metadata missing" + + # PRO CATEGORY EXAMPLES + portkey_moderation: + summary: "[PRO] OpenAI Content Moderation" + value: + name: "Advanced Content Moderation" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "portkey.moderateContent" + parameters: + categories: [ + "hate/threatening", + "harassment/threatening", + "self-harm/intent", + "sexual/minors", + "violence/graphic" + ] + timeout: 5000 + actions: + onFail: "block" + message: "Content flagged by moderation system" + + portkey_language: + summary: "[PRO] Language Detection & Validation" + value: + name: "Multi-Language Support" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "portkey.language" + parameters: + language: "eng_Latn" + not: false + timeout: 5000 + actions: + onFail: "block" + message: "Content not in expected language" + + portkey_pii: + summary: "[PRO] Advanced PII Detection" + value: + name: "PII Protection System" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "portkey.pii" + parameters: + redact: true + categories: [ + "EMAIL_ADDRESS", + "PHONE_NUMBER", + "SSN", + "CREDIT_CARD", + "NAME" + ] + timeout: 5000 + actions: + onFail: "block" + message: "PII detected and redacted" + + portkey_gibberish: + summary: "[PRO] Gibberish Detection" + value: + name: "Content Quality Filter" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "portkey.gibberish" + parameters: + timeout: 5000 + actions: + onFail: "block" + message: "Content appears to be gibberish" + + # PARTNER CATEGORY EXAMPLES + sydelabs_security: + summary: "[PARTNER] SydeLabs AI Security" + value: + name: "AI Security Suite" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "sydelabs.sydeguard" + parameters: + prompt_injection_threshold: 0.5 + toxicity_threshold: 0.3 + evasion_threshold: 0.6 + timeout: 5000 + actions: + onFail: "block" + message: "AI security check failed" + + aporia_validation: + summary: "[PARTNER] Aporia Project Validation" + value: + name: "Aporia Policy Enforcement" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "aporia.validateProject" + parameters: + projectID: "proj_abc123" + timeout: 5000 + actions: + onFail: "block" + message: "Aporia validation failed" + + pillar_scanning: + summary: "[PARTNER] Pillar Security Scanning" + value: + name: "Comprehensive Security Scan" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "pillar.scanPrompt" + parameters: + scanners: [ + "prompt_injection", + "pii", + "secrets", + "toxic_language", + "invisible_characters" + ] + timeout: 5000 + - id: "pillar.scanResponse" + parameters: + scanners: ["pii", "secrets", "toxic_language"] + timeout: 5000 + actions: + onFail: "block" + message: "Security scan detected issues" + + patronus_comprehensive: + summary: "[PARTNER] Patronus AI Complete Suite" + value: + name: "Patronus Content Analysis" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "patronus.pii" + parameters: + redact: true + timeout: 5000 + - id: "patronus.toxicity" + parameters: + timeout: 5000 + - id: "patronus.noGenderBias" + parameters: + timeout: 15000 + - id: "patronus.isHelpful" + parameters: + timeout: 15000 + - id: "patronus.custom" + parameters: + profile: "system:is-concise" + timeout: 15000 + actions: + onFail: "block" + message: "Content failed Patronus analysis" + + azure_content_safety: + summary: "[PARTNER] Azure Content Safety Suite" + value: + name: "Microsoft Azure Safety" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "azure.contentSafety" + parameters: + blocklistNames: ["company_blocklist"] + apiVersion: "2024-09-01" + severity: 2 + categories: ["Hate", "SelfHarm", "Sexual", "Violence"] + timeout: 5000 + - id: "azure.pii" + parameters: + domain: "phi" + apiVersion: "2024-11-01" + modelVersion: "latest" + redact: true + timeout: 5000 + actions: + onFail: "block" + message: "Azure safety checks failed" + + mistral_moderation: + summary: "[PARTNER] Mistral Content Moderation" + value: + name: "Mistral AI Moderation" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "mistral.moderateContent" + parameters: + categories: [ + "sexual", + "hate_and_discrimination", + "violence_and_threats", + "selfharm", + "pii" + ] + timeout: 5000 + actions: + onFail: "block" + message: "Mistral moderation flagged content" + + bedrock_enterprise: + summary: "[PARTNER] AWS Bedrock Guardrails" + value: + name: "Enterprise AWS Security" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "bedrock.guard" + parameters: + guardrailVersion: "DRAFT" + guardrailId: "gdrail123abc" + redact: true + timeout: 5000 + actions: + onFail: "block" + message: "AWS Bedrock guardrail violation" + + promptfoo_testing: + summary: "[PARTNER] Promptfoo Security Testing" + value: + name: "Security Testing Suite" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "promptfoo.guard" + parameters: + timeout: 5000 + - id: "promptfoo.pii" + parameters: + redact: true + timeout: 5000 + - id: "promptfoo.harm" + parameters: + timeout: 5000 + actions: + onFail: "block" + message: "Promptfoo security tests failed" + + acuvity_comprehensive: + summary: "[PARTNER] Acuvity Multi-Vector Security" + value: + name: "Complete Security Analysis" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "acuvity.scan" + parameters: + prompt_injection: true + prompt_injection_threshold: 0.5 + toxic: true + toxic_threshold: 0.3 + jail_break: true + jail_break_threshold: 0.6 + malicious_url: true + biased: true + harmful: true + language: true + language_values: "english" + pii: true + pii_redact: true + pii_categories: ["email_address", "ssn", "credit_card"] + secrets: true + secrets_redact: true + secrets_categories: ["aws_secret_key", "openai", "github"] + timeout: 5000 + actions: + onFail: "block" + message: "Comprehensive security scan failed" + + lasso_classification: + summary: "[PARTNER] Lasso Security Classification" + value: + name: "Content Classification" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "lasso.classify" + parameters: + timeout: 5000 + actions: + onFail: "block" + message: "Lasso classification failed" + + panw_prisma: + summary: "[PARTNER] PANW Prisma AIRS Enterprise" + value: + name: "Enterprise Security Runtime" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "panw-prisma-airs.intercept" + parameters: + profile_name: "enterprise_profile" + ai_model: "gpt-4" + app_user: "api_user_123" + actions: + onFail: "block" + message: "Prisma AIRS blocked request" + + responses: + '200': + description: Guardrail created successfully + content: + application/json: + schema: + $ref: '#/components/schemas/CreateGuardrailResponse' + '400': + description: Bad request - validation failed + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '403': + description: Forbidden - insufficient permissions or guardrail not allowed + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '500': + description: Internal server error + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + + get: + summary: List guardrails + description: Retrieves a paginated list of guardrails for the specified workspace or organisation + operationId: listGuardrails + tags: + - Guardrails + parameters: + - name: workspace_id + in: query + description: Workspace UUID to filter guardrails + schema: + type: string + format: uuid + - name: organisation_id + in: query + description: Organisation UUID to filter guardrails + schema: + type: string + format: uuid + - name: page_size + in: query + description: Number of items per page + schema: + type: integer + minimum: 1 + maximum: 1000 + default: 100 + - name: current_page + in: query + description: Current page number (0-indexed) + schema: + type: integer + minimum: 0 + default: 0 + responses: + '200': + description: List of guardrails retrieved successfully + content: + application/json: + schema: + $ref: '#/components/schemas/ListGuardrailsResponse' + '400': + description: Bad request - invalid parameters + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '403': + description: Forbidden - insufficient permissions + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + + /guardrails/{guardrailId}: + get: + summary: Get a specific guardrail + description: Retrieves details of a specific guardrail by ID or slug + operationId: getGuardrail + tags: + - Guardrails + parameters: + - name: guardrailId + in: path + required: true + description: Guardrail UUID or slug (with guard_ prefix) + schema: + type: string + examples: + uuid: + summary: Using UUID + value: "550e8400-e29b-41d4-a716-446655440000" + slug: + summary: Using slug + value: "guard_abc123" + responses: + '200': + description: Guardrail details retrieved successfully + content: + application/json: + schema: + $ref: '#/components/schemas/GuardrailDetails' + '403': + description: Forbidden - guardrail not found or insufficient permissions + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '500': + description: Internal server error + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + + put: + summary: Update a guardrail + description: Updates an existing guardrail's name, checks, or actions + operationId: updateGuardrail + tags: + - Guardrails + parameters: + - name: guardrailId + in: path + required: true + description: Guardrail UUID or slug to update + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateGuardrailRequest' + responses: + '200': + description: Guardrail updated successfully + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateGuardrailResponse' + '400': + description: Bad request - validation failed + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '403': + description: Forbidden - guardrail not found or insufficient permissions + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + + delete: + summary: Delete a guardrail + description: Deletes an existing guardrail + operationId: deleteGuardrail + tags: + - Guardrails + parameters: + - name: guardrailId + in: path + required: true + description: Guardrail UUID or slug to delete + schema: + type: string + responses: + '200': + description: Guardrail deleted successfully + '403': + description: Forbidden - guardrail not found or insufficient permissions + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '500': + description: Internal server error + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + + /images/generations: + servers: *DataPlaneServers + post: + operationId: createImage + tags: + - Images + summary: Create Image + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CreateImageRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ImagesResponse" + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + label: Default + source: | + curl https://api.portkey.ai/v1/images/generations \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -d '{ + "model": "dall-e-3", + "prompt": "A cute baby sea otter", + "n": 1, + "size": "1024x1024" + }' + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.images.generate( + model="dall-e-3", + prompt="A cute baby sea otter", + n=1, + size="1024x1024" + ) + - lang: javascript + label: Default + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const image = await client.images.generate({ model: "dall-e-3", prompt: "A cute baby sea otter" }); + + console.log(image.data); + } + main(); + - lang: curl + label: Self-Hosted + source: | + curl -X POST "SELF_HOSTED_GATEWAY_URL/images/generations" \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -d '{ + "model": "dall-e-3", + "prompt": "A cute baby sea otter", + "n": 1, + "size": "1024x1024" + }' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key="PORTKEY_API_KEY", + virtual_key="PROVIDER_VIRTUAL_KEY", + base_url="SELF_HOSTED_GATEWAY_URL" + ) + + image = client.images.generate( + model="dall-e-3", + prompt="A cute baby sea otter", + n=1, + size="1024x1024" + ) + + print(image.data) + - lang: javascript + label: Self-Hosted + source: | + import Portkey from 'portkey-ai'; + + const portkey = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY', + baseURL: 'SELF_HOSTED_GATEWAY_URL' + }); + + const image = await portkey.images.generate({ + model: "dall-e-3", + prompt: "A cute baby sea otter", + n: 1, + size: "1024x1024" + }); + + console.log(image.data); + + /images/edits: + servers: *DataPlaneServers + post: + operationId: createImageEdit + tags: + - Images + summary: Create Image Edit + requestBody: + required: true + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/CreateImageEditRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ImagesResponse" + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + label: Default + source: | + curl https://api.portkey.ai/v1/images/edits \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_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" + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + 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" + ) + - lang: javascript + label: Default + source: | + import fs from "fs"; + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const image = await client.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(); + - lang: curl + label: Self-Hosted + source: | + curl -X POST "SELF_HOSTED_GATEWAY_URL/images/edits" \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -d '{ + "image": "@otter.png", + "mask": "@mask.png", + "prompt": "A cute baby sea otter wearing a beret", + "n": 2, + "size": "1024x1024" + }' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key="PORTKEY_API_KEY", + virtual_key="PROVIDER_VIRTUAL_KEY", + base_url="SELF_HOSTED_GATEWAY_URL" + ) + + image = 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" + ) + + print(image.data) + - lang: javascript + label: Self-Hosted + source: | + import fs from "fs"; + import Portkey from 'portkey-ai'; + + const portkey = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY', + baseURL: 'SELF_HOSTED_GATEWAY_URL' + }); + + async function main() { + const image = await portkey.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(); + + /images/variations: + servers: *DataPlaneServers + post: + operationId: createImageVariation + tags: + - Images + summary: Creates Image Variation + requestBody: + required: true + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/CreateImageVariationRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ImagesResponse" + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + label: Default + source: | + curl https://api.portkey.ai/v1/images/variations \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -F image="@otter.png" \ + -F n=2 \ + -F size="1024x1024" + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + response = client.images.create_variation( + image=open("image_edit_original.png", "rb"), + n=2, + size="1024x1024" + ) + - lang: javascript + label: Default + source: | + import fs from "fs"; + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const image = await client.images.createVariation({ + image: fs.createReadStream("otter.png"), + }); + + console.log(image.data); + } + main(); + - lang: curl + label: Self-Hosted + source: | + curl -X POST "SELF_HOSTED_GATEWAY_URL/images/variations" \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -d '{ + "image": "@otter.png", + "n": 2, + "size": "1024x1024" + }' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key="PORTKEY_API_KEY", + virtual_key="PROVIDER_VIRTUAL_KEY", + base_url="SELF_HOSTED_GATEWAY_URL" + ) + + image = client.images.create_variation( + image=open("otter.png", "rb"), + n=2, + size="1024x1024" + ) + + print(image.data) + - lang: javascript + label: Self-Hosted + source: | + import fs from "fs"; + import Portkey from 'portkey-ai'; + + const portkey = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY', + baseURL: 'SELF_HOSTED_GATEWAY_URL' + }); + + async function main() { + const image = await portkey.images.createVariation({ + image: fs.createReadStream("otter.png"), + }); + + console.log(image.data); + } + main(); + + /embeddings: + servers: *DataPlaneServers + post: + operationId: createEmbedding + tags: + - Embeddings + summary: Embeddings + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CreateEmbeddingRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/CreateEmbeddingResponse" + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + label: Default + source: | + curl https://api.portkey.ai/v1/embeddings \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "input": "The food was delicious and the waiter...", + "model": "text-embedding-ada-002", + "encoding_format": "float" + }' + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.embeddings.create( + model="text-embedding-ada-002", + input="The food was delicious and the waiter...", + encoding_format="float" + ) + - lang: javascript + label: Default + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const embedding = await client.embeddings.create({ + model: "text-embedding-ada-002", + input: "The quick brown fox jumped over the lazy dog", + encoding_format: "float", + }); + + console.log(embedding); + } + + main(); + - lang: curl + label: Self-Hosted + source: | + curl -X POST "SELF_HOSTED_GATEWAY_URL/embeddings" \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -d '{ + "input": "The food was delicious and the waiter...", + "model": "text-embedding-ada-002", + "encoding_format": "float" + }' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key="PORTKEY_API_KEY", + virtual_key="PROVIDER_VIRTUAL_KEY", + base_url="SELF_HOSTED_GATEWAY_URL" + ) + + response = client.embeddings.create( + model="text-embedding-ada-002", + input="The food was delicious and the waiter...", + encoding_format="float" + ) + + print(response.data) + - lang: javascript + label: Self-Hosted + source: | + import fs from "fs"; + import Portkey from 'portkey-ai'; + + const portkey = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY', + baseURL: 'SELF_HOSTED_GATEWAY_URL' + }); + + async function main() { + const embedding = await portkey.embeddings.create({ + model: "text-embedding-ada-002", + input: "The quick brown fox jumped over the lazy dog", + encoding_format: "float", + }); + + console.log(embedding); + } + + main(); + + /audio/speech: + servers: *DataPlaneServers + post: + operationId: createSpeech + tags: + - Audio + summary: Create Speech + 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 + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + label: Default + source: | + curl https://api.portkey.ai/v1/audio/speech \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_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 + - lang: python + label: Default + source: | + from pathlib import Path + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + speech_file_path = Path(__file__).parent / "speech.mp3" + response = client.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) + - lang: javascript + label: Default + source: | + import fs from "fs"; + import path from "path"; + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + const speechFile = path.resolve("./speech.mp3"); + + async function main() { + const mp3 = await client.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(); + - lang: curl + label: Self-Hosted + source: | + curl -X POST "SELF_HOSTED_GATEWAY_URL/audio/speech" \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -d '{ + "model": "tts-1", + "input": "The quick brown fox jumped over the lazy dog.", + "voice": "alloy" + }' \ + --output speech.mp3 + - lang: python + label: Self-Hosted + source: | + from pathlib import Path + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY", + base_url="SELF_HOSTED_GATEWAY_URL" + ) + + speech_file_path = Path(__file__).parent / "speech.mp3" + response = client.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) + - lang: javascript + label: Self-Hosted + source: | + import fs from "fs"; + import path from "path"; + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL' + }); + + const speechFile = path.resolve("./speech.mp3"); + + async function main() { + const mp3 = await client.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: + servers: *DataPlaneServers + post: + operationId: createTranscription + tags: + - Audio + summary: Create Transcription + 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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + label: Default + source: | + curl https://api.portkey.ai/v1/audio/transcriptions \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: multipart/form-data" \ + -F file="@/path/to/file/audio.mp3" \ + -F model="whisper-1" + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + audio_file = open("speech.mp3", "rb") + transcript = client.audio.transcriptions.create( + model="whisper-1", + file=audio_file + ) + - lang: javascript + label: Default + source: | + import fs from "fs"; + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const transcription = await client.audio.transcriptions.create({ + file: fs.createReadStream("audio.mp3"), + model: "whisper-1", + }); + + console.log(transcription.text); + } + main(); + - lang: curl + label: Self-Hosted + source: | + curl -X POST "SELF_HOSTED_GATEWAY_URL/audio/transcriptions" \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -d '{ + "model": "whisper-1", + "file": "@/path/to/file/audio.mp3" + }' \ + --output transcription.json + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY", + base_url="SELF_HOSTED_GATEWAY_URL" + ) + + audio_file = open("speech.mp3", "rb") + transcript = client.audio.transcriptions.create( + model="whisper-1", + file=audio_file + ) + - lang: javascript + label: Self-Hosted + source: | + import fs from "fs"; + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL' + }); + + const audioFile = fs.createReadStream("speech.mp3"); + + async function main() { + const transcription = await client.audio.transcriptions.create({ + file: audioFile, + model: "whisper-1", + }); + + console.log(transcription.text); + } + main(); + + /audio/translations: + servers: *DataPlaneServers + post: + operationId: createTranslation + tags: + - Audio + summary: Create Translation + 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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + label: Default + source: | + curl https://api.portkey.ai/v1/audio/translations \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: multipart/form-data" \ + -F file="@/path/to/file/german.m4a" \ + -F model="whisper-1" + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + audio_file = open("speech.mp3", "rb") + transcript = client.audio.translations.create( + model="whisper-1", + file=audio_file + ) + - lang: javascript + label: Default + source: | + import fs from "fs"; + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const translation = await client.audio.translations.create({ + file: fs.createReadStream("speech.mp3"), + model: "whisper-1", + }); + + console.log(translation.text); + } + main(); + - lang: curl + label: Self-Hosted + source: | + curl -X POST "SELF_HOSTED_GATEWAY_URL/audio/translations" \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -d '{ + "model": "whisper-1", + "file": "@/path/to/file/german.m4a" + }' \ + --output translation.json + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY", + base_url="SELF_HOSTED_GATEWAY_URL" + ) + + audio_file = open("speech.mp3", "rb") + transcript = client.audio.translations.create( + model="whisper-1", + file=audio_file + ) + - lang: javascript + label: Self-Hosted + source: | + import fs from "fs"; + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL' + }); + + const audioFile = fs.createReadStream("speech.mp3"); + + async function main() { + const translation = await client.audio.translations.create({ + file: audioFile, + model: "whisper-1", + }); + + console.log(translation.text); + } + main(); + + /files: + servers: *DataPlaneServers + get: + operationId: listFiles + tags: + - Files + summary: List Files + parameters: + - in: query + name: purpose + required: false + schema: + type: string + description: Only return files with the given purpose. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ListFilesResponse" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/files \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.files.list() + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const list = await client.files.list(); + + for await (const file of list) { + console.log(file); + } + } + + main(); + + post: + operationId: createFile + tags: + - Files + summary: | + Upload a file to be used across various endpoints, such as Assistant (<2M tokens), Fine-Tuning, and Batch (<100 MB). Total size of your bucket is 100 GB. + requestBody: + required: true + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/CreateFileRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/OpenAIFile" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/files \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -F purpose="fine-tune" \ + -F file="@mydata.jsonl" + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.files.create( + file=open("mydata.jsonl", "rb"), + purpose="fine-tune" + ) + - lang: javascript + source: | + import fs from "fs"; + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const file = await client.files.create({ + file: fs.createReadStream("mydata.jsonl"), + purpose: "fine-tune", + }); + + console.log(file); + } + + main(); + + /files/{file_id}: + servers: *DataPlaneServers + delete: + operationId: deleteFile + tags: + - Files + summary: Delete 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: + $ref: "#/components/schemas/DeleteFileResponse" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/files/file-abc123 \ + -X DELETE \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.files.delete("file-abc123") + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const file = await client.files.del("file-abc123"); + + console.log(file); + } + + main(); + + get: + operationId: retrieveFile + tags: + - Files + summary: Returns information about a specific 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: + $ref: "#/components/schemas/OpenAIFile" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/files/file-abc123 \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.files.retrieve("file-abc123") + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const file = await client.files.retrieve("file-abc123"); + + console.log(file); + } + + main(); + + /files/{file_id}/content: + servers: *DataPlaneServers + 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 + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/files/file-abc123/content \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" > file.jsonl + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + content = client.files.content("file-abc123") + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const file = await client.files.content("file-abc123"); + + console.log(file); + } + + main(); + + /fine_tuning/jobs: + servers: *DataPlaneServers + post: + operationId: createFineTuningJob + summary: Create a Finetune Job + description: Finetune a provider model + parameters: [] + responses: + "200": + description: The request has succeeded. + content: + application/json: + schema: + $ref: "#/components/schemas/FineTuningJob" + tags: + - Finetune + requestBody: + required: true + content: + application/json: + schema: + anyOf: + - $ref: "#/components/schemas/OpenAIFinetuneJob" + - $ref: "#/components/schemas/BedrockFinetuneJob" + - $ref: "#/components/schemas/PortkeyFinetuneJob" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + label: Default + source: | + curl https://api.portkey.ai/v1/fine_tuning/jobs \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -d '{ + "training_file": "file-BK7bzQj3FfZFXr7DbL6xJwfo", + "model": "gpt-3.5-turbo" + }' + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.fine_tuning.jobs.create( + training_file="file-abc123", + model="gpt-3.5-turbo" + ) + - lang: javascript + label: Default + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const fineTune = await client.fineTuning.jobs.create({ + training_file: "file-abc123" + }); + + console.log(fineTune); + } + + main(); + - lang: curl + label: Self-hosted + source: | + curl https://SELF_HOSTED_GATEWAY_URL/fine_tuning/jobs \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -d '{ + "training_file": "file-BK7bzQj3FfZFXr7DbL6xJwfo", + "model": "gpt-3.5-turbo" + }' + - lang: python + label: Self-hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + base_url = "SELF_HOSTED_GATEWAY_URL", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.fine_tuning.jobs.create( + training_file="file-abc123", + model="gpt-3.5-turbo" + ) + - lang: javascript + label: Self-hosted + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const fineTune = await client.fineTuning.jobs.create({ + training_file: "file-abc123" + }); + + console.log(fineTune); + } + + main(); + + 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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + label: Default + source: | + curl https://api.portkey.ai/v1/fine_tuning/jobs?limit=2 \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.fine_tuning.jobs.list() + - lang: javascript + label: Default + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const list = await client.fineTuning.jobs.list(); + + for await (const fineTune of list) { + console.log(fineTune); + } + } + + main(); + - lang: curl + label: Self-hosted + source: | + curl https://SELF_HOSTED_GATEWAY_URL/fine_tuning/jobs?limit=2 \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" + - lang: python + label: Self-hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + base_url = "SELF_HOSTED_GATEWAY_URL", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.fine_tuning.jobs.list() + - lang: javascript + label: Self-hosted + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const list = await client.fineTuning.jobs.list(); + + for await (const fineTune of list) { + console.log(fineTune); + } + } + + main(); + + /fine_tuning/jobs/{fine_tuning_job_id}: + servers: *DataPlaneServers + get: + operationId: retrieveFineTuningJob + tags: + - Fine-tuning + summary: | + Get info about a fine-tuning job. + + [Learn more about fine-tuning](https://platform.openai.com/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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + label: Default + source: | + curl https://api.portkey.ai/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.fine_tuning.jobs.retrieve("ftjob-abc123") + - lang: javascript + label: Default + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const fineTune = await client.fineTuning.jobs.retrieve("ftjob-abc123"); + + console.log(fineTune); + } + + main(); + - lang: curl + label: Self-hosted + source: | + curl SELF_HOSTED_GATEWAY_URL/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" + - lang: python + label: Self-hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + base_url = "SELF_HOSTED_GATEWAY_URL", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.fine_tuning.jobs.retrieve("ftjob-abc123") + - lang: javascript + label: Self-hosted + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const fineTune = await client.fineTuning.jobs.retrieve("ftjob-abc123"); + + console.log(fineTune); + } + + main(); + + /fine_tuning/jobs/{fine_tuning_job_id}/events: + servers: *DataPlaneServers + 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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + label: Default + source: | + curl https://api.portkey.ai/v1/fine_tuning/jobs/ftjob-abc123/events \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.fine_tuning.jobs.list_events( + fine_tuning_job_id="ftjob-abc123", + limit=2 + ) + - lang: javascript + label: Default + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const list = await client.fineTuning.list_events(id="ftjob-abc123", limit=2); + + for await (const fineTune of list) { + console.log(fineTune); + } + } + + main(); + - lang: curl + label: Self-hosted + source: | + curl SELF_HOSTED_GATEWAY_URL/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F/events \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" + - lang: python + label: Self-hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + base_url = "SELF_HOSTED_GATEWAY_URL", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.fine_tuning.jobs.list_events( + fine_tuning_job_id="ftjob-abc123", + limit=2 + ) + - lang: javascript + label: Self-hosted + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const list = await client.fineTuning.list_events(id="ftjob-abc123", limit=2); + + for await (const fineTune of list) { + console.log(fineTune); + } + } + + main(); + + /fine_tuning/jobs/{fine_tuning_job_id}/cancel: + servers: *DataPlaneServers + 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. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/FineTuningJob" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + label: Default + source: | + curl -X POST https://api.portkey.ai/v1/fine_tuning/jobs/ftjob-abc123/cancel \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.fine_tuning.jobs.cancel("ftjob-abc123") + - lang: javascript + label: Default + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const fineTune = await client.fineTuning.jobs.cancel("ftjob-abc123"); + + console.log(fineTune); + } + main(); + - lang: curl + label: Self-hosted + source: | + curl -X POST SELF_HOSTED_GATEWAY_URL/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F/cancel \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" + - lang: python + label: Self-hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + base_url = "SELF_HOSTED_GATEWAY_URL", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.fine_tuning.jobs.cancel("ft-AF1WoRqd3aJAHsqc9NY7iL8F") + - lang: javascript + label: Self-hosted + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const fineTune = await client.fineTuning.jobs.cancel("ft-AF1WoRqd3aJAHsqc9NY7iL8F"); + + console.log(fineTune); + } + main(); + + /fine_tuning/jobs/{fine_tuning_job_id}/checkpoints: + servers: *DataPlaneServers + 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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + label: Default + source: | + curl https://api.portkey.ai/v1/fine_tuning/jobs/ftjob-abc123/checkpoints \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" + - lang: curl + label: Self-Hosted + source: | + curl SELF_HOSTED_GATEWAY_URL/fine_tuning/jobs/ftjob-abc123/checkpoints \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + checkpoints_list = client.fine_tuning.jobs.checkpoints.list(fine_tuning_job_id="") + print(checkpoints_list) + - lang: javascript + label: Default + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const checkpointsList = await client.fineTuning.jobs.checkpoints.list("") + console.log(checkpointsList) + } + + main(); + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY", + base_url = "SELF_HOSTED_GATEWAY_URL" + ) + + checkpoints_list = client.fine_tuning.jobs.checkpoints.list(fine_tuning_job_id="") + print(checkpoints_list) + - lang: javascript + label: Self-Hosted + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL' + }); + + async function main() { + const checkpointsList = await client.fineTuning.jobs.checkpoints.list("") + console.log(checkpointsList) + } + + main(); + + /models: + servers: *DataPlaneServers + get: + operationId: listModels + tags: + - Models + summary: List Available Models + description: >- + Lists the currently available models that can be used through Portkey, and provides basic information about each one. + parameters: + - in: query + name: ai_service + required: false + description: Filter models by the AI service (e.g., 'openai', 'anthropic'). + schema: + type: string + - in: query + name: provider + required: false + description: Filter models by the provider. + schema: + type: string + - in: query + name: limit + required: false + description: The maximum number of models to return. + schema: + type: integer + - in: query + name: offset + required: false + description: The number of models to skip before starting to collect the result set. + schema: + type: integer + - in: query + name: sort + required: false + description: The field to sort the results by. + schema: + type: string + enum: [name, provider, ai_service] + default: name + - in: query + name: order + required: false + description: The order to sort the results in. + schema: + type: string + enum: [asc, desc] + default: asc + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ListModelsResponse' + example: + object: "list" + total: 500 + data: + - id: "@ai-provider-slug/gpt-5" + slug: "gpt-5" + canonical_slug: "gpt-5" + object: "model" + security: + - Portkey-Key: [] + x-code-samples: + - lang: curl + label: Default + source: | + # Example of sending a query parameter in the URL + curl 'https://api.portkey.ai/v1/models?provider=openai' \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + # Example of sending a query parameter in the URL + curl 'https://YOUR_SELF_HOSTED_URL/models?provider=openai' \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY" + ) + + # Example of sending query parameters via extra_query + models = client.models.list( + extra_query={"provider": "openai"} + ) + print(models) + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + base_url = "https://YOUR_SELF_HOSTED_URL" + ) + + # Example of sending query parameters via extra_query + models = client.models.list( + extra_query={"provider": "openai"} + ) + print(models) + - lang: javascript + label: Default + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY' + }); + + async function main() { + // Example of sending query parameters in the list method + const list = await client.models.list({ + provider: "openai" + }); + console.log(list); + } + main(); + - lang: javascript + label: Self-Hosted + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + baseUrl: 'https://YOUR_SELF_HOSTED_URL' + }); + + async function main() { + // Example of sending query parameters in the list method + const list = await client.models.list({ + provider: "openai" + }); + console.log(list); + } + main(); + + + /models/{model}: + get: + operationId: retrieveModel + tags: + - Models + summary: Retrieves a model instance, providing basic information about the model such as the owner and permissioning. + parameters: + - in: path + name: model + required: true + schema: + type: string + # ideally this will be an actual ID, so this will always work from browser + example: gpt-3.5-turbo + description: The ID of the model to use for this request + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/Model" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/models/VAR_model_id \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.models.retrieve("VAR_model_id") + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const model = await client.models.retrieve("VAR_model_id"); + + console.log(model); + } + + main(); + + delete: + operationId: deleteModel + tags: + - Models + 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-3.5-turbo:acemeco:suffix:abc123 + description: The model to delete + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/DeleteModelResponse" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/models/ft:gpt-3.5-turbo:acemeco:suffix:abc123 \ + -X DELETE \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.models.delete("ft:gpt-3.5-turbo:acemeco:suffix:abc123") + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const model = await client.models.del("ft:gpt-3.5-turbo:acemeco:suffix:abc123"); + + console.log(model); + } + main(); + + /moderations: + servers: *DataPlaneServers + post: + operationId: createModeration + tags: + - Moderations + summary: | + Identify potentially harmful content in text and images. **Only** works with [OpenAI's Moderations endpoint](https://platform.openai.com/docs/guides/moderation) currently. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CreateModerationRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/CreateModerationResponse" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + label: Default + source: | + curl https://api.portkey.ai/v1/moderations \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -d '{ + "input": "I want to kill them." + }' + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + moderation = client.moderations.create(input="I want to kill them.") + print(moderation) + - lang: javascript + label: Default + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const moderation = await client.moderations.create({ input: "I want to kill them." }); + + console.log(moderation); + } + main(); + - lang: curl + label: Self-Hosted + source: | + curl https://SELF_HOSTED_GATEWAY_URL/moderations \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -d '{ + "input": "I want to kill them." + }' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + base_url="SELF_HOSTED_GATEWAY_URL", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + moderation = client.moderations.create(input="I want to kill them.") + print(moderation) + - lang: javascript + label: Self-Hosted + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY', + baseURL: 'SELF_HOSTED_GATEWAY_URL' + }); + + async function main() { + const moderation = await client.moderations.create({ input: "I want to kill them." }); + + console.log(moderation); + } + main(); + + /assistants: + servers: *DataPlaneServers + get: + operationId: listAssistants + tags: + - Assistants + summary: Returns a list of assistants. + parameters: + - name: limit + in: query + description: &pagination_limit_param_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: &pagination_order_param_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: &pagination_after_param_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: &pagination_before_param_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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl "https://api.portkey.ai/v1/assistants?order=desc&limit=20" \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "OpenAI-Beta: assistants=v2" + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + my_assistants = client.beta.assistants.list( + order="desc", + limit="20", + ) + print(my_assistants.data) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const myAssistants = await client.beta.assistants.list({ + order: "desc", + limit: "20", + }); + + console.log(myAssistants.data); + } + + main(); + response: &list_assistants_example | + { + "object": "list", + "data": [ + { + "id": "asst_abc123", + "object": "assistant", + "created_at": 1698982736, + "name": "Coding Tutor", + "description": null, + "model": "gpt-4-turbo", + "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-4-turbo", + "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-4-turbo", + "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. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CreateAssistantRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/AssistantObject" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl "https://api.portkey.ai/v1/assistants" \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_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-4-turbo" + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + 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-4-turbo", + ) + print(my_assistant) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const myAssistant = await client.beta.assistants.create({ instructions: - description: *assistant_instructions_param_description - type: string - nullable: true - maxLength: 256000 - tools: - description: *assistant_tools_param_description - default: [] + "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-4-turbo", + }); + + console.log(myAssistant); + } + + main(); + response: &create_assistants_example | + { + "id": "asst_abc123", + "object": "assistant", + "created_at": 1698984975, + "name": "Math Tutor", + "description": null, + "model": "gpt-4-turbo", + "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" + } + /assistants/{assistant_id}: + servers: *DataPlaneServers + get: + operationId: getAssistant + tags: + - Assistants + summary: Retrieves an assistant. + parameters: + - in: path + name: assistant_id + required: true + schema: + type: string + description: The ID of the assistant to retrieve. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/AssistantObject" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/assistants/asst_abc123 \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "OpenAI-Beta: assistants=v2" + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + my_assistant = client.beta.assistants.retrieve("asst_abc123") + print(my_assistant) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const myAssistant = await client.beta.assistants.retrieve( + "asst_abc123" + ); + + console.log(myAssistant); + } + + main(); + response: | + { + "id": "asst_abc123", + "object": "assistant", + "created_at": 1699009709, + "name": "HR Helper", + "description": null, + "model": "gpt-4-turbo", + "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. + parameters: + - in: path + name: assistant_id + required: true + schema: + type: string + description: The ID of the assistant to modify. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/ModifyAssistantRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/AssistantObject" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/assistants/asst_abc123 \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_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-4-turbo" + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + 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-4-turbo" + ) + + print(my_updated_assistant) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const myUpdatedAssistant = await 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-4-turbo" + } + ); + + console.log(myUpdatedAssistant); + } + + main(); + response: | + { + "id": "asst_123", + "object": "assistant", + "created_at": 1699009709, + "name": "HR Helper", + "description": null, + "model": "gpt-4-turbo", + "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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/assistants/asst_abc123 \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "OpenAI-Beta: assistants=v2" \ + -X DELETE + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + response = client.beta.assistants.delete("asst_abc123") + print(response) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const response = await client.beta.assistants.del("asst_abc123"); + + console.log(response); + } + main(); + response: | + { + "id": "asst_abc123", + "object": "assistant.deleted", + "deleted": true + } + /responses: + servers: *DataPlaneServers + post: + operationId: createResponse + tags: + - Responses + summary: > + Creates a model response + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CreateResponse" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/Response" + text/event-stream: + schema: + $ref: "#/components/schemas/ResponseStreamEvent" + /responses/{response_id}: + servers: *DataPlaneServers + get: + operationId: getResponse + tags: + - Responses + summary: | + Retrieves a model response with the given ID. + parameters: + - in: path + name: response_id + required: true + schema: + type: string + example: resp_677efb5139a88190b512bc3fef8e535d + description: The ID of the response to retrieve. + - in: query + name: include + schema: + type: array + items: + $ref: "#/components/schemas/Includable" + description: > + Specify additional output data to include in the response. Currently + + supported values are: + + - `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. + + - `computer_call_output.output.image_url`: Include image urls from + the computer call output. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/Response" + delete: + operationId: deleteResponse + tags: + - Responses + summary: | + Deletes a model response with the given ID. + parameters: + - in: path + name: response_id + required: true + schema: + type: string + example: resp_677efb5139a88190b512bc3fef8e535d + description: The ID of the response to delete. + responses: + "200": + description: OK + "404": + description: Not Found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /responses/{response_id}/input_items: + servers: *DataPlaneServers + get: + operationId: listInputItems + tags: + - Responses + summary: Returns a list of input items for a given response. + parameters: + - in: path + name: response_id + required: true + schema: + type: string + description: The ID of the response to retrieve input 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. + 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 `asc`. + - `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. + - in: query + name: before + schema: + type: string + description: | + An item ID to list items before, used in pagination. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ResponseItemList" + /threads: + servers: *DataPlaneServers + 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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/threads \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_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." + }] + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + 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." + }, + ] + ) + + print(message_thread) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const messageThread = await client.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(); + response: | + { + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, + "metadata": {}, + "tool_resources": {} + } + + /threads/{thread_id}: + servers: *DataPlaneServers + get: + operationId: getThread + tags: + - Assistants + summary: Retrieves a thread. + parameters: + - in: path + name: thread_id + required: true + schema: + type: string + description: The ID of the thread to retrieve. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ThreadObject" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/threads/thread_abc123 \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "OpenAI-Beta: assistants=v2" + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + my_thread = client.beta.threads.retrieve("thread_abc123") + print(my_thread) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const myThread = await client.beta.threads.retrieve( + "thread_abc123" + ); + + console.log(myThread); + } + + main(); + response: | + { + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, + "metadata": {}, + "tool_resources": { + "code_interpreter": { + "file_ids": [] + } + } + } + post: + operationId: modifyThread + tags: + - Assistants + summary: Modifies a thread. + 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. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/ModifyThreadRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ThreadObject" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/threads/thread_abc123 \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "metadata": { + "modified": "true", + "user": "abc123" + } + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + my_updated_thread = client.beta.threads.update( + "thread_abc123", + metadata={ + "modified": "true", + "user": "abc123" + } + ) + print(my_updated_thread) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const updatedThread = await client.beta.threads.update( + "thread_abc123", + { + metadata: { modified: "true", user: "abc123" }, + } + ); + + console.log(updatedThread); + } + + main(); + response: | + { + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, + "metadata": { + "modified": "true", + "user": "abc123" + }, + "tool_resources": {} + } + delete: + operationId: deleteThread + tags: + - Assistants + summary: Delete a thread. + parameters: + - in: path + name: thread_id + required: true + schema: + type: string + description: The ID of the thread to delete. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/DeleteThreadResponse" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/threads/thread_abc123 \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "OpenAI-Beta: assistants=v2" \ + -X DELETE + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + response = client.beta.threads.delete("thread_abc123") + print(response) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const response = await client.beta.threads.del("thread_abc123"); + + console.log(response); + } + main(); + response: | + { + "id": "thread_abc123", + "object": "thread.deleted", + "deleted": true + } + + /threads/{thread_id}/messages: + servers: *DataPlaneServers + 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](https://platform.openai.com/docs/api-reference/threads) the messages belong to. + - name: limit + in: query + description: *pagination_limit_param_description + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: *pagination_order_param_description + schema: + type: string + default: desc + enum: ["asc", "desc"] + - name: after + in: query + description: *pagination_after_param_description + schema: + type: string + - name: before + in: query + description: *pagination_before_param_description + schema: + type: string + - name: run_id + in: query + description: | + Filter messages by the run ID that generated them. + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ListMessagesResponse" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/threads/thread_abc123/messages \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "OpenAI-Beta: assistants=v2" + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + thread_messages = client.beta.threads.messages.list("thread_abc123") + print(thread_messages.data) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const threadMessages = await client.beta.threads.messages.list( + "thread_abc123" + ); + + console.log(threadMessages.data); + } + + 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": [ + { + "type": "text", + "text": { + "value": "How does AI work? Explain it in simple terms.", + "annotations": [] + } + } + ], + "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 + } + 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](https://platform.openai.com/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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/threads/thread_abc123/messages \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "role": "user", + "content": "How does AI work? Explain it in simple terms." + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + thread_message = client.beta.threads.messages.create( + "thread_abc123", + role="user", + content="How does AI work? Explain it in simple terms.", + ) + print(thread_message) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const threadMessages = await client.beta.threads.messages.create( + "thread_abc123", + { role: "user", content: "How does AI work? Explain it in simple terms." } + ); + + 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": [] + } + } + ], + "attachments": [], + "metadata": {} + } + + /threads/{thread_id}/messages/{message_id}: + servers: *DataPlaneServers + get: + operationId: getMessage + tags: + - Assistants + summary: Retrieve a message. + parameters: + - in: path + name: thread_id + required: true + schema: + type: string + description: The ID of the [thread](https://platform.openai.com/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. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/MessageObject" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/threads/thread_abc123/messages/msg_abc123 \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "OpenAI-Beta: assistants=v2" + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + message = client.beta.threads.messages.retrieve( + message_id="msg_abc123", + thread_id="thread_abc123", + ) + print(message) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const message = await client.beta.threads.messages.retrieve( + "thread_abc123", + "msg_abc123" + ); + + console.log(message); + } + + main(); + 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": [] + } + } + ], + "attachments": [], + "metadata": {} + } + post: + operationId: modifyMessage + tags: + - Assistants + summary: Modifies 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 modify. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/ModifyMessageRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/MessageObject" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/threads/thread_abc123/messages/msg_abc123 \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "metadata": { + "modified": "true", + "user": "abc123" + } + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + message = client.beta.threads.messages.update( + message_id="msg_abc12", + thread_id="thread_abc123", + metadata={ + "modified": "true", + "user": "abc123", + }, + ) + print(message) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const message = await client.beta.threads.messages.update( + "thread_abc123", + "msg_abc123", + { + metadata: { + modified: "true", + user: "abc123", + }, + } + }' + 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" + } + } + 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. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/DeleteMessageResponse" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl -X DELETE https://api.portkey.ai/v1/threads/thread_abc123/messages/msg_abc123 \ + -H "Content-Type: application/json" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "OpenAI-Beta: assistants=v2" + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + deleted_message = client.beta.threads.messages.delete( + message_id="msg_abc12", + thread_id="thread_abc123", + ) + print(deleted_message) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const deletedMessage = await client.beta.threads.messages.del( + "thread_abc123", + "msg_abc123" + ); + + console.log(deletedMessage); + } + response: | + { + "id": "msg_abc123", + "object": "thread.message.deleted", + "deleted": true + } + + /threads/runs: + servers: *DataPlaneServers + 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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/threads/runs \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_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."} + ] + } + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + run = client.beta.threads.create_and_run( + assistant_id="asst_abc123", + thread={ + "messages": [ + {"role": "user", "content": "Explain deep learning to a 5 year old."} + ] + } + ) + + print(run) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const run = await client.beta.threads.createAndRun({ + assistant_id: "asst_abc123", + thread: { + messages: [ + { role: "user", content: "Explain deep learning to a 5 year old." }, + ], + }, + }); + + 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-4-turbo", + "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 + } + + /threads/{thread_id}/runs: + servers: *DataPlaneServers + get: + operationId: listRuns + tags: + - Assistants + summary: Returns a list of runs belonging to a thread. + parameters: + - name: thread_id + in: path + required: true + schema: + type: string + description: The ID of the thread the run belongs to. + - name: limit + in: query + description: *pagination_limit_param_description + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: *pagination_order_param_description + schema: + type: string + default: desc + enum: ["asc", "desc"] + - name: after + in: query + description: *pagination_after_param_description + schema: + type: string + - name: before + in: query + description: *pagination_before_param_description + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ListRunsResponse" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/threads/thread_abc123/runs \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + runs = client.beta.threads.runs.list( + "thread_abc123" + ) + + print(runs) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const runs = await client.beta.threads.runs.list( + "thread_abc123" + ); + + console.log(runs); + } + + main(); + 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-4-turbo", + "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-4-turbo", + "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 + } + post: + operationId: createRun + tags: + - Assistants + summary: Create a run. + parameters: + - in: path + name: thread_id + required: true + schema: + type: string + description: The ID of the thread to run. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CreateRunRequest" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/RunObject" + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/threads/thread_abc123/runs \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "assistant_id": "asst_abc123" + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + run = client.beta.threads.runs.create( + thread_id="thread_abc123", + assistant_id="asst_abc123" + ) + + print(run) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const run = await client.beta.threads.runs.create( + "thread_abc123", + { assistant_id: "asst_abc123" } + ); + + console.log(run); + } + + main(); + response: &run_object_example | + { + "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-4-turbo", + "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 + } + + /threads/{thread_id}/runs/{run_id}: + servers: *DataPlaneServers + 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](https://platform.openai.com/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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/threads/thread_abc123/runs/run_abc123 \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "OpenAI-Beta: assistants=v2" + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + run = client.beta.threads.runs.retrieve( + thread_id="thread_abc123", + run_id="run_abc123" + ) + + print(run) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const run = await client.beta.threads.runs.retrieve( + "thread_abc123", + "run_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-4-turbo", + "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](https://platform.openai.com/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 + content: + application/json: + schema: + $ref: "#/components/schemas/ModifyRunRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/RunObject" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/threads/thread_abc123/runs/run_abc123 \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "metadata": { + "user_id": "user_abc123" + } + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + run = client.beta.threads.runs.update( + thread_id="thread_abc123", + run_id="run_abc123", + metadata={"user_id": "user_abc123"}, + ) + + print(run) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const run = await client.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-4-turbo", + "instructions": null, + "incomplete_details": null, + "tools": [ + { + "type": "code_interpreter" + } + ], + "tool_resources": { + "code_interpreter": { + "file_ids": [ + "file-abc123", + "file-abc456" + ] + } + }, + "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}/submit_tool_outputs: + servers: *DataPlaneServers + 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](https://platform.openai.com/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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/threads/thread_123/runs/run_123/submit_tool_outputs \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "tool_outputs": [ + { + "tool_call_id": "call_001", + "output": "70 degrees and sunny." + } + ] + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + 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." + } + ] + ) + + print(run) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const run = await client.beta.threads.runs.submitToolOutputs( + "thread_123", + "run_123", + { + tool_outputs: [ + { + tool_call_id: "call_001", + output: "70 degrees and sunny.", + }, + ], + } + ); + + console.log(run); + } + + 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-4-turbo", + "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 + } + + /threads/{thread_id}/runs/{run_id}/cancel: + servers: *DataPlaneServers + 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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/threads/thread_abc123/runs/run_abc123/cancel \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "OpenAI-Beta: assistants=v2" \ + -X POST + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + run = client.beta.threads.runs.cancel( + thread_id="thread_abc123", + run_id="run_abc123" + ) + + print(run) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const run = await client.beta.threads.runs.cancel( + "thread_abc123", + "run_abc123" + ); + + console.log(run); + } + + 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-4-turbo", + "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: + servers: *DataPlaneServers + 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: *pagination_limit_param_description + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: *pagination_order_param_description + schema: + type: string + default: desc + enum: ["asc", "desc"] + - name: after + in: query + description: *pagination_after_param_description + schema: + type: string + - name: before + in: query + description: *pagination_before_param_description + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ListRunStepsResponse" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/threads/thread_abc123/runs/run_abc123/steps \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + run_steps = client.beta.threads.runs.steps.list( + thread_id="thread_abc123", + run_id="run_abc123" + ) + + print(run_steps) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const runStep = await client.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}: + servers: *DataPlaneServers + 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. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/RunStepObject" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/threads/thread_abc123/runs/run_abc123/steps/step_abc123 \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + run_step = client.beta.threads.runs.steps.retrieve( + thread_id="thread_abc123", + run_id="run_abc123", + step_id="step_abc123" + ) + + print(run_step) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const runStep = await client.beta.threads.runs.steps.retrieve( + "thread_abc123", + "run_abc123", + "step_abc123" + ); + console.log(runStep); + } + + main(); + response: &run_step_object_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 + } + } + + /vector_stores: + get: + operationId: listVectorStores + tags: + - Vector Stores + summary: Returns a list of vector stores. + parameters: + - name: limit + in: query + description: *pagination_limit_param_description + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: *pagination_order_param_description + schema: + type: string + default: desc + enum: ["asc", "desc"] + - name: after + in: query + description: *pagination_after_param_description + schema: + type: string + - name: before + in: query + description: *pagination_before_param_description + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ListVectorStoresResponse" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/vector_stores \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + vector_stores = client.beta.vector_stores.list() + print(vector_stores) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const vectorStores = await client.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 + } + post: + operationId: createVectorStore + tags: + - Vector Stores + summary: Create a vector store. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CreateVectorStoreRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/VectorStoreObject" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/vector_stores \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + -d '{ + "name": "Support FAQ" + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + vector_store = client.beta.vector_stores.create( + name="Support FAQ" + ) + print(vector_store) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const vectorStore = await client.beta.vectorStores.create({ + name: "Support FAQ" + }); + console.log(vectorStore); + } + + main(); + response: | + { + "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 + } + } + + /vector_stores/{vector_store_id}: + get: + operationId: getVectorStore + tags: + - Vector Stores + summary: Retrieves a vector store. + parameters: + - in: path + name: vector_store_id + required: true + schema: + type: string + description: The ID of the vector store to retrieve. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/VectorStoreObject" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/vector_stores/vs_abc123 \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + vector_store = client.beta.vector_stores.retrieve( + vector_store_id="vs_abc123" + ) + print(vector_store) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const vectorStore = await client.beta.vectorStores.retrieve( + "vs_abc123" + ); + console.log(vectorStore); + } + + main(); + response: | + { + "id": "vs_abc123", + "object": "vector_store", + "created_at": 1699061776 + } + post: + operationId: modifyVectorStore + tags: + - Vector Stores + summary: Modifies a vector store. + parameters: + - in: path + name: vector_store_id + required: true + schema: + type: string + description: The ID of the vector store to modify. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateVectorStoreRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/VectorStoreObject" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/vector_stores/vs_abc123 \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + -d '{ + "name": "Support FAQ" + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + vector_store = client.beta.vector_stores.update( + vector_store_id="vs_abc123", + name="Support FAQ" + ) + print(vector_store) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const vectorStore = await client.beta.vectorStores.update( + "vs_abc123", + { + name: "Support FAQ" + } + ); + console.log(vectorStore); + } + + main(); + response: | + { + "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 + } + } + + delete: + operationId: deleteVectorStore + tags: + - Vector Stores + summary: Delete a vector store. + parameters: + - in: path + name: vector_store_id + required: true + schema: + type: string + description: The ID of the vector store to delete. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/DeleteVectorStoreResponse" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/vector_stores/vs_abc123 \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" \ + -X DELETE + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + deleted_vector_store = client.beta.vector_stores.delete( + vector_store_id="vs_abc123" + ) + print(deleted_vector_store) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const deletedVectorStore = await client.beta.vectorStores.del( + "vs_abc123" + ); + console.log(deletedVectorStore); + } + + main(); + response: | + { + "id": "vs_abc123", + "object": "vector_store.deleted", + "deleted": true + } + + /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: *pagination_limit_param_description + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: *pagination_order_param_description + schema: + type: string + default: desc + enum: ["asc", "desc"] + - name: after + in: query + description: *pagination_after_param_description + schema: + type: string + - name: before + in: query + description: *pagination_before_param_description + 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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + vector_store_files = client.beta.vector_stores.files.list( + vector_store_id="vs_abc123" + ) + print(vector_store_files) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const vectorStoreFiles = await client.beta.vectorStores.files.list( + "vs_abc123" + ); + console.log(vectorStoreFiles); + } + + 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](https://platform.openai.com/docs/api-reference/files) to a [vector store](https://platform.openai.com/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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "file_id": "file-abc123" + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + vector_store_file = client.beta.vector_stores.files.create( + vector_store_id="vs_abc123", + file_id="file-abc123" + ) + print(vector_store_file) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const myVectorStoreFile = await client.beta.vectorStores.files.create( + "vs_abc123", + { + file_id: "file-abc123" + } + ); + console.log(myVectorStoreFile); + } + + 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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files/file-abc123 \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + vector_store_file = client.beta.vector_stores.files.retrieve( + vector_store_id="vs_abc123", + file_id="file-abc123" + ) + print(vector_store_file) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const vectorStoreFile = await client.beta.vectorStores.files.retrieve( + "vs_abc123", + "file-abc123" + ); + console.log(vectorStoreFile); + } + + 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](https://platform.openai.com/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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files/file-abc123 \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" \ + -X DELETE + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + deleted_vector_store_file = client.beta.vector_stores.files.delete( + vector_store_id="vs_abc123", + file_id="file-abc123" + ) + print(deleted_vector_store_file) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const deletedVectorStoreFile = await client.beta.vectorStores.files.del( + "vs_abc123", + "file-abc123" + ); + console.log(deletedVectorStoreFile); + } + + main(); + response: | + { + "id": "file-abc123", + "object": "vector_store.file.deleted", + "deleted": true + } + + /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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/vector_stores/vs_abc123/file_batches \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json \ + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "file_ids": ["file-abc123", "file-abc456"] + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + 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) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const myVectorStoreFileBatch = await client.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, + } + } + + /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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123 \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + 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) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const vectorStoreFileBatch = await client.beta.vectorStores.fileBatches.retrieve( + "vs_abc123", + "vsfb_abc123" + ); + console.log(vectorStoreFileBatch); + } + + 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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/cancel \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" \ + -X POST + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + 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) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const deletedVectorStoreFileBatch = await client.vector_stores.fileBatches.cancel( + "vs_abc123", + "vsfb_abc123" + ); + console.log(deletedVectorStoreFileBatch); + } + + 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: *pagination_limit_param_description + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: *pagination_order_param_description + schema: + type: string + default: desc + enum: ["asc", "desc"] + - name: after + in: query + description: *pagination_after_param_description + schema: + type: string + - name: before + in: query + description: *pagination_before_param_description + 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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/files \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + vector_store_files = client.beta.vector_stores.file_batches.list_files( + vector_store_id="vs_abc123", + batch_id="vsfb_abc123" + ) + print(vector_store_files) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const vectorStoreFiles = await client.beta.vectorStores.fileBatches.listFiles( + "vs_abc123", + "vsfb_abc123" + ); + console.log(vectorStoreFiles); + } + + 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 + } + + /batches: + servers: *DataPlaneServers + post: + summary: Creates and executes a batch from an uploaded file of requests + operationId: createBatch + tags: + - Batch + requestBody: + required: true + content: + application/json: + schema: + anyOf: + - $ref: "#/components/schemas/OpenAIBatchJob" + - $ref: "#/components/schemas/BedrockBatchJob" + - $ref: "#/components/schemas/VertexBatchJob" + - $ref: "#/components/schemas/PortkeyBatchJob" + responses: + "200": + description: Batch created successfully. + content: + application/json: + schema: + $ref: "#/components/schemas/Batch" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + label: Default + source: | + curl https://api.portkey.ai/v1/batches \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "input_file_id": "file-abc123", + "endpoint": "/v1/chat/completions", + "completion_window": "24h" + }' + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.batches.create( + input_file_id="file-abc123", + endpoint="/v1/chat/completions", + completion_window="24h" + ) + - lang: javascript + label: Default + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const batch = await client.batches.create({ + input_file_id: "file-abc123", + endpoint: "/v1/chat/completions", + completion_window: "24h" + }); + + console.log(batch); + } + + main(); + - lang: curl + label: Self-Hosted + source: | + curl SELF_HOSTED_GATEWAY_URL/batches \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "input_file_id": "file-abc123", + "endpoint": "/v1/chat/completions", + "completion_window": "24h" + }' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + base_url = "SELF_HOSTED_GATEWAY_URL", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.batches.create( + input_file_id="file-abc123", + endpoint="/v1/chat/completions", + completion_window="24h" + ) + - lang: javascript + label: Self-Hosted + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const batch = await client.batches.create({ + input_file_id: "file-abc123", + endpoint: "/v1/chat/completions", + completion_window: "24h" + }); + + console.log(batch); + } + + main(); + + get: + operationId: listBatches + tags: + - Batch + summary: List your organization's batches. + parameters: + - in: query + name: after + required: false + schema: + type: string + description: *pagination_after_param_description + - name: limit + in: query + description: *pagination_limit_param_description + required: false + schema: + type: integer + default: 20 + responses: + "200": + description: Batch listed successfully. + content: + application/json: + schema: + $ref: "#/components/schemas/ListBatchesResponse" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + label: Default + source: | + curl https://api.portkey.ai/v1/batches?limit=2 \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.batches.list() + - lang: javascript + label: Default + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const list = await client.batches.list(); + + for await (const batch of list) { + console.log(batch); + } + } + + main(); + - lang: curl + label: Self-Hosted + source: | + curl SELF_HOSTED_GATEWAY_URL/batches?limit=2 \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + base_url = "SELF_HOSTED_GATEWAY_URL", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.batches.list() + - lang: javascript + label: Self-Hosted + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const list = await client.batches.list(); + + for await (const batch of list) { + console.log(batch); + } + } + + main(); + + /batches/{batch_id}/output: + servers: *DataPlaneServers + get: + operationId: getBatchOutput + tags: + - Batch + summary: Returns batch output as stream. + parameters: + - in: path + name: batch_id + required: true + schema: + type: string + description: The ID of the batch to retrieve output for. + responses: + "200": + description: Batch output returned successfully. + content: + application/octet-stream: + schema: + type: string + format: binary + + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + label: Default + source: | + curl https://api.portkey.ai/v1/batches/batch_abc123/output \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.batches.output("batch_abc123") + - lang: javascript + label: Default + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const batch = await client.batches.output("batch_abc123"); + + console.log(batch); + } + + main(); + - lang: curl + label: Self-Hosted + source: | + curl SELF_HOSTED_GATEWAY_URL/batches/batch_abc123/output \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + base_url = "SELF_HOSTED_GATEWAY_URL", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.batches.output("batch_abc123") + - lang: javascript + label: Self-Hosted + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const batch = await client.batches.output("batch_abc123"); + + console.log(batch); + } + + main(); + + /batches/{batch_id}: + servers: *DataPlaneServers + 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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + label: Default + source: | + curl https://api.portkey.ai/v1/batches/batch_abc123 \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.batches.retrieve("batch_abc123") + - lang: javascript + label: Default + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const batch = await client.batches.retrieve("batch_abc123"); + + console.log(batch); + } + + main(); + - lang: curl + label: Self-Hosted + source: | + curl SELF_HOSTED_GATEWAY_URL/batches/batch_abc123 \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + base_url = "SELF_HOSTED_GATEWAY_URL", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.batches.retrieve("batch_abc123") + - lang: javascript + label: Self-Hosted + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const batch = await client.batches.retrieve("batch_abc123"); + + console.log(batch); + } + + main(); + + /batches/{batch_id}/cancel: + servers: *DataPlaneServers + 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" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + + x-code-samples: + - lang: curl + label: Default + source: | + curl https://api.portkey.ai/v1/batches/batch_abc123/cancel \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -X POST + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.batches.cancel("batch_abc123") + - lang: javascript + label: Default + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const batch = await client.batches.cancel("batch_abc123"); + + console.log(batch); + } + + main(); + - lang: curl + label: Self-Hosted + source: | + curl SELF_HOSTED_GATEWAY_URL/batches/batch_abc123/cancel \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -H "Content-Type: application/json" \ + -X POST + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + base_url = "SELF_HOSTED_GATEWAY_URL", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.batches.cancel("batch_abc123") + - lang: javascript + label: Self-Hosted + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const batch = await client.batches.cancel("batch_abc123"); + + console.log(batch); + } + + main(); + + /configs: + servers: *ControlPlaneServers + get: + summary: List all configs + tags: + - Configs + operationId: listConfigs + responses: + "200": + description: A list of configs + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + data: 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 + properties: + id: + type: string + format: uuid + name: + type: string + slug: + type: string + organisation_id: + type: string + format: uuid + workspace_id: + type: string + format: uuid + is_default: + type: integer + status: + type: string + owner_id: + type: string + format: uuid + updated_by: + type: string + format: uuid + created_at: + type: string + format: date-time + last_updated_at: + type: string + format: date-time + examples: + example-1: + value: + { + "success": true, + "data": + [ + { + "id": "4e54a1a4-109c-43ee-b0f7-11e7d60b0066", + "name": "Pplx Cache Test", + "slug": "pc-pplx-c-ca7a87", + "organisation_id": "472d2804-d054-4226-b4ae-9d4e2e61e69e", + "workspace_id": "472d2804-d054-4226-b4ae-9d4e2e61e69e", + "is_default": 0, + "status": "active", + "owner_id": "c4c7996d-be62-429d-b787-5d48fe94da86", + "updated_by": "439268ba-94a2-4031-9ca7-ca88ddda5096", + "created_at": "2024-05-12T21:37:06.000Z", + "last_updated_at": "2024-05-23T23:36:06.000Z", + }, + ], + } + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Retrieve the configuration + config = portkey.configs.list( + workspace_id="WORKSPACE_ID" + ) + + print(config) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + }) + + const config=await portkey.configs.list({ + workspace_id:"WORKSPACE_ID" + }) + console.log(config); + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Retrieve the configuration + config = portkey.configs.list( + workspace_id="WORKSPACE_ID" + ) + + print(config) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const config=await portkey.configs.list({ + workspace_id:"WORKSPACE_ID" + }) + console.log(config); + post: + summary: Create a config + tags: + - Configs + operationId: createConfig + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + name: + type: string + config: + type: object + isDefault: + type: integer + workspace_id: + type: string + format: uuid + description: optional, when using organisation admin API keys + examples: + example-1: + value: + { + "name": "New config", + "config": { "retry": { "attempts": 3 } }, + "workspace_id": "", + "isDefault": 1, + } + responses: + "200": + description: Config created successfully + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + data: + type: object + properties: + id: + type: string + format: uuid + version_id: + type: string + format: uuid + examples: + example-1: + value: + { + "success": true, + "data": + { + "id": "f3d8d070-f29d-43a3-bf97-3159c60f4ce0", + "version_id": "0db4065b-ead2-4daa-bf5e-7e9106585133", + }, + } + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Create a new configuration + config = portkey.configs.create( + name="ConfigName_0909", + config={ + "retry": { + "attempts": 3 + }, + "cache": { + "mode": "simple" + } + }, + workspace_id="WORKSPACE_ID", + ) + + print(config) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + }) + + const config=await portkey.configs.create({ + name:"ConfigName_0909", + config:{ + "retry": { + "attempts": 3 + }, + "cache": { + "mode": "simple" + } + }, + workspace_id:"WORKSPACE_ID" + }) + + console.log(config); + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Create a new configuration + config = portkey.configs.create( + name="ConfigName_0909", + config={ + "retry": { + "attempts": 3 + }, + "cache": { + "mode": "simple" + } + }, + workspace_id="WORKSPACE_ID", + ) + + print(config) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const config=await portkey.configs.create({ + name:"ConfigName_0909", + config:{ + "retry": { + "attempts": 3 + }, + "cache": { + "mode": "simple" + } + }, + workspace_id:"WORKSPACE_ID" + }) + + console.log(config); + + /configs/{slug}: + servers: *ControlPlaneServers + delete: + summary: Delete a config + tags: + - Configs + operationId: deleteConfig + parameters: + - name: slug + in: path + required: true + schema: + type: string + responses: + "200": + description: Config deleted successfully + content: + application/json: + schema: + type: object + examples: + example-1: + value: + {} + x-code-samples: + - lang: python + label: Default + source: | + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + portkey.configs.delete( + id="CONFIG_SLUG" + ) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + }) + + await portkey.configs.delete({ + id:"CONFIG_SLUG" + }) + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + portkey.configs.delete( + id="CONFIG_SLUG" + ) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + await portkey.configs.delete({ + id:"CONFIG_SLUG" + }) + get: + servers: *ControlPlaneServers + summary: Get a config + tags: + - Configs + operationId: getConfig + parameters: + - name: slug + in: path + required: true + schema: + type: string + responses: + "200": + description: Config details + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + data: 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: + config: + type: object + properties: + retry: 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: + attempts: + type: integer + on_status_codes: + type: array + items: + type: integer + cache: 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: *metadata_description - type: object - x-oaiTypeLabel: map - nullable: true - temperature: - description: *run_temperature_description - 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: &run_top_p_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 - - 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: + mode: + type: string + max_age: + type: integer + strategy: + type: object + properties: + mode: + type: string + targets: + type: array + items: + type: object + properties: + provider: + type: string + virtual_key: + type: string + examples: + example-1: + value: + { + "success": true, + "data": + { + "config": + { + "retry": + { + "attempts": 5, + "on_status_codes": [429, 529], + }, + "cache": { "mode": "simple", "max_age": 3600 }, + "strategy": { "mode": "fallback" }, + "targets": + [ + { + "provider": "openai", + "virtual_key": "main-258f4d", + }, + { + "provider": "azure-openai", + "virtual_key": "azure-test-4110dd", + }, + ], + }, + }, + } + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Retrieve the configuration + config = portkey.configs.retrieve( + slug='CONFIG_SLUG' + ) + + print(config) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + }) + + const config=await portkey.configs.retrieve({ + slug:'CONFIG_SLUG' + }) + + console.log(config); + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Retrieve the configuration + config = portkey.configs.retrieve( + slug='CONFIG_SLUG' + ) + + print(config) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const config=await portkey.configs.retrieve({ + slug:'CONFIG_SLUG' + }) + + console.log(config); + + put: + servers: *ControlPlaneServers + summary: Update a config + tags: + - Configs + operationId: updateConfig + parameters: + - name: slug + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + name: + type: string + config: + type: object + properties: + virtual_key: + type: string + status: + type: string + examples: + example-1: + value: + { + "name": "testConf", + "config": { "virtual_key": "copy-of-anthrop-b20259" }, + "status": "active", + } + responses: + "200": + description: Config updated successfully + content: + application/json: + schema: + type: object + properties: + success: type: boolean - example: false - required: - - object - - data - - first_id - - last_id - - has_more - x-oaiMeta: - name: List assistants response object - group: chat - example: *list_assistants_example - - 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: + data: 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. - - 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/number-of-chunks-returned) for more information. - required: - - type - - AssistantToolsFileSearchTypeOnly: - type: object - title: FileSearch tool - properties: - type: - type: string - description: "The type of tool being defined: `file_search`" - enum: ["file_search"] - 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 - - 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: + version_id: + type: string + format: uuid + examples: + example-1: + value: + { + "success": true, + "data": + { + "version_id": "abe447e2-f6aa-4229-93b7-8ee3183b6667", + }, + } + x-code-samples: + - lang: python + label: Default + source: | + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Update the configuration + updated_config = portkey.configs.update( + slug="CONFIG_SLUG", + name="Updated Config", + config={ + "retry": { + "attempts": 3 + }, + "cache": { + "mode": "semantic" + } + } + ) + print(updated_config) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + }) + + const config=await portkey.configs.update({ + slug:"CONFIG_SLUG", + name:"Updated Config", + config:{ + "retry": { + "attempts": 3 + }, + "cache": { + "mode": "semantic" + } + }, + + }) + + console.log(config); + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Update the configuration + updated_config = portkey.configs.update( + slug="CONFIG_SLUG", + name="Updated Config", + config={ + "retry": { + "attempts": 3 + }, + "cache": { + "mode": "semantic" + } + } + ) + print(updated_config) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const config=await portkey.configs.update({ + slug:"CONFIG_SLUG", + name:"Updated Config", + config:{ + "retry": { + "attempts": 3 + }, + "cache": { + "mode": "semantic" + } + }, + + }) + + console.log(config); + + /configs/{slug}/versions: + servers: *ControlPlaneServers + get: + summary: List versions for a config + tags: + - Configs + operationId: listConfigVersions + parameters: + - name: slug + in: path + required: true + schema: + type: string + responses: + "200": + description: A list of config versions + content: + application/json: + schema: + type: object + properties: + object: + type: string + total: 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 - - 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: + data: + type: array + items: + type: object + properties: + id: + type: string + format: uuid name: - type: string - description: The name of the function to call. - required: - - name - required: - - type - - 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 + workspace_id: + type: string + format: uuid + slug: + type: string + organisation_id: + type: string + format: uuid + is_default: + type: integer + status: + type: string + owner_id: + type: string + format: uuid + updated_by: + type: string + format: uuid + created_at: + type: string + format: date-time + last_updated_at: + type: string + format: date-time + config: + type: string + description: Serialized configuration for this version + format: + type: string + type: + type: string + version_id: + type: string + format: uuid + object: + type: string + examples: + example-1: + value: + { + "object": "list", + "total": 1, + "data": [ + { + "id": "daab995b-8d3b-42c5-a490-47217fbf4e0e", + "name": "PII Redaction Guardrail", + "workspace_id": "8610029e-692a-4df6-9052-3fa3eff69911", + "slug": "pc-pii-re-7f1051", + "organisation_id": "472d2804-d054-4226-b4ae-9d4e2e61e69e", + "is_default": 0, + "status": "active", + "owner_id": "c4c7996d-be62-429d-b787-5d48fe94da86", + "updated_by": "c4c7996d-be62-429d-b787-5d48fe94da86", + "created_at": "2025-10-17T19:11:47.000Z", + "last_updated_at": "2025-10-17T19:11:47.000Z", + "config": "{\"input_guardrails\":[\"pg-patron-1d0224\"]}", + "format": "json", + "type": "ORG_CONFIG", + "version_id": "8c1a4fbf-26d9-49df-82ca-ab772ba397d2", + "object": "config" + } + ] + } + x-code-samples: + - lang: curl + label: Default + source: | + curl --location 'https://api.portkey.ai/v1/configs/pc-pii-re-7f1051/versions' \ + --header 'x-portkey-api-key: PORTKEY_API_KEY' + + /feedback: + servers: *ControlPlaneServers + post: + summary: Create new feedback + description: This endpoint allows users to submit feedback for a particular interaction or response. + operationId: createFeedback + tags: + - Feedback + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/FeedbackRequest" + responses: + "200": + description: Feedback successfully saved + content: + application/json: + schema: + $ref: "#/components/schemas/FeedbackResponse" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + portkey = Portkey(api_key="PORTKEY_API_KEY") + + feedback = portkey.feedback.create( + trace_id="REQUEST_TRACE_ID", + value=1 + ) + + print(feedback) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY" + }); + + const feedback = await portkey.feedback.create({ + trace_id: "REQUEST_TRACE_ID", + value: 1 + }); + + console.log(feedback); + - lang: curl + label: Default + source: | + curl -X POST https://api.portkey.ai/v1/feedback \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"trace_id":"REQUEST_TRACE_ID","value":1}' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + feedback = portkey.feedback.create( + trace_id="REQUEST_TRACE_ID", + value=1 + ) + + print(feedback) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + virtualKey: "PROVIDER_VIRTUAL_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }); + + async function main() { + const feedback = await portkey.feedback.create({ + trace_id: "REQUEST_TRACE_ID", + value: 1 + }); + console.log(feedback); + } + + main(); + - lang: curl + label: Self-Hosted + source: | + curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/feedback \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"trace_id":"REQUEST_TRACE_ID","value":1}' + + /feedback/{id}: + servers: *ControlPlaneServers + put: + summary: Updates existing feedback + description: This endpoint allows users to update existing feedback. + operationId: updateFeedback + parameters: + - name: id + in: path + description: Feedback ID + required: true + schema: + type: string + format: uuid + tags: + - Feedback + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/FeedbackUpdateRequest" + responses: + "200": + description: Feedback successfully updated + content: + application/json: + schema: + $ref: "#/components/schemas/FeedbackResponse" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + portkey = Portkey(api_key="PORTKEY_API_KEY") + + feedback = portkey.feedback.update( + feedback_id="FEEDBACK_ID", + value=1 + ) + + print(feedback) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY" + }); + + const feedback = await portkey.feedback.update({ + feedbackId: "FEEDBACK_ID", + value: 1 + }); + + console.log(feedback); + - lang: curl + label: Default + source: | + curl -X POST https://api.portkey.ai/v1/feedback/{id} \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"value":1}' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + feedback = portkey.feedback.update( + feedback_id="FEEDBACK_ID", + value=1 + ) + + print(feedback) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + virtualKey: "PROVIDER_VIRTUAL_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }); + + async function main() { + const feedback = await portkey.feedback.update({ + feedbackId: "FEEDBACK_ID", + value: 1 + }); + console.log(feedback); + } + + main(); + - lang: curl + label: Self-Hosted + source: | + curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/feedback/{id} \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"value":1}' + + /integrations: + servers: *ControlPlaneServers + get: + summary: List All Integrations + tags: + - Integrations + parameters: + - in: query + name: current_page + schema: + type: integer + description: Current page, defaults to 0 + - in: query + name: page_size + schema: + type: integer + description: Page size, default to 100 + - in: query + name: workspace_id + schema: + type: string + description: Filter integrations accessible by a specific workspace. When using workspace API keys, this value will be enforced based on the API key details + - in: query + name: type + schema: + type: string + enum: [workspace, organisation, all] + default: all + description: For type=workspace, the API will only return Workpace-Scoped integrations. For type=organisation, the API will only return Global (organisation level) integrations. For type=all, both types of integrations will be returned. + + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + properties: + object: type: string - enum: ["thread.run"] - created_at: - description: The Unix timestamp (in seconds) for when the run was created. + enum: [list] + total: 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`. + description: Total number of integrations + data: + type: array + items: + $ref: "#/components/schemas/IntegrationList" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # List integrations + integrations = portkey.integrations.list() + + print(integrations) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const integrations = await portkey.integrations.list({}) + console.log(integrations); + - lang: curl + label: Default + source: | + curl -X GET https://api.portkey.ai/v1/integrations \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # List integrations + integrations = portkey.integrations.list() + + print(integrations) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const integrations = await portkey.integrations.list({}) + console.log(integrations); + - lang: curl + label: Self-Hosted + source: | + curl -X GET SELF_HOSTED_CONTROL_PLANE_URL/integrations \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + + post: + summary: Create a Integration + tags: + - Integrations + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateIntegrationRequest' + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + properties: + id: + type: string + format: UUID + slug: + type: string + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Add a new integration + integration = portkey.integrations.create( + name="openai-production", + ai_provider_id="openai", + key="sk-..." + ) + + print(integration) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const integration = await portkey.integrations.create({ + name:"openai-production", + ai_provider_id:"openai", + key:"sk-...", + }) + console.log(integration); + - lang: curl + label: Default + source: | + curl -X POST https://api.portkey.ai/v1/integrations \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "openai-production", + "ai_provider_id": "openai", + "key": "sk-..." + }' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Add a new integration + integration = portkey.integrations.create( + name="openai-production", + ai_provider_id="openai", + key="sk-..." + ) + + print(integration) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const integration = await portkey.integrations.create({ + name: "openai-production", + ai_provider_id: "openai", + key: "sk-...", + }) + console.log(integration); + - lang: curl + label: Self-Hosted + source: | + curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/integrations \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "openai-production", + "ai_provider_id": "openai", + "key": "sk-..." + }' + + /integrations/{slug}: + servers: *ControlPlaneServers + get: + summary: Get a Integration + tags: + - Integrations + parameters: + - in: path + name: slug + required: true + schema: + type: string + responses: + "200": + description: Successful response + content: + application/json: + schema: + $ref: "#/components/schemas/IntegrationDetailResponse" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Get a specific virtual key + virtual_key = portkey.virtual_keys.retrieve( + slug='VIRTUAL_KEY_SLUG' + ) + + print(virtual_key) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const vKey=await portkey.virtualKeys.retrieve({ + slug:'VIRTUAL_KEY_SLUG' + }) + console.log(vKey); + - lang: curl + label: Default + source: | + curl -X GET https://api.portkey.ai/v1/virtual-keys/VIRTUAL_KEY_SLUG \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X GET SELF_HOSTED_CONTROL_PLANE_URL/virtual-keys/VIRTUAL_KEY_SLUG \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Get a specific virtual key + virtual_key = portkey.virtual_keys.retrieve( + slug='VIRTUAL_KEY_SLUG' + ) + + print(virtual_key) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const vKey=await portkey.virtualKeys.retrieve({ + slug:'VIRTUAL_KEY_SLUG' + }) + console.log(vKey); + + put: + summary: Update a Integration + tags: + - Integrations + parameters: + - in: path + name: slug + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateIntegrationRequest' + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Update a specific integration + integration = portkey.integrations.update( + slug="INTEGRATION_SLUG', + name="updated-name", + note="hello" + ) + + print(integration) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const integration = await portkey.integrations.update({ + slug:"INTEGRATION_SLUG", + name:"updated-name", + note:"hello" + }) + console.log(integration); + - lang: curl + label: Default + source: | + curl -X PUT "https://api.portkey.ai/v1/integrations/INTEGRATION_SLUG" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "updated-name", + "note": "hello" + }' + - lang: curl + label: Self-Hosted + source: | + curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/integrations/INTEGRATION_SLUG" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "updated-name", + "note": "hello" + }' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Update a specific integration + integration = portkey.integrations.update( + slug="INTEGRATION_SLUG', + name="updated-name", + note="hello" + ) + + print(integration) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const integration = await portkey.integrations.update({ + slug:'INTEGRATION_SLUG', + name:"updated-name", + note:"hello" + }) + console.log(integration); + + delete: + summary: Delete a Integration + tags: + - Integrations + parameters: + - in: path + name: slug + required: true + schema: + type: string + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Delete a specific integration + result = portkey.integrations.delete( + slug="INTEGRATION_SLUG" + ) + + print(result) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const result=await portkey.integrations.delete({ + slug:'INTEGRATION_SLUG', + }) + console.log(result); + - lang: curl + label: Default + source: | + curl -X DELETE https://api.portkey.ai/v1/integrations/INTEGRATION_SLUG + - lang: curl + label: Self-Hosted + source: | + curl -X DELETE https://SELF_HOSTED_CONTROL_PLANE_URL/integrations/INTEGRATION_SLUG + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Delete a specific integration + result = portkey.integrations.delete( + slug="INTEGRATION_SLUG" + ) + + print(result) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const result=await portkey.integrations.delete({ + slug:"INTEGRATION_SLUG", + }) + console.log(result); + + /integrations/{slug}/models: + get: + summary: List integration models + description: Retrieves all model access for a specific integration with their configuration and pricing details. + tags: + - Integrations > Models + parameters: + - in: path + name: slug + required: true + schema: + type: string + responses: + '200': + description: List of integration models + content: + application/json: + schema: + $ref: '#/components/schemas/IntegrationModelsResponse' + + put: + summary: Bulk update integration models + description: | + Updates model access, pricing configuration, and settings for multiple models in an integration. + Can enable/disable models and configure custom pricing. + tags: + - Integrations > Models + parameters: + - in: path + name: slug + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/BulkUpdateModelsRequest' + responses: + '200': + description: Models updated successfully + content: + application/json: + schema: + type: object + + delete: + summary: Bulk delete integration custom models + description: Removes multiple custom models from an integration by their slugs. + tags: + - Integrations > Models + parameters: + - in: path + name: slug + required: true + schema: + type: string + - name: slugs + in: query + required: true + description: Comma-separated list of model slugs to delete + schema: + type: string + example: "gpt-4,gpt-3.5-turbo" + responses: + '200': + description: Models deleted successfully + content: + application/json: + schema: + type: object + + /integrations/{slug}/workspaces: + get: + summary: List integration workspace access + description: Retrieves workspace access configuration for an integration, including usage limits and rate limits. + tags: + - Integrations > Workspaces + parameters: + - in: path + name: slug + required: true + schema: + type: string + responses: + '200': + description: List of workspace access configurations + content: + application/json: + schema: + $ref: '#/components/schemas/IntegrationWorkspacesResponse' + + put: + summary: Bulk update workspace access + description: | + Updates workspace access permissions, usage limits, and rate limits for an integration. + Can configure global workspace access or per-workspace settings. + tags: + - Integrations > Workspaces + parameters: + - in: path + name: slug + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/BulkUpdateWorkspacesRequest' + responses: + '200': + description: Workspace access updated successfully + content: + application/json: + schema: + type: object + + /providers: + servers: *ControlPlaneServers + get: + summary: List All Providers + tags: + - Providers + parameters: + - in: query + name: current_page + schema: + type: integer + description: Current page, defaults to 0 + - in: query + name: page_size + schema: + type: integer + description: Page size, default to 50 + - in: query + name: workspace_id + schema: + type: string + description: Not required when using workspace API keys. Required when using organisation admin keys + + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + properties: + object: 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. + enum: [list] + total: 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. + description: Total number of providers + data: + type: array + items: + $ref: "#/components/schemas/Providers" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY" + ) + + # List providers + # Optional workspace_id + providers = portkey.providers.list(workspace_id="") + + print(providers) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const providers = await portkey.providers.list({ + workspaceId: "" // Optional + }) + console.log(providers); + - lang: curl + label: Default + source: | + curl -X GET https://api.portkey.ai/v1/providers?workspace_id= \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # List virtual keys + # Optional workspace_id + providers = portkey.providers.list(workspace_id="") + + print(providers) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const providers = await portkey.providers.list({ + workspace_id: "" // Optional + }) + console.log(providers); + - lang: curl + label: Self-Hosted + source: | + curl -X GET SELF_HOSTED_CONTROL_PLANE_URL/providers?workspace_id= \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + + post: + summary: Create a Provider + tags: + - Providers + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + name: + type: string + integration_id: + type: string + description: Integration slug used for the provider creation. + workspace_id: + type: string + format: uuid + description: optional, needed when using organisation admin API keys + slug: + type: string + description: Slug for the provider. If not passed, slug will be created by adding a random suffix to the name. + note: + type: string + nullable: true + usage_limits: + $ref: "#/components/schemas/UsageLimits" + rate_limits: + $ref: "#/components/schemas/RateLimits" + expires_at: + type: string + format: date-time + required: + - name + - integration_id + examples: + generic: + value: + name: "My first provider" + note: "Provider description" + integration_id: "my-openai-integration" + usage_limits: + { + "credit_limit": 10, + "periodic_reset": "monthly", + "alert_threshold": 9, + } + workspace_id: "" + slug: "first-openai-provider" + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + properties: + id: + type: string + slug: + type: string + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Add a new provider + new_provider = portkey.providers.create( + name="openai provider", + integration_id="", + workspace_id="" + ) + + print(new_provider) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const provider = await portkey.providers.create({ + name: "openai provider", + integration_id: "", + workspace_id: "" + }) + console.log(provider); + - lang: curl + label: Default + source: | + curl -X POST https://api.portkey.ai/v1/providers \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "openai provider", + "integration_id": "", + "workspace_id": "" + }' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Add a new provider + new_provider = portkey.providers.create( + name="openai provider", + integration_id="", + workspace_id="" + ) + + print(new_provider) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const newProvider = await portkey.providers.create({ + name: "openai provider", + integration_id: "", + workspace_id: "" + }) + console.log(newProvider); + - lang: curl + label: Self-Hosted + source: | + curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/providers \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "openai provider", + "integrationId": "", + "workspaceId": "" + }' + + /providers/{slug}: + servers: *ControlPlaneServers + get: + summary: Get a Provider + tags: + - Providers + parameters: + - in: query + name: workspace_id + schema: + type: string + description: optional, needed when using organisation admin keys + - in: path + name: slug + schema: + type: string + required: true + description: Provider slug + responses: + "200": + description: Successful response + content: + application/json: + schema: + $ref: "#/components/schemas/Providers" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Get a specific provider + provider = portkey.providers.retrieve( + slug="PROVIDER_SLUG", + workspace_id="" + ) + + print(provider) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const provider = await portkey.providers.retrieve({ + slug:"PROVIDER_SLUG", + workspace_id: "" + }) + console.log(provider); + - lang: curl + label: Default + source: | + curl -X GET https://api.portkey.ai/v1/providers/PROVIDER_SLUG?workspace_id= \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X GET SELF_HOSTED_CONTROL_PLANE_URL/providers/PROVIDER_SLUG?workspace_id= \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Get a specific provider + provider = portkey.providers.retrieve( + slug="PROVIDER_SLUG", + workspace_id="" + ) + + print(provider) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const provider = await portkey.providers.retrieve({ + slug: "PROVIDER_SLUG", + workspace_id: "" + }) + console.log(provider); + + put: + summary: Update a Provider + tags: + - Providers + parameters: + - in: query + name: workspace_id + schema: + type: string + description: optional, needed when using organisation admin keys + - in: path + name: slug + schema: + type: string + required: true + description: Provider slug + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + name: + type: string + note: + type: string + usage_limits: + $ref: "#/components/schemas/UsageLimits" + nullable: true + rate_limits: + $ref: "#/components/schemas/RateLimits" + expires_at: + type: string + format: date-time + nullable: true + reset_usage: + type: boolean + + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + properties: + id: + type: string + format: UUID + slug: + type: string + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Update a specific provider + updated_provider = portkey.providers.update( + slug="PROVIDER_SLUG", + name="updated-name", + note="updated-note", + workspace_id="" + ) + + print(updated_provider) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const updatedProvider = await portkey.providers.update({ + slug: "PROVIDER_SLUG", + name:"updated-name", + note: "updated-note", + workspace_id: "" + }) + console.log(updatedProvider); + - lang: curl + label: Default + source: | + curl -X PUT "https://api.portkey.ai/v1/providers/PROVIDER_SLUG?workspace_id=" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "updated-name", + "note": "updated-note" + }' + - lang: curl + label: Self-Hosted + source: | + curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/providers/PROVIDER_SLUG?workspace_id=" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "updated-name", + "note": "updated-note" + }' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Update a specific provider + updated_provider = portkey.providers.update( + slug="PROVIDER_SLUG", + name="updated-name", + note="updated-note", + workspace_id="" + ) + + print(updated_provider) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const updatedProvider = await portkey.providers.update({ + slug: "PROVIDER_SLUG", + name:"updated-name", + note: "updated-note", + workspace_id: "" + }) + console.log(updatedProvider); + + delete: + summary: Delete a Provider + tags: + - Providers + parameters: + - in: query + name: workspace_id + schema: + type: string + description: optional, needed when using organisation admin keys + - in: path + name: slug + schema: + type: string + required: true + description: Provider slug + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Delete a specific virtual key + result = portkey.providers.delete( + slug="PROVIDER_SLUG", + workspace_id="" + ) + + print(result) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const result = await portkey.providers.delete({ + slug: "PROVIDER_SLUG", + workspace_id: "" + }) + console.log(result); + - lang: curl + label: Default + source: | + curl -X DELETE https://api.portkey.ai/v1/providers/PROVIDER_SLUG?workspace_id= + - lang: curl + label: Self-Hosted + source: | + curl -X DELETE https://SELF_HOSTED_CONTROL_PLANE_URL/providers/PROVIDER_SLUG?workspace_id + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Delete a specific provider + result = portkey.providers.delete( + slug="PROVIDER_SLUG", + workspace_id="" + ) + + print(result) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const result = await portkey.providers.delete({ + slug: "PROVIDER_SLUG", + workspace_id: "" + }) + console.log(result); + + /virtual-keys: + servers: *ControlPlaneServers + get: + summary: List All Virtual Keys + tags: + - Virtual-keys + parameters: + - in: query + name: current_page + schema: + type: integer + required: true + description: Current page, defaults to 0 + - in: query + name: page_size + schema: + type: integer + required: true + description: Page size, default to 50 + + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + properties: + object: type: string - tools: - description: The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. - default: [] + enum: [list] + total: + type: integer + description: Total number of virtual keys + data: type: array - maxItems: 20 items: - oneOf: - - $ref: "#/components/schemas/AssistantToolsCode" - - $ref: "#/components/schemas/AssistantToolsFileSearch" - - $ref: "#/components/schemas/AssistantToolsFunction" - x-oaiExpandable: true - metadata: - description: *metadata_description + $ref: "#/components/schemas/VirtualKeys" + "401": + description: Unauthorized response + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + data: 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 - x-oaiMeta: - name: The run object - beta: true - example: | + properties: + message: + type: string + example: + success: false + data: + message: "Unauthorised Request" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # List virtual keys + virtual_keys = portkey.virtual_keys.list() + + print(virtual_keys) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const virtualKeys=await portkey.virtualKeys.list({}) + console.log(virtualKeys); + - lang: curl + label: Default + source: | + curl -X GET https://api.portkey.ai/v1/virtual-keys \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # List virtual keys + virtual_keys = portkey.virtual_keys.list() + + print(virtual_keys) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + virtualKey: "PROVIDER_VIRTUAL_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const virtualKeys=await portkey.virtualKeys.list({}) + console.log(virtualKeys); + - lang: curl + label: Self-Hosted + source: | + curl -X GET SELF_HOSTED_CONTROL_PLANE_URL/virtual-keys \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: PROVIDER_VIRTUAL_KEY" + + post: + summary: Create a Virtual Key + tags: + - Virtual-keys + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + name: + type: string + provider: + type: string + enum: + - openai + - azure-openai + - ai21 + - anthropic + - anyscale + - azure-openai + - bedrock + - cohere + - deepinfra + - fireworks-ai + - google + - groq + - hugging-face + - jina + - lingyi + - mistral-ai + - monsterapi + - moonshot + - nomic + - novita-ai + - open-ai + - openrouter + - palm + - perplexity-ai + - predibase + - reka-ai + - segmind + - stability-ai + - together-ai + - vertex-ai + - workers-ai + - zhipu + key: + type: string + note: + type: string + nullable: true + apiVersion: + type: string + nullable: true + resourceName: + type: string + nullable: true + deploymentName: + type: string + nullable: true + workspace_id: + type: string + format: uuid + description: optional, needed when using organisation admin API keys + deploymentConfig: + type: array + items: + type: object + properties: + apiVersion: + type: string + alias: + type: string + is_default: + type: boolean + deploymentName: + type: string + required: ["apiVersion", "deploymentName"] + usage_limits: + $ref: "#/components/schemas/UsageLimits" + rate_limits: + $ref: "#/components/schemas/RateLimits" + expires_at: + type: string + format: date-time + secret_mappings: + type: array + items: + $ref: '#/components/schemas/SecretMapping' + description: Dynamically resolve secrets from secret references at runtime. Valid target_field values are "key" or "model_config." (e.g. "model_config.awsSecretAccessKey"). Each target_field must be unique. When "key" is mapped, the key field becomes optional. + examples: + generic: + value: + name: "My first virtual key" + provider: "openai" + key: "sk-jhkfkjs8d9f7jksfghkjhfg" + note: "Virtual key description" + usage_limits: { - "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-4-turbo", - "instructions": null, - "tools": [{"type": "file_search"}, {"type": "code_interpreter"}], - "metadata": {}, - "incomplete_details": null, - "usage": { - "prompt_tokens": 123, - "completion_tokens": 456, - "total_tokens": 579 + "credit_limit": 10, + "periodic_reset": "monthly", + "alert_threshold": 9, + } + workspace_id: "" + azure-openai: + value: + provider: "azure-openai" + key: "openai-test" + name: "Key 1 Azure Open AI" + note: "description" + deploymentConfig: + [ + { + "apiVersion": "a", + "alias": "b", + "deploymentName": "c", + is_default: true, }, - "temperature": 1.0, - "top_p": 1.0, - "max_prompt_tokens": 1000, - "max_completion_tokens": 1000, - "truncation_strategy": { - "type": "auto", - "last_messages": null + { + "apiVersion": "a", + "alias": "b", + "deploymentName": "c", + is_default: false, }, - "response_format": "auto", - "tool_choice": "auto", - "parallel_tool_calls": true - } - 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-4-turbo" - anyOf: - - type: string - - type: string - enum: - [ - "gpt-4o", - "gpt-4o-2024-05-13", - "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: *metadata_description + ] + resourceName: "c" + bedrock: + value: + provider: "bedrock" + key: "openai-test" + name: "Bedrock Key" + note: "description" + awsAccessKeyId: "a" + awsSecretAccessKey: "b" + awsRegion: "c" + vertex-ai: + value: + provider: "vertex-ai" + key: "vertex test" + name: "Vertex AI Key" + note: "description" + vertexProjectId: "a" + vertexRegion: "b" + workers-ai: + value: + provider: "vertex-ai" + key: "cloudflare test" + name: "CF Workers AI Key" + note: "description" + workersAiAccountId: "a" + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + data: type: object - x-oaiTypeLabel: map - nullable: true - temperature: - type: number - minimum: 0 - maximum: 2 - default: 1 - example: 1 - nullable: true - description: *run_temperature_description - top_p: - type: number - minimum: 0 - maximum: 1 - default: 1 - example: 1 - nullable: true - description: &run_top_p_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: + properties: + slug: + type: string + "401": + description: Unauthorized response + content: + application/json: + schema: + type: object + properties: + success: 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: - - thread_id - - assistant_id - ListRunsResponse: - type: object - properties: - object: - type: string - example: "list" + data: + type: object + properties: + message: + type: string + example: + success: false data: - type: array - items: - $ref: "#/components/schemas/RunObject" - first_id: - type: string - example: "run_abc123" - last_id: - type: string - example: "run_abc456" - has_more: + message: "Unauthorised Request" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Add a new virtual key + new_virtual_key = portkey.virtual_keys.create( + name="openaiVKey", + provider="openai", + key="PROVIDER_API_KEY" + ) + + print(new_virtual_key) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const newVkey=await portkey.virtualKeys.create({ + name:"openaiVKey", + provider:"openai", + key:"PROVIDER_API_KEY", + }) + console.log(newVkey); + - lang: curl + label: Default + source: | + curl -X POST https://api.portkey.ai/v1/virtual-keys \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "openaiVKey", + "provider": "openai", + "key": "PROVIDER_API_KEY" + }' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Add a new virtual key + new_virtual_key = portkey.virtual_keys.create( + name="openaiVKey", + provider="openai", + key="PROVIDER_API_KEY" + ) + + print(new_virtual_key) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const newVkey=await portkey.virtualKeys.create({ + name:"openaiVKey", + provider:"openai", + key:"PROVIDER_API_KEY", + }) + console.log(newVkey); + - lang: curl + label: Self-Hosted + source: | + curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/virtual-keys \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "openaiVKey", + "provider": "openai", + "key": "PROVIDER_API_KEY" + }' + + /virtual-keys/{slug}: + servers: *ControlPlaneServers + get: + summary: Get a Virtual Key + tags: + - Virtual-keys + parameters: + - in: path + name: slug + required: true + schema: + type: string + responses: + "200": + description: Successful response + content: + application/json: + schema: + $ref: "#/components/schemas/VirtualKeys" + "401": + description: Unauthorized response + content: + application/json: + schema: + type: object + properties: + success: type: boolean - example: false - required: - - object - - data - - first_id - - last_id - - has_more - ModifyRunRequest: - type: object - additionalProperties: false - properties: - metadata: - description: *metadata_description + data: type: object - x-oaiTypeLabel: map - nullable: true - 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: + properties: + message: + type: string + example: + success: false + data: + message: "Unauthorised Request" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Get a specific virtual key + virtual_key = portkey.virtual_keys.retrieve( + slug='VIRTUAL_KEY_SLUG' + ) + + print(virtual_key) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const vKey=await portkey.virtualKeys.retrieve({ + slug:'VIRTUAL_KEY_SLUG' + }) + console.log(vKey); + - lang: curl + label: Default + source: | + curl -X GET https://api.portkey.ai/v1/virtual-keys/VIRTUAL_KEY_SLUG \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X GET SELF_HOSTED_CONTROL_PLANE_URL/virtual-keys/VIRTUAL_KEY_SLUG \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Get a specific virtual key + virtual_key = portkey.virtual_keys.retrieve( + slug='VIRTUAL_KEY_SLUG' + ) + + print(virtual_key) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const vKey=await portkey.virtualKeys.retrieve({ + slug:'VIRTUAL_KEY_SLUG' + }) + console.log(vKey); + + put: + summary: Update a Virtual Key + tags: + - Virtual-keys + parameters: + - in: path + name: slug + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + name: + type: string + key: + type: string + note: + type: string + nullable: true + deploymentConfig: + type: array + items: + type: object + properties: + apiVersion: + type: string + alias: + type: string + is_default: + type: boolean + deploymentName: + type: string + required: ["apiVersion", "deploymentName"] + usage_limits: + $ref: "#/components/schemas/UsageLimits" + secret_mappings: + type: array + items: + $ref: '#/components/schemas/SecretMapping' + description: Dynamically resolve secrets from secret references at runtime. Valid target_field values are "key" or "model_config." (e.g. "model_config.awsSecretAccessKey"). Each target_field must be unique. + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + + "401": + description: Unauthorized response + content: + application/json: + schema: + type: object + properties: + success: 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 - - 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: + data: + type: object + properties: + message: + type: string + example: + success: false + data: + message: "Unauthorised Request" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Update a specific virtual key + updated_virtual_key = portkey.virtual_keys.update( + slug='VIRTUAL_KEY_SLUG', + name="openaiVKey", + note="hello", + rate_limits=[{"type": "requests", "unit": "rpm", "value": 696}] + ) + + print(updated_virtual_key) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const updatedVKey=await portkey.virtualKeys.update({ + slug:'VIRTUAL_KEY_SLUG', + name:"openaiVKey", + note:"hello", + rate_limits: [{type: "requests", unit: "rpm", value: 696}] + }) + console.log(updatedVKey); + - lang: curl + label: Default + source: | + curl -X PUT "https://api.portkey.ai/v1/virtual_keys/VIRTUAL_KEY_SLUG" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "openaiVKey", + "note": "hello", + "rate_limits": [ + { + "type": "requests", + "unit": "rpm", + "value": 696 + } + ] + }' + - lang: curl + label: Self-Hosted + source: | + curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/virtual_keys/VIRTUAL_KEY_SLUG" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "openaiVKey", + "note": "hello", + "rate_limits": [ + { + "type": "requests", + "unit": "rpm", + "value": 696 + } + ] + }' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Update a specific virtual key + updated_virtual_key = portkey.virtual_keys.update( + slug='VIRTUAL_KEY_SLUG', + name="openaiVKey", + note="hello", + rate_limits=[{"type": "requests", "unit": "rpm", "value": 696}] + ) + + print(updated_virtual_key) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const updatedVkey=await portkey.virtualKeys.update({ + slug:'VIRTUAL_KEY_SLUG', + name:"openaiVKey", + note:"hello", + rate_limits: [{type: "requests", unit: "rpm", value: 696}] + }) + console.log(updatedVkey); + + delete: + summary: Delete a Virtual Key + tags: + - Virtual-keys + parameters: + - in: path + name: slug + required: true + schema: + type: string + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + + "401": + description: Unauthorized response + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + data: + type: object + properties: + message: + type: string + example: + success: false + data: + message: "Unauthorised Request" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Delete a specific virtual key + result = portkey.virtual_keys.delete( + slug='VIRTUAL_KEY_SLUG' + ) + + print(result) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const result=await portkey.virtualKeys.delete({ + slug:'VIRTUAL_KEY_SLUG', + }) + console.log(result); + - lang: curl + label: Default + source: | + curl -X DELETE https://api.portkey.ai/v1/virtual_keys/VIRTUAL_KEY_SLUG + - lang: curl + label: Self-Hosted + source: | + curl -X DELETE https://SELF_HOSTED_CONTROL_PLANE_URL/virtual_keys/VIRTUAL_KEY_SLUG + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Delete a specific virtual key + result = portkey.virtual_keys.delete( + slug='VIRTUAL_KEY_SLUG' + ) + + print(result) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const result=await portkey.virtualKeys.delete({ + slug:'VIRTUAL_KEY_SLUG', + }) + console.log(result); + + /admin/users/invites: + servers: *ControlPlaneServers + post: + operationId: Invites_create + summary: Invite User + description: Send an invite to user for your organization + parameters: [] + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/SuccessInvite" + tags: + - User-invites + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CreateInvite" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Add a user invite + user = portkey.admin.users.invites.create( + email="user@example.com", + role="member", + workspaces=[ + { + "id": "WORKSPACE_SLUG", + "role": "admin" + } + ], + workspace_api_key_details={ + "scopes": [ + "workspaces.list", + "logs.export", + "logs.list", + "logs.view", + ] + } + ) + + print(user) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const user=await portkey.admin.users.invites.create({ + email:"user@example.com", + role: "member", + workspaces: [ + { + id:"WORKSPACE_SLUG", + role:"admin" + }], + workspace_api_key_details:{ + scopes: [ + "workspaces.list", + "logs.export", + "logs.list", + "logs.view", + ] + } + }) + + console.log(user); + - lang: curl + label: Default + source: | + curl -X POST https://api.portkey.ai/v1/admin/users/invites + -H "x-portkey-api-key: PORTKEY_API_KEY" + -H "Content-Type: application/json" + -d '{ + "email": "user@example.com", + "role": "member", + "workspaces": [ + { + "id": "WORKSPACE_SLUG", + "role": "admin" + } + ], + "workspace_api_key_details": { + "scopes": [ + "workspaces.list", + "logs.export", + "logs.list", + "logs.view" + ] + } + }' + - lang: curl + label: Self-Hosted + source: | + curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/admin/users/invites + -H "x-portkey-api-key: PORTKEY_API_KEY" + -H "Content-Type: application/json" + -d '{ + "email": "user@example.com", + "role": "member", + "workspaces": [ + { + "id": "WORKSPACE_SLUG", + "role": "admin" + } + ], + "workspace_api_key_details": { + "scopes": [ + "workspaces.list", + "logs.export", + "logs.list", + "logs.view" + ] + } + }' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Add a user invite + user = portkey.admin.users.invites.create( + email="user@example.com", + role="member", + workspaces=[ + { + "id": "WORKSPACE_SLUG", + "role": "admin" + } + ], + workspace_api_key_details={ + "scopes": [ + "workspaces.list", + "logs.export", + "logs.list", + "logs.view", + ] + } + ) + + print(user) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const user = await portkey.admin.users.invites.create({ + email: "user@example.com", + role: "member", + workspaces: [ + { + id: "WORKSPACE_SLUG", + role: "admin" + } + ], + workspace_api_key_details: { + scopes: [ + "workspaces.list", + "logs.export", + "logs.list", + "logs.view", + ] + } + }) + + console.log(user); + + get: + tags: + - User-invites + summary: Get All Invites + parameters: + - name: pageSize + in: query + schema: + type: integer + example: "1" + - name: currentPage + in: query + schema: + type: integer + example: "0" + - name: role + in: query + schema: + type: string + enum: + - admin + - member + example: "admin" + - name: email + in: query + schema: + type: string + format: email + example: "foo@bar.com" + - name: status + in: query + schema: + type: string + enum: + - pending + - cancelled + - accepted + - expired + example: "pending" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + $ref: "#/components/schemas/InviteList" + example: + object: list + total: 2 + data: + - object: invite + id: 419641fb-1458-47d6-94d0-e308159b3ec2 + email: horace.slughorn@example.com + role: member + created_at: "2023-12-12 13:56:32" + expires_at: "2023-12-12 13:56:32" + accepted_at: "2023-12-12 13:56:32" + status: pending + invited_by: a90e74fb-269e-457b-8b59-9426cdd8907e + workspaces: + - workspace_id: "" + role: "" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # List user invites + user_invites = portkey.admin.users.invites.list( + email="user@example.com" + ) + + print(user_invites) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const user=await portkey.admin.users.invites.list({ + email:"user@example.com" + }); + console.log(user); + - lang: curl + label: Default + source: | + curl -X GET "https://api.portkey.ai/v1/admin/users/invites?email=user@example.com" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/admin/users/invites?email=user@example.com" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # List user invites + user_invites = portkey.admin.users.invites.list( + email="user@example.com" + ) + + print(user_invites) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const user=await portkey.admin.users.invites.list({ + email:"user@example.com" + }); + console.log(user); + + /admin/users/invites/{inviteId}: + servers: *ControlPlaneServers + get: + tags: + - User-invites + summary: Get Invite + parameters: + - name: inviteId + in: path + schema: + type: string + required: true + description: string + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + $ref: "#/components/schemas/Invite" + example: + object: invite + id: 419641fb-1458-47d6-94d0-e308159b3ec2 + email: horace.slughorn@example.com + role: member + created_at: "2023-12-12 13:56:32" + expires_at: "2023-12-12 13:56:32" + accepted_at: "2023-12-12 13:56:32" + status: pending + invited_by: 8dcfa174-c5ed-42c7-8a63-be755cc6e3123 + workspaces: + - workspace_id: "" + role: "" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Get a user invite + user = portkey.admin.users.invites.retrieve( + invite_id='INVITE_ID' + ) + + print(user) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const user=await portkey.admin.users.invites.retrieve({ + inviteId: 'INVITE_ID', + }); + console.log(user); + - lang: curl + label: Default + source: | + curl -X GET "https://api.portkey.ai/v1/admin/users/invites/INVITE_ID" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/admin/users/invites/INVITE_ID" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Get a user invite + user = portkey.admin.users.invites.retrieve( + invite_id='INVITE_ID' + ) + + print(user) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const user=await portkey.admin.users.invites.retrieve({ + inviteId: 'INVITE_ID', + }); + console.log(user); + delete: + tags: + - User-invites + summary: Delete Invite By ID + parameters: + - name: inviteId + in: path + schema: + type: string + required: true + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + example: {} + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + + + # Delete a user invite + user = portkey.admin.users.invites.delete( + invite_id="INVITE_ID" + ) + + print(user) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const user=await portkey.admin.users.invites.delete({ + inviteId:"INVITE_ID" + }) + + console.log(user); + - lang: curl + label: Default + source: | + curl -X DELETE "https://api.portkey.ai/v1/admin/users/invites/INVITE_ID" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X DELETE "SELF_HOSTED_CONTROL_PLANE_URL/admin/users/invites/INVITE_ID" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Delete a user invite + user = portkey.admin.users.invites.delete( + invite_id="INVITE_ID" + ) + + print(user) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const user=await portkey.admin.users.invites.delete({ + inviteId:"INVITE_ID" + }) + + console.log(user); + + /admin/users/invites/{inviteId}/resend: + servers: *ControlPlaneServers + post: + tags: + - User-invites + summary: Resend Invite + description: Resend an invite to user for your organization + parameters: + - name: inviteId + in: path + schema: + type: string + required: true + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + inviteLink: + type: string + format: uri + example: + inviteLink: https://app.portkey.ai/invite/some-invite-link + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + + + # Delete a user invite + user = portkey.admin.users.invites.resend( + invite_id="INVITE_ID" + ) + + print(user) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const user=await portkey.admin.users.invites.resend({ + inviteId:"INVITE_ID" + }); + + console.log(user); + - lang: curl + label: Default + source: | + curl -X POST "https://api.portkey.ai/v1/admin/users/invites/INVITE_ID/resend" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X POST "SELF_HOSTED_CONTROL_PLANE_URL/admin/users/invites/INVITE_ID/resend" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Delete a user invite + user = portkey.admin.users.invites.resend( + invite_id="INVITE_ID" + ) + + print(user) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const user=await portkey.admin.users.invites.resend({ + inviteId:"INVITE_ID" + }); + + console.log(user); + + /admin/users: + servers: + - url: https://api.portkey.ai/v1 + - url: https://SELF_HOSTED_CONTROL_PLANE_URL + get: + tags: + - Users + summary: Get users + parameters: + - name: x-portkey-api-key + in: header + schema: + type: string + example: "{{PORTKEY_API_KEY}}" + - name: pageSize + in: query + schema: + type: integer + example: "1" + - name: currentPage + in: query + schema: + type: integer + example: "0" + - name: role + in: query + schema: + type: string + enum: + - admin + - member + - owner + example: "admin" + - name: email + in: query + schema: + type: string + format: email + example: "foo@bar.com" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + $ref: "#/components/schemas/UserList" + example: + total: 2 + object: list + data: + - object: user + id: 61e08f60-4822-465e-ba23-39f85cd741cb + first_name: horace + last_name: slughorn + role: member + email: horace.slughorn@example.com + created_at: "2024-01-25 11:35:07" + last_updated_at: "2024-01-25 11:35:07" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # List users + users = portkey.admin.users.list() + + print(users) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const users=await portkey.admin.users.list({}) + + console.log(users); + - lang: curl + label: Default + source: | + curl -X GET "https://api.portkey.ai/v1/admin/users" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/admin/users" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # List users + users = portkey.admin.users.list() + + print(users) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const users=await portkey.admin.users.list({}) + + console.log(users); + + /admin/users/{userId}: + servers: + - url: https://api.portkey.ai/v1 + - url: https://SELF_HOSTED_CONTROL_PLANE_URL + get: + tags: + - Users + summary: Get user + parameters: + - name: userId + in: path + schema: + type: string + required: true + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + $ref: "#/components/schemas/User" + example: + object: user + id: 61e08f60-4822-465e-ba23-39f85cd741cb + first_name: horace + last_name: slughorn + role: member + email: horace.slughorn@example.com + created_at: "2024-01-25 11:35:07" + last_updated_at: "2024-01-25 11:35:07" + workspace_ids: ["ws-shared-123"] + x-code-sample: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Get a specific user + user = portkey.admin.users.retrieve( + user_id='USER_ID' + ) + + print(user) + + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + const user = await portkey.admin.users.retrieve({ + userId: 'USER_ID', + }); + + console.log(user); + - lang: curl + label: Default + source: | + curl -X GET "https://api.portkey.ai/v1/admin/users/USER_ID" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/admin/users/USER_ID" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Get a specific user + user = portkey.admin.users.retrieve( + user_id='USER_ID' + ) + + print(user) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + const user = await portkey.admin.users.retrieve({ + userId: 'USER_ID', + }); + + console.log(user); + + delete: + tags: + - Users + summary: Remove a user + parameters: + - name: userId + in: path + schema: + type: string + required: true + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + example: {} + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Delete a user + user = portkey.admin.users.delete( + user_id='USER_ID' + ) + + print(user) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const user=await portkey.admin.users.delete({ + userId: 'USER_ID', + }) + + console.log(user); + - lang: curl + label: Default + source: | + curl -X DELETE "https://api.portkey.ai/v1/admin/users/USER_ID" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X DELETE "SELF_HOSTED_CONTROL_PLANE_URL/admin/users/USER_ID" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Delete a user + user = portkey.admin.users.delete( + user_id='USER_ID' + ) + + print(user) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const user=await portkey.admin.users.delete({ + userId: 'USER_ID', + }) + + console.log(user); + put: + tags: + - Users + summary: Update user + requestBody: + content: + application/json: + schema: + type: object + properties: + role: + type: string + enum: + - admin + - member + example: + role: admin + parameters: + - name: userId + in: path + schema: + type: string + required: true + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + example: {} + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Update a user + user = portkey.admin.users.update( + user_id='USER_ID', + role="member" + ) + + print(user) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const user = await portkey.admin.users.update({ + userId: 'USER_ID', + role: "member" + }) + + console.log(user); + - lang: curl + label: Default + source: | + curl -X PUT "https://api.portkey.ai/v1/admin/users/USER_ID" + -H "x-portkey-api-key: PORTKEY_API_KEY" + -d '{"role":"member"}' + - lang: curl + label: Self-Hosted + source: | + curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/admin/users/USER_ID" + -H "x-portkey-api-key: PORTKEY_API_KEY" + -d '{"role":"member"}' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Update a user + user = portkey.admin.users.update( + user_id='USER_ID', + role="member" + ) + + print(user) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const user = await portkey.admin.users.update({ + userId: 'USER_ID', + role: "member" + }) + + console.log(user); + + /admin/workspaces/{workspaceId}/users: + servers: + - url: https://api.portkey.ai/v1 + - url: https://SELF_HOSTED_CONTROL_PLANE_URL + post: + tags: + - Workspaces > Members + summary: Add workspace member + requestBody: + content: + application/json: + schema: + type: object + properties: + users: + type: array + items: + type: object + properties: + id: + type: string + format: uuid + example: 25afb7bd-f98a-11ee-85fe-0e27d7367987 + role: + type: string + example: member + enum: + - admin + - member + - manager + example: + users: + - id: 419641fb-1458-47d6-94d0-e308159b3ec2 + role: member + - id: 419641fb-1458-47d6-94d0-e308159b3ec3 + role: member + parameters: + - name: workspaceId + in: path + schema: + type: string + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + type: object + example: {} + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Add user to workspace + user = portkey.admin.workspaces.users.create( + workspace_id="WORKSPACE_SLUG", + users=[ + { + "id": "USER_ID", + "role": "member" + } + ] + ) + + print(user) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const user=await portkey.admin.workspaces.users.create({ + workspaceId: "WORKSPACE_SLUG", + users:[{ + id:"USER_ID", + role:'member' + }] + }) + console.log(user); + - lang: curl + label: Default + source: | + curl -X POST "https://api.portkey.ai/v1/admin/workspaces/{workspaceId}/users" + -H "x-portkey-api-key: PORTKEY_API_KEY" + -d '{"users":[{"id":"USER_ID","role":"member"}]}' + - lang: curl + label: Self-Hosted + source: | + curl -X POST "SELF_HOSTED_CONTROL_PLANE_URL/admin/workspaces/{workspaceId}/users" + -H "x-portkey-api-key: PORTKEY_API_KEY" + -d '{"users":[{"id":"USER_ID","role":"member"}]}' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Add user to workspace + user = portkey.admin.workspaces.users.create( + workspace_id="WORKSPACE_SLUG", + users=[ + { + "id": "USER_ID", + "role": "member" + } + ] + ) + + print(user) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const user = await portkey.admin.workspaces.users.create({ + workspaceId: "WORKSPACE_SLUG", + users: [{ + id: "USER_ID", + role: 'member' + }] + }) + + console.log(user); + + get: + tags: + - Workspaces > Members + summary: Get workspace members + parameters: + - name: workspaceId + in: path + schema: + type: string + required: true + - name: current_page + in: query + schema: + type: number + default: 50 + required: false + - name: page_size + in: query + schema: + type: number + default: 0 + required: false + - name: role + in: query + schema: + type: string + enum: ["admin", "manager", "member"] + example: "admin" + - name: email + in: query + schema: + type: string + example: "foo@bar.com" + + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/WorkspaceMemberList" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Get user from workspace + users = portkey.admin.workspaces.users.list( + workspace_id="WORKSPACE_SLUG", + ) + + print(users) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const user=await portkey.admin.workspaces.users.list({ + workspaceId: 'WORKSPACE_SLUG', + }) + console.log(user); + - lang: curl + label: Default + source: | + curl -X GET "https://api.portkey.ai/v1/admin/workspaces/{workspaceId}/users" + - lang: curl + label: Self-Hosted + source: | + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/admin/workspaces/{workspaceId}/users" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Get user from workspace + users = portkey.admin.workspaces.users.list( + workspace_id="WORKSPACE_SLUG", + ) + + print(users) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const user=await portkey.admin.workspaces.users.list({ + workspaceId: 'WORKSPACE_SLUG', + }) + console.log(user); + + /admin/workspaces/{workspaceId}/users/{userId}: + servers: *ControlPlaneServers + put: + tags: + - Workspaces > Members + summary: Update workspace member + requestBody: + content: + application/json: + schema: + type: object + properties: + role: + type: string + enum: + - admin + - member + - manager + example: + role: member + parameters: + - name: workspaceId + in: path + schema: + type: string + required: true + - name: userId + in: path + schema: + type: string + required: true + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + example: {} + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Update user in workspace + updated_user = portkey.admin.workspaces.users.update( + workspace_id='WORKSPACE_SLUG', + user_id="USER_ID", + role='member' + ) + + print(updated_user) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const user=await portkey.admin.workspaces.users.update({ + workspaceId: 'WORKSPACE_SLUG', + userId:"USER_ID", + role:'member' + }) + console.log(user); + - lang: curl + label: Default + source: | + curl -X PUT "https://api.portkey.ai/v1/admin/workspaces/{workspaceId}/users/{userId}" + -H "x-portkey-api-key: PORTKEY_API_KEY" + -d '{"role":"member"}' + - lang: curl + label: Self-Hosted + source: | + curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/admin/workspaces/{workspaceId}/users/{userId}" + -H "x-portkey-api-key: PORTKEY_API_KEY" + -d '{"role":"member"}' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Update user in workspace + updated_user = portkey.admin.workspaces.users.update( + workspace_id='WORKSPACE_SLUG', + user_id="USER_ID", + role='member' + ) + + print(updated_user) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const user=await portkey.admin.workspaces.users.update({ + workspaceId: 'WORKSPACE_SLUG', + userId:"USER_ID", + role:'member' + }) + console.log(user); + + delete: + tags: + - Workspaces > Members + summary: Remove workspace member + parameters: + - name: workspaceId + in: path + schema: + type: string + required: true + - name: userId + in: path + schema: + type: string + required: true + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + example: {} + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Delete user from workspace + result = portkey.admin.workspaces.users.delete( + workspace_id='WORKSPACE_SLUG', + user_id='USER_ID' + ) + + # Print the result (if any) + print(result) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + user = await portkey.admin.workspaces.users.delete({ + workspaceId: 'WORKSPACE_SLUG', + userId:'USER_ID' + }) + + console.log(user) + - lang: curl + label: Default + source: | + curl -X DELETE "https://api.portkey.ai/v1/admin/workspaces/{workspaceId}/users/{userId}" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X DELETE "SELF_HOSTED_CONTROL_PLANE_URL/admin/workspaces/{workspaceId}/users/{userId}" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Delete user from workspace + result = portkey.admin.workspaces.users.delete( + workspace_id='WORKSPACE_SLUG', + user_id='USER_ID' + ) + + # Print the result (if any) + print(result) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + user = await portkey.admin.workspaces.users.delete({ + workspaceId: 'WORKSPACE_SLUG', + userId:'USER_ID' + }) + + console.log(user) + + get: + tags: + - Workspaces > Members + summary: Get member + parameters: + - name: workspaceId + in: path + schema: + type: string + required: true + - name: userId + in: path + schema: + type: string + required: true + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + $ref: "#/components/schemas/WorkspaceMember" + example: + object: workspace_member + user_id: 61e08f60-4822-465e-ba23-39f85cd741cb + user: + object: user + id: 61e08f60-4822-465e-ba23-39f85cd741cb + first_name: horace + last_name: slughorn + email: horace.slughorn@example.com + role: admin + created_at: "2024-01-25 11:35:07" + last_updated_at: "2024-01-25 11:35:07" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Get user from workspace + user = portkey.admin.workspaces.users.retrieve( + workspace_id="WORKSPACE_SLUG", + user_id="USER_ID" + ) + + print(user) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const user=await portkey.admin.workspaces.users.retrieve({ + workspaceId: 'WORKSPACE_SLUG', + userId:'USER_ID', + }) + console.log(user); + - lang: curl + label: Default + source: | + curl -X GET "https://api.portkey.ai/v1/admin/workspaces/{workspaceId}/users/{userId}" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/admin/workspaces/{workspaceId}/users/{userId}" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Get user from workspace + user = portkey.admin.workspaces.users.retrieve( + workspace_id="WORKSPACE_SLUG", + user_id="USER_ID" + ) + + print(user) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const user=await portkey.admin.workspaces.users.retrieve({ + workspaceId: 'WORKSPACE_SLUG', + userId:'USER_ID', + }) + console.log(user); + + /admin/workspaces: + servers: *ControlPlaneServers + post: + tags: + - Workspaces + summary: Create Workspace + requestBody: + content: + application/json: + schema: + type: object + properties: + name: + type: string + description: + type: string + defaults: + type: object + properties: + metadata: + type: object + additionalProperties: + type: string + users: + type: array + items: + type: string + usage_limits: + type: array + items: + $ref: "#/components/schemas/UsageLimits" + rate_limits: + type: array + items: + $ref: "#/components/schemas/RateLimits" + + example: + name: My Workspace + description: My Description + defaults: + metadata: + environment: production + foo: bar + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + $ref: "#/components/schemas/Workspace" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Add a workspace + workspace = portkey.admin.workspaces.create( + name='WORKSPACE_NAME_0909', + description="WORKSPACE_DESCRIPTION", + defaults={ + "metadata": { + "environment": "production", + "foo": "bar" + } + } + ) + + print(workspace) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const workspace=await portkey.admin.workspaces.create({ + name: 'WORKSPACE_NAME_0909', + description: "WORKSPACE_DESCRIPTION", + defaults: { + metadata: { + environment: "production", + foo: "bar" + } + } + }) + console.log(workspace); + - lang: curl + label: Default + source: | + curl -X POST https://api.portkey.ai/v1/admin/workspaces \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "WORKSPACE_NAME_0909", + "description": "WORKSPACE_DESCRIPTION", + "defaults": { + "metadata": { + "environment": "production", + "foo": "bar" + } + } + }' + - lang: curl + label: Self-Hosted + source: | + curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/admin/workspaces \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "WORKSPACE_NAME_0909", + "description": "WORKSPACE_DESCRIPTION", + "defaults": { + "metadata": { + "environment": "production", + "foo": "bar" + } + } + }' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Add a workspace + workspace = portkey.admin.workspaces.create( + name='WORKSPACE_NAME_0909', + description="WORKSPACE_DESCRIPTION", + defaults={ + "metadata": { + "environment": "production", + "foo": "bar" + } + } + ) + + print(workspace) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const workspace = await portkey.admin.workspaces.create({ + name: 'WORKSPACE_NAME_0909', + description: "WORKSPACE_DESCRIPTION", + defaults: { + metadata: { + environment: "production", + foo: "bar" + } + } + }) + + console.log(workspace) + + get: + tags: + - Workspaces + summary: Get All Workspaces + parameters: + - name: page_size + in: query + schema: + type: integer + example: "1" + - name: current_page + in: query + schema: + type: integer + example: "0" + - name: name + in: query + schema: + type: string + example: "workspace" + description: "Workspace name to filter results, case sensitive" + - name: exact_name + in: query + schema: + type: string + description: "Workspace name filter with strict check" + - name: status + in: query + schema: + type: string + enum: + - active + - archived + example: "active,archived" + description: "Workspace status to filter results, comma separated" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + $ref: "#/components/schemas/WorkspaceList" + example: + total: 2 + object: list + data: + - id: test-prod-ws-12345 + name: Test prod workspace + description: This is a production workspace + created_at: "2023-07-13 13:51:27" + last_updated_at: "2023-07-13 14:51:27" + object: workspace + - id: test-prod-ws-12345 + name: Test prod workspace + description: This is a production workspace + created_at: "2023-07-13 13:51:27" + last_updated_at: "2023-07-13 14:51:27" + object: workspace + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # List workspaces + workspaces = portkey.admin.workspaces.list() + + print(workspaces) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const workspaces=await portkey.admin.workspaces.list({}) + console.log(workspaces); + - lang: curl + label: Default + source: | + curl -X GET https://api.portkey.ai/v1/admin/workspaces + - lang: curl + label: Self-Hosted + source: | + curl -X GET SELF_HOSTED_CONTROL_PLANE_URL/admin/workspaces + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # List workspaces + workspaces = portkey.admin.workspaces.list() + + print(workspaces) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const workspaces=await portkey.admin.workspaces.list({}) + console.log(workspaces); + + /admin/workspaces/{workspaceId}: + servers: *ControlPlaneServers + put: + tags: + - Workspaces + summary: Update Workspace + requestBody: + content: + application/json: + schema: + type: object + properties: + name: + type: string + description: + type: string + defaults: + type: object + properties: + metadata: + type: object + additionalProperties: + type: string + input_guardrails: + type: array + items: + type: string + output_guardrails: + type: array + items: + type: string + usage_limits: + type: array + items: + $ref: "#/components/schemas/UsageLimits" + rate_limits: + type: array + items: + $ref: "#/components/schemas/RateLimits" + + example: + name: My Workspace + description: My Description + defaults: + metadata: + foo: bar + parameters: + - name: workspaceId + in: path + schema: + type: string + required: true + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + example: {} + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Update workspace + workspace = portkey.admin.workspaces.update( + workspace_id='WORKSPACE_ID', + name='WORKSPACE 0909', + description='This is a test description', + defaults={ + "x": "y" + } + ) + + print(workspace) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const workspace=await portkey.admin.workspaces.update({ + workspaceId: 'WORKSPACE_ID', + name: 'WORKSPACE 0909', + description: 'This is a test description', + defaults: { + x: "y" + } + }) + console.log(workspace); + - lang: curl + label: Default + source: | + curl -X PUT "https://api.portkey.ai/v1/admin/workspaces/{workspaceId}" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"name":"WORKSPACE 0909","description":"This is a test description","defaults":{"x":"y"}}' + - lang: curl + label: Self-Hosted + source: | + curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/admin/workspaces/{workspaceId}" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"name":"WORKSPACE 0909","description":"This is a test description","defaults":{"x":"y"}}' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Update workspace + workspace = portkey.admin.workspaces.update( + workspace_id='WORKSPACE_ID', + name='WORKSPACE 0909', + description='This is a test description', + defaults={ + x: "y" + } + ) + + print(workspace) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const workspace=await portkey.admin.workspaces.update({ + workspaceId: 'WORKSPACE_ID', + name: 'WORKSPACE 0909', + description: 'This is a test description', + defaults: { + x: "y" + } + }) + console.log(workspace); + + get: + tags: + - Workspaces + summary: Get workspace + parameters: + - name: workspaceId + in: path + schema: + type: string + required: true + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + $ref: "#/components/schemas/WorkspaceWithUsers" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Get workspace details + workspace = portkey.admin.workspaces.retrieve( + workspace_id='WORKSPACE_SLUG' + ) + + print(workspace) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const workspace=await portkey.admin.workspaces.retrieve({ + workspaceId: 'WORKSPACE_SLUG', + }) + console.log(workspace); + - lang: curl + label: Default + source: | + curl -X GET "https://api.portkey.ai/v1/admin/workspaces/{workspaceId}" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/admin/workspaces/{workspaceId}" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + baseUrl="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Get workspace details + workspace = portkey.admin.workspaces.retrieve( + workspace_id='WORKSPACE_SLUG' + ) + + print(workspace) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const workspace=await portkey.admin.workspaces.retrieve({ + workspaceId: 'WORKSPACE_SLUG', + }) + console.log(workspace); + + delete: + tags: + - Workspaces + summary: Delete a workspace + parameters: + - name: workspaceId + in: path + schema: + type: string + required: true + responses: + "200": + description: OK + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Delete workspace + result = portkey.admin.workspaces.delete( + workspace_id='WORKSPACE_SLUG' + ) + + print(result) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const workspace=await portkey.admin.workspaces.delete({ + workspaceId: 'WORKSPACE_SLUG', + }) + console.log(workspace); + - lang: curl + label: Default + source: | + curl -X DELETE "https://api.portkey.ai/v1/admin/workspaces/{workspaceId}" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X DELETE "SELF_HOSTED_CONTROL_PLANE_URL/admin/workspaces/{workspaceId}" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Delete workspace + result = portkey.admin.workspaces.delete( + workspace_id='WORKSPACE_SLUG' + ) + + print(result) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const workspace=await portkey.admin.workspaces.delete({ + workspaceId: 'WORKSPACE_SLUG', + }) + console.log(workspace); + + /mcp-integrations: + servers: *ControlPlaneServers + post: + operationId: McpIntegrations_create + tags: + - MCP Integrations + summary: Create MCP Integration + description: Create a new MCP Integration. Requires either organisation_id (with admin API key) or workspace_id in body. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CreateMcpIntegration" + examples: + default: + summary: Minimal (required fields only) + value: + name: "My MCP Server" + url: "https://mcp.example.com/mcp" + auth_type: "none" + transport: "http" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/McpIntegrationCreateResponse" + get: + operationId: McpIntegrations_list + tags: + - MCP Integrations + summary: List MCP Integrations + description: List MCP Integrations for the organisation or workspace. Requires organisation_id (when using org admin API key) or x-portkey-api-key header. + parameters: + - name: organisation_id + in: query + schema: + type: string + format: uuid + description: Organisation ID (required when using org admin API key) + - name: type + in: query + schema: + type: string + enum: + - workspace + - organisation + - all + - name: workspace_id + in: query + schema: + type: string + - name: page_size + in: query + schema: + type: integer + minimum: 1 + maximum: 1000 + default: 100 + - name: current_page + in: query + schema: + type: integer + minimum: 0 + default: 0 + - name: search + in: query + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/McpIntegrationListResponse" + + /mcp-integrations/{mcpIntegrationId}: + servers: *ControlPlaneServers + parameters: + - name: mcpIntegrationId + in: path + required: true + schema: + type: string + description: MCP Integration ID (UUID) or slug + get: + operationId: McpIntegrations_retrieve + tags: + - MCP Integrations + summary: Get MCP Integration + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/McpIntegration" + put: + operationId: McpIntegrations_update + tags: + - MCP Integrations + summary: Update MCP Integration + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateMcpIntegration" + responses: + "200": + description: OK + content: + application/json: + schema: + type: object + delete: + operationId: McpIntegrations_delete + tags: + - MCP Integrations + summary: Delete MCP Integration + responses: + "200": + description: OK + content: + application/json: + schema: + type: object + + /mcp-integrations/{mcpIntegrationId}/workspaces: + servers: *ControlPlaneServers + parameters: + - name: mcpIntegrationId + in: path + required: true + schema: + type: string + description: MCP Integration ID (UUID) or slug + get: + operationId: McpIntegrationWorkspaces_list + tags: + - MCP Integrations > Workspaces + summary: List MCP Integration Workspaces + parameters: + - name: version + in: query + schema: + type: string + description: When set, response uses data/total shape instead of workspaces + responses: + "200": + description: OK + content: + application/json: + schema: + oneOf: + - $ref: "#/components/schemas/McpIntegrationWorkspacesListResponse" + - $ref: "#/components/schemas/McpIntegrationWorkspacesLegacyResponse" + put: + operationId: McpIntegrationWorkspaces_bulkUpdate + tags: + - MCP Integrations > Workspaces + summary: Bulk Update MCP Integration Workspaces + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/BulkUpdateMcpIntegrationWorkspaces" + responses: + "200": + description: OK + content: + application/json: + schema: + type: object + + /mcp-integrations/{mcpIntegrationId}/capabilities: + servers: *ControlPlaneServers + parameters: + - name: mcpIntegrationId + in: path + required: true + schema: + type: string + description: MCP Integration ID (UUID) or slug + get: + operationId: McpIntegrationCapabilities_list + tags: + - MCP Integrations > Capabilities + summary: List MCP Integration Capabilities + parameters: + - name: page + in: query + schema: + type: integer + minimum: 1 + default: 1 + - name: page_size + in: query + schema: + type: integer + minimum: 1 + maximum: 500 + default: 100 + - name: type + in: query + schema: + type: string + enum: + - tool + - prompt + - resource + - resource_template + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/McpIntegrationCapabilitiesListResponse" + put: + operationId: McpIntegrationCapabilities_bulkUpdate + tags: + - MCP Integrations > Capabilities + summary: Bulk Update MCP Integration Capabilities + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/BulkUpdateMcpIntegrationCapabilities" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/McpIntegrationCapabilitiesBulkUpdateResponse" + /mcp-integrations/{mcpIntegrationId}/metadata: + servers: *ControlPlaneServers + parameters: + - name: mcpIntegrationId + in: path + required: true + schema: + type: string + description: MCP Integration ID (UUID) or slug + get: + operationId: McpIntegrationMetadata_retrieve + tags: + - MCP Integrations > Metadata + summary: Get MCP Integration Metadata + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/McpIntegrationMetadata" + + /mcp-servers: + servers: *ControlPlaneServers + post: + operationId: McpServers_create + tags: + - MCP Servers + summary: Create MCP Server + description: Create a new MCP Server (workspace instance of an MCP Integration). Requires workspace_id or x-portkey-api-key header. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CreateMcpServer" + examples: + default: + summary: Minimal (required fields only) + value: + name: "My MCP Server" + mcp_integration_id: "MCP_INTEGRATION_ID_OR_SLUG" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/McpServerCreateResponse" + get: + operationId: McpServers_list + tags: + - MCP Servers + summary: List MCP Servers + description: List MCP Servers for the workspace. Requires workspace_id or x-portkey-api-key header. + parameters: + - name: workspace_id + in: query + schema: + type: string + description: Workspace ID or slug. Required when using org admin API key; optional when API key is workspace-scoped. + - name: current_page + in: query + schema: + type: integer + minimum: 0 + default: 0 + - name: page_size + in: query + schema: + type: integer + minimum: 1 + maximum: 100 + default: 100 + - name: id + in: query + schema: + type: string + description: Filter by MCP Server ID(s), comma-separated + - name: search + in: query + schema: + type: string + maxLength: 255 + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/McpServerListResponse" + + /mcp-servers/{mcpServerId}: + servers: *ControlPlaneServers + parameters: + - name: mcpServerId + in: path + required: true + schema: + type: string + description: MCP Server ID (UUID) or slug + get: + operationId: McpServers_retrieve + tags: + - MCP Servers + summary: Get MCP Server + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/McpServer" + put: + operationId: McpServers_update + tags: + - MCP Servers + summary: Update MCP Server + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateMcpServer" + responses: + "200": + description: OK + content: + application/json: + schema: + type: object + delete: + operationId: McpServers_delete + tags: + - MCP Servers + summary: Delete MCP Server + responses: + "200": + description: OK + content: + application/json: + schema: + type: object + + /mcp-servers/{mcpServerId}/test: + servers: *ControlPlaneServers + parameters: + - name: mcpServerId + in: path + required: true + schema: + type: string + description: MCP Server ID (UUID) or slug + post: + operationId: McpServers_test + tags: + - MCP Servers + summary: Test MCP Server Connection + description: Test connectivity to the MCP server via its integration URL. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/McpServerTestResponse" + + /mcp-servers/{mcpServerId}/capabilities: + servers: *ControlPlaneServers + parameters: + - name: mcpServerId + in: path + required: true + schema: + type: string + description: MCP Server ID (UUID) or slug + get: + operationId: McpServerCapabilities_list + tags: + - MCP Servers > Capabilities + summary: List MCP Server Capabilities + parameters: + - name: page + in: query + schema: + type: integer + minimum: 1 + default: 1 + - name: page_size + in: query + schema: + type: integer + minimum: 1 + maximum: 500 + default: 100 + - name: type + in: query + schema: + type: string + enum: + - tool + - prompt + - resource + - resource_template + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/McpServerCapabilitiesListResponse" + put: + operationId: McpServerCapabilities_bulkUpdate + tags: + - MCP Servers > Capabilities + summary: Bulk Update MCP Server Capabilities + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/BulkUpdateMcpServerCapabilities" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/McpServerCapabilitiesBulkUpdateResponse" + + /mcp-servers/{mcpServerId}/user-access: + servers: *ControlPlaneServers + parameters: + - name: mcpServerId + in: path + required: true + schema: + type: string + description: MCP Server ID (UUID) or slug + get: + operationId: McpServerUserAccess_list + tags: + - MCP Servers > User Access + summary: List MCP Server User Access + parameters: + - name: page + in: query + schema: + type: integer + minimum: 1 + default: 1 + - name: page_size + in: query + schema: + type: integer + minimum: 1 + maximum: 500 + default: 100 + - name: search + in: query + schema: + type: string + description: Search by user name or email + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/McpServerUserAccessListResponse" + put: + operationId: McpServerUserAccess_bulkUpdate + tags: + - MCP Servers > User Access + summary: Bulk Update MCP Server User Access + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/BulkUpdateMcpServerUserAccess" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/McpServerUserAccessBulkUpdateResponse" + + /logs: + servers: *DataPlaneServers + post: + summary: Insert New logs + tags: + - Logs + description: Submit one or more log entries + requestBody: + required: true + content: + application/json: + schema: + oneOf: + - $ref: "#/components/schemas/CustomLog" + - type: array + items: + $ref: "#/components/schemas/CustomLog" + responses: + "200": + description: Successful response + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + request = { + "url": "https://api.someprovider.com/model/generate", + "method": "POST", + "headers": {"Content-Type": "application/json"}, + "body": {"prompt": "What is AI?"}, + } + response = { + "status": 200, + "headers": {"Content-Type": "application/json"}, + "body": {"response": "AI stands for Artificial Intelligence..."}, + "response_time": 123, + } + metadata = { + "user_id": "123", + "user_name": "John Doe", + } + + result = portkey.logs.create(request=request, response=response, metadata=metadata) + + print(result) + + - lang: javascript + label: Default + source: | + import Portkey from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY" + }) + + async function main() { + const request = { + url: "https://api.someprovider.com/model/generate", + method: "POST", + headers: { "Content-Type": "application/json" }, + body: { prompt: "What is AI?" }, + }; + const response = { + status: 200, + headers: { "Content-Type": "application/json" }, + body: { response: "AI stands for Artificial Intelligence..." }, + response_time: 123, + }; + const metadata = { + user_id: "123", + user_name: "John Doe", + }; + const result = await portkey.logs.create({ + request: request, + response: response, + metadata: metadata, + }); + console.log(result); + } + + main(); + - lang: curl + label: Default + source: | + curl -X POST "https://api.portkey.ai/v1/logs" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "request": { + "url": "https://api.someprovider.com/model/generate", + "method": "POST", + "headers": { "Content-Type": "application/json" }, + "body": { "prompt": "What is AI?" } + }, + "response": { + "status": 200, + "headers": { "Content-Type": "application/json" }, + "body": { "response": "AI stands for Artificial Intelligence..." }, + "response_time": 123 + }, + "metadata": { + "user_id": "123", + "user_name": "John Doe" + } + }' + - lang: curl + label: Self-Hosted + source: | + curl -X POST "SELF_HOSTED_GATEWAY_URL/logs" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "request": { + "url": "https://api.someprovider.com/model/generate", + "method": "POST", + "headers": { "Content-Type": "application/json" }, + "body": { "prompt": "What is AI?" } + }, + "response": { + "status": 200, + "headers": { "Content-Type": "application/json" }, + "body": { "response": "AI stands for Artificial Intelligence..." }, + "response_time": 123 + }, + "metadata": { + "user_id": "123", + "user_name": "John Doe" + } + }' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_GATEWAY_URL" + ) + + request = { + "url": "https://api.someprovider.com/model/generate", + "method": "POST", + "headers": {"Content-Type": "application/json"}, + "body": {"prompt": "What is AI?"}, + } + response = { + "status": 200, + "headers": {"Content-Type": "application/json"}, + "body": {"response": "AI stands for Artificial Intelligence..."}, + "response_time": 123, + } + metadata = { + "user_id": "123", + "user_name": "John Doe", + } + + result = portkey.logs.create(request=request, response=response, metadata=metadata) + + print(result) + - lang: javascript + label: Self-Hosted + source: | + import Portkey from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_GATEWAY_URL" + }) + + async function main() { + const request = { + url: "https://api.someprovider.com/model/generate", + method: "POST", + headers: { "Content-Type": "application/json" }, + body: { prompt: "What is AI?" }, + }; + const response = { + status: 200, + headers: { "Content-Type": "application/json" }, + body: { response: "AI stands for Artificial Intelligence..." }, + response_time: 123, + }; + const metadata = { + user_id: "123", + user_name: "John Doe", + }; + const result = await portkey.logs.create({ + request: request, + response: response, + metadata: metadata, + }); + console.log(result); + } + + main(); + + /logs/{logId}: + servers: *DataPlaneServers + get: + tags: + - Logs + summary: Get a specific log + parameters: + - name: logId + in: path + required: true + schema: + type: string + responses: + "200": + description: Successful response + content: + application/json: + schema: + $ref: "#/components/schemas/LogObject" + /logs/exports/{exportId}: + servers: *ControlPlaneServers + get: + tags: + - Logs Export + summary: Get a specific logs export + parameters: + - name: exportId + in: path + required: true + schema: + type: string + responses: + "200": + description: Successful response + content: + application/json: + schema: + $ref: "#/components/schemas/ExportItem" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY" + ) + + res = portkey.logs.exports.retrieve( + export_id="EXPORT_ID" + ) + + print(res) + - lang: javascript + label: Default + source: | + import Portkey from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY" + }) + + async function main() { + const res= await portkey.logs.exports.retrieve({ + exportId:"EXPORT_ID" + }); + + console.log(res); + } + + main(); + - lang: curl + label: Default + source: | + curl -X GET "https://api.portkey.ai/v1/logs/exports/EXPORT_ID" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/logs/exports/EXPORT_ID" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + res = portkey.logs.exports.retrieve( + export_id='EXPORT_ID' + ) + + print(res) + - lang: javascript + label: Self-Hosted + source: | + import Portkey from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + baseUrl:"SELF_HOSTED_CONTROL_PLANE_URL" + }) + + async function main() { + const res= await portkey.logs.exports.retrieve({ + exportId:'EXPORT_ID' + });; + + console.log(res); + } + + main() + put: + tags: + - Logs Export + summary: Update a logs export + parameters: + - name: exportId + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + properties: + workspace_id: + type: string + filters: + $ref: "#/components/schemas/GenerationsFilterSchema" + requested_data: + $ref: "#/components/schemas/LogExportsRequestedData" + required: + - filters + responses: + "200": + description: Successful response + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateExportResponse" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY" + ) + + res = portkey.logs.exports.update( + export_id="EXPORT_ID", + workspace_id="WORKSPACE_ID", + filters={ + "time_of_generation_max": "2024-07-25" + } + ) + + print(res) + - lang: javascript + label: Default + source: | + import Portkey from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY" + }) + + async function main() { + const res = await portkey.logs.exports.update({ + exportId:"7ef9f738-a93a-xxx-xxx-xxxxx", + workspaceId: "ws-shared-xxx", + filters: { + "time_of_generation_max": "2024-07-25" + } + }); + + console.log(res); + } + + main(); + - lang: curl + label: Default + source: | + curl -X PUT "https://api.portkey.ai/v1/logs/exports/EXPORT_ID" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"workspace_id":"WORKSPACE_ID","filters":{"time_of_generation_max":"2024-07-25"}}' + - lang: curl + label: Self-Hosted + source: | + curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/logs/exports/EXPORT_ID" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"workspace_id":"WORKSPACE_ID","filters":{"time_of_generation_max":"2024-07-25"}}' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + res = portkey.logs.exports.update( + export_id='EXPORT_ID', + workspace_id='WORKSPACE_ID', + filters={ + 'time_of_generation_max': '2024-07-25' + } + ) + + print(res) + - lang: javascript + label: Self-Hosted + source: | + import Portkey from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + baseUrl:"SELF_HOSTED_CONTROL_PLANE_URL" + }) + + async function main() { + const res = await portkey.logs.exports.update({ + exportId:"7ef9f738-a93a-xxx-xxx-xxxxx", + workspaceId: "ws-shared-xxx", + filters: { + "time_of_generation_max": "2024-07-25" + } + }); + + console.log(res); + } + + main(); + + /logs/exports: + servers: *ControlPlaneServers + get: + tags: + - Logs Export + summary: Get all logs exports + parameters: + - name: workspace_id + in: query + schema: + type: string + responses: + "200": + description: Successful response + content: + application/json: + schema: + $ref: "#/components/schemas/ExportListResponse" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY" + ) + + res = portkey.logs.exports.list( + workspace_id="WORKSPACE_ID" + ) + + print(res) + - lang: javascript + label: Default + source: | + import Portkey from "portkey-ai"; + + async function main() { + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY" + }) + + const res = await portkey.logs.exports.list({ + workspaceId:"WORKSPACE_ID" + }); + + console.log(res); + } + + main(); + - lang: curl + label: Default + source: | + curl -X GET "https://api.portkey.ai/v1/logs/exports?workspace_id=WORKSPACE_ID" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/logs/exports?workspace_id=WORKSPACE_ID" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + res = portkey.logs.exports.list( + workspace_id="WORKSPACE_ID" + ) + + print(res) + - lang: javascript + label: Self-Hosted + source: | + import Portkey from "portkey-ai"; + + async function main() { + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + baseUrl:"SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const res = await portkey.logs.exports.list({ + workspaceId:"WORKSPACE_ID" + }); + + console.log(res); + } + + main(); + post: + tags: + - Logs Export + summary: Create log export + requestBody: + content: + application/json: + schema: + type: object + properties: + workspace_id: + type: string + filters: + $ref: "#/components/schemas/GenerationsFilterSchema" + requested_data: + $ref: "#/components/schemas/LogExportsRequestedData" + required: + - filters + - requested_data + responses: + "200": + description: Successful response + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateExportResponse" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY" + ) + + res = portkey.logs.exports.create( + filters={ + 'time_of_generation_min': "2024-10-20", + 'time_of_generation_max': "2024-10-30" + }, + workspace_id="WORKSPACE_ID", + description="This is random description", + requested_data=[ + "id", + "trace_id", + "created_at", + "request", + "response", + "is_success", + "ai_org", + "ai_model", + "req_units", + "res_units", + "total_units", + "request_url", + "cost", + "cost_currency", + "response_time", + "response_status_code", + "mode", + "config", + "prompt_slug", + "metadata" + ] + ) + + print(res) + - lang: javascript + label: Default + source: | + import Portkey from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY" + }) + + async function main() { + const res = await portkey.logs.exports.create({ + filters: { + time_of_generation_min: "2024-10-20", + time_of_generation_max: "2024-10-30" + }, + "workspaceId": "WORKSPACE_ID",", + "description": "This is random description", + "requestedData": [ + "id", + "trace_id", + "created_at", + "request", + "response", + "is_success", + "ai_org", + "ai_model", + "req_units", + "res_units", + "total_units", + "request_url", + "cost", + "cost_currency", + "response_time", + "response_status_code", + "mode", + "config", + "prompt_slug", + "metadata" + ] + }); + + console.log(res); + } + + main(); + - lang: curl + label: Default + source: | + curl -X POST "https://api.portkey.ai/v1/logs/exports" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "workspace_id": "WORKSPACE_ID", + "filters": { + "time_of_generation_min": "2024-10-20", + "time_of_generation_max": "2024-10-30" + }, + "description": "This is random description", + "requested_data": [ + "id", + "trace_id", + "created_at", + "request", + "response", + "is_success", + "ai_org", + "ai_model", + "req_units", + "res_units", + "total_units", + "request_url", + "cost", + "cost_currency", + "response_time", + "response_status_code", + "mode", + "config", + "prompt_slug", + "metadata" + ] + }' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + res = portkey.logs.exports.create( + filters={ + 'time_of_generation_min': "2024-10-20", + 'time_of_generation_max': "2024-10-30" + }, + workspace_id="WORKSPACE_ID", + description="This is random description", + requested_data=[ + "id", + "trace_id", + "created_at", + "request", + "response", + "is_success", + "ai_org", + "ai_model", + "req_units", + "res_units", + "total_units", + "request_url", + "cost", + "cost_currency", + "response_time", + "response_status_code", + "mode", + "config", + "prompt_slug", + "metadata" + ] + ) + + print(res) + - lang: javascript + label: Self-Hosted + source: | + import Portkey from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + baseUrl:"SELF_HOSTED_CONTROL_PLANE_URL" + }) + + async function main() { + const res = await portkey.logs.exports.create({ + filters: { + time_of_generation_min: "2024-10-20", + time_of_generation_max: "2024-10-30" + }, + "workspaceId": "WORKSPACE_ID",", + "description": "This is random description", + "requestedData": [ + "id", + "trace_id", + "created_at", + "request", + "response", + "is_success", + "ai_org", + "ai_model", + "req_units", + "res_units", + "total_units", + "request_url", + "cost", + "cost_currency", + "response_time", + "response_status_code", + "mode", + "config", + "prompt_slug", + "metadata" + ] + }); + + console.log(res); + } + + main(); + + /logs/exports/{exportId}/start: + servers: *ControlPlaneServers + post: + tags: + - Logs Export + summary: Start log export + parameters: + - name: exportId + in: path + required: true + schema: + type: string + responses: + "200": + description: Successful response + content: + application/json: + schema: + $ref: "#/components/schemas/ExportTaskResponse" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY" + ) + + res = portkey.logs.exports.start( + export_id='EXPORT_ID' + ) + + print(res) + - lang: javascript + label: Default + source: | + import Portkey from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY" + }) + + async function main() { + const res = await portkey.logs.exports.start({ + exportId:'EXPORT_ID' + }); + + console.log(res); + } + + main(); + - lang: curl + label: Default + source: | + curl -X POST https://api.portkey.ai/v1/logs/exports/EXPORT_ID/start + -H "x-portkey-api-key: PORTKEY_API_KEY" + -H "Content-Type: application/json" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + res = portkey.logs.exports.start( + export_id='EXPORT_ID' + ) + + print(res) + - lang: javascript + label: Self-Hosted + source: | + import Portkey from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + baseUrl:"SELF_HOSTED_CONTROL_PLANE_URL" + }) + + async function main() { + const res = await portkey.logs.exports.start({ + exportId:'EXPORT_ID' + }); + + console.log(res); + } + + main(); + + /logs/exports/{exportId}/cancel: + servers: *ControlPlaneServers + post: + tags: + - Logs Export + summary: Cancel log export + parameters: + - name: exportId + in: path + required: true + schema: + type: string + responses: + "200": + description: Successful response + content: + application/json: + schema: + $ref: "#/components/schemas/ExportTaskResponse" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY" + ) + + res = portkey.logs.exports.cancel( + export_id='EXPORT_ID' + ) + + print(res) + - lang: javascript + label: Default + source: | + import Portkey from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + }) + + async function main() { + const res = await portkey.logs.exports.cancel({ + exportId:'EXPORT_ID' + }); + + console.log(res); + } + + main(); + - lang: curl + label: Default + source: | + curl -X POST https://api.portkey.ai/v1/logs/exports/EXPORT_ID/cancel + -H "x-portkey-api-key: PORTKEY_API_KEY" + -H "Content-Type: application/json" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + res = portkey.logs.exports.cancel( + export_id='EXPORT_ID' + ) + + print(res) + - lang: javascript + label: Self-Hosted + source: | + import Portkey from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + baseUrl:"SELF_HOSTED_CONTROL_PLANE_URL" + }) + + async function main() { + const res = await portkey.logs.exports.cancel({ + exportId:'EXPORT_ID' + }); + + console.log(res); + } + + main(); + + /logs/exports/{exportId}/download: + servers: *ControlPlaneServers + get: + tags: + - Logs Export + summary: Download log export + parameters: + - name: exportId + in: path + required: true + schema: + type: string + responses: + "200": + description: Successful response + content: + application/json: + schema: + $ref: "#/components/schemas/DownloadLogsResponse" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY" + ) + + res = portkey.logs.exports.download( + export_id='EXPORT_ID' + ) + + print(res) + - lang: javascript + label: Default + source: | + import Portkey from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY" + }) + + async function main() { + const config=await portkey.logs.exports.download({ + exportId:'EXPORT_ID' + });; + + console.log(config); + } + + main() + - lang: curl + label: Default + source: | + curl -X GET https://api.portkey.ai/v1/logs/exports/EXPORT_ID/download + -H "x-portkey-api-key: PORTKEY_API_KEY" + -H "Content-Type: application/json" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + res = portkey.logs.exports.download( + export_id='EXPORT_ID' + ) + + print(res) + - lang: javascript + label: Self-Hosted + source: | + import Portkey from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + baseUrl:"SELF_HOSTED_CONTROL_PLANE_URL" + }) + + async function main() { + const config=await portkey.logs.exports.download({ + exportId:'EXPORT_ID' + });; + + console.log(config); + } + + main() + + /audit-logs: + servers: *ControlPlaneServers + get: + tags: + - Audit Logs + summary: Get Audit Logs + parameters: + - name: start_time + in: query + required: true + description: Start time for filtering logs (ISO8601 format) + schema: + type: string + - name: end_time + in: query + required: true + description: End time for filtering logs (ISO8601 format) + schema: + type: string + - name: organisation_id + in: query + required: true + description: Organisation ID for filtering logs + schema: + type: string + - name: method + in: query + required: false + description: HTTP method for filtering logs + schema: + type: string + enum: [POST, PUT, DELETE] + - name: uri + in: query + required: false + description: URI path for filtering logs + schema: + type: string + - name: request_id + in: query + required: false + description: Request ID for filtering logs + schema: + type: string + - name: user_id + in: query + required: false + description: User ID for filtering logs + schema: + type: string + - name: user_type + in: query + required: false + description: Type of user for filtering logs + schema: + type: string + enum: [user, api_key] + - name: workspace_id + in: query + required: false + description: Workspace ID for filtering logs + schema: + type: string + - name: response_status_code + in: query + required: false + description: HTTP response status code for filtering logs + schema: + type: integer + - name: resource_type + in: query + required: false + description: Resource type for filtering logs + schema: + type: string + - name: action + in: query + required: false + description: Action type for filtering logs + schema: + type: string + - name: client_ip + in: query + required: false + description: Client IP address for filtering logs + schema: + type: string + - name: country + in: query + required: false + description: Country for filtering logs + schema: + type: string + - name: current_page + in: query + required: false + description: Current page number for pagination + schema: + type: integer + minimum: 0 + - name: page_size + in: query + required: false + description: Number of items per page + schema: + type: integer + minimum: 0 + maximum: 100 + responses: + "200": + description: Successful response + content: + application/json: + schema: + $ref: "#/components/schemas/AuditLogObjectList" + + /api-keys/{type}/{sub-type}: + servers: *ControlPlaneServers + post: + tags: + - Api-Keys + summary: Create API Keys + description: | + Creates a new API key. + parameters: + - name: type + in: path + schema: + type: string + enum: ["organisation", "workspace"] + required: true + - name: sub-type + in: path + schema: + type: string + enum: ["user", "service"] + required: true + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/CreateApiKeyObject" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + id: + type: string + format: uuid + example: "183f497a-2a7f-4f47-992e-26213fa863we" + key: + type: string + example: "abssofjosfjs" + object: + type: string + enum: ["api-key"] + example: "api-key" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Create a new API key + api_key = portkey.api_keys.create( + name="API_KEY_NAME_0909", + type="organisation", + sub_type="service", + workspace_id="WORKSPACE_ID", + scopes=[ + "logs.export", + "logs.list", + "logs.view", + "configs.create", + "configs.update", + "configs.delete", + "configs.read", + "configs.list", + "virtual_keys.create", + "virtual_keys.update", + "virtual_keys.delete", + "virtual_keys.read", + "virtual_keys.list", + "virtual_keys.copy" + ] + ) + + print(api_key) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const apiKey=await portkey.apiKeys.create({ + name:"API_KEY_NAME_0909", + type:"organisation", + "sub-type":"service", + workspace_id:"WORKSPACE_ID", + "scopes": [ + "logs.export", + "logs.list", + "logs.view", + "configs.create", + "configs.update", + "configs.delete", + "configs.read", + "configs.list", + "virtual_keys.create", + "virtual_keys.update", + "virtual_keys.delete", + "virtual_keys.read", + "virtual_keys.list", + "virtual_keys.copy" + ] + }) + console.log(apiKey); + - lang: curl + label: Default + source: | + curl -X POST https://api.portkey.ai/v1/api-keys/organisation/service + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name":"API_KEY_NAME_0909", + "type":"organisation", + "sub-type":"service", + "workspace_id":"WORKSPACE_ID", + "scopes":[ + "logs.export", + "logs.list", + "logs.view", + "configs.create", + "configs.update", + "configs.delete", + "configs.read", + "configs.list", + "virtual_keys.create", + "virtual_keys.update", + "virtual_keys.delete", + "virtual_keys.read", + "virtual_keys.list", + "virtual_keys.copy" + ] + }' + - lang: curl + label: Self-Hosted + source: | + curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/api-keys/organisation/service + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name":"API_KEY_NAME_0909", + "type":"organisation", + "sub-type":"service", + "workspace_id":"WORKSPACE_ID", + "scopes":[ + "logs.export", + "logs.list", + "logs.view", + "configs.create", + "configs.update", + "configs.delete", + "configs.read", + "configs.list", + "virtual_keys.create", + "virtual_keys.update", + "virtual_keys.delete", + "virtual_keys.read", + "virtual_keys.list", + "virtual_keys.copy" + ] + }' + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const apiKey = await portkey.admin.apiKeys.create({ + name: "API_KEY_NAME_0909", + type: "organisation", + subType: "service", + workspaceId: "WORKSPACE_ID", + scopes: [ + "logs.export", + "logs.list", + "logs.view", + "configs.create", + "configs.update", + "configs.delete", + "configs.read", + "configs.list", + "virtual_keys.create", + "virtual_keys.update", + "virtual_keys.delete", + "virtual_keys.read", + "virtual_keys.list", + "virtual_keys.copy" + ] + }) + console.log(apiKey); + - lang: python + label: Self-Hosted + source: | + from portkey import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + api_key = portkey.admin.api_keys.create( + name="API_KEY_NAME_0909", + type="organisation", + sub_type="service", + workspace_id="WORKSPACE_ID", + scopes=[ + "logs.export", + "logs.list", + "logs.view", + "configs.create", + "configs.update", + "configs.delete", + "configs.read", + "configs.list", + "virtual_keys.create", + "virtual_keys.update", + "virtual_keys.delete", + "virtual_keys.read", + "virtual_keys.list", + "virtual_keys.copy" + ] + ) + print(api_key) + - lang: python + label: User API Key + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Create a user API key (requires user_id) + api_key = portkey.api_keys.create( + name="User API Key", + type="workspace", + sub_type="user", + workspace_id="WORKSPACE_ID", + user_id="USER_ID", # Required for user API keys + scopes=[ + "completions.write", + "logs.view" + ] + ) + + print(api_key) + - lang: javascript + label: User API Key + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const apiKey = await portkey.apiKeys.create({ + name: "User API Key", + type: "workspace", + "sub-type": "user", + workspace_id: "WORKSPACE_ID", + user_id: "USER_ID", // Required for user API keys + "scopes": [ + "completions.write", + "logs.view" + ] + }) + console.log(apiKey); + - lang: curl + label: User API Key + source: | + curl -X POST https://api.portkey.ai/v1/api-keys/workspace/user + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name":"User API Key", + "type":"workspace", + "sub-type":"user", + "workspace_id":"WORKSPACE_ID", + "user_id":"USER_ID", + "scopes":[ + "completions.write", + "logs.view" + ] + }' + + /api-keys: + servers: + - url: https://api.portkey.ai/v1 + - url: https://SELF_HOSTED_CONTROL_PLANE_URL + get: + tags: + - Api-Keys + summary: Get All + parameters: + - name: page_size + in: query + schema: + type: integer + example: "1" + - name: current_page + in: query + schema: + type: integer + example: "0" + - name: workspace_id + in: query + schema: + type: string + example: "ws-shared-123" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + $ref: "#/components/schemas/ApiKeyObjectList" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY" + ) + + api_keys = portkey.api_keys.list( + workspace_id="WORKSPACE_SLUG" + ) + + print(api_keys) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY" + }) + + const apiKey=await portkey.apiKeys.list({ + workspaceId:"WORKSPACE_SLUG" + }) + + console.log(apiKey); + - lang: curl + label: Default + source: | + curl -X GET "https://api.portkey.ai/v1/api-keys?workspace_id=WORKSPACE_SLUG" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/api-keys?workspace_id=WORKSPACE_SLUG" + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + api_keys = portkey.api_keys.list( + workspace_id="WORKSPACE_SLUG" + ) + + print(api_keys) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const apiKey=await portkey.apiKeys.list({ + workspaceId:"WORKSPACE_SLUG" + }) + + console.log(apiKey); + + /api-keys/{id}: + servers: *ControlPlaneServers + put: + tags: + - Api-Keys + summary: Update API Keys + description: | + Updates an existing API key. The API key type (user vs service) and associated user_id cannot be changed after creation. + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateApiKeyObject" + examples: + update_api_key: + summary: Update key metadata and limits + value: + name: API_KEY_NAME_0909 + rate_limits: + - type: requests + unit: rpm + value: 100 + reset_usage: + summary: Reset accumulated usage for this key + value: + reset_usage: true + parameters: + - name: id + in: path + schema: + type: string + format: uuid + required: true + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + example: {} + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Update the API key + updated_api_key = portkey.api_keys.update( + id="API_KEY_ID", + name="API_KEY_NAME_0909", + rate_limits=[ + { + "type": "requests", + "unit": "rpm", + "value": 100 + } + ], + scopes=[ + "organisation_users.create", "organisation_users.read", "organisation_users.update", + "organisation_users.delete", "organisation_users.list", + "organisation_service_api_keys.create", "organisation_service_api_keys.update", + "organisation_service_api_keys.read", "organisation_service_api_keys.delete", + "organisation_service_api_keys.list", "workspaces.delete", "workspaces.create", + "workspaces.read", "workspaces.update", "workspaces.list", "logs.export", + "logs.list", "logs.view", "configs.create", "configs.update", "configs.delete", + "configs.read", "configs.list", "virtual_keys.create", "virtual_keys.update", + "virtual_keys.delete", "virtual_keys.duplicate", "virtual_keys.read", + "virtual_keys.list", "virtual_keys.copy", "workspace_service_api_keys.create", + "workspace_service_api_keys.delete", "workspace_service_api_keys.update", + "workspace_service_api_keys.read", "workspace_service_api_keys.list", + "workspace_user_api_keys.create", "workspace_user_api_keys.delete", + "workspace_user_api_keys.update", "workspace_user_api_keys.read", + "workspace_user_api_keys.list", "workspace_users.create", "workspace_users.read", + "workspace_users.update", "workspace_users.delete", "workspace_users.list", + "analytics.view" + ] + ) + + print(updated_api_key) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const apiKey=await portkey.apiKeys.update({ + id:"API_KEY_ID", + name:"API_KEY_NAME_0909", + rate_limits:[ { + "type": "requests", + "unit": "rpm", + "value": 100 + }], + "scopes": [ + "organisation_users.create", + "organisation_users.read", + "organisation_users.update", + "organisation_users.delete", + "organisation_users.list", + "organisation_service_api_keys.create", + "organisation_service_api_keys.update", + "organisation_service_api_keys.read", + "organisation_service_api_keys.delete", + "organisation_service_api_keys.list", + "workspaces.delete", + "workspaces.create", + "workspaces.read", + "workspaces.update", + "workspaces.list", + "logs.export", + "logs.list", + "logs.view", + "configs.create", + "configs.update", + "configs.delete", + "configs.read", + "configs.list", + "virtual_keys.create", + "virtual_keys.update", + "virtual_keys.delete", + "virtual_keys.duplicate", + "virtual_keys.read", + "virtual_keys.list", + "virtual_keys.copy", + "workspace_service_api_keys.create", + "workspace_service_api_keys.delete", + "workspace_service_api_keys.update", + "workspace_service_api_keys.read", + "workspace_service_api_keys.list", + "workspace_user_api_keys.create", + "workspace_user_api_keys.delete", + "workspace_user_api_keys.update", + "workspace_user_api_keys.read", + "workspace_user_api_keys.list", + "workspace_users.create", + "workspace_users.read", + "workspace_users.update", + "workspace_users.delete", + "workspace_users.list", + "analytics.view" + ], + + }) + console.log(apiKey); + - lang: curl + label: Default + source: | + curl -X PUT "https://api.portkey.ai/v1/api-keys/{id}" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name":"API_KEY_NAME_0909", + "rate_limits":[ + { + "type": "requests", + "unit": "rpm", + "value": 100 + } + ], + "scopes": [ + "organisation_users.create", + "organisation_users.read", + "organisation_users.update", + "organisation_users.delete", + "organisation_users.list", + "organisation_service_api_keys.create", + "organisation_service_api_keys.update", + "organisation_service_api_keys.read", + "organisation_service_api_keys.delete", + "organisation_service_api_keys.list", + "workspaces.delete", + "workspaces.create", + "workspaces.read", + "workspaces.update", + "workspaces.list", + "logs.export", + "logs.list", + "logs.view", + "configs.create", + "configs.update", + "configs.delete", + "configs.read", + "configs.list", + "virtual_keys.create", + "virtual_keys.update", + "virtual_keys.delete", + "virtual_keys.duplicate", + "virtual_keys.read", + "virtual_keys.list", + "virtual_keys.copy", + "workspace_service_api_keys.create", + "workspace_service_api_keys.delete", + "workspace_service_api_keys.update", + "workspace_service_api_keys.read", + "workspace_service_api_keys.list", + "workspace_user_api_keys.create", + "workspace_user_api_keys.delete", + "workspace_user_api_keys.update", + "workspace_user_api_keys.read", + "workspace_user_api_keys.list", + "workspace_users.create", + "workspace_users.read", + "workspace_users.update", + "workspace_users.delete", + "workspace_users.list", + "analytics.view" + ] + }' + - lang: curl + label: Self-Hosted + source: | + curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/api-keys/{id}" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name":"API_KEY_NAME_0909", + "rate_limits":[ + { + "type": "requests", + "unit": "rpm", + "value": 100 + } + ], + "scopes":[ + "organisation_users.create", + "organisation_users.read", + "organisation_users.update", + "organisation_users.delete", + "organisation_users.list", + "organisation_service_api_keys.create", + "organisation_service_api_keys.update", + "organisation_service_api_keys.read", + "organisation_service_api_keys.delete", + "organisation_service_api_keys.list", + "workspaces.delete", + "workspaces.create", + "workspaces.read", + "workspaces.update", + "workspaces.list", + "logs.export", + "logs.list", + "logs.view", + "configs.create", + "configs.update", + "configs.delete", + "configs.read", + "configs.list", + "virtual_keys.create", + "virtual_keys.update", + "virtual_keys.delete", + "virtual_keys.duplicate", + "virtual_keys.read", + "virtual_keys.list", + "virtual_keys.copy", + "workspace_service_api_keys.create", + "workspace_service_api_keys.delete", + "workspace_service_api_keys.update", + "workspace_service_api_keys.read", + "workspace_service_api_keys.list", + "workspace_user_api_keys.create", + "workspace_user_api_keys.delete", + "workspace_user_api_keys.update", + "workspace_user_api_keys.read", + "workspace_user_api_keys.list", + "workspace_users.create", + "workspace_users.read", + "workspace_users.update", + "workspace_users.delete", + "workspace_users.list", + "analytics.view" + ] + }' + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Update the API key + updated_api_key = portkey.api_keys.update( + id="API_KEY_ID", + name="API_KEY_NAME_0909", + rate_limits=[ + { + "type": "requests", + "unit": "rpm", + "value": 100 + } + ], + scopes=[ + "organisation_users.create", "organisation_users.read", "organisation_users.update", + "organisation_users.delete", "organisation_users.list", + "organisation_service_api_keys.create", "organisation_service_api_keys.update", + "organisation_service_api_keys.read", "organisation_service_api_keys.delete", + "organisation_service_api_keys.list", "workspaces.delete", "workspaces.create", + "workspaces.read", "workspaces.update", "workspaces.list", "logs.export", + "logs.list", "logs.view", "configs.create", "configs.update", "configs.delete", + "configs.read", "configs.list", "virtual_keys.create", "virtual_keys.update", + "virtual_keys.delete", "virtual_keys.duplicate", "virtual_keys.read", + "virtual_keys.list", "virtual_keys.copy", "workspace_service_api_keys.create", + "workspace_service_api_keys.delete", "workspace_service_api_keys.update", + "workspace_service_api_keys.read", "workspace_service_api_keys.list", + "workspace_user_api_keys.create", "workspace_user_api_keys.delete", + "workspace_user_api_keys.update", "workspace_user_api_keys.read", + "workspace_user_api_keys.list", "workspace_users.create", "workspace_users.read", + "workspace_users.update", "workspace_users.delete", "workspace_users.list", + "analytics.view" + ] + ) + + print(updated_api_key) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const apiKey=await portkey.apiKeys.update({ + id:"API_KEY_ID", + name:"API_KEY_NAME_0909", + rate_limits:[ { + "type": "requests", + "unit": "rpm", + "value": 100 + }], + "scopes": [ + "organisation_users.create", + "organisation_users.read", + "organisation_users.update", + "organisation_users.delete", + "organisation_users.list", + "organisation_service_api_keys.create", + "organisation_service_api_keys.update", + "organisation_service_api_keys.read", + "organisation_service_api_keys.delete", + "organisation_service_api_keys.list", + "workspaces.delete", + "workspaces.create", + "workspaces.read", + "workspaces.update", + "workspaces.list", + "logs.export", + "logs.list", + "logs.view", + "configs.create", + "configs.update", + "configs.delete", + "configs.read", + "configs.list", + "virtual_keys.create", + "virtual_keys.update", + "virtual_keys.delete", + "virtual_keys.duplicate", + "virtual_keys.read", + "virtual_keys.list", + "virtual_keys.copy", + "workspace_service_api_keys.create", + "workspace_service_api_keys.delete", + "workspace_service_api_keys.update", + "workspace_service_api_keys.read", + "workspace_service_api_keys.list", + "workspace_user_api_keys.create", + "workspace_user_api_keys.delete", + "workspace_user_api_keys.update", + "workspace_user_api_keys.read", + "workspace_user_api_keys.list", + "workspace_users.create", + "workspace_users.read", + "workspace_users.update", + "workspace_users.delete", + "workspace_users.list", + "analytics.view" + ], + + }) + console.log(apiKey); + + get: + tags: + - Api-Keys + summary: Get API Keys + parameters: + - name: id + in: path + schema: + type: string + format: uuid + required: true + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + $ref: "#/components/schemas/ApiKeyObject" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Get API keys + api_keys = portkey.api_keys.retrieve( + id="API_KEY_ID" + ) + + print(api_keys) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const apiKey=await portkey.apiKeys.retrieve({ + id:"API_KEY_ID" + }) + + console.log(apiKey); + - lang: curl + label: Default + source: | + curl -X GET "https://api.portkey.ai/v1/api_keys/{id}" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/api_keys/{id}" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Get API keys + api_keys = portkey.api_keys.retrieve( + id="API_KEY_ID" + ) + + print(api_keys) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const apiKey=await portkey.apiKeys.retrieve({ + id:"API_KEY_ID" + }) + + console.log(apiKey); + + delete: + tags: + - Api-Keys + summary: Remove an API Key + parameters: + - name: id + in: path + schema: + type: string + format: uuid + required: true + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + example: {} + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Delete the API key + result = portkey.api_keys.delete( + id="API_KEY_ID" + ) + + print(result) + - lang: javascript + label: Default + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const apiKey=await portkey.apiKeys.delete({ + id:"API_KEY_ID" + }) + console.log(apiKey); + - lang: curl + label: Default + source: | + curl -X DELETE "https://api.portkey.ai/v1/api_keys/{id}" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X DELETE "SELF_HOSTED_CONTROL_PLANE_URL/api_keys/{id}" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" + ) + + # Delete the API key + result = portkey.api_keys.delete( + id="API_KEY_ID" + ) + + print(result) + - lang: javascript + label: Self-Hosted + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) + + const apiKey=await portkey.apiKeys.delete({ + id:"API_KEY_ID" + }) + console.log(apiKey); + + /api-keys/{id}/rotate: + servers: *ControlPlaneServers + post: + tags: + - Api-Keys + summary: Rotate API Key + description: | + Rotates an existing API key and returns a newly generated key value. + The previous key remains valid during the transition period and expires at `key_transition_expires_at`. + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/RotateApiKeyRequest" + examples: + default: + summary: Rotate with a custom transition period + value: + key_transition_period_ms: 3600000 + parameters: + - name: id + in: path + schema: + type: string + format: uuid + required: true + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + $ref: "#/components/schemas/RotateApiKeyResponse" + x-code-samples: + - lang: python + label: Default + source: | + import requests + + response = requests.post( + "https://api.portkey.ai/v1/api-keys/API_KEY_ID/rotate", + headers={ + "x-portkey-api-key": "PORTKEY_API_KEY", + "Content-Type": "application/json", + }, + json={ + "key_transition_period_ms": 3600000 + } + ) + + print(response.json()) + - lang: javascript + label: Default + source: | + const response = await fetch("https://api.portkey.ai/v1/api-keys/API_KEY_ID/rotate", { + method: "POST", + headers: { + "x-portkey-api-key": "PORTKEY_API_KEY", + "Content-Type": "application/json", + }, + body: JSON.stringify({ + key_transition_period_ms: 3600000 + }), + }); + + const rotatedApiKey = await response.json(); + console.log(rotatedApiKey); + - lang: curl + label: Default + source: | + curl -X POST "https://api.portkey.ai/v1/api-keys/{id}/rotate" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "key_transition_period_ms": 3600000 + }' + - lang: python + label: Self-Hosted + source: | + import requests + + response = requests.post( + "SELF_HOSTED_CONTROL_PLANE_URL/api-keys/API_KEY_ID/rotate", + headers={ + "x-portkey-api-key": "PORTKEY_API_KEY", + "Content-Type": "application/json", + }, + json={ + "key_transition_period_ms": 3600000 + } + ) + + print(response.json()) + - lang: javascript + label: Self-Hosted + source: | + const response = await fetch("SELF_HOSTED_CONTROL_PLANE_URL/api-keys/API_KEY_ID/rotate", { + method: "POST", + headers: { + "x-portkey-api-key": "PORTKEY_API_KEY", + "Content-Type": "application/json", + }, + body: JSON.stringify({ + key_transition_period_ms: 3600000 + }), + }); + + const rotatedApiKey = await response.json(); + console.log(rotatedApiKey); + - lang: curl + label: Self-Hosted + source: | + curl -X POST "SELF_HOSTED_CONTROL_PLANE_URL/api-keys/{id}/rotate" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "key_transition_period_ms": 3600000 + }' + + /policies/usage-limits: + post: + tags: + - Usage Limits Policies + summary: Create Usage Limits Policy + description: Create a new usage limits policy to control total usage (cost or tokens) over a period. + operationId: createUsageLimitsPolicy + security: + - Portkey-Key: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateUsageLimitsPolicyRequest' + examples: + monthlyCostLimit: + summary: Monthly Cost Limit per API Key + value: + name: Monthly Cost Limit per API Key + conditions: + - key: workspace_id + value: workspace-123 + group_by: + - key: api_key + type: cost + credit_limit: 1000.0 + alert_threshold: 800.0 + periodic_reset: monthly + tokenLimit: + summary: Token Limit per User + value: + name: Token Limit per User + conditions: + - key: workspace_id + value: workspace-123 + group_by: + - key: metadata.user_id + type: tokens + credit_limit: 1000000 + periodic_reset: weekly + responses: + '200': + description: Policy created successfully + content: + application/json: + schema: + $ref: '#/components/schemas/CreatePolicyResponse' + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Policy not found + '500': + description: Server error + + get: + tags: + - Usage Limits Policies + summary: List Usage Limits Policies + description: List all usage limits policies with optional filtering. + operationId: listUsageLimitsPolicies + security: + - Portkey-Key: [] + parameters: + - $ref: '#/components/parameters/WorkspaceIdQuery' + - name: status + in: query + description: Filter by status + required: false + schema: + type: string + enum: [active, archived] + default: active + - name: type + in: query + description: Filter by policy type + required: false + schema: + type: string + enum: [cost, tokens] + - $ref: '#/components/parameters/PageSize' + - $ref: '#/components/parameters/CurrentPage' + responses: + '200': + description: List of usage limits policies + content: + application/json: + schema: + $ref: '#/components/schemas/UsageLimitsPolicyListResponse' + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Policy not found + '500': + description: Server error + + /policies/usage-limits/{policyUsageLimitsId}: + get: + tags: + - Usage Limits Policies + summary: Get Usage Limits Policy + description: Get a single usage limits policy by ID. + operationId: getUsageLimitsPolicy + security: + - Portkey-Key: [] + parameters: + - $ref: '#/components/parameters/PolicyUsageLimitsId' + - name: status + in: query + description: Filter by status + required: false + schema: + type: string + enum: [active, archived] + default: active + - name: include_usage + in: query + description: Include usage information for each value key + required: false + schema: + type: boolean + default: false + responses: + '200': + description: Usage limits policy details + content: + application/json: + schema: + $ref: '#/components/schemas/UsageLimitsPolicyResponse' + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Policy not found + '500': + description: Server error + + put: + tags: + - Usage Limits Policies + summary: Update Usage Limits Policy + description: Update an existing usage limits policy. + operationId: updateUsageLimitsPolicy + security: + - Portkey-Key: [] + parameters: + - $ref: '#/components/parameters/PolicyUsageLimitsId' + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateUsageLimitsPolicyRequest' + example: + credit_limit: 2000.0 + alert_threshold: 1500.0 + reset_usage_for_value: api-key-123 + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + example: {} + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Policy not found + '500': + description: Server error + + delete: + tags: + - Usage Limits Policies + summary: Delete Usage Limits Policy + description: Archive (soft delete) a usage limits policy. + operationId: deleteUsageLimitsPolicy + security: + - Portkey-Key: [] + parameters: + - $ref: '#/components/parameters/PolicyUsageLimitsId' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + example: {} + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Policy not found + '500': + description: Server error + + /policies/usage-limits/{policyUsageLimitsId}/entities: + get: + tags: + - Usage Limits Policies + summary: List Usage Limits Policy Entities + description: List entities tracked by a usage limits policy with their current usage. + operationId: listUsageLimitsPolicyEntities + security: + - Portkey-Key: [] + parameters: + - $ref: '#/components/parameters/PolicyUsageLimitsId' + - name: status + in: query + description: Filter by entity usage status + required: false + schema: + type: string + enum: [active, exhausted] + - name: search + in: query + description: Filter entities by value key + required: false + schema: + type: string + - name: page_size + in: query + description: Number of items per page + required: false + schema: + type: integer + minimum: 1 + maximum: 100 + - $ref: '#/components/parameters/CurrentPage' + responses: + '200': + description: List of entities for the policy + content: + application/json: + schema: + $ref: '#/components/schemas/UsageLimitsPolicyEntityListResponse' + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Policy not found + '500': + description: Server error + + /policies/usage-limits/{policyUsageLimitsId}/entities/{entityId}/reset: + put: + tags: + - Usage Limits Policies + summary: Reset Usage Limits Policy Entity + description: Reset the current usage for a specific entity in a usage limits policy. + operationId: resetUsageLimitsPolicyEntity + security: + - Portkey-Key: [] + parameters: + - $ref: '#/components/parameters/PolicyUsageLimitsId' + - $ref: '#/components/parameters/UsageLimitsPolicyEntityId' + responses: + '200': + description: Entity usage reset successfully + content: + application/json: + schema: + type: object + example: {} + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Policy or entity not found + '500': + description: Server error + + /policies/rate-limits: + post: + tags: + - Rate Limits Policies + summary: Create Rate Limits Policy + description: Create a new rate limits policy to control the rate of requests or tokens consumed per minute, hour, or day. + operationId: createRateLimitsPolicy + security: + - Portkey-Key: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateRateLimitsPolicyRequest' + examples: + requestsPerMinute: + summary: 100 Requests per Minute per API Key + value: + name: 100 RPM per API Key + conditions: + - key: workspace_id + value: workspace-123 + group_by: + - key: api_key + type: requests + unit: rpm + value: 100 + tokensPerHour: + summary: 10K Tokens per Hour per User + value: + name: 10K Tokens per Hour per User + conditions: + - key: workspace_id + value: workspace-123 + group_by: + - key: metadata.user_id + type: tokens + unit: rph + value: 10000 + responses: + '200': + description: Policy created successfully + content: + application/json: + schema: + $ref: '#/components/schemas/CreatePolicyResponse' + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '500': + description: Server error + + get: + tags: + - Rate Limits Policies + summary: List Rate Limits Policies + description: List all rate limits policies with optional filtering. + operationId: listRateLimitsPolicies + security: + - Portkey-Key: [] + parameters: + - $ref: '#/components/parameters/WorkspaceIdQuery' + - name: status + in: query + description: Filter by status + required: false + schema: + type: string + enum: [active, archived] + default: active + - name: type + in: query + description: Filter by policy type + required: false + schema: + type: string + enum: [requests, tokens] + - name: unit + in: query + description: Filter by rate unit + required: false + schema: + type: string + enum: [rpm, rph, rpd] + - $ref: '#/components/parameters/PageSize' + - $ref: '#/components/parameters/CurrentPage' + responses: + '200': + description: List of rate limits policies + content: + application/json: + schema: + $ref: '#/components/schemas/RateLimitsPolicyListResponse' + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Policy not found + '500': + description: Server error + + /policies/rate-limits/{rateLimitsPolicyId}: + get: + tags: + - Rate Limits Policies + summary: Get Rate Limits Policy + description: Get a single rate limits policy by ID. + operationId: getRateLimitsPolicy + security: + - Portkey-Key: [] + parameters: + - $ref: '#/components/parameters/RateLimitsPolicyId' + - name: status + in: query + description: Filter by status + required: false + schema: + type: string + enum: [active, archived] + default: active + responses: + '200': + description: Rate limits policy details + content: + application/json: + schema: + $ref: '#/components/schemas/RateLimitsPolicyResponse' + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Policy not found + '500': + description: Server error + + put: + tags: + - Rate Limits Policies + summary: Update Rate Limits Policy + description: Update an existing rate limits policy. + operationId: updateRateLimitsPolicy + security: + - Portkey-Key: [] + parameters: + - $ref: '#/components/parameters/RateLimitsPolicyId' + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateRateLimitsPolicyRequest' + example: + value: 200 + unit: rph + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + example: {} + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Policy not found + '500': + description: Server error + + delete: + tags: + - Rate Limits Policies + summary: Delete Rate Limits Policy + description: Delete a rate limits policy. + operationId: deleteRateLimitsPolicy + security: + - Portkey-Key: [] + parameters: + - $ref: '#/components/parameters/RateLimitsPolicyId' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + example: {} + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Policy not found + '500': + description: Server error + + /analytics/graphs/requests: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Graphs + summary: Get requests graph + parameters: + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: 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. + total: + type: integer + description: Total requests across all data points required: - - name - - arguments - required: - - id - - type - - function - - 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-4-turbo" - anyOf: - - type: string - - type: string - enum: - [ - "gpt-4o", - "gpt-4o-2024-05-13", - "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 + - total + data_points: 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: *metadata_description - type: object - x-oaiTypeLabel: map - nullable: true - temperature: - type: number - minimum: 0 - maximum: 2 - default: 1 - example: 1 - nullable: true - description: *run_temperature_description - top_p: - type: number - minimum: 0 - maximum: 1 - default: 1 - example: 1 - nullable: true - description: *run_top_p_description - 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: - - thread_id - - assistant_id - - 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 + properties: + timestamp: + type: string + format: date-time + description: The timestamp for the data point bucket + total: + type: integer + description: Total requests for this data point bucket + required: + - timestamp + - total + description: An array of data points, each with a timestamp and metrics + object: + type: string + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/cost: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Graphs + summary: Get cost graph + parameters: + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: 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: *metadata_description - type: object - x-oaiTypeLabel: map - nullable: true - 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": {} - } - - CreateThreadRequest: - type: object - additionalProperties: false - properties: - messages: - description: A list of [messages](/docs/api-reference/messages) to start the thread with. + total: + type: integer + description: Total cost in cents across all data points + avg: + type: integer + description: Average cost per request across all data points + required: + - total + - avg + data_points: 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: - # Ideally we'd reuse the chunking strategy schema here, but it doesn't expand properly - 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 maxium of 512 characters long. - x-oaiTypeLabel: map - x-oaiExpandable: true - oneOf: - - required: [vector_store_ids] - - required: [vector_stores] - nullable: true - metadata: - description: *metadata_description - type: object - x-oaiTypeLabel: map - nullable: true - - ModifyThreadRequest: - type: object - additionalProperties: false - properties: - tool_resources: + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp for the data point bucket + total: + type: integer + description: Total cost in cents for this data point bucket + avg: + type: integer + description: Average cost per request for this data point bucket + required: + - timestamp + - total + - avg + description: An array of data points, each with a timestamp and metrics + object: + type: string + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/latency: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Graphs + summary: Get latency graph + parameters: + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: 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: *metadata_description - 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 + avg: + type: integer + description: Average latency in ms across all data points + p50: + type: integer + description: 50th percentile latency in ms across all data points + p90: + type: integer + description: 90th percentile latency in ms across all data points + p99: + type: integer + description: 99th percentile latency in ms across all data points - ListThreadsResponse: - properties: - object: - type: string - example: "list" - data: + required: + - avg + - p50 + - p90 + - p99 + data_points: type: array items: - $ref: "#/components/schemas/ThreadObject" - 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 - - 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: + timestamp: + type: string + format: date-time + description: The timestamp for the data point bucket + avg: + type: integer + description: Average latency in ms for this data point bucket + p50: + type: integer + description: 50th percentile latency in ms for this data point bucket + p90: + type: integer + description: 90th percentile latency in ms for this data point bucket + p99: + type: integer + description: 99th percentile latency in ms for this data point bucket + required: + - timestamp + - avg + - p50 + - p90 + - p99 + description: An array of data points, each with a timestamp and metrics + object: + type: string + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/tokens: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Graphs + summary: Get tokens graph + parameters: + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: 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 + total: + type: integer + description: Total tokens across all data points + avg: + type: integer + description: Average tokens per request across all data points 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" - 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: + - total + - avg + data_points: 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: *metadata_description - 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": {} - } - - MessageDeltaObject: - type: object - title: Message delta object - description: | - Represents a message delta i.e. any changed fields on a message during streaming. - properties: - id: - description: The identifier of the message, which can be referenced in API endpoints. - type: string - object: - description: The object type, which is always `thread.message.delta`. - type: string - enum: ["thread.message.delta"] - delta: - description: The delta containing the fields that have changed on the Message. + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp for the data point bucket + total: + type: integer + description: Total tokens for this data point bucket + avg: + type: integer + description: Average tokens per request for this data point bucket + required: + - timestamp + - avg + - total + description: An array of data points, each with a timestamp and metrics + object: + type: string + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/users: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Graphs + summary: Get users graph. Returns unique user count across different time buckets + parameters: + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: type: object properties: - 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/MessageDeltaContentImageFileObject" - - $ref: "#/components/schemas/MessageDeltaContentTextObject" - - $ref: "#/components/schemas/MessageDeltaContentImageUrlObject" - x-oaiExpandable: true - required: - - id - - object - - delta - x-oaiMeta: - name: The message delta object - beta: true - example: | - { - "id": "msg_123", - "object": "thread.message.delta", - "delta": { - "content": [ - { - "index": 0, - "type": "text", - "text": { "value": "Hello", "annotations": [] } - } - ] - } - } - - 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. - 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. + total: + type: integer + description: Total unique users across all data points required: - - file_id - - tools - nullable: true - metadata: - description: *metadata_description - type: object - x-oaiTypeLabel: map - nullable: true - - ModifyMessageRequest: - type: object - additionalProperties: false - properties: - metadata: - description: *metadata_description - 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 - - ListMessagesResponse: - properties: - object: - type: string - example: "list" - data: + - total + data_points: 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 - - 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 - - MessageDeltaContentImageFileObject: - title: Image file - type: object - description: References an image [File](/docs/api-reference/files) in the content of a message. - properties: - index: - type: integer - description: The index of the content part in the message. - type: - description: Always `image_file`. - type: string - enum: ["image_file"] - image_file: + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp for the data point bucket + total: + type: integer + description: Total unique users for this data point bucket + required: + - timestamp + - total + description: An array of data points, each with a timestamp and metrics + object: + type: string + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/users/requests: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Graphs + summary: Get users requests graph. Returns average requests per user across different time buckets + parameters: + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: 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: - - index - - type - - 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: + total: + type: integer + description: Total requests across all data points + unique: + type: integer + description: Total unique users across all data points + avg: + type: integer + description: Average requests per user across all data points + required: + - total + - unique + - avg + data_points: + type: array + items: + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp for the data point bucket + avg: + type: integer + description: Average requests per user for this data point bucket + required: + - timestamp + - avg + description: An array of data points, each with a timestamp and metrics + object: + type: string + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/errors: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Graphs + summary: Get errors graph + parameters: + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: 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" + total: + type: integer + description: Total errors across all data points required: - - url - required: - - type - - image_url - - MessageDeltaContentImageUrlObject: - title: Image URL - type: object - description: References an image URL in the content of a message. - properties: - index: - type: integer - description: The index of the content part in the message. - type: - description: Always `image_url`. - type: string - enum: ["image_url"] - image_url: + - total + data_points: + type: array + items: + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp for the data point bucket + total: + type: integer + description: Total errors this data point bucket + required: + - timestamp + - total + description: An array of data points, each with a timestamp and metrics + object: + type: string + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/errors/rate: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Graphs + summary: Get percentage error rate graph + parameters: + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: type: object properties: - url: - description: "The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp." - type: string - detail: - type: string - description: Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. - enum: ["auto", "low", "high"] - default: "auto" - required: - - index - - 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"] - text: + rate: + type: integer + description: Percentage error rate across all data points + required: + - rate + data_points: + type: array + items: + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp for the data point bucket + rate: + type: integer + description: Percentage error rate for this data point bucket + required: + - timestamp + - rate + description: An array of data points, each with a timestamp and metrics + object: + type: string + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/errors/stacks: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Graphs + summary: Get status code wise stacked error graph + parameters: + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: 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 + total: + type: integer + description: Total errors across all data points required: - - value - - annotations - required: - - type - - text - - 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 - - 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: + - total + data_points: + type: array + items: + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp for the data point bucket + stats: + type: array + items: + type: object + properties: + response_status_code: + type: integer + description: Response status code + count: + type: integer + description: Total occurences of this response status code + required: + - timestamp + - stats + description: An array of data points, each with a timestamp and metrics + object: + type: string + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/errors/status-codes: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Graphs + summary: Get status code wise grouped error graph. + parameters: + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: type: object properties: - file_id: - description: The ID of the specific File the citation is from. - type: string - quote: - description: The specific quote in the file. - type: string + total_errors: + type: integer + description: Total errors across all data points + unique_error_codes: + type: integer + description: Unique error codes across all data points required: - - file_id - - quote - 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: + - total_errors + - unique_error_codes + data_points: + type: array + items: + type: object + properties: + status_code: + type: integer + description: Response status code + count: + type: integer + description: Occurences of this response status code + required: + - status_code + - count + description: An array of data points, each with a timestamp and metrics + object: + type: string + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/requests/rescued: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Graphs + summary: Get retry and fallback rescued requests graph + parameters: + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: type: object properties: - file_id: - description: The ID of the file that was generated. - type: string + retry: + type: integer + description: Total requests rescued using retries across all data points + fallback: + type: integer + description: Total requests rescued using fallback across all data points required: - - file_id - start_index: - type: integer - minimum: 0 - end_index: - type: integer - minimum: 0 - required: - - type - - text - - file_path - - start_index - - end_index - - MessageDeltaContentTextObject: - title: Text - type: object - description: The text content that is part of a message. - properties: - index: - type: integer - description: The index of the content part in the message. - type: - description: Always `text`. - type: string - enum: ["text"] - text: + - retry + - fallback + data_points: + type: array + items: + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp for the data point bucket + retry: + type: array + items: + type: object + properties: + retry_success_count: + type: integer + description: "Retry attempt count at which the request was rescued" + count: + type: integer + description: "Total requests rescued at this retry attempt" + fallback: + type: integer + description: Total requests rescued using fallback for this data point bucket + required: + - timestamp + - retry + - fallback + description: An array of data points, each with a timestamp and metrics + object: + type: string + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/cache/hit-rate: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Graphs + summary: Get cache hit rate graph + parameters: + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: type: object properties: - value: - description: The data that makes up the text. - type: string - annotations: - type: array - items: - oneOf: - - $ref: "#/components/schemas/MessageDeltaContentTextAnnotationsFileCitationObject" - - $ref: "#/components/schemas/MessageDeltaContentTextAnnotationsFilePathObject" - x-oaiExpandable: true - required: - - index - - type - - MessageDeltaContentTextAnnotationsFileCitationObject: - 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: - index: - type: integer - description: The index of the annotation in the text content part. - 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: + total: + type: integer + description: Total cache hits across all data points + rate: + type: integer + description: Percentage cache hit rate across all data points + required: + - total + - rate + data_points: + type: array + items: + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp for the data point bucket + simple_hits: + type: integer + description: Total simple cache hits for this data point bucket + semantic_hits: + type: integer + description: Total semantic cache hits for this data point bucket + rate: + type: integer + description: Percentage cache hit rate for this data point bucket + cumulative_simple_cache_savings: + type: integer + description: Cumulative simple cache cost savings in cents based on all previous data point buckets and this bucket + cumulative_semantic_cache_savings: + type: integer + description: Cumulative semantic cache cost savings in cents based on all previous data point buckets and this bucket + required: + - timestamp + - simple_hits + - semantic_hits + - rate + - cumulative_simple_cache_savings + - cumulative_semantic_cache_savings + description: An array of data points, each with a timestamp and metrics + object: + type: string + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/cache/latency: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Graphs + summary: Get cache hit latency graph + parameters: + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: type: object - properties: - file_id: - description: The ID of the specific File the citation is from. - type: string - quote: - description: The specific quote in the file. - type: string - start_index: - type: integer - minimum: 0 - end_index: - type: integer - minimum: 0 - required: - - index - - type - - MessageDeltaContentTextAnnotationsFilePathObject: - 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: - index: - type: integer - description: The index of the annotation in the text content part. - 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: + data_points: + type: array + items: + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp for the data point bucket + avg: + type: integer + description: Average latency (in ms) for cache hit for this data point bucket + required: + - timestamp + - avg + description: An array of data points, each with a timestamp and metrics + object: + type: string + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/feedbacks: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Graphs + summary: Get feedbacks graph + parameters: + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: type: object properties: - file_id: - description: The ID of the file that was generated. - type: string - start_index: - type: integer - minimum: 0 - end_index: - type: integer - minimum: 0 - required: - - index - - type - - 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: + total: + type: integer + description: Total feedbacks across all data points + required: + - total + data_points: + type: array + items: + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp for the data point bucket + total: + type: integer + description: Total feedbacks for this data point bucket + required: + - timestamp + - total + description: An array of data points, each with a timestamp and metrics + object: + type: string + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/feedbacks/scores: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Graphs + summary: Get score-wise feedbacks distribution graph + parameters: + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: type: object - description: The details of the run step. - oneOf: - - $ref: "#/components/schemas/RunStepDetailsMessageCreationObject" - - $ref: "#/components/schemas/RunStepDetailsToolCallsObject" - x-oaiExpandable: true - last_error: + properties: + total: + type: integer + description: Total feedbacks across all data points + required: + - total + data_points: + type: array + items: + type: object + properties: + score: + type: integer + description: Feedback value for which total is calculated + total: + type: integer + description: Total feedbacks for this feedback score + required: + - score + - total + description: An array of data points, each with a timestamp and metrics + object: + type: string + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/feedbacks/weighted: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Graphs + summary: Get weighted feedbacks graph. Weighted feedback is (value * score) + parameters: + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: 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. + avg: + type: integer + description: Average weighted feedback across all data points 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: *metadata_description + - avg + data_points: + type: array + items: + type: object + properties: + timestamp: + type: string + format: date-time + description: The timestamp for the data point bucket + avg: + type: integer + description: Average weighted feedback for this data point bucket + required: + - timestamp + - avg + description: An array of data points, each with a timestamp and metrics + object: + type: string + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/feedbacks/ai-models: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Graphs + summary: Get feedbacks per ai_models graph + parameters: + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: 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: *run_step_object_example - - RunStepDeltaObject: - type: object - title: Run step delta object - description: | - Represents a run step delta i.e. any changed fields on a run step during streaming. - 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.delta`. - type: string - enum: ["thread.run.step.delta"] - delta: - description: The delta containing the fields that have changed on the run step. + data_points: + type: array + items: + type: object + properties: + ai_model: + type: string + description: AI model for which feedback data is calculated + total: + type: integer + description: Total feedbacks for this ai_model requests + avg_weighted_feedback: + type: integer + description: Average weighted feedback for this ai_model requests + required: + - ai_model + - total + - avg_weighted_feedback + description: An array of data points, each with a timestamp and metrics + object: + type: string + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/summary/cache: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Summary + summary: Get cache summary data for the selected time period + parameters: + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: type: object properties: - step_details: - type: object - description: The details of the run step. - oneOf: - - $ref: "#/components/schemas/RunStepDeltaStepDetailsMessageCreationObject" - - $ref: "#/components/schemas/RunStepDeltaStepDetailsToolCallsObject" - x-oaiExpandable: true - required: - - id - - object - - delta - x-oaiMeta: - name: The run step delta object - beta: true - example: | - { - "id": "step_123", - "object": "thread.run.step.delta", - "delta": { - "step_details": { - "type": "tool_calls", - "tool_calls": [ - { - "index": 0, - "id": "call_123", - "type": "code_interpreter", - "code_interpreter": { "input": "", "outputs": [] } - } - ] - } - } - } - - ListRunStepsResponse: - properties: - object: + hits: + type: integer + description: Total cache hits + avg_latency: + type: integer + description: Average latency for a cache hit + total_requests: + type: integer + description: Total requests + cache_speedup: + type: integer + description: Percentage speedup for cache hits compared to non cache hit requests + object: + type: string + description: The type of object being returned + enum: [analytics-summary] + required: + - summary + - object + + /analytics/groups/users: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Groups + summary: Get metadata users grouped data. + parameters: + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/CurrentPage" + - $ref: "#/components/parameters/PageSize" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + object: type: string - example: "list" - data: + enum: [list] + total: + type: integer + description: Total records present across all pages + data: type: array items: - $ref: "#/components/schemas/RunStepObject" - first_id: + type: object + properties: + user: + type: string + description: The user for which the data is calculated + requests: + type: string + description: Total requests made by this user + cost: + type: string + description: Total cost in cents for the requests made by this user + object: + type: string + description: The type of object being returned + enum: [analytics-group] + required: + - total + - object + - data + + /analytics/groups/ai-models: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Groups + summary: Get ai model grouped data. + parameters: + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/CurrentPage" + - $ref: "#/components/parameters/PageSize" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + object: type: string - example: "step_abc123" - last_id: + enum: [list] + total: + type: integer + description: Total records present across all pages + data: + type: array + items: + type: object + properties: + ai_model: + type: string + description: The ai model for which the data is calculated + requests: + type: string + description: Total requests made for this ai model + object: + type: string + description: The type of object being returned + enum: [analytics-group] + required: + - total + - object + - data + + /analytics/groups/metadata/{metadataKey}: + servers: *ControlPlaneServers + get: + tags: + - Analytics > Groups + summary: Get metadata key based grouped data. + parameters: + - name: metadataKey + in: path + schema: + type: string + required: true + - $ref: "#/components/parameters/WorkspaceSlug" + - $ref: "#/components/parameters/TimeOfGenerationMin" + - $ref: "#/components/parameters/TimeOfGenerationMax" + - $ref: "#/components/parameters/TotalUnitsMin" + - $ref: "#/components/parameters/TotalUnitsMax" + - $ref: "#/components/parameters/CostMin" + - $ref: "#/components/parameters/CostMax" + - $ref: "#/components/parameters/PromptTokenMin" + - $ref: "#/components/parameters/PromptTokenMax" + - $ref: "#/components/parameters/CompletionTokenMin" + - $ref: "#/components/parameters/CompletionTokenMax" + - $ref: "#/components/parameters/StatusCode" + - $ref: "#/components/parameters/WeightedFeedbackMin" + - $ref: "#/components/parameters/WeightedFeedbackMax" + - $ref: "#/components/parameters/VirtualKeys" + - $ref: "#/components/parameters/Configs" + - $ref: "#/components/parameters/ApiKeyIds" + - $ref: "#/components/parameters/CurrentPage" + - $ref: "#/components/parameters/PageSize" + - $ref: "#/components/parameters/Metadata" + - $ref: "#/components/parameters/AiOrgModel" + - $ref: "#/components/parameters/TraceId" + - $ref: "#/components/parameters/SpanId" + - $ref: "#/components/parameters/PromptSlug" + responses: + "200": + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + object: type: string - example: "step_abc456" - has_more: - type: boolean - example: false - required: - - object - - data - - first_id - - last_id - - has_more - - RunStepDetailsMessageCreationObject: - title: Message creation - type: object - description: Details of the message creation by the run step. - properties: - type: - description: Always `message_creation`. + enum: [list] + total: + type: integer + description: Total records present across all pages + data: + type: array + items: + type: object + properties: + metadata_value: + type: string + description: Value of the metadata on which grouping has been done + requests: + type: integer + description: Total requests made with this metadata + cost: + type: integer + description: Total cost for all requests made with this metadata + avg_tokens: + type: integer + description: Average tokens per request for all requests made with this metadata + avg_weighted_feedback: + type: integer + description: Average weighted feedback for all requests made with this metadata + requests_with_feedback: + type: integer + description: Total requests with feedback + last_seen: + type: string + format: date-time + description: The last seen timestamp for this metadata + object: + type: string + description: The type of object being returned + enum: [analytics-group] + required: + - total + - object + - data + + /model-configs/pricing/{provider}/{model}: + servers: *PublicServers + get: + summary: Get Model Pricing + security: [] + description: | + Returns pricing configuration for a specific model. + + **Note:** Prices are in USD cents per token. + + ## Supported Providers + + openai, anthropic, google, azure-openai, bedrock, mistral-ai, cohere, + together-ai, groq, deepseek, fireworks-ai, perplexity-ai, anyscale, + deepinfra, cerebras, x-ai, and 25+ more. + + ## Example Response Fields + + | Field | Description | Unit | + |-------|-------------|------| + | `request_token.price` | Input token cost | cents/token | + | `response_token.price` | Output token cost | cents/token | + | `cache_write_input_token.price` | Cache write cost | cents/token | + | `cache_read_input_token.price` | Cache read cost | cents/token | + | `additional_units.*` | Provider-specific features | cents/unit | + + operationId: getModelPricing + tags: + - Model Pricing + parameters: + - name: provider + in: path + required: true + description: | + Provider identifier. Use lowercase with hyphens. + + Examples: `openai`, `anthropic`, `google`, `azure-openai`, `bedrock`, `x-ai` + schema: + type: string + example: openai + - name: model + in: path + required: true + description: | + Model identifier. Use the exact model name as specified by the provider. + + Examples: `gpt-5`, `gpt-5.2`, `claude-opus-4-5-20251101`, `gemini-3.0-pro` + schema: + type: string + example: gpt-5 + responses: + '200': + description: Pricing configuration for the specified model + content: + application/json: + schema: + $ref: '#/components/schemas/ModelPricingConfig' + examples: + openai-gpt4: + summary: OpenAI GPT-4 + value: + pay_as_you_go: + request_token: + price: 0.003 + response_token: + price: 0.006 + calculate: + request: + operation: sum + operands: + - operation: multiply + operands: + - value: input_tokens + - value: rates.request_token + - operation: multiply + operands: + - value: cache_write_tokens + - value: rates.cache_write_input_token + - operation: multiply + operands: + - value: cache_read_tokens + - value: rates.cache_read_input_token + response: + operation: multiply + operands: + - value: output_tokens + - value: rates.response_token + currency: USD + openai-gpt4o-with-tools: + summary: OpenAI GPT-4o (with additional units) + value: + pay_as_you_go: + request_token: + price: 0.00025 + response_token: + price: 0.001 + cache_write_input_token: + price: 0 + cache_read_input_token: + price: 0.000125 + additional_units: + web_search: + price: 1 + file_search: + price: 0.25 + calculate: + request: + operation: sum + operands: + - operation: multiply + operands: + - value: input_tokens + - value: rates.request_token + response: + operation: multiply + operands: + - value: output_tokens + - value: rates.response_token + currency: USD + anthropic-claude: + summary: Anthropic Claude 3.5 Sonnet + value: + pay_as_you_go: + request_token: + price: 0.0003 + response_token: + price: 0.0015 + cache_read_input_token: + price: 0.00003 + cache_write_input_token: + price: 0.000375 + currency: USD + google-gemini: + summary: Google Gemini 2.5 Pro (with thinking tokens) + value: + pay_as_you_go: + request_token: + price: 0.000125 + response_token: + price: 0.001 + additional_units: + thinking_token: + price: 0.001 + web_search: + price: 3.5 + search: + price: 3.5 + currency: USD + '404': + description: Model or provider not found + content: + application/json: + schema: + type: object + properties: + error: + type: string + example: Model not found + + /secret-references: + servers: *ControlPlaneServers + get: + operationId: listSecretReferences + summary: List All Secret References + tags: + - Secret-References + parameters: + - in: query + name: manager_type + schema: + type: string + enum: [aws_sm, azure_kv, hashicorp_vault] + description: Filter by secret manager type + - in: query + name: tags + schema: + type: string + description: JSON-encoded object for tag filtering + - in: query + name: search + schema: + type: string + minLength: 1 + maxLength: 255 + description: Search by name + - in: query + name: current_page + schema: + type: integer + minimum: 0 + default: 0 + description: Page index (0-based), defaults to 0 + - in: query + name: page_size + schema: + type: integer + minimum: 1 + maximum: 100 + default: 20 + description: Items per page (1-100), defaults to 20 + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + properties: + object: 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 + enum: [list] + total: + type: integer + data: + type: array + items: + $ref: "#/components/schemas/SecretReferenceListItem" + security: + - Portkey-Key: [] + x-code-samples: + - lang: curl + label: Default + source: | + curl -X GET "https://api.portkey.ai/v1/secret-references?current_page=0&page_size=20" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/secret-references?current_page=0&page_size=20" \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + + post: + operationId: createSecretReference + summary: Create a Secret Reference + tags: + - Secret-References + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CreateSecretReferenceRequest" + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + properties: + id: + type: string + format: uuid + slug: + type: string + object: + type: string + enum: [secret-reference] + "400": + description: Validation failure (schema, duplicate slug, invalid workspaces, conflicting allow_all_workspaces + allowed_workspaces) + "403": + description: secretReferences feature not enabled on subscription + security: + - Portkey-Key: [] + x-code-samples: + - lang: curl + label: Default + source: | + curl -X POST https://api.portkey.ai/v1/secret-references \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "my-aws-secret", + "manager_type": "aws_sm", + "auth_config": { + "aws_auth_type": "accessKey", + "aws_access_key_id": "AKIA...", + "aws_secret_access_key": "wJal...", + "aws_region": "us-east-1" + }, + "secret_path": "prod/api-keys/openai" + }' + - lang: curl + label: Self-Hosted + source: | + curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/secret-references \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "my-aws-secret", + "manager_type": "aws_sm", + "auth_config": { + "aws_auth_type": "accessKey", + "aws_access_key_id": "AKIA...", + "aws_secret_access_key": "wJal...", + "aws_region": "us-east-1" + }, + "secret_path": "prod/api-keys/openai" + }' + + /secret-references/{secretReferenceId}: + servers: *ControlPlaneServers + get: + operationId: getSecretReference + summary: Get a Secret Reference + tags: + - Secret-References + parameters: + - in: path + name: secretReferenceId + required: true + schema: + type: string + description: UUID or slug of the secret reference + responses: + "200": + description: Successful response + content: + application/json: + schema: + $ref: "#/components/schemas/SecretReferenceDetailResponse" + "404": + description: Secret reference not found + security: + - Portkey-Key: [] + x-code-samples: + - lang: curl + label: Default + source: | + curl -X GET https://api.portkey.ai/v1/secret-references/SECRET_REFERENCE_ID \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X GET SELF_HOSTED_CONTROL_PLANE_URL/secret-references/SECRET_REFERENCE_ID \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + + put: + operationId: updateSecretReference + summary: Update a Secret Reference + tags: + - Secret-References + parameters: + - in: path + name: secretReferenceId + required: true + schema: + type: string + description: UUID or slug of the secret reference + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateSecretReferenceRequest" + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + "400": + description: Validation failure or no valid fields to update + "404": + description: Secret reference not found + security: + - Portkey-Key: [] + x-code-samples: + - lang: curl + label: Default + source: | + curl -X PUT https://api.portkey.ai/v1/secret-references/SECRET_REFERENCE_ID \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "updated-secret-name", + "secret_path": "prod/api-keys/updated" + }' + - lang: curl + label: Self-Hosted + source: | + curl -X PUT SELF_HOSTED_CONTROL_PLANE_URL/secret-references/SECRET_REFERENCE_ID \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "updated-secret-name", + "secret_path": "prod/api-keys/updated" + }' + + delete: + operationId: deleteSecretReference + summary: Delete a Secret Reference + tags: + - Secret-References + parameters: + - in: path + name: secretReferenceId + required: true + schema: + type: string + description: UUID or slug of the secret reference + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + "400": + description: Secret reference is in use by integrations or virtual keys + "404": + description: Secret reference not found + security: + - Portkey-Key: [] + x-code-samples: + - lang: curl + label: Default + source: | + curl -X DELETE https://api.portkey.ai/v1/secret-references/SECRET_REFERENCE_ID \ + -H "x-portkey-api-key: PORTKEY_API_KEY" + - lang: curl + label: Self-Hosted + source: | + curl -X DELETE SELF_HOSTED_CONTROL_PLANE_URL/secret-references/SECRET_REFERENCE_ID \ + -H "x-portkey-api-key: PORTKEY_API_KEY" - RunStepDeltaStepDetailsMessageCreationObject: - 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: - - type - RunStepDetailsToolCallsObject: - title: Tool calls +components: + securitySchemes: + Portkey-Key: + type: apiKey + in: header + name: x-portkey-api-key + Virtual-Key: + type: apiKey + in: header + name: x-portkey-virtual-key + Provider-Auth: + type: http + scheme: "bearer" + Provider-Name: + type: apiKey + in: header + name: x-portkey-provider + Config: + type: apiKey + in: header + name: x-portkey-config + Custom-Host: + type: apiKey + in: header + name: x-portkey-custom-host + + parameters: + TimeOfGenerationMin: + in: query + name: time_of_generation_min + required: true + schema: + type: string + format: date-time + example: "2026-02-23T14:20:31+05:30" + description: Minimum time of generation in ISO8601 format (YYYY-MM-DDTHH:MM:SS±HH:MM). + TimeOfGenerationMax: + in: query + name: time_of_generation_max + required: true + schema: + type: string + format: date-time + example: "2026-02-24T14:20:31+05:30" + description: Maximum time of generation in ISO8601 format (YYYY-MM-DDTHH:MM:SS±HH:MM). + TotalUnitsMin: + in: query + name: total_units_min + schema: + type: integer + minimum: 0 + description: Minimum total units (tokens) + TotalUnitsMax: + in: query + name: total_units_max + schema: + type: integer + minimum: 0 + description: Maximum total units (tokens) + CostMin: + in: query + name: cost_min + schema: + type: number + minimum: 0 + description: Minimum cost (in cents) + CostMax: + in: query + name: cost_max + schema: + type: number + minimum: 0 + description: Maximum cost (in cents) + PromptTokenMin: + in: query + name: prompt_token_min + schema: + type: integer + minimum: 0 + description: Minimum number of prompt tokens + PromptTokenMax: + in: query + name: prompt_token_max + schema: + type: integer + minimum: 0 + description: Maximum number of prompt tokens + CompletionTokenMin: + in: query + name: completion_token_min + schema: + type: integer + minimum: 0 + description: Minimum number of completion tokens + CompletionTokenMax: + in: query + name: completion_token_max + schema: + type: integer + minimum: 0 + description: Maximum number of completion tokens + StatusCode: + in: query + name: status_code + schema: + type: string + description: Comma separated response status codes + example: 401,403 + PageSize: + in: query + name: page_size + schema: + type: integer + minimum: 0 + description: Number of items per page + CurrentPage: + in: query + name: current_page + schema: + type: integer + minimum: 0 + description: Current page number + WeightedFeedbackMin: + in: query + name: weighted_feedback_min + schema: + type: number + minimum: -10 + maximum: 10 + description: Minimum weighted feedback score + WeightedFeedbackMax: + in: query + name: weighted_feedback_max + schema: + type: number + minimum: -10 + maximum: 10 + description: Maximum weighted feedback score + OrderBy: + in: query + name: order_by + schema: + type: string + description: Field to order results by + OrderByType: + in: query + name: order_by_type + schema: + type: string + description: Type of ordering (e.g., asc, desc) + VirtualKeys: + in: query + name: virtual_keys + schema: + type: string + description: Comma separated virtual key slugs + example: vk-slug-1,vk-slug-2 + Configs: + in: query + name: configs + schema: + type: string + description: Comma separated config slugs + example: pc-config-slug-1,pc-config-slug-2 + WorkspaceSlug: + in: query + name: workspace_slug + required: true + schema: + type: string + description: Workspace slug filter. If a workspace API key is being used, this filter will not be taken into consideration. If an organisation API key is used and no workspace slug is passed, default workspace will be used. + ApiKeyIds: + in: query + name: api_key_ids + schema: + type: string + description: Comma separated API key UUIDs + example: 765768a9-b4ec-4694-962c-d55f40cdb0dc,7c22af5a-8119-46b8-8d9b-bad3ad382387 + Metadata: + in: query + name: metadata + schema: + type: string + description: Stringifed json object with key value metadata pairs + example: '{"_user":"user_1", "env": "staging"}' + AiOrgModel: + in: query + name: ai_org_model + schema: + type: string + description: Comma separated ai provider and model combination. Double underscore (__) should be used as a separator for each provider and model combination + example: openai__gpt-3.5-turbo,azure-openai__gpt-35-turbo + TraceId: + in: query + name: trace_id + schema: + type: string + description: Comma separated trace IDs + example: my-unique-trace-1,my-unique-trace-2 + SpanId: + in: query + name: span_id + schema: + type: string + description: Comma separated span IDs + example: my-unique-span-1,my-unique-span-2 + PromptSlug: + in: query + name: prompt_slug + schema: + type: string + description: Comma separated prompt slugs + example: prompt-slug-1,prompt-slug-2 + PortkeyTraceId: + in: header + name: x-portkey-trace-id + schema: + type: string + description: An ID you can pass to refer to one or more requests later on. If not provided, Portkey generates a trace ID automatically for each request. [Docs](https://portkey.ai/docs/product/observability/traces) + required: false + PortkeySpanId: + in: header + name: x-portkey-span-id + schema: + type: string + description: An ID you can pass to refer to a span under a trace. + required: false + PortkeySpanName: + in: header + name: x-portkey-span-name + schema: + type: string + description: Name for the Span ID + required: false + PortkeyParentSpanId: + in: header + name: x-portkey-parent-span-id + schema: + type: string + description: Link a child span to a parent span + required: false + PortkeyMetadata: + in: header + name: x-portkey-metadata + schema: + type: object + description: Pass any arbitrary metadata along with your request + required: false + PortkeyCacheNamespace: + in: header + name: x-portkey-cache-namespace + schema: + type: string + description: Partition your Portkey cache store based on custom strings, ignoring metadata and other headers + PortkeyCacheForceRefresh: + in: header + name: x-portkey-cache-force-refresh + schema: + type: boolean + description: Forces a cache refresh for your request by making a new API call and storing the updated value + + PolicyUsageLimitsId: + name: policyUsageLimitsId + in: path + required: true + description: Usage limits policy UUID + schema: + type: string + format: uuid + UsageLimitsPolicyEntityId: + name: entityId + in: path + required: true + description: Usage limits policy entity ID + schema: + type: string + RateLimitsPolicyId: + name: rateLimitsPolicyId + in: path + required: true + description: Rate limits policy UUID + schema: + type: string + format: uuid + WorkspaceIdQuery: + name: workspace_id + in: query + required: false + description: Workspace ID or slug + schema: + type: string + + schemas: + ModelPricingConfig: + type: object + description: Complete pricing configuration for a model + properties: + pay_as_you_go: + $ref: '#/components/schemas/ModelPayAsYouGo' + calculate: + $ref: '#/components/schemas/ModelCalculateConfig' + currency: + type: string + enum: [USD] + description: Currency code (always USD) + finetune_config: + $ref: '#/components/schemas/ModelFinetuneConfig' + + ModelPayAsYouGo: + type: object + description: Token-based pricing (all prices in USD cents) + properties: + request_token: + $ref: '#/components/schemas/ModelTokenPrice' + response_token: + $ref: '#/components/schemas/ModelTokenPrice' + cache_write_input_token: + $ref: '#/components/schemas/ModelTokenPrice' + cache_read_input_token: + $ref: '#/components/schemas/ModelTokenPrice' + request_audio_token: + $ref: '#/components/schemas/ModelTokenPrice' + response_audio_token: + $ref: '#/components/schemas/ModelTokenPrice' + cache_read_audio_input_token: + $ref: '#/components/schemas/ModelTokenPrice' + additional_units: + type: object + description: | + Provider-specific additional pricing units. + + Common additional units: + - `web_search`: Web search tool usage + - `file_search`: File search tool usage + - `thinking_token`: Chain-of-thought reasoning tokens (Google) + - `image_token`: Image generation tokens + - `video_duration_seconds_*`: Video generation (OpenAI Sora) + additionalProperties: + $ref: '#/components/schemas/ModelTokenPrice' + image: + $ref: '#/components/schemas/ModelImagePricing' + + ModelTokenPrice: + type: object + description: Price object (value is in USD cents) + properties: + price: + type: number + description: | + Price in USD cents per token/unit. + + Example: `0.003` = 0.003 cents/token = $0.03 per 1K tokens + + ModelImagePricing: + type: object + description: Image generation pricing by quality and size + additionalProperties: + type: object + additionalProperties: + $ref: '#/components/schemas/ModelTokenPrice' + example: + standard: + 1024x1024: + price: 4 + 1024x1792: + price: 8 + hd: + 1024x1024: + price: 8 + 1024x1792: + price: 12 + + ModelCalculateConfig: + type: object + description: Cost calculation formulas + properties: + request: + $ref: '#/components/schemas/ModelCalculateOperation' + response: + $ref: '#/components/schemas/ModelCalculateOperation' + + ModelCalculateOperation: + type: object + description: Mathematical operation for cost calculation + properties: + operation: + type: string + enum: [sum, multiply] + description: Operation type + operands: + type: array + description: Operands for the operation + items: + oneOf: + - $ref: '#/components/schemas/ModelCalculateOperation' + - $ref: '#/components/schemas/ModelValueReference' + + ModelValueReference: + type: object + properties: + value: + type: string + description: | + Reference to a value or rate. + + Examples: + - `input_tokens`: Number of input tokens + - `output_tokens`: Number of output tokens + - `rates.request_token`: Request token rate + - `rates.response_token`: Response token rate + + ModelFinetuneConfig: + type: object + description: Fine-tuning pricing configuration + properties: + pay_per_token: + $ref: '#/components/schemas/ModelTokenPrice' + pay_per_hour: + $ref: '#/components/schemas/ModelTokenPrice' + + 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 + ErrorResponse: + type: object + properties: + error: + $ref: "#/components/schemas/Error" + required: + - error + + CreateInvite: + type: object + required: + - email + - workspaces + - role + properties: + email: + type: string + workspaces: + type: array + items: + $ref: "#/components/schemas/WorkspaceInvite" + role: + $ref: "#/components/schemas/InviteRole" + workspace_api_key_details: + type: object + properties: + scopes: + type: array + items: + type: string + required: + - scopes + example: + email: test@john.doe + role: admin + workspaces: + - id: ws-slug + role: member + InviteRole: + type: string + enum: + - admin + - member + WorkspaceInvite: + type: object + required: + - id + - role + properties: + id: + type: string + description: Workspace Slug + role: + $ref: "#/components/schemas/WorkspaceInviteRole" + WorkspaceInviteRole: + type: string + enum: + - admin + - member + - manager + WorkspaceInviteType: + type: string + enum: + - update + - add + - remove + SuccessInvite: + type: object + required: + - id + - invite_link + properties: + id: + type: string + invite_link: + type: string + example: + id: a286286b-633d-4c4f-bddb-86b84a50a25c + invite_link: https://app.portkey.ai/invite_id + ListModelsResponse: + type: object + properties: + object: + type: string + enum: [list] + data: + type: array + items: + $ref: "#/components/schemas/Model" + required: + - object + - data + DeleteModelResponse: + type: object + properties: + id: + type: string + deleted: + type: boolean + object: + type: string + required: + - id + - object + - deleted + + CreateCompletionRequest: + type: object + properties: + model: + description: &model_description | + ID of the model to use. You can use the [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](https://platform.openai.com/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: &completions_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: &completions_best_of_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: &completions_echo_description > + Echo back the prompt in addition to the completion + frequency_penalty: + type: number + default: 0 + minimum: -2 + maximum: 2 + nullable: true + description: &completions_frequency_penalty_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.](https://platform.openai.com/docs/guides/text-generation/parameter-details) + logit_bias: &completions_logit_bias + type: object + x-oaiTypeLabel: map + default: null + nullable: true + additionalProperties: + type: integer + description: &completions_logit_bias_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](https://platform.openai.com/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: &completions_logprobs_configuration + type: integer + minimum: 0 + maximum: 5 + default: null + nullable: true + description: &completions_logprobs_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: &completions_max_tokens_description | + The maximum number of [tokens](https://platform.openai.com/tokenizer?view=bpe) 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: &completions_completions_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: &completions_presence_penalty_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.](https://platform.openai.com/docs/guides/text-generation/parameter-details) + seed: &completions_seed_param + type: integer + minimum: -9223372036854775808 + maximum: 9223372036854775807 + 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: &completions_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: "\n" + 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-UShttps://platform.openai.com/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: &completions_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. + + 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: &completions_top_p_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: &end_user_param_configuration + type: string + example: user-1234 + description: | + A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](https://platform.openai.com/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 - description: Details of the tool call. + required: + - finish_reason + - index + - logprobs + - text properties: - type: - description: Always `tool_calls`. - type: string - enum: ["tool_calls"] - tool_calls: + finish_reason: + type: string + description: &completion_finish_reason_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 - 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 - - RunStepDeltaStepDetailsToolCallsObject: - 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: integer + token_logprobs: 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/RunStepDeltaStepDetailsToolCallsCodeObject" - - $ref: "#/components/schemas/RunStepDeltaStepDetailsToolCallsFileSearchObject" - - $ref: "#/components/schemas/RunStepDeltaStepDetailsToolCallsFunctionObject" - x-oaiExpandable: true - required: - - type - - RunStepDetailsToolCallsCodeObject: - title: Code Interpreter tool call + 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-code-samples: + 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 + } + } + + ChatCompletionRequestMessageContentPart: + oneOf: + - $ref: "#/components/schemas/ChatCompletionRequestMessageContentPartText" + - $ref: "#/components/schemas/ChatCompletionRequestMessageContentPartImage" + x-oaiExpandable: true + + ChatCompletionRequestMessageContentPartImage: + type: object + title: Image content part + 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](https://platform.openai.com/docs/guides/vision/low-or-high-fidelity-image-understanding). + enum: ["auto", "low", "high"] + default: "auto" + required: + - url + required: + - type + - image_url + + ChatCompletionRequestMessageContentPartText: + type: object + title: Text content part + properties: + type: + type: string + enum: ["text"] + description: The type of the content part. + text: + type: string + description: The text content. + required: + - type + - text + + ChatCompletionMessageContentPartThinking: + type: object + title: Thinking content part + properties: + type: + type: string + enum: ["thinking"] + description: The type of the content part. + thinking: + type: string + description: The thinking content. + required: + - type + - thinking + + ChatCompletionMessageContentPartRedactedThinking: + type: object + title: Redacted thinking content part + properties: + type: + type: string + enum: ["redacted_thinking"] + description: The type of the content part. + data: + type: string + description: The redacted thinking content. + required: + - type + - data + + ChatCompletionRequestMessage: + oneOf: + - $ref: "#/components/schemas/ChatCompletionRequestSystemMessage" + - $ref: "#/components/schemas/ChatCompletionRequestDeveloperMessage" + - $ref: "#/components/schemas/ChatCompletionRequestUserMessage" + - $ref: "#/components/schemas/ChatCompletionRequestAssistantMessage" + - $ref: "#/components/schemas/ChatCompletionRequestToolMessage" + - $ref: "#/components/schemas/ChatCompletionRequestFunctionMessage" + x-oaiExpandable: true + + ChatCompletionRequestSystemMessage: + type: object + title: System message + properties: + content: + description: The contents of the system message. + type: string + 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 + + ChatCompletionRequestDeveloperMessage: + type: object + title: Developer message + description: New role by OpenAI for select models. Must be explicitly used for models that support it. When used with incompatible models or providers, Portkey automatically converts it to a system role. + properties: + content: + description: The contents of the Developer message. + type: string + role: + type: string + enum: ["developer"] + description: The role of the messages author, in this case `Developer`. + 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, each can be of type `text` or `image_url` when passing in images. You can pass multiple images by adding multiple `image_url` content parts. Image input is only supported when using the `gpt-4-visual-preview` model. + title: Array of content parts + items: + $ref: "#/components/schemas/ChatCompletionRequestMessageContentPart" + 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: + nullable: true + type: string + description: | + The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified. + 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. + 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 + FileSearchTool: + type: object + title: File search + description: | + A tool that searches for relevant content from uploaded files. + Learn more about the [file search tool](/docs/guides/tools-file-search). + properties: + type: + type: string + enum: + - file_search + description: | + The type of the file search tool. Always `file_search`. + x-stainless-const: true + vector_store_ids: + type: array + items: + type: string + 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. + filters: + description: A filter to apply based on file attributes. + oneOf: + - $ref: "#/components/schemas/ComparisonFilter" + - $ref: "#/components/schemas/CompoundFilter" + x-oaiExpandable: true + ranking_options: + description: Ranking options for search. + type: object + additionalProperties: false + properties: + ranker: + type: string + description: The ranker to use for the file search. + enum: + - auto + - default-2024-11-15 + default: auto + 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. + minimum: 0 + maximum: 1 + default: 0 + required: + - type + - vector_store_ids + 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 - 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 - - RunStepDeltaStepDetailsToolCallsCodeObject: - title: Code interpreter tool call + 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. + nullable: true + required: + - id + - type + - status + - queries + # TODO(apeng): This is only because we don't support tools yet. Use allOf once we do. + FineTuneChatCompletionRequestAssistantMessage: + type: object + title: Assistant message + properties: + content: + nullable: true + type: string + description: | + The contents of the assistant message. Required unless `function_call` is specified. + 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. + function_call: + type: object + description: 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 + weight: + type: integer + enum: [0, 1] + description: "Controls whether the assistant message is trained against (0 or 1)" + 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: + type: string + 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 + + # TODO(apeng): This is only because we don't support tools yet. Add back deprecated once we do. + FineTuneChatCompletionRequestFunctionMessage: + allOf: + - type: object + title: Function message + deprecated: false + - $ref: "#/components/schemas/ChatCompletionRequestFunctionMessage" + + FunctionParameters: + type: object + description: "The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. \n\nOmitting `parameters` defines a function with an empty parameter list." + additionalProperties: true + + 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 + + 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 + + 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 + + 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 + OutputAudio: + type: object + title: Output audio + description: | + An audio output from the model. + properties: + type: + type: string + description: | + The type of the output audio. Always `output_audio`. + enum: + - output_audio + x-stainless-const: true + data: + type: string + description: | + Base64-encoded audio data from the model. + transcript: + type: string + description: | + The transcript of the audio data from the model. + required: + - type + - data + - transcript + OutputContent: + oneOf: + - $ref: "#/components/schemas/OutputText" + - $ref: "#/components/schemas/Refusal" + OutputItem: + anyOf: + - $ref: "#/components/schemas/OutputMessage" + - $ref: "#/components/schemas/FileSearchToolCall" + - $ref: "#/components/schemas/FunctionToolCall" + - $ref: "#/components/schemas/WebSearchToolCall" + - $ref: "#/components/schemas/ComputerToolCall" + - $ref: "#/components/schemas/ReasoningItem" + x-oaiExpandable: true + discriminator: + propertyName: type + 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. + x-oaiExpandable: true + items: + x-oaiExpandable: true + $ref: "#/components/schemas/OutputContent" + 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 + OutputText: + 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. + annotations: + type: array + description: | + The annotations of the text output. + items: + x-oaiExpandable: true + $ref: "#/components/schemas/Annotation" + required: + - type + - text + - annotations + ParallelToolCalls: + description: Whether to enable [parallel function calling](https://platform.openai.com/docs/guides/function-calling/parallel-function-calling) during tool use. + type: boolean + default: true + + ChatCompletionMessageToolCalls: + type: array + description: The tool calls generated by the model, such as function calls. + items: + $ref: "#/components/schemas/ChatCompletionMessageToolCall" + + ChatCompletionMessageToolCall: + type: object + properties: + # TODO: index included when streaming + 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 + + ChatCompletionMessageToolCallChunk: + type: object + properties: + index: + type: integer + 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 + 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: + - index + + # Note, this isn't referenced anywhere, but is kept as a convenience to record all possible roles in one place. + ChatCompletionRole: + type: string + description: The role of the author of a message + enum: + - system + - user + - assistant + - tool + - function + + 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. + + ChatCompletionMessageContentBlock: + type: object + description: A block of content in a chat completion message. + oneOf: + - $ref: "#/components/schemas/ChatCompletionRequestMessageContentPartText" + - $ref: "#/components/schemas/ChatCompletionMessageContentPartThinking" + - $ref: "#/components/schemas/ChatCompletionMessageContentPartRedactedThinking" + + ChatCompletionResponseMessage: + type: object + description: A chat completion message generated by the model. + properties: + content: + type: string + description: The contents of the message. + 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 + content_blocks: + nullable: true + type: array + description: The content blocks of the message. This is only present for certain providers with strict-open-ai-compliance flag set to false + items: type: object - description: Details of the Code Interpreter tool call the run step was involved in. - properties: - index: - type: integer - description: The index of the tool call in the tool calls array. - 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. - 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/RunStepDeltaStepDetailsToolCallsCodeOutputLogsObject" - - $ref: "#/components/schemas/RunStepDeltaStepDetailsToolCallsCodeOutputImageObject" - x-oaiExpandable: true - required: - - index - - type - - RunStepDetailsToolCallsCodeOutputLogsObject: - title: Code Interpreter log output + $ref: "#/components/schemas/ChatCompletionMessageContentBlock" + required: + - role + - content + + ChatCompletionStreamResponseDelta: + type: object + description: A chat completion delta generated by streamed model responses. + properties: + content: + type: string + description: The contents of the chunk message. + nullable: true + function_call: + deprecated: true + type: object + 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. + tool_calls: + type: array + items: + $ref: "#/components/schemas/ChatCompletionMessageToolCallChunk" + role: + type: string + enum: ["system", "user", "assistant", "tool"] + description: The role of the author of this message. + + CreateChatCompletionRequest: + type: object + properties: + messages: + description: A list of messages comprising the conversation so far. [Example Python code](https://cookbook.openai.com/examples/how_to_format_inputs_to_chatgpt_models). + type: array + minItems: 1 + items: + $ref: "#/components/schemas/ChatCompletionRequestMessage" + model: + description: ID of the model to use. See the [model endpoint compatibility](https://platform.openai.com/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API. + example: "gpt-4-turbo" + anyOf: + - type: string + - type: string + enum: + [ + "gpt-4o", + "gpt-4o-2024-05-13", + "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 + frequency_penalty: + type: number + default: 0 + minimum: -2 + maximum: 2 + nullable: true + description: *completions_frequency_penalty_description + 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](https://platform.openai.com/tokenizer?view=bpe) that can be generated in the chat completion. + + The total length of input tokens and generated tokens is limited by the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. + 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. + presence_penalty: + type: number + default: 0 + minimum: -2 + maximum: 2 + nullable: true + description: *completions_presence_penalty_description + response_format: + type: object + 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. Works across all the providers that support this functionality. [OpenAI & Azure OpenAI](/integrations/llms/openai/structured-outputs), [Gemini & Vertex AI](/integrations/llms/vertex-ai/controlled-generations). + + 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" + seed: + type: integer + minimum: -9223372036854775808 + maximum: 9223372036854775807 + 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-code-samples: + beta: true + 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-UShttps://platform.openai.com/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" + thinking: + type: object + nullable: true + description: | + View the thinking/reasoning tokens as part of your response. Thinking models produce a long internal chain of thought before generating a response. Supported only for specific Claude models on Anthropic, Google Vertex AI, and AWS Bedrock. Requires setting `strict_openai_compliance = false` in your API call. + properties: + type: + type: string + enum: ["enabled", "disabled"] + description: Enables or disables the thinking mode capability. + default: "disabled" + budget_tokens: + type: integer + description: | + The maximum number of tokens to allocate for the thinking process. + A higher token budget allows for more thorough reasoning but may increase overall response time. + minimum: 1 + example: 2030 + required: + - type + example: { "type": "enabled", "budget_tokens": 2030 } + temperature: + type: number + minimum: 0 + maximum: 2 + default: 1 + example: 1 + nullable: true + description: *completions_temperature_description + top_p: + type: number + minimum: 0 + maximum: 1 + default: 1 + example: 1 + nullable: true + description: *completions_top_p_description + 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: *end_user_param_configuration + 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 - 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 - - RunStepDeltaStepDetailsToolCallsCodeOutputLogsObject: - title: Code interpreter log output - type: object - description: Text output from the Code Interpreter tool call as part of a run step. + - finish_reason + - index + - message + - logprobs properties: - index: - type: integer - description: The index of the output in the outputs array. - type: - description: Always `logs`. - type: string - enum: ["logs"] - logs: - type: string - description: The text output from the Code Interpreter tool call. - required: - - index - - type - - RunStepDetailsToolCallsCodeOutputImageObject: - title: Code Interpreter image output + finish_reason: + type: string + description: &chat_completion_finish_reason_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: &chat_completion_response_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 + required: + - content + 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. + 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 + + CreateChatCompletionFunctionResponse: + 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 - 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 - - RunStepDeltaStepDetailsToolCallsCodeOutputImageObject: - title: Code interpreter image output - type: object + - finish_reason + - index + - message + - logprobs properties: - index: - type: integer - description: The index of the output in the outputs array. - 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: - - index - - type - - RunStepDetailsToolCallsFileSearchObject: - title: File search tool call + finish_reason: + type: string + description: + &chat_completion_function_finish_reason_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, or `function_call` if the model called a function. + enum: ["stop", "length", "function_call", "content_filter"] + index: + type: integer + description: The index of the choice in the list of choices. + message: + $ref: "#/components/schemas/ChatCompletionResponseMessage" + 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. + 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 + + ChatCompletionTokenLogprob: + type: object + properties: + token: &chat_completion_response_logprobs_token + description: The token. + type: string + logprob: &chat_completion_response_logprobs_token_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: &chat_completion_response_logprobs_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: - 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 + token: *chat_completion_response_logprobs_token + logprob: *chat_completion_response_logprobs_token_logprob + bytes: *chat_completion_response_logprobs_bytes required: - - id - - type - - file_search - - RunStepDeltaStepDetailsToolCallsFileSearchObject: - title: File search tool call + - token + - logprob + - bytes + required: + - token + - logprob + - bytes + - top_logprobs + + 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 + + CreateChatCompletionStreamResponse: + type: object + description: Represents a streamed chunk of a chat completion response returned by model, based on the provided input. + properties: + id: + type: string + description: A unique identifier for the chat completion. Each chunk has the same ID. + choices: + type: array + description: | + A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the + last chunk if you set `stream_options: {"include_usage": true}`. + items: type: object - properties: - index: - type: integer - description: The index of the tool call in the tool calls array. - 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 required: - - index - - type - - file_search - - RunStepDetailsToolCallsFunctionObject: + - delta + - finish_reason + - index + properties: + delta: + $ref: "#/components/schemas/ChatCompletionStreamResponseDelta" + logprobs: *chat_completion_response_logprobs + finish_reason: + type: string + description: *chat_completion_finish_reason_description + enum: + [ + "stop", + "length", + "tool_calls", + "content_filter", + "function_call", + ] + nullable: true + index: + type: integer + description: The index of the choice in the list of choices. + created: + type: integer + description: The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp. + model: + type: string + description: The model to generate the 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 `chat.completion.chunk`. + enum: [chat.completion.chunk] + usage: + type: object + description: | + An optional field that will only be present when you set `stream_options: {"include_usage": true}` in your request. + When present, it contains a null value except for the last chunk which contains the token usage statistics for the entire 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). + required: + - prompt_tokens + - completion_tokens + - total_tokens + required: + - choices + - created + - id + - model + - object + + CreateChatCompletionImageResponse: + type: object + description: Represents a streamed chunk of a chat completion response returned by model, based on the provided input. + + 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: &images_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: &images_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: &images_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: *end_user_param_configuration + required: + - prompt + + ImagesResponse: + properties: + created: + type: integer + data: + type: array + items: + $ref: "#/components/schemas/Image" + required: + - created + - data + Includable: + type: string + description: > + Specify additional output data to include in the model response. + Currently + + supported values are: + + - `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. + + - `computer_call_output.output.image_url`: Include image urls from the + computer call output. + enum: + - file_search_call.results + - message.input_image.image_url + - computer_call_output.output.image_url + 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 + FunctionTool: + type: object + title: Function + description: > + Defines a function in your own code the model can choose to call. Learn + more + + about [function calling](/docs/guides/function-calling). + properties: + type: + type: string + enum: + - function + description: | + The type of the function tool. Always `function`. + x-stainless-const: true + name: + type: string + description: | + The name of the function to call. + description: + type: string + nullable: true + description: > + A description of the function. Used by the model to determine + whether + + or not to call the function. + parameters: + type: object + description: | + A JSON schema object describing the parameters of the function. + additionalProperties: true + strict: + type: boolean + description: | + Whether to enforce strict parameter validation. Default `true`. + required: + - type + - name + - parameters + - strict + 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. + 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 + 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: + type: string + description: | + A JSON string of the output of the function tool 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 + - call_id + - output + FunctionToolCallOutputResource: + allOf: + - $ref: "#/components/schemas/FunctionToolCallOutput" + - type: object + properties: + id: + type: string + description: | + The unique ID of the function call tool output. + required: + - id + FunctionToolCallResource: + allOf: + - $ref: "#/components/schemas/FunctionToolCall" + - type: object + properties: + id: + type: string + description: | + The unique ID of the function tool call. + required: + - id + Image: + type: object + description: Represents the url or the content of an image generated by the Portkey 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-code-samples: + name: The image object + example: | + { + "url": "...", + "revised_prompt": "..." + } + InputAudio: + type: object + title: Audio input + 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 + 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: + - type + - data + - format + InputContent: + oneOf: + - $ref: "#/components/schemas/InputText" + - $ref: "#/components/schemas/InputImage" + - $ref: "#/components/schemas/InputFile" + x-oaiExpandable: true + InputFile: + type: object + title: File input + description: | + A file input to the model. + properties: + type: + type: string + description: | + The type of the input item. Always `input_file`. + enum: + - 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. + required: + - type + InputImage: + type: object + title: Image input + description: > + An image input to the model. Learn about [image + inputs](/docs/guides/vision). + properties: + type: + type: string + description: | + The type of the input item. Always `input_image`. + enum: + - input_image + x-stainless-const: true + image_url: + type: string + description: > + The URL of the image to be sent to the model. A fully qualified URL + or + + base64 encoded image in a data URL. + nullable: true + file_id: + type: string + description: | + The ID of the file to be sent to the model. + nullable: true + 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`. + enum: + - high + - low + - auto + default: auto + required: + - type + - detail + InputItem: + oneOf: + - $ref: "#/components/schemas/EasyInputMessage" + - type: object + title: Item + description: | + An item representing part of the context for the response to be + generated by the model. Can contain text, images, and audio inputs, + as well as previous assistant responses and tool call outputs. + $ref: "#/components/schemas/Item" + - $ref: "#/components/schemas/ItemReference" + discriminator: + propertyName: type + 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 + InputMessageContentList: + type: array + title: Input item content list + description: > + A list of one or many input items to the model, containing different + content + + types. + x-oaiExpandable: true + items: + x-oaiExpandable: true + $ref: "#/components/schemas/InputContent" + InputMessageResource: + allOf: + - $ref: "#/components/schemas/InputMessage" + - type: object + properties: + id: + type: string + description: | + The unique ID of the message input. + required: + - id + InputText: + type: object + title: Text input + description: | + A text input to the model. + properties: + type: + type: string + description: | + The type of the input item. Always `input_text`. + enum: + - input_text + x-stainless-const: true + text: + type: string + description: | + The text input to the model. + required: + - type + - text + 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: &dalle2_images_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: *images_response_format + user: *end_user_param_configuration + required: + - prompt + - image + + 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: *images_n + response_format: *images_response_format + size: *dalle2_images_size + user: *end_user_param_configuration + required: + - image + CreateModelResponseProperties: + allOf: + - $ref: "#/components/schemas/ModelResponseProperties" + CreateModerationRequest: + type: object + properties: + input: + description: The input text to classify + oneOf: + - type: string + default: "" + example: "I want to kill them." + - type: array + items: + type: string + default: "" + example: "I want to kill them." + model: + description: | + Two content moderations models are available: `text-moderation-stable` and `text-moderation-latest`. + + The default is `text-moderation-latest` which will be automatically upgraded over time. This ensures you are always using our most accurate model. If you use `text-moderation-stable`, we will provide advanced notice before updating the model. Accuracy of `text-moderation-stable` may be slightly lower than for `text-moderation-latest`. + nullable: false + default: "text-moderation-latest" + example: "text-moderation-stable" + anyOf: + - type: string + - type: string + enum: ["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 - 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 + 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. + 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 + - 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'. + 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 + - self-harm + - self-harm/intent + - self-harm/instructions + - sexual + - sexual/minors + - violence + - violence/graphic required: - - id - - type - - function + - flagged + - categories + - category_scores + required: + - id + - model + - results + CreateResponse: + allOf: + - $ref: "#/components/schemas/CreateModelResponseProperties" + - $ref: "#/components/schemas/ResponseProperties" + - type: object + properties: + input: + description: > + Text, image, or file inputs to the model, used to generate a + response. + + + Learn more: + + - [Text inputs and outputs](https://platform.openai.com/docs/guides/text?api-mode=responses) + + - [Image inputs](https://platform.openai.com/docs/guides/images-vision?api-mode=responses) + + - [File inputs](https://platform.openai.com/docs/guides/pdf-files?api-mode=responses) + + - [Conversation state](https://platform.openai.com/docs/guides/conversation-state?api-mode=responses) + + - [Function calling](https://platform.openai.com/docs/guides/function-calling?api-mode=responses) + x-oaiExpandable: true + oneOf: + - type: string + title: Text input + description: > + A text input to the model, equivalent to a text input with + the - RunStepDeltaStepDetailsToolCallsFunctionObject: + `user` role. + - type: array + title: Input item list + description: | + A list of one or many input items to the model, containing + different content types. + items: + x-oaiExpandable: true + $ref: "#/components/schemas/InputItem" + include: + type: array + description: > + Specify additional output data to include in the model response. + Currently + + supported values are: + + - `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. + + - `computer_call_output.output.image_url`: Include image urls + from the computer call output. + items: + x-oaiExpandable: true + $ref: "#/components/schemas/Includable" + nullable: true + parallel_tool_calls: + type: boolean + description: | + Whether to allow the model to run tool calls in parallel. + default: true + nullable: true + store: + type: boolean + description: > + Whether to store the generated model response for later + retrieval via + + API. + default: true + nullable: true + stream: + description: > + If set to true, the model response data will be streamed to the + client + + as it is generated using [server-sent + events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format). + + See the [Streaming section + below](/docs/api-reference/responses-streaming) + + for more information. + type: boolean + nullable: true + default: false + required: + - model + - input + ListFilesResponse: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/OpenAIFile" + object: + type: string + enum: [list] + required: + - object + - data + + 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](https://platform.openai.com/docs/api-reference/assistants) and [Message](https://platform.openai.com/docs/api-reference/messages) files, "vision" for Assistants image file inputs, "batch" for [Batch API](https://platform.openai.com/docs/guides/batch), and "fine-tune" for [Fine-tuning](https://platform.openai.com/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 + + BedrockFinetuneJob: + type: object + description: Gateway supported body params for bedrock fine-tuning. + title: Bedrock Params + properties: + job_name: + type: string + description: Job name for the bedrock finetune job + role_arn: + type: string + description: Role ARN for the bedrock finetune job + output_file: + type: string + description: Finetune job's output s3 location, will be constructed based on `training_file` if not provided + allOf: + - $ref: "#/components/schemas/OpenAIFinetuneJob" + + OpenAIFinetuneJob: + type: object + description: Gateway supported body params for OpenAI, Azure OpenAI and VertexAI. + title: OpenAI Params + required: + - model + - training_file + - suffix + - method + properties: + model: + type: string + description: The base model to finetune + training_file: + type: string + description: The training file to use for the finetune job + validation_file: + type: string + description: The validation file to use for the finetune job + suffix: + type: string + description: The suffix to append to the fine-tuned model name + method: + type: object + properties: + type: + type: string + enum: + - supervised + - dpo + supervised: + type: object + properties: + hyperparameters: + type: object + properties: + n_epochs: + type: integer + format: int32 + learning_rate_multiplier: + type: number + format: float + batch_size: + type: integer + format: int32 + required: + - n_epochs + - learning_rate_multiplier + - batch_size + required: + - hyperparameters + dpo: + type: object + properties: + hyperparameters: + type: object + properties: + n_epochs: + type: integer + format: int32 + learning_rate_multiplier: + type: number + format: float + batch_size: + type: integer + format: int32 + required: + - n_epochs + - learning_rate_multiplier + - batch_size + required: + - hyperparameters + required: + - type + description: Hyperparameters for the finetune job + + BedrockParams: + type: object + properties: + job_name: + type: string + description: Job name for the bedrock finetune job + role_arn: + type: string + description: Role ARN for the bedrock finetune job + output_file: + type: string + description: Finetune job's output s3 location, will be constructed based on `training_file` if not provided + + PortkeyFinetuneJob: + type: object + properties: + job_name: + type: string + description: Job name for the bedrock finetune job + role_arn: + type: string + description: Role ARN for the bedrock finetune job + output_file: + type: string + description: Finetune job's output s3 location, will be constructed based on `training_file` if not provided + portkey_options: + allOf: + - $ref: "#/components/schemas/PortkeyOptions" + description: Portkey Gateway Provider specific headers to be passed to the provider, if portkey is used as a provider + provider_options: + allOf: + - $ref: "#/components/schemas/BedrockParams" + description: Provider specific options to be passed to the provider, optional can be passed directly as well. Can be skipped if same keys are passed at top the level. + allOf: + - $ref: "#/components/schemas/OpenAIFinetuneJob" + description: Gateway supported body params for portkey managed fine-tuning. + title: Portkey Params + PortkeyOptions: + type: object + required: + - x-portkey-virtual-key + properties: + x-portkey-virtual-key: + type: string + description: The virtual key to communicate with the provider + x-portkey-aws-s3-bucket: + type: string + description: The AWS S3 bucket to use for file upload during finetune + x-portkey-vertex-storage-bucket-name: + type: string + description: Google Storage bucket to use for file upload during finetune + example: + x-portkey-virtual-key: vkey-1234567890 + x-portkey-aws-s3-bucket: my-bucket + x-portkey-vertex-storage-bucket-name: my-bucket + description: Options to be passed to the provider, supports all options supported by the provider from gateway. + + VertexFinetuneJob: + type: object + allOf: + - $ref: "#/components/schemas/OpenAIFinetuneJob" + + ListFineTuningJobEventsResponse: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/FineTuningJobEvent" + object: + type: string + enum: [list] + required: + - object + - data + + 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 + + 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: *model_description + 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: *end_user_param_configuration + 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 + + 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. The options are `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, and `whisper-1`. + 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](https://platform.openai.com/docs/guides/speech-to-text/prompting) should match the audio language. + type: string + response_format: + description: | + The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`. + type: string + enum: + - json + - text + - srt + - verbose_json + - vtt + default: json + 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 + + # Note: This does not currently support the non-default response format types. + 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 + + 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 + + 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] + + 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] + + 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. The options are `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, and `whisper-1`. + 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](https://platform.openai.com/docs/guides/speech-to-text/prompting) should be in English. + type: string + response_format: + description: | + The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`. + type: string + default: json + 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 + + # Note: This does not currently support the non-default response format types. + 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] + + CreateSpeechRequest: + type: object + additionalProperties: false + properties: + model: + description: | + One of the available [TTS models](https://platform.openai.com/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](https://platform.openai.com/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.0 + minimum: 0.25 + maximum: 4.0 + required: + - model + - input + - voice + + 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 + Move: + type: object + title: Move + description: | + A mouse move action. + properties: + type: + type: string + enum: + - move + default: move + description: | + Specifies the event type. For a move action, this property is + always set to `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. + required: + - type + - x + - y + 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-code-samples: + name: The file object + example: | + { + "id": "file-abc123", + "object": "file", + "bytes": 120000, + "created_at": 1677610602, + "filename": "salesOverview.pdf", + "purpose": "assistants", + } + DoubleClick: + type: object + title: DoubleClick + description: | + A double click action. + properties: + type: + type: string + enum: + - double_click + default: double_click + description: > + Specifies the event type. For a double click action, this property + is + + always set to `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. + required: + - type + - x + - y + Drag: + type: object + title: Drag + description: | + A drag action. + properties: + type: + type: string + enum: + - drag + default: drag + description: | + Specifies the event type. For a drag action, this property is + always set to `drag`. + x-stainless-const: true + path: + 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 } + ] + + ``` + x-oaiExpandable: true + items: + title: Drag path coordinates + x-oaiExpandable: true + description: | + A series of x/y coordinate pairs in the drag path. + $ref: "#/components/schemas/Coordinate" + required: + - type + - path + 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. + x-oaiExpandable: true + oneOf: + - type: string + title: Text input + description: | + A text input to the model. + - $ref: "#/components/schemas/InputMessageContentList" + type: + type: string + description: | + The type of the message input. Always `message`. + enum: + - message + x-stainless-const: true + required: + - role + - content + 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](https://platform.openai.com/docs/guides/embeddings). + items: + type: number + object: + type: string + description: The object type, which is always "embedding". + enum: [embedding] + required: + - index + - object + - embedding + x-code-samples: + name: The embedding object + example: | + { + "object": "embedding", + "embedding": [ + 0.0023064255, + -0.009327292, + .... (1536 floats total for ada-002) + -0.0028842222, + ], + "index": 0 + } + + FineTuningJob: + type: object + title: FineTuningJob + 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. + created_at: + type: integer + 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. + properties: + code: + type: string + description: A machine-readable error code. + message: + 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 + 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. + 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. + hyperparameters: + type: object + description: The hyperparameters used for the fine-tuning job. See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning) for more details. + properties: + n_epochs: + oneOf: + - type: string + enum: [auto] + - 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". + enum: [fine_tuning.job] + 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](https://platform.openai.com/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`. + enum: + [ + "validating_files", + "queued", + "running", + "succeeded", + "failed", + "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. + training_file: + type: string + description: The file ID used for training. You can retrieve the training data with the [Files API](https://platform.openai.com/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](https://platform.openai.com/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 + + 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" + + FineTuningJobEvent: + 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-code-samples: + 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" + } + + 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] + required: + - created_at + - fine_tuning_job_id + - fine_tuned_model_checkpoint + - id + - metrics + - object + - step_number + x-code-samples: + 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-3.5-turbo-0125: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 + } + + FinetuneChatRequestInput: + type: object + description: The per-line training example of a fine-tuning input file for chat models + properties: + messages: + type: array + minItems: 1 + items: + oneOf: + - $ref: "#/components/schemas/ChatCompletionRequestSystemMessage" + - $ref: "#/components/schemas/ChatCompletionRequestUserMessage" + - $ref: "#/components/schemas/FineTuneChatCompletionRequestAssistantMessage" + - $ref: "#/components/schemas/FineTuneChatCompletionRequestFunctionMessage" + x-oaiExpandable: true + functions: + description: A list of functions the model may generate JSON inputs for. + type: array + minItems: 1 + maxItems: 128 + items: + $ref: "#/components/schemas/ChatCompletionFunctions" + x-code-samples: + name: Training format for chat models + example: | + {"messages":[{"role":"user","content":"What is the weather in San Francisco?"},{"role":"assistant","function_call":{"name":"get_current_weather","arguments":"{\"location\": \"San Francisco, USA\", \"format\": \"celsius\"}"}}],"functions":[{"name":"get_current_weather","description":"Get the current weather","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and country, eg. San Francisco, USA"},"format":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location","format"]}}]} + + FinetuneCompletionRequestInput: + type: object + description: The per-line training example of a fine-tuning input file for completions models + properties: + prompt: + type: string + description: The input prompt for this training example. + completion: + type: string + description: The desired completion for this training example. + x-code-samples: + name: Training format for completions models + example: | + {"prompt": "What is the answer to 2+2", "completion": "4"} + Click: + type: object + title: Click + description: | + A click action. + properties: + type: + type: string + enum: + - click + default: click + description: | + Specifies the event type. For a click action, this property is + always set to `click`. + x-stainless-const: true + button: + type: string + enum: + - left + - right + - wheel + - back + - forward + 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. + required: + - type + - button + - x + - y + CodeInterpreterFileOutput: + type: object + title: Code interpreter file output + description: | + The output of a code interpreter tool call that is a file. + properties: + type: + type: string + enum: + - files + description: | + The type of the code interpreter file output. Always `files`. + x-stainless-const: true + files: + type: array + items: type: object - title: Function tool call properties: - index: - type: integer - description: The index of the tool call in the tool calls array. - 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 + mime_type: + type: string + description: | + The MIME type of the file. + file_id: + type: string + description: | + The ID of the file. required: - - index - - type - - VectorStoreExpirationAfter: + - mime_type + - file_id + required: + - type + - files + CodeInterpreterTextOutput: + type: object + title: Code interpreter text output + description: | + The output of a code interpreter tool call that is text. + properties: + type: + type: string + enum: + - logs + description: | + The type of the code interpreter text output. Always `logs`. + x-stainless-const: true + logs: + type: string + description: | + The logs of the code interpreter tool call. + required: + - type + - logs + CodeInterpreterTool: + type: object + title: Code interpreter + description: | + A tool that runs code. + properties: + type: + type: string + enum: + - code_interpreter + description: | + The type of the code interpreter tool. Always `code_interpreter`. + x-stainless-const: true + file_ids: + type: array + items: + type: string + description: | + The IDs of the files to run the code on. + required: + - type + - file_ids + CodeInterpreterToolCall: + type: object + title: Code interpreter tool call + description: | + A tool call to run code. + properties: + id: + type: string + description: | + The unique ID of the code interpreter tool call. + type: + type: string + enum: + - code_interpreter_call + description: > + The type of the code interpreter tool call. Always + `code_interpreter_call`. + x-stainless-const: true + code: + type: string + description: | + The code to run. + status: + type: string + enum: + - in_progress + - interpreting + - completed + description: | + The status of the code interpreter tool call. + results: + type: array + items: + x-oaiExpandable: true + $ref: "#/components/schemas/CodeInterpreterToolOutput" + description: | + The results of the code interpreter tool call. + required: + - id + - type + - code + - status + - results + CodeInterpreterToolOutput: + oneOf: + - $ref: "#/components/schemas/CodeInterpreterTextOutput" + - $ref: "#/components/schemas/CodeInterpreterFileOutput" + 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 + description: > + Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, + `lte`. + + - `eq`: equals + + - `ne`: not equal + + - `gt`: greater than + + - `gte`: greater than or equal + + - `lt`: less than + + - `lte`: less than or equal + key: + type: string + description: The key to compare against the value. + value: + oneOf: + - type: string + - type: number + - type: boolean + description: + The value to compare against the attribute key; supports string, + number, or boolean types. + required: + - type + - key + - value + 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 + 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). + required: + - prompt_tokens + - completion_tokens + - total_tokens + CompoundFilter: + 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" + - type: object + additionalProperties: true + required: + - type + - filters + ComputerAction: + oneOf: + - $ref: "#/components/schemas/Click" + - $ref: "#/components/schemas/DoubleClick" + - $ref: "#/components/schemas/Drag" + - $ref: "#/components/schemas/KeyPress" + - $ref: "#/components/schemas/Move" + - $ref: "#/components/schemas/Screenshot" + - $ref: "#/components/schemas/Scroll" + - $ref: "#/components/schemas/Type" + - $ref: "#/components/schemas/Wait" + 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 + description: The URL of the screenshot image. + file_id: + type: string + description: The identifier of an uploaded file that contains the screenshot. + required: + - type + ComputerTool: + type: object + title: Computer use + description: | + A tool that controls a virtual computer. Learn more about the + [computer tool](/docs/guides/tools-computer-use). + properties: + type: + type: string + enum: + - computer_use_preview + description: | + The type of the computer use tool. Always `computer_use_preview`. + x-stainless-const: true + display_width: + type: number + description: | + The width of the computer display. + display_height: + type: number + description: | + The height of the computer display. + environment: + type: string + description: | + The type of computer environment to control. + enum: + - mac + - windows + - ubuntu + - browser + required: + - type + - display_width + - display_height + - environment + 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" + x-oaiExpandable: true + pending_safety_checks: + type: array + x-oaiExpandable: true + items: + $ref: "#/components/schemas/ComputerToolCallSafetyCheck" + 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 + - action + - call_id + - pending_safety_checks + - status + 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 + x-oaiExpandable: true + description: > + The safety checks reported by the API that have been acknowledged by + the + + developer. + items: + $ref: "#/components/schemas/ComputerToolCallSafetyCheck" + 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 + ComputerToolCallOutputResource: + allOf: + - $ref: "#/components/schemas/ComputerToolCallOutput" + - type: object + properties: + id: + type: string + description: | + The unique ID of the computer call tool output. + required: + - id + ComputerToolCallSafetyCheck: + type: object + description: | + A pending safety check for the computer call. + 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. + required: + - id + - code + - message + Content: + description: | + Multi-modal input and output contents. + oneOf: + - title: Input content types + x-oaiExpandable: true + $ref: "#/components/schemas/InputContent" + - title: Output content types + x-oaiExpandable: true + $ref: "#/components/schemas/OutputContent" + Coordinate: + type: object + title: Coordinate + description: | + An x/y coordinate pair, e.g. `{ x: 100, y: 200 }`. + properties: + x: + type: integer + description: | + The x-coordinate. + y: + type: integer + description: | + The y-coordinate. + required: + - x + - y + 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 + nullable: true + description: + When `group_by=line_item`, this field provides the line item of the + grouped costs result. + project_id: + type: string + nullable: true + description: + When `group_by=project_id`, this field provides the project ID of + the grouped costs result. + required: + - object + Reasoning: + type: object + description: | + **o-series models only** + + Configuration options for + [reasoning models](https://platform.openai.com/docs/guides/reasoning). + title: Reasoning + x-oaiExpandable: true + properties: + effort: + $ref: "#/components/schemas/ReasoningEffort" + generate_summary: + type: string + description: > + **computer_use_preview only** + + + A summary of the reasoning performed by the model. This can be + + useful for debugging and understanding the model's reasoning + process. + + One of `concise` or `detailed`. + enum: + - concise + - detailed + nullable: true + ReasoningEffort: + type: string + enum: + - low + - medium + - high + default: medium + nullable: true + description: | + **o-series models only** + + Constrains effort on reasoning for + [reasoning models](https://platform.openai.com/docs/guides/reasoning). + Currently supported values are `low`, `medium`, and `high`. Reducing + reasoning effort can result in faster responses and fewer tokens used + on reasoning in a response. + ReasoningItem: + type: object + description: > + A description of the chain of thought used by a reasoning model while + generating + + a response. + title: Reasoning + x-oaiExpandable: true + 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. + summary: + type: array + description: | + Reasoning text contents. + items: 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 + type: + type: string + description: | + The type of the object. Always `summary_text`. + enum: + - summary_text + x-stainless-const: true + text: + type: string + description: > + A short summary of the reasoning used by the model when + generating + + the response. required: - - anchor - - days - - 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 + - text + 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 + Refusal: + type: object + title: Refusal + description: | + A refusal from the model. + properties: + type: + type: string + description: | + The type of the refusal. Always `refusal`. + enum: + - refusal + x-stainless-const: true + refusal: + type: string + description: | + The refusal explanationfrom the model. + required: + - type + - refusal + Response: + allOf: + - $ref: "#/components/schemas/ModelResponseProperties" + - $ref: "#/components/schemas/ResponseProperties" + - type: object + properties: + id: + type: string + description: | + Unique identifier for this Response. + object: + type: string + description: | + The object type of this resource - always set to `response`. + enum: + - response + x-stainless-const: true + status: + type: string + description: > + The status of the response generation. One of `completed`, + `failed`, + + `in_progress`, or `incomplete`. + enum: + - completed + - failed + - in_progress + - incomplete + created_at: + type: number + description: | + Unix timestamp (in seconds) of when this Response was created. + error: + $ref: "#/components/schemas/ResponseError" + incomplete_details: + type: object + nullable: true + description: | + Details about why the response is incomplete. + properties: + reason: + type: string + description: The reason why the response is incomplete. + enum: + - max_output_tokens + - content_filter + output: + type: array + x-oaiExpandable: true + description: > + An array of content items generated by the model. + + + - The length and order of items in the `output` array is + dependent + on the model's response. + - Rather than accessing the first item in the `output` array + and + assuming it's an `assistant` message with the content generated by + the model, you might consider using the `output_text` property where + supported in SDKs. + items: + $ref: "#/components/schemas/OutputItem" + x-oaiExpandable: true + output_text: + type: string + nullable: true + description: > + SDK-only convenience property that contains the aggregated text + output + + from all `output_text` items in the `output` array, if any are + present. + + Supported in the Python and JavaScript SDKs. + x-oaiSupportedSDKs: + - python + - javascript + usage: + $ref: "#/components/schemas/ResponseUsage" + parallel_tool_calls: + type: boolean + description: | + Whether to allow the model to run tool calls in parallel. + default: true + required: + - id + - object + - created_at + - error + - incomplete_details + - instructions + - model + - tools + - output + - parallel_tool_calls + - metadata + - tool_choice + - temperature + - top_p + ResponseAudioDeltaEvent: + type: object + description: Emitted when there is a partial audio response. + properties: + type: + type: string + description: | + The type of the event. Always `response.audio.delta`. + enum: + - response.audio.delta + x-stainless-const: true + delta: + type: string + description: | + A chunk of Base64 encoded response audio bytes. + required: + - type + - delta + ResponseAudioDoneEvent: + type: object + description: Emitted when the audio response is complete. + properties: + type: + type: string + description: | + The type of the event. Always `response.audio.done`. + enum: + - response.audio.done + x-stainless-const: true + required: + - type + - response_id + ResponseAudioTranscriptDeltaEvent: + type: object + description: Emitted when there is a partial transcript of audio. + properties: + type: + type: string + description: | + The type of the event. Always `response.audio.transcript.delta`. + enum: + - response.audio.transcript.delta + x-stainless-const: true + delta: + type: string + description: | + The partial transcript of the audio response. + required: + - type + - response_id + - delta + ResponseAudioTranscriptDoneEvent: + type: object + description: Emitted when the full audio transcript is completed. + properties: + type: + type: string + description: | + The type of the event. Always `response.audio.transcript.done`. + enum: + - response.audio.transcript.done + x-stainless-const: true + required: + - type + - response_id + ResponseCodeInterpreterCallCodeDeltaEvent: + type: object + description: Emitted when a partial code snippet is added by the code interpreter. + properties: + type: + type: string + description: > + The type of the event. Always + `response.code_interpreter_call.code.delta`. + enum: + - response.code_interpreter_call.code.delta + x-stainless-const: true + output_index: + type: integer + description: > + The index of the output item that the code interpreter call is in + progress. + delta: + type: string + description: | + The partial code snippet added by the code interpreter. + required: + - type + - response_id + - output_index + - delta + ResponseCodeInterpreterCallCodeDoneEvent: + type: object + description: Emitted when code snippet output is finalized by the code interpreter. + properties: + type: + type: string + description: > + The type of the event. Always + `response.code_interpreter_call.code.done`. + enum: + - response.code_interpreter_call.code.done + x-stainless-const: true + output_index: + type: integer + description: > + The index of the output item that the code interpreter call is in + progress. + code: + type: string + description: | + The final code snippet output by the code interpreter. + required: + - type + - response_id + - output_index + - code + ResponseCodeInterpreterCallCompletedEvent: + type: object + description: Emitted when the code interpreter call is completed. + properties: + type: + type: string + description: > + The type of the event. Always + `response.code_interpreter_call.completed`. + enum: + - response.code_interpreter_call.completed + x-stainless-const: true + output_index: + type: integer + description: > + The index of the output item that the code interpreter call is in + progress. + code_interpreter_call: + $ref: "#/components/schemas/CodeInterpreterToolCall" + required: + - type + - response_id + - output_index + - code_interpreter_call + ResponseCodeInterpreterCallInProgressEvent: + type: object + description: Emitted when a code interpreter call is in progress. + properties: + type: + type: string + description: > + The type of the event. Always + `response.code_interpreter_call.in_progress`. + enum: + - response.code_interpreter_call.in_progress + x-stainless-const: true + output_index: + type: integer + description: > + The index of the output item that the code interpreter call is in + progress. + code_interpreter_call: + $ref: "#/components/schemas/CodeInterpreterToolCall" + required: + - type + - response_id + - output_index + - code_interpreter_call + ResponseCodeInterpreterCallInterpretingEvent: + type: object + description: + Emitted when the code interpreter is actively interpreting the code + snippet. + properties: + type: + type: string + description: > + The type of the event. Always + `response.code_interpreter_call.interpreting`. + enum: + - response.code_interpreter_call.interpreting + x-stainless-const: true + output_index: + type: integer + description: > + The index of the output item that the code interpreter call is in + progress. + code_interpreter_call: + $ref: "#/components/schemas/CodeInterpreterToolCall" + required: + - type + - response_id + - output_index + - code_interpreter_call + ResponseCompletedEvent: + type: object + description: Emitted when the model response is complete. + properties: + type: + type: string + description: | + The type of the event. Always `response.completed`. + enum: + - response.completed + x-stainless-const: true + response: + $ref: "#/components/schemas/Response" + description: | + Properties of the completed response. + required: + - type + - response + ResponseContentPartAddedEvent: + type: object + description: Emitted when a new content part is added. + properties: + type: + type: string + description: | + The type of the event. Always `response.content_part.added`. + enum: + - response.content_part.added + x-stainless-const: true + item_id: + type: string + description: | + The ID of the output item that the content part was added to. + output_index: + type: integer + description: | + The index of the output item that the content part was added to. + content_index: + type: integer + description: | + The index of the content part that was added. + part: + x-oaiExpandable: true + $ref: "#/components/schemas/OutputContent" + description: | + The content part that was added. + required: + - type + - item_id + - output_index + - content_index + - part + ResponseContentPartDoneEvent: + type: object + description: Emitted when a content part is done. + properties: + type: + type: string + description: | + The type of the event. Always `response.content_part.done`. + enum: + - response.content_part.done + x-stainless-const: true + item_id: + type: string + description: | + The ID of the output item that the content part was added to. + output_index: + type: integer + description: | + The index of the output item that the content part was added to. + content_index: + type: integer + description: | + The index of the content part that is done. + part: + x-oaiExpandable: true + $ref: "#/components/schemas/OutputContent" + description: | + The content part that is done. + required: + - type + - item_id + - output_index + - content_index + - part + ResponseCreatedEvent: + type: object + description: | + An event that is emitted when a response is created. + properties: + type: + type: string + description: | + The type of the event. Always `response.created`. + enum: + - response.created + x-stainless-const: true + response: + $ref: "#/components/schemas/Response" + description: | + The response that was created. + required: + - type + - response + ResponseError: + type: object + description: | + An error object returned when the model fails to generate a Response. + nullable: true + properties: + code: + $ref: "#/components/schemas/ResponseErrorCode" + message: + type: string + description: | + A human-readable description of the error. + required: + - code + - message + ResponseErrorCode: + type: string + description: | + The error code for the response. + enum: + - server_error + - rate_limit_exceeded + - invalid_prompt + - vector_store_timeout + - invalid_image + - invalid_image_format + - invalid_base64_image + - invalid_image_url + - image_too_large + - image_too_small + - image_parse_error + - image_content_policy_violation + - invalid_image_mode + - image_file_too_large + - unsupported_image_media_type + - empty_image_file + - failed_to_download_image + - image_file_not_found + ResponseErrorEvent: + type: object + description: Emitted when an error occurs. + properties: + type: + type: string + description: | + The type of the event. Always `error`. + enum: + - error + x-stainless-const: true + code: + type: string + description: | + The error code. + nullable: true + message: + type: string + description: | + The error message. + param: + type: string + description: | + The error parameter. + nullable: true + required: + - type + - code + - message + - param + ResponseFailedEvent: + type: object + description: | + An event that is emitted when a response fails. + properties: + type: + type: string + description: | + The type of the event. Always `response.failed`. + enum: + - response.failed + x-stainless-const: true + response: + $ref: "#/components/schemas/Response" + description: | + The response that failed. + required: + - type + - response + ResponseFileSearchCallCompletedEvent: + type: object + description: Emitted when a file search call is completed (results found). + properties: + type: + type: string + description: | + The type of the event. Always `response.file_search_call.completed`. + enum: + - response.file_search_call.completed + x-stainless-const: true + output_index: + type: integer + description: | + The index of the output item that the file search call is initiated. + item_id: + type: string + description: | + The ID of the output item that the file search call is initiated. + required: + - type + - output_index + - item_id + ResponseFileSearchCallInProgressEvent: + type: object + description: Emitted when a file search call is initiated. + properties: + type: + type: string + description: > + The type of the event. Always + `response.file_search_call.in_progress`. + enum: + - response.file_search_call.in_progress + x-stainless-const: true + output_index: + type: integer + description: | + The index of the output item that the file search call is initiated. + item_id: + type: string + description: | + The ID of the output item that the file search call is initiated. + required: + - type + - output_index + - item_id + ResponseFileSearchCallSearchingEvent: + type: object + description: Emitted when a file search is currently searching. + properties: + type: + type: string + description: | + The type of the event. Always `response.file_search_call.searching`. + enum: + - response.file_search_call.searching + x-stainless-const: true + output_index: + type: integer + description: | + The index of the output item that the file search call is searching. + item_id: + type: string + description: | + The ID of the output item that the file search call is initiated. + required: + - type + - output_index + - item_id + 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 + 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: + 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: + - name + required: + - type + - json_schema + 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 + 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 + ResponseFunctionCallArgumentsDeltaEvent: + type: object + description: Emitted when there is a partial function-call arguments delta. + properties: + type: + type: string + description: > + The type of the event. Always + `response.function_call_arguments.delta`. + enum: + - response.function_call_arguments.delta + x-stainless-const: true + item_id: + type: string + description: > + The ID of the output item that the function-call arguments delta is + added to. + output_index: + type: integer + description: > + The index of the output item that the function-call arguments delta + is added to. + delta: + type: string + description: | + The function-call arguments delta that is added. + required: + - type + - item_id + - output_index + - delta + ResponseFunctionCallArgumentsDoneEvent: + type: object + description: Emitted when function-call arguments are finalized. + properties: + type: + type: string + enum: + - response.function_call_arguments.done + x-stainless-const: true + item_id: + type: string + description: The ID of the item. + output_index: + type: integer + description: The index of the output item. + arguments: + type: string + description: The function-call arguments. + required: + - type + - item_id + - output_index + - arguments + ResponseInProgressEvent: + type: object + description: Emitted when the response is in progress. + properties: + type: + type: string + description: | + The type of the event. Always `response.in_progress`. + enum: + - response.in_progress + x-stainless-const: true + response: + $ref: "#/components/schemas/Response" + description: | + The response that is in progress. + required: + - type + - response + ResponseIncompleteEvent: + type: object + description: | + An event that is emitted when a response finishes as incomplete. + properties: + type: + type: string + description: | + The type of the event. Always `response.incomplete`. + enum: + - response.incomplete + x-stainless-const: true + response: + $ref: "#/components/schemas/Response" + description: | + The response that was incomplete. + required: + - type + - response + ResponseItemList: + type: object + description: A list of Response 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 items used to generate this response. + items: + $ref: "#/components/schemas/ItemResource" + 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-oaiExpandable: true + ResponseModalities: + type: array + nullable: true + description: > + Output types that you would like the model to generate. + + 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 + ResponseModalitiesTextOnly: + type: array + nullable: true + description: > + Output types that you would like the model to generate. + + Most models are capable of generating text, which is the default: + + + `["text"]` + + + This API will soon support other output modalities, including audio and + images. + items: + type: string + enum: + - text + ResponseOutputItemAddedEvent: + type: object + description: Emitted when a new output item is added. + properties: + type: + type: string + description: | + The type of the event. Always `response.output_item.added`. + enum: + - response.output_item.added + x-stainless-const: true + output_index: + type: integer + description: | + The index of the output item that was added. + item: + $ref: "#/components/schemas/OutputItem" + x-oaiExpandable: true + description: | + The output item that was added. + required: + - type + - output_index + - item + ResponseOutputItemDoneEvent: + type: object + description: Emitted when an output item is marked done. + properties: + type: + type: string + description: | + The type of the event. Always `response.output_item.done`. + enum: + - response.output_item.done + x-stainless-const: true + output_index: + type: integer + description: | + The index of the output item that was marked done. + item: + $ref: "#/components/schemas/OutputItem" + x-oaiExpandable: true + description: | + The output item that was marked done. + required: + - type + - output_index + - item + ResponseProperties: + type: object + properties: + previous_response_id: + type: string + description: | + The unique ID of the previous response to the model. Use this to + create multi-turn conversations. Learn more about + [conversation state](/docs/guides/conversation-state). + nullable: true + model: + description: > + Model ID used to generate the response, like `gpt-4o` or `o1`. + 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. + $ref: "#/components/schemas/ModelIdsResponses" + reasoning: + $ref: "#/components/schemas/Reasoning" + nullable: true + max_output_tokens: + description: > + An upper bound for the number of tokens that can be generated for a + response, including visible output tokens and [reasoning + tokens](/docs/guides/reasoning). + type: integer + nullable: true + instructions: + type: string + description: > + Inserts a system (or developer) message as the first item in the + model's context. + + + When using along with `previous_response_id`, the instructions from + a previous + + response will be not be carried over to the next response. This + makes it simple + + to swap out system (or developer) messages in new responses. + nullable: true + 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" + 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" + tool_choice: + description: > + How the model should select which tool (or tools) to use when + generating + + a response. See the `tools` parameter to see how to specify which + tools + + the model can call. + x-oaiExpandable: true + oneOf: + - $ref: "#/components/schemas/ToolChoiceOptions" + - $ref: "#/components/schemas/ToolChoiceTypes" + - $ref: "#/components/schemas/ToolChoiceFunction" + truncation: + type: string + description: > + The truncation strategy to use for the model response. + + - `auto`: If the context of this response and previous ones exceeds + the model's context window size, the model will truncate the + response to fit the context window by dropping input items in the + middle of the conversation. + - `disabled` (default): If a model response will exceed the context + window + size for a model, the request will fail with a 400 error. + enum: + - auto + - disabled + nullable: true + default: disabled + ResponseRefusalDeltaEvent: + type: object + description: Emitted when there is a partial refusal text. + properties: + type: + type: string + description: | + The type of the event. Always `response.refusal.delta`. + enum: + - response.refusal.delta + x-stainless-const: true + item_id: + type: string + description: | + The ID of the output item that the refusal text is added to. + output_index: + type: integer + description: | + The index of the output item that the refusal text is added to. + content_index: + type: integer + description: | + The index of the content part that the refusal text is added to. + delta: + type: string + description: | + The refusal text that is added. + required: + - type + - item_id + - output_index + - content_index + - delta + ResponseRefusalDoneEvent: + type: object + description: Emitted when refusal text is finalized. + properties: + type: + type: string + description: | + The type of the event. Always `response.refusal.done`. + enum: + - response.refusal.done + x-stainless-const: true + item_id: + type: string + description: | + The ID of the output item that the refusal text is finalized. + output_index: + type: integer + description: | + The index of the output item that the refusal text is finalized. + content_index: + type: integer + description: | + The index of the content part that the refusal text is finalized. + refusal: + type: string + description: | + The refusal text that is finalized. + required: + - type + - item_id + - output_index + - content_index + - refusal + ResponseStreamEvent: + anyOf: + - $ref: "#/components/schemas/ResponseAudioDeltaEvent" + - $ref: "#/components/schemas/ResponseAudioDoneEvent" + - $ref: "#/components/schemas/ResponseAudioTranscriptDeltaEvent" + - $ref: "#/components/schemas/ResponseAudioTranscriptDoneEvent" + - $ref: "#/components/schemas/ResponseCodeInterpreterCallCodeDeltaEvent" + - $ref: "#/components/schemas/ResponseCodeInterpreterCallCodeDoneEvent" + - $ref: "#/components/schemas/ResponseCodeInterpreterCallCompletedEvent" + - $ref: "#/components/schemas/ResponseCodeInterpreterCallInProgressEvent" + - $ref: "#/components/schemas/ResponseCodeInterpreterCallInterpretingEvent" + - $ref: "#/components/schemas/ResponseCompletedEvent" + - $ref: "#/components/schemas/ResponseContentPartAddedEvent" + - $ref: "#/components/schemas/ResponseContentPartDoneEvent" + - $ref: "#/components/schemas/ResponseCreatedEvent" + - $ref: "#/components/schemas/ResponseErrorEvent" + - $ref: "#/components/schemas/ResponseFileSearchCallCompletedEvent" + - $ref: "#/components/schemas/ResponseFileSearchCallInProgressEvent" + - $ref: "#/components/schemas/ResponseFileSearchCallSearchingEvent" + - $ref: "#/components/schemas/ResponseFunctionCallArgumentsDeltaEvent" + - $ref: "#/components/schemas/ResponseFunctionCallArgumentsDoneEvent" + - $ref: "#/components/schemas/ResponseInProgressEvent" + - $ref: "#/components/schemas/ResponseFailedEvent" + - $ref: "#/components/schemas/ResponseIncompleteEvent" + - $ref: "#/components/schemas/ResponseOutputItemAddedEvent" + - $ref: "#/components/schemas/ResponseOutputItemDoneEvent" + - $ref: "#/components/schemas/ResponseRefusalDeltaEvent" + - $ref: "#/components/schemas/ResponseRefusalDoneEvent" + - $ref: "#/components/schemas/ResponseTextAnnotationDeltaEvent" + - $ref: "#/components/schemas/ResponseTextDeltaEvent" + - $ref: "#/components/schemas/ResponseTextDoneEvent" + - $ref: "#/components/schemas/ResponseWebSearchCallCompletedEvent" + - $ref: "#/components/schemas/ResponseWebSearchCallInProgressEvent" + - $ref: "#/components/schemas/ResponseWebSearchCallSearchingEvent" + discriminator: + propertyName: type + ResponseTextAnnotationDeltaEvent: + type: object + description: Emitted when a text annotation is added. + properties: + type: + type: string + description: > + The type of the event. Always + `response.output_text.annotation.added`. + enum: + - response.output_text.annotation.added + x-stainless-const: true + item_id: + type: string + description: | + The ID of the output item that the text annotation was added to. + output_index: + type: integer + description: | + The index of the output item that the text annotation was added to. + content_index: + type: integer + description: | + The index of the content part that the text annotation was added to. + annotation_index: + type: integer + description: | + The index of the annotation that was added. + annotation: + $ref: "#/components/schemas/Annotation" + required: + - type + - item_id + - output_index + - content_index + - annotation_index + - annotation + ResponseTextDeltaEvent: + type: object + description: Emitted when there is an additional text delta. + properties: + type: + type: string + description: | + The type of the event. Always `response.output_text.delta`. + enum: + - response.output_text.delta + x-stainless-const: true + item_id: + type: string + description: | + The ID of the output item that the text delta was added to. + output_index: + type: integer + description: | + The index of the output item that the text delta was added to. + content_index: + type: integer + description: | + The index of the content part that the text delta was added to. + delta: + type: string + description: | + The text delta that was added. + required: + - type + - item_id + - output_index + - content_index + - delta + ResponseTextDoneEvent: + type: object + description: Emitted when text content is finalized. + properties: + type: + type: string + description: | + The type of the event. Always `response.output_text.done`. + enum: + - response.output_text.done + x-stainless-const: true + item_id: + type: string + description: | + The ID of the output item that the text content is finalized. + output_index: + type: integer + description: | + The index of the output item that the text content is finalized. + content_index: + type: integer + description: | + The index of the content part that the text content is finalized. + text: + type: string + description: | + The text content that is finalized. + required: + - type + - item_id + - output_index + - content_index + - text + ResponseUsage: + type: object + description: | + Represents token usage details including input tokens, output tokens, + a breakdown of output tokens, and the total tokens used. + 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 + ResponseWebSearchCallCompletedEvent: + type: object + description: Emitted when a web search call is completed. + properties: + type: + type: string + description: | + The type of the event. Always `response.web_search_call.completed`. + enum: + - response.web_search_call.completed + x-stainless-const: true + output_index: + type: integer + description: > + The index of the output item that the web search call is associated + with. + item_id: + type: string + description: | + Unique ID for the output item associated with the web search call. + required: + - type + - output_index + - item_id + ResponseWebSearchCallInProgressEvent: + type: object + description: Emitted when a web search call is initiated. + properties: + type: + type: string + description: > + The type of the event. Always `response.web_search_call.in_progress`. + enum: + - response.web_search_call.in_progress + x-stainless-const: true + output_index: + type: integer + description: > + The index of the output item that the web search call is associated + with. + item_id: + type: string + description: | + Unique ID for the output item associated with the web search call. + required: + - type + - output_index + - item_id + ResponseWebSearchCallSearchingEvent: + type: object + description: Emitted when a web search call is executing. + properties: + type: + type: string + description: | + The type of the event. Always `response.web_search_call.searching`. + enum: + - response.web_search_call.searching + x-stainless-const: true + output_index: + type: integer + description: > + The index of the output item that the web search call is associated + with. + item_id: + type: string + description: | + Unique ID for the output item associated with the web search call. + required: + - type + - output_index + - item_id + 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 + + 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 + + AssistantsApiResponseFormatOption: + description: | + Specifies the format that the model must output. Compatible with [GPT-4o](https://platform.openai.com/docs/models/gpt-4o), [GPT-4 Turbo](https://platform.openai.com/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_object" }` enables JSON mode, which guarantees 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: + - type: string + description: > + `auto` is the default value + enum: [none, auto] + - $ref: "#/components/schemas/AssistantsApiResponseFormat" + x-oaiExpandable: true + + AssistantsApiResponseFormat: + type: object + description: | + An object describing the expected output of the model. If `json_object` only `function` type `tools` are allowed to be passed to the Run. If `text` the model can return text or any value needed. + properties: + type: + type: string + enum: ["text", "json_object"] + example: "json_object" + default: "text" + description: Must be one of `text` or `json_object`. + Annotation: + oneOf: + - $ref: "#/components/schemas/FileCitation" + - $ref: "#/components/schemas/UrlCitation" + - $ref: "#/components/schemas/FilePath" + 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: &assistant_name_param_description | + The name of the assistant. The maximum length is 256 characters. + type: string + maxLength: 256 + nullable: true + description: + description: &assistant_description_param_description | + The description of the assistant. The maximum length is 512 characters. + type: string + maxLength: 512 + nullable: true + model: + description: *model_description + type: string + instructions: + description: &assistant_instructions_param_description | + The system instructions that the assistant uses. The maximum length is 256,000 characters. + type: string + maxLength: 256000 + nullable: true + tools: + description: &assistant_tools_param_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](https://platform.openai.com/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](https://platform.openai.com/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: &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 maxium of 512 characters long. + type: object + x-oaiTypeLabel: map + nullable: true + temperature: + description: &run_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: &run_top_p_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 + x-code-samples: + name: The assistant object + beta: true + example: *create_assistants_example + + CreateAssistantRequest: + type: object + additionalProperties: false + properties: + model: + description: *model_description + example: "gpt-4-turbo" + anyOf: + - type: string + - type: string + enum: + [ + "gpt-4o", + "gpt-4o-2024-05-13", + "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: *assistant_name_param_description + type: string + nullable: true + maxLength: 256 + description: + description: *assistant_description_param_description + type: string + nullable: true + maxLength: 512 + instructions: + description: *assistant_instructions_param_description + type: string + nullable: true + maxLength: 256000 + tools: + description: *assistant_tools_param_description + 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](https://platform.openai.com/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](https://platform.openai.com/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 - usage_bytes: - description: The total number of bytes used by the files in the vector store. - type: integer - file_counts: + vector_stores: + type: array + description: | + A helper to create a [vector store](https://platform.openai.com/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: - 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: *metadata_description - 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 - } + file_ids: + type: array + description: | + A list of [file](https://platform.openai.com/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: + # Ideally we'd reuse the chunking strategy schema here, but it doesn't expand properly + 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`. - CreateVectorStoreRequest: - type: object - additionalProperties: false - properties: + 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 maxium of 512 characters long. + x-oaiTypeLabel: map + oneOf: + - required: [vector_store_ids] + - required: [vector_stores] + nullable: true + metadata: + description: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: true + temperature: + description: *run_temperature_description + 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: *run_top_p_description + response_format: + $ref: "#/components/schemas/AssistantsApiResponseFormatOption" + nullable: true + required: + - model + 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 + nullable: true + ModelIdsResponses: + example: gpt-4o + anyOf: + - type: string + enum: + - o1-pro + - o1-pro-2025-03-19 + - computer-use-preview + - computer-use-preview-2025-03-11 + ModelResponseProperties: + type: object + properties: + 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. + + 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). + ModifyAssistantRequest: + type: object + additionalProperties: false + properties: + model: + description: *model_description + anyOf: + - type: string + name: + description: *assistant_name_param_description + type: string + nullable: true + maxLength: 256 + description: + description: *assistant_description_param_description + type: string + nullable: true + maxLength: 512 + instructions: + description: *assistant_instructions_param_description + type: string + nullable: true + maxLength: 256000 + tools: + description: *assistant_tools_param_description + 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: - 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: *metadata_description - type: object - x-oaiTypeLabel: map - nullable: true - - 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: *metadata_description - type: object - x-oaiTypeLabel: map - nullable: true - - 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 - - DeleteVectorStoreResponse: - type: object - properties: - id: - type: string - deleted: - type: boolean - object: - type: string - enum: [vector_store.deleted] - required: - - id - - object - - deleted - - VectorStoreFileObject: + type: array + description: | + Overrides the list of [file](https://platform.openai.com/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](https://platform.openai.com/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: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: true + temperature: + description: *run_temperature_description + 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: *run_top_p_description + 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 + Item: + type: object + description: | + Content item used to generate a response. + oneOf: + - $ref: "#/components/schemas/InputMessage" + - $ref: "#/components/schemas/OutputMessage" + - $ref: "#/components/schemas/FileSearchToolCall" + - $ref: "#/components/schemas/ComputerToolCall" + - $ref: "#/components/schemas/ComputerToolCallOutput" + - $ref: "#/components/schemas/WebSearchToolCall" + - $ref: "#/components/schemas/FunctionToolCall" + - $ref: "#/components/schemas/FunctionToolCallOutput" + - $ref: "#/components/schemas/ReasoningItem" + x-oaiExpandable: true + discriminator: + propertyName: type + ItemReference: + type: object + title: Item reference + description: | + An internal identifier for an item to reference. + properties: + id: + type: string + description: | + The ID of the item to reference. + type: + type: string + description: | + The type of item to reference. Always `item_reference`. + enum: + - item_reference + x-stainless-const: true + required: + - id + - type + ItemResource: + description: | + Content item used to generate a response. + oneOf: + - $ref: "#/components/schemas/InputMessageResource" + - $ref: "#/components/schemas/OutputMessage" + - $ref: "#/components/schemas/FileSearchToolCall" + - $ref: "#/components/schemas/ComputerToolCall" + - $ref: "#/components/schemas/ComputerToolCallOutputResource" + - $ref: "#/components/schemas/WebSearchToolCall" + - $ref: "#/components/schemas/FunctionToolCallResource" + - $ref: "#/components/schemas/FunctionToolCallOutputResource" + x-oaiExpandable: true + discriminator: + propertyName: type + KeyPress: + type: object + title: KeyPress + description: | + A collection of keypresses the model would like to perform. + properties: + type: + type: string + enum: + - keypress + default: keypress + description: | + Specifies the event type. For a keypress action, this property is + always set to `keypress`. + x-stainless-const: true + keys: + type: array + items: + type: string + description: | + One of the keys the model is requesting to be pressed. + description: > + The combination of keys the model is requesting to be pressed. This + is an + + array of strings, each representing a key. + required: + - type + - keys + 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-code-samples: + name: List assistants response object + group: chat + example: *list_assistants_example + + 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. + + Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/number-of-chunks-returned) for more information. + required: + - type + + AssistantToolsFileSearchTypeOnly: + type: object + title: FileSearch tool + properties: + type: + type: string + description: "The type of tool being defined: `file_search`" + enum: ["file_search"] + 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 + + 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 + + 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 + + RunObject: + type: object + title: A run on a thread + description: Represents an execution run on a [thread](https://platform.openai.com/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](https://platform.openai.com/docs/api-reference/threads) that was executed on as a part of this run. + type: string + assistant_id: + description: The ID of the [assistant](https://platform.openai.com/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](https://platform.openai.com/docs/api-reference/assistants) used for this run. + type: string + instructions: + description: The instructions that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run. + type: string + tools: + description: The list of tools that the [assistant](https://platform.openai.com/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: *metadata_description + 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 + x-code-samples: + name: The run object + 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-4-turbo", + "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 + } + CreateRunRequest: + type: object + additionalProperties: false + properties: + assistant_id: + description: The ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to execute this run. + type: string + model: + description: The ID of the [Model](https://platform.openai.com/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-4-turbo" + anyOf: + - type: string + - type: string + enum: + [ + "gpt-4o", + "gpt-4o-2024-05-13", + "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](https://platform.openai.com/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: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: true + temperature: + type: number + minimum: 0 + maximum: 2 + default: 1 + example: 1 + nullable: true + description: *run_temperature_description + top_p: + type: number + minimum: 0 + maximum: 1 + default: 1 + example: 1 + nullable: true + description: *run_top_p_description + 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: + - thread_id + - assistant_id + 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 + ModifyRunRequest: + type: object + additionalProperties: false + properties: + metadata: + description: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: true + 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 - 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. + 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 + 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. + oneOf: + - $ref: "#/components/schemas/ResponseFormatText" + - $ref: "#/components/schemas/TextResponseFormatJsonSchema" + - $ref: "#/components/schemas/ResponseFormatJsonObject" + x-oaiExpandable: true + 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 + 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 + - schema + 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](https://platform.openai.com/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 + Screenshot: + type: object + title: Screenshot + description: | + A screenshot action. + properties: + type: + type: string + enum: + - screenshot + default: screenshot + description: | + Specifies the event type. For a screenshot action, this property is + always set to `screenshot`. + x-stainless-const: true + required: + - type + Scroll: + type: object + title: Scroll + description: | + A scroll action. + properties: + type: + type: string + enum: + - scroll + default: scroll + description: | + Specifies the event type. For a scroll action, this property is + always set to `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. + required: + - type + - x + - y + - scroll_x + - scroll_y + CreateThreadAndRunRequest: + type: object + additionalProperties: false + properties: + assistant_id: + description: The ID of the [assistant](https://platform.openai.com/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](https://platform.openai.com/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-4-turbo" + anyOf: + - type: string + - type: string + enum: + [ + "gpt-4o", + "gpt-4o-2024-05-13", + "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](https://platform.openai.com/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](https://platform.openai.com/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: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: true + temperature: + type: number + minimum: 0 + maximum: 2 + default: 1 + example: 1 + nullable: true + description: *run_temperature_description + top_p: + type: number + minimum: 0 + maximum: 1 + default: 1 + example: 1 + nullable: true + description: *run_top_p_description + 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: + - thread_id + - assistant_id + + ThreadObject: + type: object + title: Thread + description: Represents a thread that contains [messages](https://platform.openai.com/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](https://platform.openai.com/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](https://platform.openai.com/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: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: true + required: + - id + - object + - created_at + - tool_resources + - metadata + x-code-samples: + name: The thread object + beta: true + example: | + { + "id": "thread_abc123", + "object": "thread", + "created_at": 1698107661, + "metadata": {} + } + + CreateThreadRequest: + type: object + additionalProperties: false + properties: + messages: + description: A list of [messages](https://platform.openai.com/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](https://platform.openai.com/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](https://platform.openai.com/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 - enum: ["in_progress", "completed", "cancelled", "failed"] - last_error: + vector_stores: + type: array + description: | + A helper to create a [vector store](https://platform.openai.com/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 - 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: - [ - "internal_error", - "file_not_found", - "parsing_error", - "unhandled_mime_type", - ] - 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 - 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 - } - } - } + file_ids: + type: array + description: | + A list of [file](https://platform.openai.com/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: + # Ideally we'd reuse the chunking strategy schema here, but it doesn't expand properly + 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`. - OtherChunkingStrategyResponseParam: + 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 maxium of 512 characters long. + x-oaiTypeLabel: map + x-oaiExpandable: true + oneOf: + - required: [vector_store_ids] + - required: [vector_stores] + nullable: true + metadata: + description: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: 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](https://platform.openai.com/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](https://platform.openai.com/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: *metadata_description + 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 + + ListThreadsResponse: + properties: + object: + type: string + example: "list" + data: + type: array + items: + $ref: "#/components/schemas/ThreadObject" + 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 + + MessageObject: + type: object + title: The message object + description: Represents a message within a [thread](https://platform.openai.com/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](https://platform.openai.com/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" + x-oaiExpandable: true + assistant_id: + description: If applicable, the ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) that authored this message. + type: string + nullable: true + run_id: + description: The ID of the [run](https://platform.openai.com/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 - 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 - - StaticChunkingStrategyResponseParam: + 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: *metadata_description + 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-code-samples: + 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": {} + } + + MessageDeltaObject: + type: object + title: Message delta object + description: | + Represents a message delta i.e. any changed fields on a message during streaming. + properties: + id: + description: The identifier of the message, which can be referenced in API endpoints. + type: string + object: + description: The object type, which is always `thread.message.delta`. + type: string + enum: ["thread.message.delta"] + delta: + description: The delta containing the fields that have changed on the Message. + type: object + properties: + 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/MessageDeltaContentImageFileObject" + - $ref: "#/components/schemas/MessageDeltaContentTextObject" + - $ref: "#/components/schemas/MessageDeltaContentImageUrlObject" + x-oaiExpandable: true + required: + - id + - object + - delta + x-code-samples: + name: The message delta object + beta: true + example: | + { + "id": "msg_123", + "object": "thread.message.delta", + "delta": { + "content": [ + { + "index": 0, + "type": "text", + "text": { "value": "Hello", "annotations": [] } + } + ] + } + } + + 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. + 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](https://platform.openai.com/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 - title: Static Chunking Strategy - additionalProperties: false 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: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: true + + ModifyMessageRequest: + type: object + additionalProperties: false + properties: + metadata: + description: *metadata_description + 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 + + 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 + + MessageContentImageFileObject: + title: Image file + type: object + description: References an image [File](https://platform.openai.com/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](https://platform.openai.com/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 + + MessageDeltaContentImageFileObject: + title: Image file + type: object + description: References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. + properties: + index: + type: integer + description: The index of the content part in the message. + type: + description: Always `image_file`. + type: string + enum: ["image_file"] + image_file: + type: object + properties: + file_id: + description: The [File](https://platform.openai.com/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: + - index + - type + + 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 + + MessageDeltaContentImageUrlObject: + title: Image URL + type: object + description: References an image URL in the content of a message. + properties: + index: + type: integer + description: The index of the content part in the message. + type: + description: Always `image_url`. + type: string + enum: ["image_url"] + image_url: + type: object + properties: + url: + description: "The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp." + type: string + detail: + type: string + description: Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. + enum: ["auto", "low", "high"] + default: "auto" + required: + - index + - 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"] + 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 + + 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 + + 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 + quote: + description: The specific quote in the file. + type: string + required: + - file_id + - quote + 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 + + MessageDeltaContentTextObject: + title: Text + type: object + description: The text content that is part of a message. + properties: + index: + type: integer + description: The index of the content part in the message. + 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/MessageDeltaContentTextAnnotationsFileCitationObject" + - $ref: "#/components/schemas/MessageDeltaContentTextAnnotationsFilePathObject" + x-oaiExpandable: true + required: + - index + - type + + MessageDeltaContentTextAnnotationsFileCitationObject: + 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: + index: + type: integer + description: The index of the annotation in the text content part. + 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 + quote: + description: The specific quote in the file. + type: string + start_index: + type: integer + minimum: 0 + end_index: + type: integer + minimum: 0 + required: + - index + - type + + MessageDeltaContentTextAnnotationsFilePathObject: + 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: + index: + type: integer + description: The index of the annotation in the text content part. + 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 + start_index: + type: integer + minimum: 0 + end_index: + type: integer + minimum: 0 + required: + - index + - type + + 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](https://platform.openai.com/docs/api-reference/assistants) associated with the run step. + type: string + thread_id: + description: The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) that was run. + type: string + run_id: + description: The ID of the [run](https://platform.openai.com/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: *metadata_description + 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-code-samples: + name: The run step object + beta: true + example: *run_step_object_example + + RunStepDeltaObject: + type: object + title: Run step delta object + description: | + Represents a run step delta i.e. any changed fields on a run step during streaming. + 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.delta`. + type: string + enum: ["thread.run.step.delta"] + delta: + description: The delta containing the fields that have changed on the run step. + type: object + properties: + step_details: + type: object + description: The details of the run step. + oneOf: + - $ref: "#/components/schemas/RunStepDeltaStepDetailsMessageCreationObject" + - $ref: "#/components/schemas/RunStepDeltaStepDetailsToolCallsObject" + x-oaiExpandable: true + required: + - id + - object + - delta + x-code-samples: + name: The run step delta object + beta: true + example: | + { + "id": "step_123", + "object": "thread.run.step.delta", + "delta": { + "step_details": { + "type": "tool_calls", + "tool_calls": [ + { + "index": 0, + "id": "call_123", + "type": "code_interpreter", + "code_interpreter": { "input": "", "outputs": [] } + } + ] + } + } + } + + 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 + + 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 + + RunStepDeltaStepDetailsMessageCreationObject: + 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: + - type + + 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 + + RunStepDeltaStepDetailsToolCallsObject: + 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/RunStepDeltaStepDetailsToolCallsCodeObject" + - $ref: "#/components/schemas/RunStepDeltaStepDetailsToolCallsFileSearchObject" + - $ref: "#/components/schemas/RunStepDeltaStepDetailsToolCallsFunctionObject" + x-oaiExpandable: true + required: + - type + + 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 + + RunStepDeltaStepDetailsToolCallsCodeObject: + title: Code interpreter tool call + type: object + description: Details of the Code Interpreter tool call the run step was involved in. + properties: + index: + type: integer + description: The index of the tool call in the tool calls array. + 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. + 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/RunStepDeltaStepDetailsToolCallsCodeOutputLogsObject" + - $ref: "#/components/schemas/RunStepDeltaStepDetailsToolCallsCodeOutputImageObject" + x-oaiExpandable: true + required: + - index + - type + + 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 + + RunStepDeltaStepDetailsToolCallsCodeOutputLogsObject: + title: Code interpreter log output + type: object + description: Text output from the Code Interpreter tool call as part of a run step. + properties: + index: + type: integer + description: The index of the output in the outputs array. + type: + description: Always `logs`. + type: string + enum: ["logs"] + logs: + type: string + description: The text output from the Code Interpreter tool call. + required: + - index + - type + + 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](https://platform.openai.com/docs/api-reference/files) ID of the image. + type: string + required: + - file_id + required: + - type + - image + + RunStepDeltaStepDetailsToolCallsCodeOutputImageObject: + title: Code interpreter image output + type: object + properties: + index: + type: integer + description: The index of the output in the outputs array. + type: + description: Always `image`. + type: string + enum: ["image"] + image: + type: object + properties: + file_id: + description: The [file](https://platform.openai.com/docs/api-reference/files) ID of the image. + type: string + required: + - index + - type + + 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 + required: + - id + - type + - file_search + + RunStepDeltaStepDetailsToolCallsFileSearchObject: + title: File search tool call + type: object + properties: + index: + type: integer + description: The index of the tool call in the tool calls array. + 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 + required: + - index + - 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](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs) yet. + nullable: true + required: + - name + - arguments + - output + required: + - id + - type + - function + + RunStepDeltaStepDetailsToolCallsFunctionObject: + type: object + title: Function tool call + properties: + index: + type: integer + description: The index of the tool call in the tool calls array. + 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](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs) yet. + nullable: true + required: + - index + - type + + 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 + + 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: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: true + required: + - id + - object + - usage_bytes + - created_at + - status + - last_active_at + - name + - file_counts + - metadata + x-code-samples: + 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 + } + VectorStoreSearchRequest: + type: object + additionalProperties: false + properties: + query: + description: A query string for a search + oneOf: + - type: string + - type: array + 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. + oneOf: + - $ref: "#/components/schemas/ComparisonFilter" + - $ref: "#/components/schemas/CompoundFilter" + x-oaiExpandable: true + ranking_options: + description: Ranking options for search. + type: object + additionalProperties: false + properties: + ranker: + type: string + enum: + - auto + - default-2024-11-15 + default: auto + score_threshold: + type: number + minimum: 0 + maximum: 1 + default: 0 + required: + - query + 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 + 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 + 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 + 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. + nullable: true + required: + - object + - search_query + - data + - has_more + - next_page + VoiceIdsShared: + example: ash + anyOf: + - type: string + - type: string + enum: + - alloy + - ash + - ballad + - coral + - echo + - fable + - onyx + - nova + - sage + - shimmer + - verse + Wait: + type: object + title: Wait + description: | + A wait action. + properties: + type: + type: string + enum: + - wait + default: wait + description: | + Specifies the event type. For a wait action, this property is + always set to `wait`. + x-stainless-const: true + required: + - type + WebSearchContextSize: + type: string + 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. + enum: + - low + - medium + - high + default: medium + WebSearchLocation: + type: object + title: Web search location + description: Approximate location parameters for the search. + properties: + 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`. + WebSearchTool: + type: object + title: Web search + description: | + This tool searches the web for relevant results to use in a response. + Learn more about the [web search tool](/docs/guides/tools-web-search). + 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` + - `web_search_preview_2025_03_11` + user_location: + allOf: + - $ref: "#/components/schemas/WebSearchLocation" + - type: object + properties: type: - type: string - description: Always `static`. - enum: ["static"] - static: - $ref: "#/components/schemas/StaticChunkingStrategy" - required: + type: string + description: | + The type of location approximation. Always `approximate`. + enum: + - approximate + x-stainless-const: true + 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: + nullable: true + search_context_size: + $ref: "#/components/schemas/WebSearchContextSize" + required: + - type + 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 + required: + - id + - type + - status + CreateVectorStoreRequest: + type: object + additionalProperties: false + properties: + file_ids: + description: A list of [File](https://platform.openai.com/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: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: true + Type: + type: object + title: Type + description: | + An action to type in text. + properties: + type: + type: string + enum: + - type + default: type + description: | + Specifies the event type. For a type action, this property is + always set to `type`. + x-stainless-const: true + text: + type: string + description: | + The text to type. + required: + - type + - text + 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: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: true + UrlCitation: + type: object + title: URL citation + description: | + A citation for a web resource used to generate a model response. + properties: + url: + type: string + description: | + The URL of the web resource. + title: + type: string + description: | + The title of the web resource. + type: + type: string + description: | + The type of the URL citation. Always `url_citation`. + enum: + - url_citation + x-stainless-const: true + 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. + required: + - url + - title + - type + - start_index + - end_index + 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 + + DeleteVectorStoreResponse: + type: object + properties: + id: + type: string + deleted: + type: boolean + object: + type: string + enum: [vector_store.deleted] + required: + - id + - object + - deleted + + 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](https://platform.openai.com/docs/api-reference/vector-stores/object) that the [File](https://platform.openai.com/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: + [ + "internal_error", + "file_not_found", + "parsing_error", + "unhandled_mime_type", + ] + 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 + x-code-samples: + 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 + } + } + } + + 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 + + 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 + + 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 + + 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 + + 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 + + CreateVectorStoreFileRequest: + type: object + additionalProperties: false + properties: + file_id: + description: A [File](https://platform.openai.com/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 + + 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 + + DeleteVectorStoreFileResponse: + type: object + properties: + id: + type: string + deleted: + type: boolean + object: + type: string + enum: [vector_store.file.deleted] + required: + - id + - object + - deleted + 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 + additionalProperties: + oneOf: + - type: string + maxLength: 512 + - type: number + - type: boolean + x-oaiTypeLabel: map + nullable: true + 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](https://platform.openai.com/docs/api-reference/vector-stores/object) that the [File](https://platform.openai.com/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-code-samples: + 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 + } + } + + CreateVectorStoreFileBatchRequest: + type: object + additionalProperties: false + properties: + file_ids: + description: A list of [File](https://platform.openai.com/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: + type: string + chunking_strategy: + $ref: "#/components/schemas/ChunkingStrategyRequestParam" + required: + - file_ids + + AssistantStreamEvent: + description: | + Represents an event emitted when streaming a Run. + + Each event in a server-sent events stream has an `event` and `data` property: + + ``` + event: thread.created + data: {"id": "thread_123", "object": "thread", ...} + ``` + + We emit events whenever a new object is created, transitions to a new state, or is being + streamed in parts (deltas). For example, we emit `thread.run.created` when a new run + is created, `thread.run.completed` when a run completes, and so on. When an Assistant chooses + to create a message during a run, we emit a `thread.message.created event`, a + `thread.message.in_progress` event, many `thread.message.delta` events, and finally a + `thread.message.completed` event. + + We may add additional events over time, so we recommend handling unknown events gracefully + in your code. See the [Assistants API quickstart](https://platform.openai.com/docs/assistants/overview) to learn how to + integrate the Assistants API with streaming. + oneOf: + - $ref: "#/components/schemas/ThreadStreamEvent" + - $ref: "#/components/schemas/RunStreamEvent" + - $ref: "#/components/schemas/RunStepStreamEvent" + - $ref: "#/components/schemas/MessageStreamEvent" + - $ref: "#/components/schemas/ErrorEvent" + - $ref: "#/components/schemas/DoneEvent" + x-code-samples: + name: Assistant stream events + beta: true + + ThreadStreamEvent: + oneOf: + - type: object + properties: + event: + type: string + enum: ["thread.created"] + data: + $ref: "#/components/schemas/ThreadObject" + required: + - event + - data + description: Occurs when a new [thread](https://platform.openai.com/docs/api-reference/threads/object) is created. + x-code-samples: + dataDescription: "`data` is a [thread](https://platform.openai.com/docs/api-reference/threads/object)" + Tool: + oneOf: + - $ref: "#/components/schemas/FileSearchTool" + - $ref: "#/components/schemas/FunctionTool" + - $ref: "#/components/schemas/ComputerTool" + - $ref: "#/components/schemas/WebSearchTool" + x-oaiExpandable: true + ToolChoiceFunction: + type: object + title: Function tool + description: | + Use this option to force the model to call a specific function. + properties: + type: + type: string + enum: + - function + description: For function calling, the type is always `function`. + x-stainless-const: true + name: + type: string + description: The name of the function to call. + required: + - type + - name + ToolChoiceOptions: + type: string + title: Tool choice mode + 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. + enum: + - none + - auto + - required + ToolChoiceTypes: + type: object + title: Hosted tool + description: > + Indicates that the model should use a built-in tool to generate a + response. + + [Learn more about built-in tools](/docs/guides/tools). + properties: + type: + type: string + description: | + The type of hosted tool the model should to use. Learn more about + [built-in tools](/docs/guides/tools). + + Allowed values are: + - `file_search` + - `web_search_preview` + - `computer_use_preview` + enum: + - file_search + - web_search_preview + - computer_use_preview + - web_search_preview_2025_03_11 + required: + - type + RunStreamEvent: + oneOf: + - type: object + properties: + event: + type: string + enum: ["thread.run.created"] + data: + $ref: "#/components/schemas/RunObject" + required: + - event + - data + description: Occurs when a new [run](https://platform.openai.com/docs/api-reference/runs/object) is created. + x-code-samples: + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.queued"] + data: + $ref: "#/components/schemas/RunObject" + required: + - event + - data + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `queued` status. + x-code-samples: + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.in_progress"] + data: + $ref: "#/components/schemas/RunObject" + required: + - event + - data + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to an `in_progress` status. + x-code-samples: + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.requires_action"] + data: + $ref: "#/components/schemas/RunObject" + required: + - event + - data + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `requires_action` status. + x-code-samples: + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.completed"] + data: + $ref: "#/components/schemas/RunObject" + required: + - event + - data + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) is completed. + x-code-samples: + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.incomplete"] + data: + $ref: "#/components/schemas/RunObject" + required: + - event + - data + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) ends with status `incomplete`. + x-code-samples: + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.failed"] + data: + $ref: "#/components/schemas/RunObject" + required: + - event + - data + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) fails. + x-code-samples: + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.cancelling"] + data: + $ref: "#/components/schemas/RunObject" + required: + - event + - data + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `cancelling` status. + x-code-samples: + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.cancelled"] + data: + $ref: "#/components/schemas/RunObject" + required: + - event + - data + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) is cancelled. + x-code-samples: + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.expired"] + data: + $ref: "#/components/schemas/RunObject" + required: + - event + - data + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) expires. + x-code-samples: + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" + + RunStepStreamEvent: + oneOf: + - type: object + properties: + event: + type: string + enum: ["thread.run.step.created"] + data: + $ref: "#/components/schemas/RunStepObject" + required: + - event + - data + description: Occurs when a [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is created. + x-code-samples: + dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.step.in_progress"] + data: + $ref: "#/components/schemas/RunStepObject" + required: + - event + - data + description: Occurs when a [run step](https://platform.openai.com/docs/api-reference/runs/step-object) moves to an `in_progress` state. + x-code-samples: + dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.step.delta"] + data: + $ref: "#/components/schemas/RunStepDeltaObject" + required: + - event + - data + description: Occurs when parts of a [run step](https://platform.openai.com/docs/api-reference/runs/step-object) are being streamed. + x-code-samples: + dataDescription: "`data` is a [run step delta](https://platform.openai.com/docs/api-reference/assistants-streaming/run-step-delta-object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.step.completed"] + data: + $ref: "#/components/schemas/RunStepObject" + required: + - event + - data + description: Occurs when a [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is completed. + x-code-samples: + dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.step.failed"] + data: + $ref: "#/components/schemas/RunStepObject" + required: + - event + - data + description: Occurs when a [run step](https://platform.openai.com/docs/api-reference/runs/step-object) fails. + x-code-samples: + dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.step.cancelled"] + data: + $ref: "#/components/schemas/RunStepObject" + required: + - event + - data + description: Occurs when a [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is cancelled. + x-code-samples: + dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" + - type: object + properties: + event: + type: string + enum: ["thread.run.step.expired"] + data: + $ref: "#/components/schemas/RunStepObject" + required: + - event + - data + description: Occurs when a [run step](https://platform.openai.com/docs/api-reference/runs/step-object) expires. + x-code-samples: + dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" + + MessageStreamEvent: + oneOf: + - type: object + properties: + event: + type: string + enum: ["thread.message.created"] + data: + $ref: "#/components/schemas/MessageObject" + required: + - event + - data + description: Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) is created. + x-code-samples: + dataDescription: "`data` is a [message](https://platform.openai.com/docs/api-reference/messages/object)" + - type: object + properties: + event: + type: string + enum: ["thread.message.in_progress"] + data: + $ref: "#/components/schemas/MessageObject" + required: + - event + - data + description: Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) moves to an `in_progress` state. + x-code-samples: + dataDescription: "`data` is a [message](https://platform.openai.com/docs/api-reference/messages/object)" + - type: object + properties: + event: + type: string + enum: ["thread.message.delta"] + data: + $ref: "#/components/schemas/MessageDeltaObject" + required: + - event + - data + description: Occurs when parts of a [Message](https://platform.openai.com/docs/api-reference/messages/object) are being streamed. + x-code-samples: + dataDescription: "`data` is a [message delta](https://platform.openai.com/docs/api-reference/assistants-streaming/message-delta-object)" + - type: object + properties: + event: + type: string + enum: ["thread.message.completed"] + data: + $ref: "#/components/schemas/MessageObject" + required: + - event + - data + description: Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) is completed. + x-code-samples: + dataDescription: "`data` is a [message](https://platform.openai.com/docs/api-reference/messages/object)" + - type: object + properties: + event: + type: string + enum: ["thread.message.incomplete"] + data: + $ref: "#/components/schemas/MessageObject" + required: + - event + - data + description: Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) ends before it is completed. + x-code-samples: + dataDescription: "`data` is a [message](https://platform.openai.com/docs/api-reference/messages/object)" + + ErrorEvent: + type: object + properties: + event: + type: string + enum: ["error"] + data: + $ref: "#/components/schemas/Error" + required: + - event + - data + description: Occurs when an [error](https://platform.openai.com/docs/guides/error-codes/api-errors) occurs. This can happen due to an internal server error or a timeout. + x-code-samples: + dataDescription: "`data` is an [error](https://platform.openai.com/docs/guides/error-codes/api-errors)" + FileCitation: + type: object + title: File citation + description: | + A citation to a file. + properties: + type: + type: string + description: | + The type of the file citation. Always `file_citation`. + enum: + - file_citation + x-stainless-const: true + index: + type: integer + description: | + The index of the file in the list of files. + file_id: + type: string + description: | + The ID of the file. + required: + - type + - index + - file_id + 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 + DoneEvent: + type: object + properties: + event: + type: string + enum: ["done"] + data: + type: string + enum: ["[DONE]"] + required: + - event + - data + description: Occurs when a stream ends. + x-code-samples: + dataDescription: "`data` is `[DONE]`" + + 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 Portkey 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 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 - - 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 - - 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 + 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: *metadata_description + type: object + x-oaiTypeLabel: map + nullable: true + required: + - id + - object + - endpoint + - input_file_id + - completion_window + - status + - created_at + + BatchRequestInput: + type: object + description: The per-line object of the batch input file + properties: + custom_id: + type: string + description: A developer-provided per-request id that will be used to match outputs to inputs. Must be unique for each request in a batch. + method: + type: string + enum: ["POST"] + description: The HTTP method to be used for the request. Currently only `POST` is supported. + url: + type: string + description: The Portkey API relative URL to be used for the request. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. + x-code-samples: + name: The request input object + example: | + {"custom_id": "request-1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is 2+2?"}]}} + + BatchRequestOutput: + type: object + description: The per-line object of the batch output and error files + properties: + id: + type: string + custom_id: + type: string + description: A developer-provided per-request id that will be used to match outputs to inputs. + response: + type: object + nullable: true + properties: + status_code: + type: integer + description: The HTTP status code of the response + request_id: + type: string + description: An unique identifier for the provider API request. Please include this request ID when contacting your provider support. + body: + type: object + x-oaiTypeLabel: map + description: The JSON body of the response + error: + type: object + nullable: true + description: For requests that failed with a non-HTTP error, this will contain more information on the cause of the failure. + properties: + code: + type: string + description: A machine-readable error code. + message: + type: string + description: A human-readable error message. + x-code-samples: + name: The request output object + example: | + {"id": "batch_req_wnaDys", "custom_id": "request-2", "response": {"status_code": 200, "request_id": "req_c187b3", "body": {"id": "chatcmpl-9758Iw", "object": "chat.completion", "created": 1711475054, "model": "gpt-3.5-turbo", "choices": [{"index": 0, "message": {"role": "assistant", "content": "2 + 2 equals 4."}, "finish_reason": "stop"}], "usage": {"prompt_tokens": 24, "completion_tokens": 15, "total_tokens": 39}, "system_fingerprint": null}}, "error": null} + + 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 + + FeedbackRequest: + type: object + required: + - trace_id + - value + properties: + trace_id: + type: string + description: Unique identifier for the request trace. + value: + type: integer + description: Feedback value, an integer between -10 and 10. + minimum: -10 + maximum: 10 + weight: + type: number + format: float + description: Weight of the feedback, a float between 0 and 1. Default is 1.0. + minimum: 0 + maximum: 1 + default: 1.0 + metadata: + type: object + additionalProperties: true + description: Additional metadata for the feedback. + + FeedbackResponse: + type: object + properties: + status: + type: string + description: success or failure + message: + type: string + description: Confirmation message indicating successful feedback submission. + feedback_ids: + type: array + description: Ids of Feedbacks created returned in the same order as input + items: + type: string - CreateVectorStoreFileRequest: + FeedbackUpdateRequest: + type: object + required: + - value + properties: + value: + type: integer + description: Feedback value, an integer between -10 and 10. + minimum: -10 + maximum: 10 + weight: + type: number + format: float + description: Weight of the feedback, a float between 0 and 1. Default is 1.0. + minimum: 0 + maximum: 1 + default: 1.0 + metadata: + type: object + additionalProperties: true + description: Additional metadata for the feedback. + + RateLimits: + type: object + properties: + type: + type: string + enum: ["requests", "tokens"] + unit: + type: string + enum: ["rpd", "rph", "rpm"] + value: + type: integer + UsageLimits: + type: object + properties: + credit_limit: + type: integer + description: Credit Limit. Used for tracking usage + minimum: 1 + default: null + type: + type: string + description: Type of credit limit + enum: ["cost", "tokens"] + alert_threshold: + type: integer + description: Alert Threshold. Used for alerting when usage reaches more than this + minimum: 1 + default: null + periodic_reset: + type: string + description: Reset the usage periodically. + enum: ["monthly", "weekly"] + example: + credit_limit: 10 + periodic_reset: monthly + alert_threshold: 8 + + CreateIntegrationRequest: + type: object + required: + - name + - ai_provider_id + properties: + name: + type: string + description: Human-readable name for the integration + example: "Production OpenAI" + slug: + type: string + pattern: '^[a-zA-Z0-9_-]+$' + description: URL-friendly identifier (auto-generated if not provided) + example: "production-openai" + ai_provider_id: + type: string + description: ID of the base AI provider + example: "openai" + key: + type: string + description: API key for the provider (if required) + example: "sk-..." + description: + type: string + description: Optional description of the integration + example: "Production OpenAI integration for customer-facing applications" + workspace_id: + type: string + description: Workspace ID (for workspace-scoped integrations) + example: ws-my-team-1234 + configurations: + type: object + description: Provider-specific configuration object + oneOf: + - $ref: '#/components/schemas/OpenAIConfiguration' + title: OpenAI + - $ref: '#/components/schemas/AzureOpenAIConfiguration' + title: Azure OpenAI + - $ref: '#/components/schemas/BedrockConfiguration' + title: AWS Bedrock + - $ref: '#/components/schemas/VertexAIConfiguration' + title: Vertex AI + - $ref: '#/components/schemas/AzureAIConfiguration' + title: Azure AI + - $ref: '#/components/schemas/WorkersAIConfiguration' + title: Workers AI + - $ref: '#/components/schemas/SageMakerConfiguration' + title: AWS Sagemaker + - $ref: '#/components/schemas/HuggingFaceConfiguration' + title: Hugginface + - $ref: '#/components/schemas/CortexConfiguration' + title: Cortex + - $ref: '#/components/schemas/CustomHostConfiguration' + title: Custom Base URL + create_default_provider: + type: boolean + default: true + description: Whether to automatically create a default provider when creating a workspace-scoped integration. Defaults to true. + default_provider_slug: + type: string + pattern: '^[a-zA-Z0-9_-]+$' + maxLength: 255 + description: Custom slug for the auto-created default provider. Only applicable for workspace-scoped integrations. If the slug already exists in the workspace, the request will fail with a validation error. + secret_mappings: + type: array + items: + $ref: '#/components/schemas/SecretMapping' + description: Dynamically resolve secrets from secret references at runtime. Valid target_field values are "key" or "configurations." (e.g. "configurations.aws_secret_access_key", "configurations.azure_entra_client_secret"). Each target_field must be unique. When "key" is mapped, the key body field can be omitted. + + UpdateIntegrationRequest: + type: object + properties: + name: + type: string + description: Human-readable name for the integration + example: "Production OpenAI" + key: + type: string + description: API key for the provider (if required) + example: "sk-..." + description: + type: string + description: Optional description of the integration + example: "Production OpenAI integration for customer-facing applications" + configurations: + type: object + description: Provider-specific configuration object + oneOf: + - $ref: '#/components/schemas/OpenAIConfiguration' + title: OpenAI + - $ref: '#/components/schemas/AzureOpenAIConfiguration' + title: Azure OpenAI + - $ref: '#/components/schemas/BedrockConfiguration' + title: AWS Bedrock + - $ref: '#/components/schemas/VertexAIConfiguration' + title: Vertex AI + - $ref: '#/components/schemas/AzureAIConfiguration' + title: Azure AI + - $ref: '#/components/schemas/WorkersAIConfiguration' + title: Workers AI + - $ref: '#/components/schemas/SageMakerConfiguration' + title: AWS Sagemaker + - $ref: '#/components/schemas/HuggingFaceConfiguration' + title: Hugginface + - $ref: '#/components/schemas/CortexConfiguration' + title: Cortex + - $ref: '#/components/schemas/CustomHostConfiguration' + title: Custom Base URL + secret_mappings: + type: array + items: + $ref: '#/components/schemas/SecretMapping' + description: Dynamically resolve secrets from secret references at runtime. Valid target_field values are "key" or "configurations." (e.g. "configurations.aws_secret_access_key", "configurations.azure_entra_client_secret"). Each target_field must be unique. + + IntegrationDetailResponse: + allOf: + - $ref: '#/components/schemas/IntegrationList' + - type: object + properties: + masked_key: + type: string + description: Masked API key + configurations: + type: object + description: | + Provider-specific configuration object + + **⚠️ Security Note - Response Masking:** + When retrieving integration details, sensitive fields are automatically masked: + - Sensitive fields get a `masked_` prefix (e.g., `client_secret` → `masked_client_secret`) + - Non-sensitive fields (IDs, URLs, regions, etc.) remain unchanged + oneOf: + - $ref: '#/components/schemas/OpenAIConfiguration' + title: OpenAI + - $ref: '#/components/schemas/AzureOpenAIConfiguration' + title: Azure OpenAI + - $ref: '#/components/schemas/BedrockConfiguration' + title: AWS Bedrock + - $ref: '#/components/schemas/VertexAIConfiguration' + title: Vertex AI + - $ref: '#/components/schemas/AzureAIConfiguration' + title: Azure AI + - $ref: '#/components/schemas/WorkersAIConfiguration' + title: Workers AI + - $ref: '#/components/schemas/SageMakerConfiguration' + title: AWS Sagemaker + - $ref: '#/components/schemas/HuggingFaceConfiguration' + title: Hugginface + - $ref: '#/components/schemas/CortexConfiguration' + title: Cortex + - $ref: '#/components/schemas/CustomHostConfiguration' + title: Custom Base URL + global_workspace_access_settings: + type: object + nullable: true + $ref: '#/components/schemas/GlobalWorkspaceAccess' + description: Global workspace access configuration + allow_all_models: + type: boolean + description: Whether new models will be enabled by default + workspace_count: + type: integer + description: Number of workspaces with access to this integration + secret_mappings: + type: array + items: + $ref: '#/components/schemas/SecretMapping' + description: Secret reference mappings for this integration. Valid target_field values are "key" or "configurations.". + + GlobalWorkspaceAccess: + type: object + required: + - enabled + properties: + enabled: + type: boolean + description: Whether global workspace access is enabled. When enabled, the integration will be enabled for all workspaces that are created in future. + usage_limits: + type: array + nullable: true + maxItems: 1 + items: + $ref: '#/components/schemas/UsageLimits' + rate_limits: + type: array + nullable: true + maxItems: 1 + items: + $ref: '#/components/schemas/RateLimits' + + OpenAIConfiguration: + type: object + properties: + openai_organization: + type: string + description: OpenAI organization ID + openai_project: + type: string + description: OpenAI project ID + + AzureOpenAIConfiguration: + type: object + required: + - azure_resource_name + - azure_deployment_config + - azure_auth_mode + properties: + azure_auth_mode: + type: string + enum: [default, entra, managed] + description: Authentication mode for Azure + azure_resource_name: + type: string + description: Azure OpenAI resource name + azure_deployment_config: + type: array + minItems: 1 + items: + $ref: '#/components/schemas/AzureDeploymentConfig' + # Entra-specific fields + azure_entra_tenant_id: + type: string + description: Azure AD tenant ID (required for entra auth) + azure_entra_client_id: + type: string + description: Azure AD client ID (required for entra auth) + azure_entra_client_secret: + type: string + description: Azure AD client secret (required for entra auth) + # Managed identity fields + azure_managed_client_id: + type: string + description: Managed identity client ID (optional for managed auth) + + AzureDeploymentConfig: + type: object + required: + - azure_api_version + - azure_deployment_name + - azure_model_slug + properties: + alias: + type: string + description: Alias for the deployment + azure_api_version: + type: string + maxLength: 30 + description: Azure API version + azure_deployment_name: + type: string + description: Azure deployment name + is_default: + type: boolean + default: false + description: Whether this is the default deployment + azure_model_slug: + type: string + description: Azure model slug + + BedrockConfiguration: + type: object + required: + - aws_auth_type + - aws_region + properties: + aws_auth_type: + type: string + enum: [accessKey, assumedRole] + description: AWS authentication type + aws_region: + type: string + description: AWS region + # Access key fields + aws_access_key_id: + type: string + description: AWS access key ID (required for accessKey auth) + aws_secret_access_key: + type: string + description: AWS secret access key (required for accessKey auth) + # Assumed role fields + aws_role_arn: + type: string + description: AWS role ARN (required for assumedRole auth) + aws_external_id: + type: string + nullable: true + description: AWS external ID (optional for assumedRole auth) + + SageMakerConfiguration: + allOf: + - $ref: '#/components/schemas/BedrockConfiguration' + - type: object + properties: + amzn_sagemaker_custom_attributes: + type: string + description: Custom attributes for SageMaker + amzn_sagemaker_target_model: + type: string + description: Target model for SageMaker + amzn_sagemaker_target_variant: + type: string + description: Target variant for SageMaker + amzn_sagemaker_target_container_hostname: + type: string + description: Target container hostname + amzn_sagemaker_inference_id: + type: string + description: Inference ID + amzn_sagemaker_enable_explanations: + type: string + description: Enable explanations + amzn_sagemaker_inference_component: + type: string + description: Inference component + amzn_sagemaker_session_id: + type: string + description: Session ID + amzn_sagemaker_model_name: + type: string + description: Model name + + VertexAIConfiguration: + type: object + required: + - vertex_auth_type + - vertex_region + properties: + vertex_auth_type: + type: string + enum: [basic, serviceAccount] + description: Vertex AI authentication type + vertex_region: + type: string + description: GCP region + # Basic auth fields + vertex_project_id: + type: string + description: GCP project ID (required for basic auth) + # Service account fields + vertex_service_account_json: + type: object + description: Service account JSON (required for serviceAccount auth) + + AzureAIConfiguration: + type: object + required: + - azure_foundry_url + - azure_auth_mode + properties: + azure_auth_mode: + type: string + enum: [default, entra, managed] + description: Authentication mode for Azure AI + azure_foundry_url: + type: string + description: Azure AI Foundry URL + azure_api_version: + type: string + maxLength: 30 + description: Azure API version + azure_deployment_name: + type: string + description: Azure deployment name + # Entra-specific fields + azure_entra_tenant_id: + type: string + description: Azure AD tenant ID (required for entra auth) + azure_entra_client_id: + type: string + description: Azure AD client ID (required for entra auth) + azure_entra_client_secret: + type: string + description: Azure AD client secret (required for entra auth) + # Managed identity fields + azure_managed_client_id: + type: string + description: Managed identity client ID (optional for managed auth) + + WorkersAIConfiguration: + type: object + required: + - workers_ai_account_id + properties: + workers_ai_account_id: + type: string + description: Cloudflare Workers AI account ID + + HuggingFaceConfiguration: + type: object + properties: + huggingface_base_url: + type: string + description: Custom Hugging Face base URL + + CortexConfiguration: + type: object + required: + - snowflake_account + properties: + snowflake_account: + type: string + description: Snowflake account identifier + + CustomHostConfiguration: + type: object + properties: + custom_host: + type: string + description: Custom host URL (can be used along with other provider specific configuration fields) + custom_headers: + type: object + additionalProperties: + type: string + description: Custom headers to send with requests (can be used along with other provider specific configuration fields) + + SecretMapping: + type: object + required: + - target_field + - secret_reference_id + properties: + target_field: + type: string + description: | + The field on the entity to populate from the secret reference. Must be unique within the array. + - **Integrations**: `key` or `configurations.` (e.g. `configurations.aws_secret_access_key`) + - **Virtual Keys**: `key` or `model_config.` (e.g. `model_config.awsSecretAccessKey`) + example: "key" + secret_reference_id: + type: string + description: UUID or slug of the secret reference. Must belong to the same organisation and be accessible by the workspace. + example: "my-aws-secret" + secret_key: + type: string + nullable: true + description: Override the secret_key defined on the secret reference. Use to pick a specific key from a multi-value secret. + + CreateSecretReferenceRequest: + type: object + required: + - name + - manager_type + - auth_config + - secret_path + properties: + organisation_id: + type: string + format: uuid + description: Required if not using API key auth + name: + type: string + minLength: 1 + maxLength: 255 + slug: + type: string + pattern: '^[a-zA-Z0-9_-]+$' + maxLength: 255 + description: Auto-generated from name if omitted + description: + type: string + maxLength: 1024 + nullable: true + manager_type: + type: string + enum: [aws_sm, azure_kv, hashicorp_vault] + auth_config: + oneOf: + - $ref: "#/components/schemas/AwsAccessKeyAuthConfig" + - $ref: "#/components/schemas/AwsAssumedRoleAuthConfig" + - $ref: "#/components/schemas/AwsServiceRoleAuthConfig" + - $ref: "#/components/schemas/AzureEntraAuthConfig" + - $ref: "#/components/schemas/AzureManagedAuthConfig" + - $ref: "#/components/schemas/AzureDefaultAuthConfig" + - $ref: "#/components/schemas/HashicorpTokenAuthConfig" + - $ref: "#/components/schemas/HashicorpAppRoleAuthConfig" + - $ref: "#/components/schemas/HashicorpKubernetesAuthConfig" + discriminator: + propertyName: aws_auth_type + secret_path: + type: string + maxLength: 1024 + secret_key: + type: string + maxLength: 255 + nullable: true + allow_all_workspaces: + type: boolean + default: true + description: Cannot be true when allowed_workspaces is provided + allowed_workspaces: + type: array + items: + type: string + minItems: 1 + description: Array of workspace UUIDs or slugs. Mutually exclusive with allow_all_workspaces=true. + tags: + type: object + additionalProperties: + type: string + nullable: true + + UpdateSecretReferenceRequest: + type: object + properties: + name: + type: string + minLength: 1 + maxLength: 255 + description: + type: string + maxLength: 1024 + nullable: true + auth_config: + type: object + description: Merged with existing config, validated against existing manager_type + secret_path: + type: string + maxLength: 1024 + secret_key: + type: string + maxLength: 255 + nullable: true + allow_all_workspaces: + type: boolean + description: When true, all workspace-specific mappings are purged + allowed_workspaces: + type: array + items: + type: string + minItems: 1 + description: Replaces existing workspace mappings. Automatically sets allow_all_workspaces to false. + tags: + type: object + additionalProperties: + type: string + nullable: true + + SecretReferenceListItem: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + slug: + type: string + manager_type: + type: string + enum: [aws_sm, azure_kv, hashicorp_vault] + status: + type: string + enum: [ACTIVE] + created_at: + type: string + format: date-time + last_updated_at: + type: string + format: date-time + object: + type: string + enum: [secret-reference] + + SecretReferenceDetailResponse: + type: object + properties: + id: + type: string + format: uuid + organisation_id: + type: string + format: uuid + name: + type: string + slug: + type: string + description: + type: string + nullable: true + manager_type: + type: string + enum: [aws_sm, azure_kv, hashicorp_vault] + secret_path: + type: string + secret_key: + type: string + nullable: true + allow_all_workspaces: + type: boolean + tags: + type: object + additionalProperties: + type: string + nullable: true + status: + type: string + enum: [ACTIVE] + created_by: + type: string + created_at: + type: string + format: date-time + last_updated_at: + type: string + format: date-time + auth_config: + type: object + description: Sensitive fields are masked for non-system users + object: + type: string + enum: [secret-reference] + + AwsAccessKeyAuthConfig: + type: object + required: + - aws_auth_type + - aws_access_key_id + - aws_secret_access_key + - aws_region + properties: + aws_auth_type: + type: string + enum: [accessKey] + aws_access_key_id: + type: string + aws_secret_access_key: + type: string + aws_region: + type: string + + AwsAssumedRoleAuthConfig: + type: object + required: + - aws_auth_type + - aws_role_arn + - aws_region + properties: + aws_auth_type: + type: string + enum: [assumedRole] + aws_role_arn: + type: string + aws_external_id: + type: string + nullable: true + aws_region: + type: string + + AwsServiceRoleAuthConfig: + type: object + required: + - aws_auth_type + properties: + aws_auth_type: + type: string + enum: [serviceRole] + aws_region: + type: string + + AzureEntraAuthConfig: + type: object + required: + - azure_auth_mode + - azure_entra_tenant_id + - azure_entra_client_id + - azure_entra_client_secret + - azure_vault_url + properties: + azure_auth_mode: + type: string + enum: [entra] + azure_entra_tenant_id: + type: string + azure_entra_client_id: + type: string + azure_entra_client_secret: + type: string + azure_vault_url: + type: string + format: uri + + AzureManagedAuthConfig: + type: object + required: + - azure_auth_mode + - azure_vault_url + properties: + azure_auth_mode: + type: string + enum: [managed] + azure_managed_client_id: + type: string + azure_vault_url: + type: string + format: uri + + AzureDefaultAuthConfig: + type: object + required: + - azure_auth_mode + - azure_vault_url + properties: + azure_auth_mode: + type: string + enum: [default] + azure_vault_url: + type: string + format: uri + + HashicorpTokenAuthConfig: + type: object + required: + - vault_auth_type + - vault_addr + - vault_token + properties: + vault_auth_type: + type: string + enum: [token] + vault_addr: + type: string + format: uri + vault_token: + type: string + vault_namespace: + type: string + + HashicorpAppRoleAuthConfig: + type: object + required: + - vault_auth_type + - vault_addr + - vault_role_id + - vault_secret_id + properties: + vault_auth_type: + type: string + enum: [approle] + vault_addr: + type: string + format: uri + vault_role_id: + type: string + vault_secret_id: + type: string + vault_namespace: + type: string + + HashicorpKubernetesAuthConfig: + type: object + required: + - vault_auth_type + - vault_addr + - vault_role + properties: + vault_auth_type: + type: string + enum: [kubernetes] + vault_addr: + type: string + format: uri + vault_role: + type: string + vault_namespace: + type: string + + IntegrationList: + type: object + properties: + id: + type: string + format: UUID + organisation_id: + type: string + format: UUID + ai_provider_id: + type: string + name: + type: string + status: + type: string + enum: [active, archived] + created_at: + type: string + format: date-time + last_updated_at: + type: string + format: date-time + nullable: true + slug: + type: string + description: + type: string + object: + type: string + enum: [integration] + + IntegrationModelsResponse: + type: object + properties: + total: + type: integer + description: Total number of models + models: + type: array + items: + $ref: '#/components/schemas/IntegrationModel' + + IntegrationModel: + type: object + properties: + slug: + type: string + description: Model slug identifier + name: + type: string + description: Human-readable model name + enabled: + type: boolean + description: Whether the model is enabled + is_custom: + type: boolean + nullable: true + description: Whether this is a custom model + is_finetune: + type: boolean + nullable: true + description: Whether this is a fine-tuned model + base_model_slug: + type: string + nullable: true + description: Base model slug for fine-tuned models + pricing_config: + $ref: '#/components/schemas/PricingConfig' + + PricingConfig: + type: object + properties: + type: + type: string + enum: [static] + description: Pricing type + pay_as_you_go: + $ref: '#/components/schemas/PayAsYouGoPricing' + + PayAsYouGoPricing: + type: object + properties: + request_token: + $ref: '#/components/schemas/TokenPricing' + response_token: + $ref: '#/components/schemas/TokenPricing' + + TokenPricing: + type: object + properties: + price: + type: number + format: float + description: Price per token + + BulkUpdateModelsRequest: + type: object + required: + - models + properties: + models: + type: array + items: + $ref: '#/components/schemas/ModelUpdateRequest' + allow_all_models: + type: boolean + description: Whether to allow all models by default + + ModelUpdateRequest: + type: object + required: + - slug + - enabled + properties: + slug: + type: string + description: Model slug identifier + enabled: + type: boolean + description: Whether to enable the model + is_custom: + type: boolean + nullable: true + description: Whether this is a custom model + is_finetune: + type: boolean + nullable: true + description: Whether this is a fine-tuned model + base_model_slug: + type: string + nullable: true + description: Base model slug for fine-tuned models + pricing_config: + $ref: '#/components/schemas/PricingConfig' + + IntegrationWorkspacesResponse: + type: object + properties: + total: + type: integer + description: Total number of workspaces + workspaces: + type: array + items: + $ref: '#/components/schemas/IntegrationWorkspace' + + IntegrationWorkspace: + type: object + properties: + id: + type: string + description: Workspace ID + example: "ws-my-team-1234" + enabled: + type: boolean + description: Whether the workspace has access + usage_limits: + type: array + nullable: true + items: + $ref: '#/components/schemas/UsageLimits' + rate_limits: + type: array + nullable: true + items: + $ref: '#/components/schemas/RateLimits' + + BulkUpdateWorkspacesRequest: + type: object + properties: + workspaces: + type: array + items: + $ref: '#/components/schemas/WorkspaceUpdateRequest' + global_workspace_access: + $ref: '#/components/schemas/GlobalWorkspaceAccess' + override_existing_workspace_access: + type: boolean + description: Whether to override existing workspace access settings + create_default_provider: + type: boolean + default: true + description: Whether to automatically create a default provider when granting workspace access. Defaults to true. Can be overridden per workspace. + default_provider_slug: + type: string + description: Custom slug for the auto-created default provider. Applies to all workspaces unless overridden per workspace. If the slug already exists, the request will fail with a validation error. + + WorkspaceUpdateRequest: + type: object + required: + - id + - enabled + properties: + id: + type: string + description: Workspace ID + example: ws-my-team-1234 + enabled: + type: boolean + description: Whether to enable workspace access + usage_limits: + type: array + nullable: true + maxItems: 1 + items: + $ref: '#/components/schemas/UsageLimits' + rate_limits: + type: array + nullable: true + maxItems: 1 + items: + $ref: '#/components/schemas/RateLimits' + reset_usage: + type: boolean + description: Whether to reset current usage. If the current status is exhausted, this will change it back to active. + create_default_provider: + type: boolean + description: Whether to automatically create a default provider for this workspace. Overrides the top-level create_default_provider setting. + default_provider_slug: + type: string + description: Custom slug for the auto-created default provider for this workspace. Overrides the top-level default_provider_slug. If the slug already exists, the request will fail with a validation error. + + Providers: + type: object + properties: + name: + type: string + example: "Open AI Workspace" + integration_id: + type: string + note: + type: string + nullable: true + example: "randomness" + status: + type: string + enum: [active, exhausted, expired] + usage_limits: + $ref: "#/components/schemas/UsageLimits" + reset_usage: + type: number + nullable: true + example: 0 + created_at: + type: string + format: date-time + slug: + type: string + rate_limits: + type: array + items: + $ref: "#/components/schemas/RateLimits" + nullable: true + expires_at: + type: string + format: date-time + object: + type: string + enum: [provider] + + VirtualKeys: + type: object + properties: + name: + type: string + example: "Open AI Workspace" + note: + type: string + nullable: true + example: "randomness" + status: + type: string + enum: [active, exhausted] + usage_limits: + $ref: "#/components/schemas/UsageLimits" + reset_usage: + type: number + nullable: true + example: 0 + created_at: + type: string + format: date-time + slug: + type: string + model_config: + type: object + rate_limits: + type: array + items: + $ref: "#/components/schemas/RateLimits" + nullable: true + expires_at: + type: string + format: date-time + secret_mappings: + type: array + items: + $ref: '#/components/schemas/SecretMapping' + description: Secret reference mappings for this virtual key. Valid target_field values are "key" or "model_config.". + object: + type: string + enum: [virtual-key] + + Invite: + type: object + properties: + object: + type: string + example: invite + id: + type: string + format: uuid + email: + type: string + format: email + role: + type: string + enum: + - admin + - member + created_at: + type: string + format: date-time + expires_at: + type: string + format: date-time + accepted_at: + type: string + format: date-time + status: + type: string + enum: + - pending + - cancelled + - accepted + - expired + invited_by: + type: string + format: uuid + InviteList: + type: object + properties: + object: + type: string + enum: + - list + total: + type: integer + data: + type: array + items: + $ref: "#/components/schemas/Invite" + + User: + type: object + properties: + object: + type: string + enum: + - user + id: + type: string + format: uuid + first_name: + type: string + last_name: + type: string + role: + type: string + enum: + - admin + - member + - owner + email: + type: string + format: email + created_at: + type: string + format: date-time + last_updated_at: + type: string + format: date-time + workspace_ids: + type: array + + items: + type: string + UserList: + type: object + properties: + total: + type: integer + example: 2 + object: + type: string + enum: + - list + data: + type: array + items: + $ref: "#/components/schemas/User" + + WorkspaceMember: + type: object + properties: + object: + type: string + example: workspace-user + enum: + - workspace-user + id: + type: string + format: uuid + example: 25afb7bd-f98a-11ee-85fe-0e27d7367987 + first_name: + type: string + example: John + last_name: + type: string + example: Doe + org_role: + type: string + example: member + enum: + - admin + - member + - owner + role: + type: string + example: member + enum: + - admin + - member + - manager + created_at: + type: string + example: 2024-01-01T00:00:00.000Z + format: date-time + last_updated_at: + type: string + example: 2024-01-01T00:00:00.000Z + format: date-time + status: + type: string + example: active + enum: + - active + WorkspaceMemberList: + type: object + properties: + total: + type: integer + example: 2 + object: + type: string + example: list + enum: + - list + data: + type: array + items: + $ref: "#/components/schemas/WorkspaceMember" + + Workspace: + type: object + properties: + id: + type: string + example: ws-test-a-174eb1 + slug: + type: string + example: ws-test-a-174eb1 + name: + type: string + example: New Workspace + description: + type: string + nullable: true + example: null + created_at: + type: string + format: date-time + example: 2024-07-30T13:27:29.000Z + last_updated_at: + type: string + format: date-time + example: 2024-07-30T13:27:29.000Z + defaults: + type: object + nullable: true + properties: + metadata: + type: object + additionalProperties: + type: string + example: + foo: bar + is_default: + type: integer + example: 0 + object: + type: string + enum: + - workspace + usage_limits: + type: array + items: + $ref: "#/components/schemas/UsageLimits" + rate_limits: + type: array + items: + $ref: "#/components/schemas/RateLimits" + + WorkspaceList: + type: object + properties: + total: + type: integer + example: 2 + object: + type: string + enum: + - list + data: + type: array + items: + $ref: "#/components/schemas/Workspace" + + WorkspaceWithUsers: + type: object + properties: + id: + type: string + example: ws-test-a-174eb1 + slug: + type: string + example: ws-test-a-174eb1 + name: + type: string + example: New Workspace + description: + type: string + nullable: true + example: null + created_at: + type: string + format: date-time + example: 2024-07-30T13:27:29.000Z + last_updated_at: + type: string + format: date-time + example: 2024-07-30T13:27:29.000Z + defaults: + type: object + nullable: true + properties: + metadata: + type: object + additionalProperties: + type: string + example: + foo: bar + is_default: + type: integer + example: 0 + input_guardrails: + type: array + items: + type: string + output_guardrails: + type: array + items: + type: string + object: + type: string + enum: + - workspace + users: + type: array + items: 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 - - 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 - - DeleteVectorStoreFileResponse: + $ref: "#/components/schemas/WorkspaceMember" + usage_limits: + type: array + items: + $ref: "#/components/schemas/UsageLimits" + rate_limits: + type: array + items: + $ref: "#/components/schemas/RateLimits" + + Collection: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + workspace_id: + type: string + format: uuid + slug: + type: string + parent_collection_id: + type: string + format: uuid + nullable: true + is_default: + type: boolean + status: + type: string + enum: [active, archived] + created_at: + type: string + format: date-time + last_updated_at: + type: string + format: date-time + + CollectionDetails: + type: object + properties: + child_collections_count: + type: integer + prompts_count: + type: integer + child_collections_last_updated_at: + type: string + format: date-time + nullable: true + prompts_last_updated_at: + type: string + format: date-time + nullable: true + + CollectionWithDetails: + allOf: + - $ref: '#/components/schemas/Collection' + - type: object + properties: + collection_details: + $ref: '#/components/schemas/CollectionDetails' + + ChildCollection: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + last_updated_at: + type: string + format: date-time + collection_details: + $ref: '#/components/schemas/CollectionDetails' + + CollectionWithChildCollections: + allOf: + - $ref: '#/components/schemas/Collection' + - type: object + properties: + child_collections: + type: array + items: + $ref: '#/components/schemas/ChildCollection' + + Label: + type: object + properties: + id: + type: string + format: uuid + description: Unique identifier for the label + name: + type: string + description: Name of the label + description: + type: string + description: Description of the label + color_code: + type: string + description: Color code for the label + organisation_id: + type: string + format: uuid + description: ID of the organisation the label belongs to + workspace_id: + type: string + format: uuid + description: ID of the workspace the label belongs to + is_universal: + type: boolean + description: Whether the label is universal + created_at: + type: string + format: date-time + description: When the label was created + last_updated_at: + type: string + format: date-time + description: When the label was last updated + status: + type: string + description: Status of the label + + CreateLabelRequest: + type: object + required: + - name + properties: + organisation_id: + type: string + format: uuid + description: ID of the organisation + workspace_id: + type: string + description: ID or slug of the workspace + name: + type: string + description: Name of the label + pattern: ^(?!latest$)(?!default$)(?!\d+$)[a-zA-Z0-9_-]*[^@\s]?[a-zA-Z0-9_-]*$ + description: + type: string + description: Description of the label + color_code: + type: string + description: Color code for the label + + UpdateLabelRequest: + type: object + properties: + name: + type: string + description: Name of the label + pattern: ^(?!latest$)(?!default$)(?!\d+$)[a-zA-Z0-9_-]*[^@\s]?[a-zA-Z0-9_-]*$ + description: + type: string + description: Description of the label + color_code: + type: string + description: Color code for the label + + CreateLabelResponse: + type: object + properties: + id: + type: string + format: uuid + description: ID of the created label + + ListLabelsResponse: + type: object + properties: + total: + type: integer + description: Total number of labels + data: + type: array + items: + $ref: '#/components/schemas/Label' + + PromptSummary: + type: object + properties: + id: + type: string + format: uuid + slug: + type: string + name: + type: string + collection_id: + type: string + format: uuid + model: + type: string + format: string + status: + type: string + created_at: + type: string + format: date-time + last_updated_at: + type: string + format: date-time + object: + type: string + enum: ["prompt"] + + Prompt: + type: object + properties: + id: + type: string + format: uuid + slug: + type: string + name: + type: string + collection_id: + type: string + format: uuid + string: + type: string + parameters: + type: object + prompt_version: + type: number + prompt_version_id: + type: string + format: uuid + prompt_version_status: + type: string + enum: ["active", "archived"] + prompt_version_description: + type: string + prompt_version_label_id: + type: string + format: uuid + virtual_key: + type: string + model: + type: string + functions: + type: array + items: type: object - properties: - id: - type: string - deleted: - type: boolean - object: - type: string - enum: [vector_store.file.deleted] - required: - - id - - object - - deleted - - VectorStoreFileBatchObject: + tools: + type: array + items: 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 - } - } - - CreateVectorStoreFileBatchRequest: + tool_choice: + type: object + template_metadata: + type: object + is_raw_template: + type: boolean + status: + type: string + created_at: + type: string + format: date-time + last_updated_at: + type: string + format: date-time + + PromptVersionSummary: + type: object + properties: + id: + type: string + format: uuid + prompt_id: + type: string + format: uuid + prompt_template: + type: object + prompt_version: + type: number + prompt_description: + type: string + label_id: + type: string + format: uuid + created_at: + type: string + format: date-time + status: + type: string + enum: ["active", "archived"] + object: + type: string + enum: ["prompt"] + + PromptPartialSummary: + type: object + properties: + id: + type: string + format: uuid + slug: + type: string + name: + type: string + collection_id: + type: string + format: uuid + created_at: + type: string + format: date-time + last_updated_at: + type: string + format: date-time + status: + type: string + enum: ["active", "archived"] + object: + type: string + enum: ["partial"] + + PromptPartial: + type: object + properties: + id: + type: string + format: uuid + slug: + type: string + name: + type: string + collection_id: + type: string + format: uuid + string: + type: string + version: + type: number + version_description: + type: string + prompt_partial_version_id: + type: string + format: uuid + created_at: + type: string + format: date-time + last_updated_at: + type: string + format: date-time + status: + type: string + enum: ["active"] + + PromptPartialVersion: + type: object + properties: + prompt_partial_id: + type: string + format: uuid + prompt_partial_version_id: + type: string + format: uuid + slug: + type: string + version: + type: string + string: + type: string + description: + type: string + created_at: + type: string + format: date-time + prompt_version_status: + type: string + enum: ["active", "archived"] + object: + type: string + enum: ["partial"] + + CustomLog: + type: object + properties: + request: + type: object + properties: + url: + type: string + method: + type: string + headers: + type: object + additionalProperties: + type: string + body: + type: object + required: + - url + - body + response: + type: object + properties: + status: + type: integer + headers: + type: object + additionalProperties: + type: string + body: + type: object + response_time: + type: integer + required: + - body + metadata: + type: object + properties: + trace_id: + type: string + span_id: + type: string + span_name: + type: string + additionalProperties: + type: string + required: + - request + - response + + ExportListResponse: + type: object + properties: + object: + type: string + enum: [list] + total: + type: integer + data: + type: array + items: + $ref: "#/components/schemas/ExportItem" + ExportItem: + type: object + properties: + id: + type: string + format: uuid + organisation_id: + type: string + format: uuid + filters: + $ref: "#/components/schemas/GenerationsFilterSchema" + requested_data: + $ref: "#/components/schemas/LogExportsRequestedData" + status: + type: string + enum: + - draft + - in_progress + - success + - failed + - stopped + description: + type: string + created_at: + type: string + format: date-time + last_updated_at: + type: string + format: date-time + created_by: + type: string + format: uuid + workspace_id: + type: string + format: uuid + object: + type: string + enum: [export] + required: + - id + - organisation_id + - filters + - requested_data + - status + - description + - created_at + - last_updated_at + - created_by + - workspace_id + - object + UpdateExportResponse: + type: object + properties: + id: + type: string + format: uuid + description: The unique identifier of the updated export + total: + type: integer + description: The total number of items in the export + object: + type: string + enum: [export] + description: The type of the object + required: + - id + - total + - object + ExportTaskResponse: + type: object + properties: + message: + type: string + description: A message indicating the status of the export task + object: + type: string + enum: [export] + description: The type of the object + required: + - message + - object + DownloadLogsResponse: + type: object + properties: + signed_url: + type: string + format: uri + description: A pre-signed URL for downloading the exported logs + required: + - signed_url + + GenerationsFilterSchema: + type: object + properties: + time_of_generation_min: + type: string + format: date-time + time_of_generation_max: + type: string + format: date-time + total_units_min: + type: integer + total_units_max: + type: integer + cost_min: + type: number + cost_max: + type: number + ai_model: + type: string + prompt_token_min: + type: integer + prompt_token_max: + type: integer + completion_token_min: + type: integer + completion_token_max: + type: integer + status_code: + type: string + metadata: + type: object + additionalProperties: true + ai_org_model: + type: string + example: "openai__gpt-3.5-turbo, anthropic__claude-2.1" + weighted_feedback_min: + type: number + weighted_feedback_max: + type: number + virtual_keys: + type: string + trace_id: + type: string + configs: + type: string + workspace_slug: + type: string + prompt_slug: + type: string + page_size: + type: number + description: "max: 50000, default: 50000" + example: 50000 + current_page: + type: number + example: 0 + + LogObject: + type: object + required: + - _id + - request + - response + - organisation_id + - created_at + properties: + _id: + type: string + format: uuid + description: Unique identifier for the log entry + nullable: true + example: "550e8400-e29b-41d4-a716-446655440000" + + request: + $ref: '#/components/schemas/LogRequest' + + response: + $ref: '#/components/schemas/LogResponse' + + organisation_id: + type: string + description: Organization identifier + nullable: true + example: "org-123" + + created_at: + type: string + format: date-time + description: Timestamp when the log was created + nullable: true + example: "2024-01-15T10:30:00.000Z" + + metrics: + $ref: '#/components/schemas/AnalyticsMetrics' + description: Analytics metrics object containing detailed metrics about the request + + finalUntransformedRequest: + $ref: '#/components/schemas/RequestResponseObject' + description: The original request before any transformations (only present when debug logging is enabled) + + originalResponse: + $ref: '#/components/schemas/RequestResponseObject' + description: The original response from the provider (only present when debug logging is enabled or request failed) + + transformedRequest: + $ref: '#/components/schemas/RequestResponseObject' + description: The request after transformations (only present when debug logging is enabled) + + LogRequest: + type: object + required: + - url + - method + - portkeyHeaders + properties: + url: + type: string + format: uri + description: Sanitized request URL + example: "https://api.openai.com/v1/chat/completions" + + method: + type: string + description: HTTP method + enum: [GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD] + example: "POST" + + headers: + type: object + additionalProperties: + type: string + description: Request headers (only present when debug logging is enabled) + example: + "Content-Type": "application/json" + "Authorization": "Bearer hashed_value" + + body: + type: object + additionalProperties: true + description: Request body (only present when debug logging is enabled) + + portkeyHeaders: + type: object + additionalProperties: + type: string + description: Portkey-specific headers + example: + "x-portkey-trace-id": "trace-123" + "x-portkey-span-id": "span-456" + "x-portkey-metadata": "{\"key\":\"value\"}" + + LogResponse: + type: object + required: + - status + - responseTime + - lastUsedOptionJsonPath + properties: + status: + type: integer + format: int32 + description: HTTP response status code + example: 200 + + headers: + type: object + additionalProperties: + type: string + description: Response headers (only present when debug logging is enabled or request failed) + example: + "Content-Type": "application/json" + + body: + type: object + additionalProperties: true + description: Response body (only present when debug logging is enabled or request failed). May be redacted for certain embedding models. + example: + id: "chatcmpl-123" + object: "chat.completion" + created: 1677652288 + + responseTime: + type: integer + format: int64 + description: Response time in milliseconds + example: 1234 + + lastUsedOptionJsonPath: + type: string + description: JSON path to the last used option in the config + example: "$.config.options[0]" + + RequestResponseObject: + type: object + properties: + body: + type: object + additionalProperties: true + description: The body content + headers: + type: object + additionalProperties: + type: string + description: Headers if present + url: + type: string + format: uri + description: URL if present + method: + type: string + description: HTTP method if present + + AnalyticsMetrics: + type: object + description: Analytics metrics extracted from the log entry + properties: + id: + type: string + format: uuid + description: Unique identifier for the log entry + example: "550e8400-e29b-41d4-a716-446655440000" + + organisation_id: + type: string + description: Organization identifier + example: "org-123" + + organisation_name: + type: string + description: Organization name + example: "Acme Corp" + + prompt_id: + type: string + description: Prompt identifier + example: "prompt-789" + + prompt_version_id: + type: string + description: Prompt version identifier + example: "prompt-v1" + + config_id: + type: string + description: Configuration identifier + example: "config-123" + + created_at: + type: string + format: date-time + description: Timestamp when the log was created + example: "2024-01-15T10:30:00.000" + + is_success: + type: boolean + description: Whether the request was successful (status code 200-299) + example: true + + ai_org: + type: string + description: AI provider organization (e.g., openai, anthropic) + example: "openai" + + ai_model: + type: string + description: AI model used + example: "gpt-4o" + + req_units: + type: number + format: float + description: Request token units + example: 100 + + res_units: + type: number + format: float + description: Response token units + example: 50 + + total_units: + type: number + format: float + description: Total token units (req_units + res_units) + example: 150 + + cost: + type: number + format: float + description: Cost in the specified currency + example: 0.002 + + cost_currency: + type: string + description: Currency code for the cost + default: "USD" + example: "USD" + + request_url: + type: string + format: uri + description: Sanitized request URL + example: "https://api.openai.com/v1/chat/completions" + + request_method: + type: string + description: HTTP method + example: "POST" + + response_status_code: + type: integer + format: int32 + description: HTTP response status code + example: 200 + + response_time: + type: integer + format: int64 + description: Response time in milliseconds + example: 1234 + + is_proxy_call: + type: boolean + description: Whether this was a proxy call + example: true + + cache_status: + type: string + nullable: true + description: Cache status (e.g., HIT, MISS, DISABLED, SEMANTIC HIT) + example: "MISS" + + cache_type: + type: string + nullable: true + description: Type of cache used + example: "semantic" + + stream_mode: + type: integer + nullable: true + description: Whether streaming was enabled (1) or not (0) + example: 1 + + retry_success_count: + type: integer + description: Number of successful retries + example: 0 + + trace_id: + type: string + description: Distributed tracing trace ID + example: "trace-123" + + span_id: + type: string + description: Distributed tracing span ID + example: "span-456" + + span_name: + type: string + description: Name of the span + example: "llm" + + parent_span_id: + type: string + description: Parent span ID in distributed tracing + example: "span-789" + + mode: + type: string + description: Request mode (e.g., single, loadbalance, fallback) + example: "single" + + virtual_key: + type: string + description: Virtual key identifier + example: "vk-123" + + source: + type: string + description: Source of the request (e.g., rubeus, proxy) + example: "rubeus" + + runtime: + type: string + description: Runtime environment + example: "node" + + runtime_version: + type: string + description: Runtime version + example: "18.0.0" + + sdk_version: + type: string + description: SDK version + example: "1.0.0" + + config: + type: string + description: Configuration slug or ID + example: "pc-config-123" + + internal_trace_id: + type: string + description: Internal trace ID for gateway tracking + example: "internal-trace-123" + + last_used_option_index: + type: integer + description: Index of the last used option in the config + example: 0 + + config_version_id: + type: string + description: Configuration version identifier + example: "config-v1" + + prompt_slug: + type: string + description: Prompt slug + example: "my-prompt" + + workspace_slug: + type: string + nullable: true + description: Workspace slug + example: "my-workspace" + + log_store_file_path_format: + type: string + description: Path format version for log storage + example: "v1" + + metadata.key: + type: array + items: + type: string + nullable: true + description: Array of metadata keys + example: ["key1", "key2"] + + metadata.value: + type: array + items: + type: string + nullable: true + description: Array of metadata values + example: ["value1", "value2"] + + api_key_id: + type: string + description: API key identifier + example: "api-key-123" + + request_parsing_time: + type: integer + format: int64 + description: Time taken to parse the request in milliseconds + example: 5 + + pre_processing_time: + type: integer + format: int64 + description: Time taken for pre-processing in milliseconds + example: 10 + + cache_processing_time: + type: integer + format: int64 + description: Time taken for cache processing in milliseconds + example: 2 + + response_parsing_time: + type: integer + format: int64 + description: Time taken to parse the response in milliseconds + example: 8 + + gateway_processing_time: + type: integer + format: int64 + description: Total gateway processing time in milliseconds + example: 50 + + upstream_response_time: + type: integer + format: int64 + description: Upstream provider response time in milliseconds + example: 1200 + + LogExportsRequestedData: + type: array + items: + type: string + enum: + - id + - trace_id + - created_at + - request + - response + - is_success + - ai_org + - ai_model + - req_units + - res_units + - total_units + - request_url + - cost + - cost_currency + - response_time + - response_status_code + - mode + - config + - prompt_slug + - metadata + + AuditLogObjectList: + type: object + properties: + records: + type: array + items: 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: - type: string - chunking_strategy: - $ref: "#/components/schemas/ChunkingStrategyRequestParam" - required: - - file_ids - - AssistantStreamEvent: - description: | - Represents an event emitted when streaming a Run. - - Each event in a server-sent events stream has an `event` and `data` property: - - ``` - event: thread.created - data: {"id": "thread_123", "object": "thread", ...} - ``` - - We emit events whenever a new object is created, transitions to a new state, or is being - streamed in parts (deltas). For example, we emit `thread.run.created` when a new run - is created, `thread.run.completed` when a run completes, and so on. When an Assistant chooses - to create a message during a run, we emit a `thread.message.created event`, a - `thread.message.in_progress` event, many `thread.message.delta` events, and finally a - `thread.message.completed` event. - - We may add additional events over time, so we recommend handling unknown events gracefully - in your code. See the [Assistants API quickstart](/docs/assistants/overview) to learn how to - integrate the Assistants API with streaming. - oneOf: - - $ref: "#/components/schemas/ThreadStreamEvent" - - $ref: "#/components/schemas/RunStreamEvent" - - $ref: "#/components/schemas/RunStepStreamEvent" - - $ref: "#/components/schemas/MessageStreamEvent" - - $ref: "#/components/schemas/ErrorEvent" - - $ref: "#/components/schemas/DoneEvent" - x-oaiMeta: - name: Assistant stream events - beta: true - - ThreadStreamEvent: - oneOf: - - type: object - properties: - event: - type: string - enum: ["thread.created"] - data: - $ref: "#/components/schemas/ThreadObject" - required: - - event - - data - description: Occurs when a new [thread](/docs/api-reference/threads/object) is created. - x-oaiMeta: - dataDescription: "`data` is a [thread](/docs/api-reference/threads/object)" - - RunStreamEvent: - oneOf: - - type: object - properties: - event: - type: string - enum: ["thread.run.created"] - data: - $ref: "#/components/schemas/RunObject" - required: - - event - - data - description: Occurs when a new [run](/docs/api-reference/runs/object) is created. - x-oaiMeta: - dataDescription: "`data` is a [run](/docs/api-reference/runs/object)" - - type: object - properties: - event: - type: string - enum: ["thread.run.queued"] - data: - $ref: "#/components/schemas/RunObject" - required: - - event - - data - description: Occurs when a [run](/docs/api-reference/runs/object) moves to a `queued` status. - x-oaiMeta: - dataDescription: "`data` is a [run](/docs/api-reference/runs/object)" - - type: object - properties: - event: - type: string - enum: ["thread.run.in_progress"] - data: - $ref: "#/components/schemas/RunObject" - required: - - event - - data - description: Occurs when a [run](/docs/api-reference/runs/object) moves to an `in_progress` status. - x-oaiMeta: - dataDescription: "`data` is a [run](/docs/api-reference/runs/object)" - - type: object - properties: - event: - type: string - enum: ["thread.run.requires_action"] - data: - $ref: "#/components/schemas/RunObject" - required: - - event - - data - description: Occurs when a [run](/docs/api-reference/runs/object) moves to a `requires_action` status. - x-oaiMeta: - dataDescription: "`data` is a [run](/docs/api-reference/runs/object)" - - type: object - properties: - event: - type: string - enum: ["thread.run.completed"] - data: - $ref: "#/components/schemas/RunObject" - required: - - event - - data - description: Occurs when a [run](/docs/api-reference/runs/object) is completed. - x-oaiMeta: - dataDescription: "`data` is a [run](/docs/api-reference/runs/object)" - - type: object - properties: - event: - type: string - enum: [ "thread.run.incomplete" ] - data: - $ref: "#/components/schemas/RunObject" - required: - - event - - data - description: Occurs when a [run](/docs/api-reference/runs/object) ends with status `incomplete`. - x-oaiMeta: - dataDescription: "`data` is a [run](/docs/api-reference/runs/object)" - - type: object - properties: - event: - type: string - enum: ["thread.run.failed"] - data: - $ref: "#/components/schemas/RunObject" - required: - - event - - data - description: Occurs when a [run](/docs/api-reference/runs/object) fails. - x-oaiMeta: - dataDescription: "`data` is a [run](/docs/api-reference/runs/object)" - - type: object - properties: - event: - type: string - enum: ["thread.run.cancelling"] - data: - $ref: "#/components/schemas/RunObject" - required: - - event - - data - description: Occurs when a [run](/docs/api-reference/runs/object) moves to a `cancelling` status. - x-oaiMeta: - dataDescription: "`data` is a [run](/docs/api-reference/runs/object)" - - type: object - properties: - event: - type: string - enum: ["thread.run.cancelled"] - data: - $ref: "#/components/schemas/RunObject" - required: - - event - - data - description: Occurs when a [run](/docs/api-reference/runs/object) is cancelled. - x-oaiMeta: - dataDescription: "`data` is a [run](/docs/api-reference/runs/object)" - - type: object - properties: - event: - type: string - enum: ["thread.run.expired"] - data: - $ref: "#/components/schemas/RunObject" - required: - - event - - data - description: Occurs when a [run](/docs/api-reference/runs/object) expires. - x-oaiMeta: - dataDescription: "`data` is a [run](/docs/api-reference/runs/object)" - - RunStepStreamEvent: - oneOf: - - type: object - properties: - event: - type: string - enum: ["thread.run.step.created"] - data: - $ref: "#/components/schemas/RunStepObject" - required: - - event - - data - description: Occurs when a [run step](/docs/api-reference/runs/step-object) is created. - x-oaiMeta: - dataDescription: "`data` is a [run step](/docs/api-reference/runs/step-object)" - - type: object - properties: - event: - type: string - enum: ["thread.run.step.in_progress"] - data: - $ref: "#/components/schemas/RunStepObject" - required: - - event - - data - description: Occurs when a [run step](/docs/api-reference/runs/step-object) moves to an `in_progress` state. - x-oaiMeta: - dataDescription: "`data` is a [run step](/docs/api-reference/runs/step-object)" - - type: object - properties: - event: - type: string - enum: ["thread.run.step.delta"] - data: - $ref: "#/components/schemas/RunStepDeltaObject" - required: - - event - - data - description: Occurs when parts of a [run step](/docs/api-reference/runs/step-object) are being streamed. - x-oaiMeta: - dataDescription: "`data` is a [run step delta](/docs/api-reference/assistants-streaming/run-step-delta-object)" - - type: object - properties: - event: - type: string - enum: ["thread.run.step.completed"] - data: - $ref: "#/components/schemas/RunStepObject" - required: - - event - - data - description: Occurs when a [run step](/docs/api-reference/runs/step-object) is completed. - x-oaiMeta: - dataDescription: "`data` is a [run step](/docs/api-reference/runs/step-object)" - - type: object - properties: - event: - type: string - enum: ["thread.run.step.failed"] - data: - $ref: "#/components/schemas/RunStepObject" - required: - - event - - data - description: Occurs when a [run step](/docs/api-reference/runs/step-object) fails. - x-oaiMeta: - dataDescription: "`data` is a [run step](/docs/api-reference/runs/step-object)" - - type: object - properties: - event: - type: string - enum: ["thread.run.step.cancelled"] - data: - $ref: "#/components/schemas/RunStepObject" - required: - - event - - data - description: Occurs when a [run step](/docs/api-reference/runs/step-object) is cancelled. - x-oaiMeta: - dataDescription: "`data` is a [run step](/docs/api-reference/runs/step-object)" - - type: object - properties: - event: - type: string - enum: ["thread.run.step.expired"] - data: - $ref: "#/components/schemas/RunStepObject" - required: - - event - - data - description: Occurs when a [run step](/docs/api-reference/runs/step-object) expires. - x-oaiMeta: - dataDescription: "`data` is a [run step](/docs/api-reference/runs/step-object)" - - MessageStreamEvent: - oneOf: - - type: object - properties: - event: - type: string - enum: ["thread.message.created"] - data: - $ref: "#/components/schemas/MessageObject" - required: - - event - - data - description: Occurs when a [message](/docs/api-reference/messages/object) is created. - x-oaiMeta: - dataDescription: "`data` is a [message](/docs/api-reference/messages/object)" - - type: object - properties: - event: - type: string - enum: ["thread.message.in_progress"] - data: - $ref: "#/components/schemas/MessageObject" - required: - - event - - data - description: Occurs when a [message](/docs/api-reference/messages/object) moves to an `in_progress` state. - x-oaiMeta: - dataDescription: "`data` is a [message](/docs/api-reference/messages/object)" - - type: object - properties: - event: - type: string - enum: ["thread.message.delta"] - data: - $ref: "#/components/schemas/MessageDeltaObject" - required: - - event - - data - description: Occurs when parts of a [Message](/docs/api-reference/messages/object) are being streamed. - x-oaiMeta: - dataDescription: "`data` is a [message delta](/docs/api-reference/assistants-streaming/message-delta-object)" - - type: object - properties: - event: - type: string - enum: ["thread.message.completed"] - data: - $ref: "#/components/schemas/MessageObject" - required: - - event - - data - description: Occurs when a [message](/docs/api-reference/messages/object) is completed. - x-oaiMeta: - dataDescription: "`data` is a [message](/docs/api-reference/messages/object)" - - type: object - properties: - event: - type: string - enum: ["thread.message.incomplete"] - data: - $ref: "#/components/schemas/MessageObject" - required: - - event - - data - description: Occurs when a [message](/docs/api-reference/messages/object) ends before it is completed. - x-oaiMeta: - dataDescription: "`data` is a [message](/docs/api-reference/messages/object)" - - ErrorEvent: + timestamp: + type: string + description: Timestamp of when the action occurred + method: + type: string + enum: [POST, PUT, DELETE] + description: HTTP method used for the request + uri: + type: string + description: URI path that was accessed + request_id: + type: string + description: Unique ID of the request + request_body: + type: string + description: JSON string of the request body + query_params: + type: string + description: JSON string of the query parameters + request_headers: + type: string + description: JSON string of the request headers (partially masked) + user_id: + type: string + format: uuid + description: ID of the user who made the request + user_type: + type: string + enum: [user, api_key] + description: Type of user who made the request + organisation_id: + type: string + format: uuid + description: ID of the organisation the user belongs to + workspace_id: + type: string + description: ID of the workspace the resource belongs to + response_status_code: + type: integer + description: HTTP status code of the response + resource_type: + type: string + description: Type of resource that was accessed + action: + type: string + description: Action performed on the resource + client_ip: + type: string + description: IP address of the client + country: + type: string + description: Country of origin based on the IP address + total: + type: integer + description: Total number of records in the response + object: + type: string + description: The type of object being returned + enum: [analytics-graph] + + ApiKeyObject: + type: object + properties: + id: + type: string + format: uuid + example: "f47ac10b-58cc-4372-a567-0e02b2c3d479" + key: + type: string + example: "Xk*******S4" + name: + type: string + example: "Development API Key" + description: + type: string + example: "API key for development environment" + type: + type: string + enum: ["organisation-service", "workspace-service", "workspace-user"] + example: "organisation-service" + organisation_id: + type: string + format: uuid + example: "a1b2c3d4-e5f6-4a5b-8c7d-9e0f1a2b3c4d" + workspace_id: + type: string + example: "ws-myworkspace" + user_id: + type: string + format: uuid + example: "c3d4e5f6-a7b8-6c7d-0e1f-2a3b4c5d6e7f" + status: + type: string + enum: ["active", "exhausted"] + example: "active" + created_at: + type: string + format: date-time + example: "2023-09-15T10:30:00Z" + last_updated_at: + type: string + format: date-time + example: "2023-09-15T10:30:00Z" + creation_mode: + type: string + enum: ["ui", "api", "auto"] + example: "ui" + rate_limits: + type: array + items: type: object properties: - event: - type: string - enum: ["error"] - data: - $ref: "#/components/schemas/Error" - required: - - event - - data - description: Occurs when an [error](/docs/guides/error-codes/api-errors) occurs. This can happen due to an internal server error or a timeout. - x-oaiMeta: - dataDescription: "`data` is an [error](/docs/guides/error-codes/api-errors)" - - DoneEvent: + type: + type: string + example: "requests" + unit: + type: string + example: "rpm" + value: + type: integer + example: 100 + usage_limits: + $ref: "#/components/schemas/UsageLimits" + reset_usage: + type: number + example: 0 + scopes: + type: array + items: + type: string + example: ["completions.write"] + defaults: + type: object + properties: + metadata: + type: object + additionalProperties: true + example: + environment: "development" + team: "backend" + config_id: + type: string + example: config-abc + alert_emails: + type: array + items: + type: string + format: email + example: "foo@bar.com" + expires_at: + type: string + format: date-time + object: + type: string + enum: ["api-key"] + example: "api-key" + + ApiKeyObjectList: + type: object + properties: + total: + type: integer + example: 2 + object: + type: string + enum: + - list + data: + type: array + items: + $ref: "#/components/schemas/ApiKeyObject" + + CreateApiKeyObject: + type: object + required: + - name + - scopes + properties: + name: + type: string + example: "Development API Key" + description: + type: string + example: "API key for development environment" + workspace_id: + type: string + example: "ws-myworkspace" + user_id: + type: string + format: uuid + description: "**Required** when sub-type path parameter is 'user'. Not required when sub-type is 'service'." + example: "c3d4e5f6-a7b8-6c7d-0e1f-2a3b4c5d6e7f" + rate_limits: + type: array + items: type: object properties: - event: - type: string - enum: ["done"] - data: - type: string - enum: ["[DONE]"] - required: - - event - - data - description: Occurs when a stream ends. - x-oaiMeta: - dataDescription: "`data` is `[DONE]`" - - Batch: + type: + type: string + example: "requests" + unit: + type: string + example: "rpm" + value: + type: integer + example: 100 + usage_limits: + $ref: "#/components/schemas/UsageLimits" + scopes: + type: array + items: + type: string + example: ["completions.write"] + defaults: + type: object + properties: + metadata: + type: object + additionalProperties: true + example: + environment: "development" + team: "backend" + config_id: + type: string + example: config-abc + alert_emails: + type: array + items: + type: string + format: email + example: "foo@bar.com" + expires_at: + type: string + format: date-time + + UpdateApiKeyObject: + type: object + properties: + name: + type: string + example: "Development API Key" + description: + type: string + example: "API key for development environment" + rate_limits: + type: array + items: 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. + type: + type: string + example: "requests" + unit: + type: string + example: "rpm" + value: + type: integer + example: 100 + usage_limits: + $ref: "#/components/schemas/UsageLimits" + reset_usage: + type: boolean + description: Whether to reset current usage. If the current status is exhausted, this will change it back to active. + example: true + scopes: + type: array + items: + type: string + example: ["completions.write"] + defaults: + type: object + properties: + metadata: + type: object + additionalProperties: true + example: + environment: "development" + team: "backend" + config_id: + type: string + example: config-abc + alert_emails: + type: array + items: + type: string + format: email + example: "foo@bar.com" + + RotateApiKeyRequest: + type: object + properties: + key_transition_period_ms: + type: integer + minimum: 1800000 + description: Optional transition period in milliseconds during which the previous key remains valid. + example: 3600000 + + RotateApiKeyResponse: + type: object + properties: + id: + type: string + format: uuid + example: "550e8400-e29b-41d4-a716-446655440000" + key: + type: string + description: Newly rotated API key value. + example: "pk_live_new_rotated_key_value" + key_transition_expires_at: + type: string + format: date-time + description: Timestamp when the previous key version stops being accepted. + example: "2026-01-15T10:30:00.000Z" + + PromptRenderResponse: + type: object + required: + - success + - data + properties: + success: + type: boolean + description: Indicates if the render was successful + data: + oneOf: + - title: Chat Completions + $ref: "#/components/schemas/CreateChatCompletionRequest" + - title: Completions + $ref: "#/components/schemas/CreateCompletionRequest" + + CreateGuardrailRequest: + type: object + required: + - name + - checks + - actions + properties: + name: + type: string + description: Name of the guardrail + example: "Content Safety Check" + workspace_id: + type: string + format: uuid + description: Workspace UUID (required if organisation_id not provided and not using API key) + organisation_id: + type: string + format: uuid + description: Organisation UUID (required if workspace_id not provided and not using API key) + checks: + type: array + description: Array of guardrail checks to apply + items: + $ref: '#/components/schemas/GuardrailCheck' + minItems: 1 + actions: + $ref: '#/components/schemas/GuardrailActions' + + UpdateGuardrailRequest: + type: object + properties: + name: + type: string + description: Updated name of the guardrail + checks: + type: array + description: Updated array of guardrail checks + items: + $ref: '#/components/schemas/GuardrailCheck' + minItems: 1 + actions: + $ref: '#/components/schemas/GuardrailActions' + + GuardrailActions: + type: object + description: Actions to take when guardrail checks fail or pass + properties: + deny: + type: boolean + description: Whether to deny the request when guardrail check fails + default: false + async: + type: boolean + description: Whether the guardrail check should be performed asynchronously + default: false + on_success: + type: object + description: Actions to take when guardrail check passes + properties: + feedback: + type: object + description: Feedback configuration for successful checks + properties: + value: + type: number + description: Feedback value for successful checks + default: 5 + weight: + type: number + description: Weight of the feedback + default: 1 metadata: - description: *metadata_description - 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: *batch_object - - BatchRequestInput: + type: string + description: Additional metadata for the feedback + default: "" + required: + - value + - weight + - metadata + required: + - feedback + on_fail: + type: object + description: Actions to take when guardrail check fails + properties: + feedback: + type: object + description: Feedback configuration for failed checks + properties: + value: + type: number + description: Feedback value for failed checks + default: -5 + weight: + type: number + description: Weight of the feedback + default: 1 + metadata: + type: string + description: Additional metadata for the feedback + default: "" + required: + - value + - weight + - metadata + required: + - feedback + required: + - deny + - async + - on_success + - on_fail + + GuardrailCheck: + type: object + required: + - id + properties: + id: + type: string + description: Identifier of the guardrail check type + enum: + # BASIC category guardrails + - "default.jwt" + - "default.modelWhitelist" + - "default.isAllLowerCase" + - "default.regexMatch" + - "default.sentenceCount" + - "default.wordCount" + - "default.characterCount" + - "default.jsonSchema" + - "default.jsonKeys" + - "default.contains" + - "default.validUrls" + - "default.containsCode" + - "default.webhook" + - "default.endsWith" + - "default.alluppercase" + - "default.requiredMetadataKeys" + - "default.allowedRequestTypes" + # PRO category guardrails + - "portkey.moderateContent" + - "portkey.language" + - "portkey.pii" + - "portkey.gibberish" + # PARTNER category guardrails + - "sydelabs.sydeguard" + - "aporia.validateProject" + - "pillar.scanPrompt" + - "pillar.scanResponse" + - "patronus.phi" + - "patronus.pii" + - "patronus.isConcise" + - "patronus.isHelpful" + - "patronus.isPolite" + - "patronus.noApologies" + - "patronus.noGenderBias" + - "patronus.noRacialBias" + - "patronus.retrievalAnswerRelevance" + - "patronus.toxicity" + - "patronus.custom" + - "mistral.moderateContent" + - "bedrock.guard" + - "promptfoo.guard" + - "promptfoo.pii" + - "promptfoo.harm" + - "acuvity.scan" + - "lasso.classify" + - "azure.contentSafety" + - "azure.pii" + - "panw-prisma-airs.intercept" + parameters: + oneOf: + - $ref: '#/components/schemas/JWTParameters' + - $ref: '#/components/schemas/ModelWhitelistParameters' + - $ref: '#/components/schemas/RegexMatchParameters' + - $ref: '#/components/schemas/SentenceCountParameters' + - $ref: '#/components/schemas/WordCountParameters' + - $ref: '#/components/schemas/CharacterCountParameters' + - $ref: '#/components/schemas/JSONSchemaParameters' + - $ref: '#/components/schemas/JSONKeysParameters' + - $ref: '#/components/schemas/ContainsParameters' + - $ref: '#/components/schemas/ValidUrlsParameters' + - $ref: '#/components/schemas/ContainsCodeParameters' + - $ref: '#/components/schemas/WebhookParameters' + - $ref: '#/components/schemas/EndsWithParameters' + - $ref: '#/components/schemas/UppercaseParameters' + - $ref: '#/components/schemas/RequiredMetadataKeysParameters' + - $ref: '#/components/schemas/AllowedRequestTypesParameters' + - $ref: '#/components/schemas/SydeGuardParameters' + - $ref: '#/components/schemas/AporiaParameters' + - $ref: '#/components/schemas/PillarScanParameters' + - $ref: '#/components/schemas/PatronusParameters' + - $ref: '#/components/schemas/PatronusCustomParameters' + - $ref: '#/components/schemas/PortkeyModerationParameters' + - $ref: '#/components/schemas/PortkeyLanguageParameters' + - $ref: '#/components/schemas/PortkeyPIIParameters' + - $ref: '#/components/schemas/MistralModerationParameters' + - $ref: '#/components/schemas/BedrockGuardParameters' + - $ref: '#/components/schemas/PromptfooParameters' + - $ref: '#/components/schemas/AcuvityScanParameters' + - $ref: '#/components/schemas/AzureContentSafetyParameters' + - $ref: '#/components/schemas/AzurePIIParameters' + - $ref: '#/components/schemas/PANWPrismaParameters' + - $ref: '#/components/schemas/BasicParameters' + description: Configuration parameters specific to the check type + name: + type: string + description: Custom name for this specific check instance + is_enabled: + type: boolean + description: Whether this check is enabled + default: true + + CreateGuardrailResponse: + type: object + required: + - id + - slug + - version_id + properties: + id: + type: string + description: Unique identifier of the created guardrail + slug: + type: string + description: URL-friendly slug for the guardrail + version_id: + type: string + description: Version identifier for the guardrail configuration + + UpdateGuardrailResponse: + type: object + required: + - id + - slug + properties: + id: + type: string + description: Unique identifier of the updated guardrail + slug: + type: string + description: URL-friendly slug for the guardrail + version_id: + type: string + description: New version identifier after update + + ListGuardrailsResponse: + type: object + required: + - data + - total + properties: + data: + type: array + description: Array of guardrail summaries + items: + $ref: '#/components/schemas/GuardrailSummary' + total: + type: integer + description: Total number of guardrails available + minimum: 0 + + GuardrailSummary: + type: object + required: + - id + - name + - slug + - created_at + - last_updated_at + - owner_id + properties: + id: + type: string + description: Unique identifier of the guardrail + name: + type: string + description: Name of the guardrail + slug: + type: string + description: URL-friendly slug + organisation_id: + type: string + format: uuid + description: Organisation UUID + workspace_id: + type: string + format: uuid + nullable: true + description: Workspace UUID (null for organisation-level guardrails) + status: + type: string + enum: ["active", "archived"] + description: Current status of the guardrail + created_at: + type: string + format: date-time + description: Creation timestamp + last_updated_at: + type: string + format: date-time + description: Last update timestamp + owner_id: + type: string + format: uuid + description: UUID of the user who created the guardrail + updated_by: + type: string + format: uuid + nullable: true + description: UUID of the user who last updated the guardrail + + GuardrailDetails: + allOf: + - $ref: '#/components/schemas/GuardrailSummary' + - type: object + properties: + checks: + type: array + description: Array of configured guardrail checks + items: + $ref: '#/components/schemas/GuardrailCheck' + actions: + $ref: '#/components/schemas/GuardrailActions' + +# Detailed parameter schemas for specific guardrail types + JWTParameters: + title: JWT Parameters + type: object + required: + - jwksUri + - headerKey + properties: + jwksUri: + type: string + format: uri + description: JWKS URI of the JWT token + headerKey: + type: string + description: Header key to check for the JWT token + cacheMaxAge: + type: number + description: Cache max age in seconds + default: 86400 + clockTolerance: + type: number + description: Clock tolerance in seconds + default: 5 + maxTokenAge: + type: string + description: Max token age + default: "1d" + algorithms: + type: array + items: + type: string + description: Algorithms to check for the JWT token + default: ["RS256"] + + RegexMatchParameters: + title: Regex Match Parameters + type: object + required: + - rule + properties: + rule: + type: string + description: Regex pattern to match + not: + type: boolean + description: If true, the check will fail when the regex pattern matches + default: false + + ModelWhitelistParameters: + title: Model Whitelist Parameters + type: object + required: + - models + properties: + models: + type: array + items: + type: string + description: List of allowed models + + WordCountParameters: + title: Word Count Parameters + type: object + properties: + minWords: + type: number + description: Minimum number of words to allow + default: 0 + maxWords: + type: number + description: Maximum number of words to allow + default: 99999 + not: + type: boolean + description: If true, the verdict will be inverted + default: false + + SentenceCountParameters: + title: Sentence Count Parameters + type: object + properties: + minSentences: + type: number + description: Minimum number of sentences to allow + default: 0 + maxSentences: + type: number + description: Maximum number of sentences to allow + default: 99999 + not: + type: boolean + description: If true, the verdict will be inverted + default: false + + CharacterCountParameters: + title: Character Count Parameters + type: object + properties: + minCharacters: + type: number + description: Minimum number of characters to allow + default: 0 + maxCharacters: + type: number + description: Maximum number of characters to allow + default: 9999999 + not: + type: boolean + description: If true, the verdict will be inverted + default: false + + JSONSchemaParameters: + title: JSON Schema Parameters + type: object + required: + - schema + properties: + schema: + type: object + additionalProperties: true + description: JSON schema to validate against + not: + type: boolean + description: If true, the verdict will be inverted + default: false + + JSONKeysParameters: + title: JSON Keys Parameters + type: object + required: + - keys + - operator + properties: + keys: + type: array + items: + type: string + description: Keys to check for in JSON + operator: + type: string + enum: ["any", "all", "none"] + description: Operator to use for key checking + default: "any" + + ContainsParameters: + title: Contains Parameters + type: object + required: + - words + - operator + properties: + words: + type: array + items: + type: string + description: Words or phrases to check for + operator: + type: string + enum: ["any", "all", "none"] + description: Operator to use for word checking + default: "any" + + ValidUrlsParameters: + title: Valid URLs Parameters + type: object + properties: + onlyDNS: + type: boolean + description: Only check if URL domains resolve (10x faster) + default: false + not: + type: boolean + description: If true, the verdict will be inverted + default: false + + ContainsCodeParameters: + title: Contains Code Parameters + type: object + required: + - format + properties: + format: + type: string + enum: + - "SQL" + - "Python" + - "TypeScript" + - "JavaScript" + - "Java" + - "C#" + - "C++" + - "C" + - "Ruby" + - "PHP" + - "Swift" + - "Kotlin" + - "Go" + - "Rust" + - "Scala" + - "R" + - "Perl" + - "Shell" + - "HTML" + - "CSS" + - "XML" + - "JSON" + - "YAML" + - "Markdown" + - "Dockerfile" + description: Code format to check for + not: + type: boolean + description: If true, the verdict will be inverted + default: false + + WebhookParameters: + title: Webhook Parameters + type: object + required: + - webhookURL + properties: + webhookURL: + type: string + format: uri + description: Webhook URL to call + headers: + type: object + additionalProperties: true + description: Headers to send with the request + timeout: + type: number + description: Timeout in milliseconds + default: 3000 + failOnError: + type: boolean + description: Fail if webhook returns non-200 status or times out + default: false + + EndsWithParameters: + title: Ends With Parameters + type: object + required: + - suffix + properties: + suffix: + type: string + description: Suffix to check for + not: + type: boolean + description: If true, the verdict will be inverted + default: false + + UppercaseParameters: + title: Uppercase Parameters + type: object + properties: + not: + type: boolean + description: If true, the verdict will be inverted + default: false + + RequiredMetadataKeysParameters: + title: Required Metadata Keys Parameters + type: object + required: + - metadataKeys + - operator + properties: + metadataKeys: + type: array + items: + type: string + description: Metadata keys to check for + operator: + type: string + enum: ["all", "any", "none"] + description: Operator to use for key checking + default: "all" + + AllowedRequestTypesParameters: + title: Allowed Request Types Parameters + type: object + description: Parameters for default.allowedRequestTypes check. Restrict which request types are allowed or blocked. You can use either or both; when both are specified, blocked types take precedence. + properties: + allowedTypes: + type: array + items: + type: string + enum: + - complete + - chatComplete + - embed + - rerank + - moderate + - proxy + - imageGenerate + - createSpeech + - createTranscription + - createTranslation + - realtime + - uploadFile + - listFiles + - retrieveFile + - deleteFile + - retrieveFileContent + - createBatch + - retrieveBatch + - cancelBatch + - listBatches + - getBatchOutput + - listFinetunes + - createFinetune + - retrieveFinetune + - cancelFinetune + - createModelResponse + - getModelResponse + - deleteModelResponse + - listResponseInputItems + - messages + description: Request types to allow (allowlist). When set, only these request types are permitted. + blockedTypes: + type: array + items: + type: string + enum: + - complete + - chatComplete + - embed + - rerank + - moderate + - proxy + - imageGenerate + - createSpeech + - createTranscription + - createTranslation + - realtime + - uploadFile + - listFiles + - retrieveFile + - deleteFile + - retrieveFileContent + - createBatch + - retrieveBatch + - cancelBatch + - listBatches + - getBatchOutput + - listFinetunes + - createFinetune + - retrieveFinetune + - cancelFinetune + - createModelResponse + - getModelResponse + - deleteModelResponse + - listResponseInputItems + - messages + description: Request types to block (blocklist). When set, these request types are denied. + + SydeGuardParameters: + title: SydeGuard Parameters + type: object + properties: + prompt_injection_threshold: + type: number + minimum: 0 + maximum: 1 + multipleOf: 0.01 + description: Threshold for prompt injection risk score (0-1) + default: 0.5 + toxicity_threshold: + type: number + minimum: 0 + maximum: 1 + multipleOf: 0.01 + description: Threshold for toxicity risk score (0-1) + default: 0.5 + evasion_threshold: + type: number + minimum: 0 + maximum: 1 + multipleOf: 0.01 + description: Threshold for evasion risk score (0-1) + default: 0.5 + timeout: + type: number + description: Timeout in milliseconds + default: 5000 + + AporiaParameters: + title: Aporia Parameters + type: object + required: + - projectID + properties: + projectID: + type: string + description: Aporia Project ID to validate + timeout: + type: number + description: Timeout in milliseconds + default: 5000 + + PillarScanParameters: + title: Pillar Scan Parameters + type: object + required: + - scanners + properties: + scanners: + type: array + items: + type: string + enum: + - "prompt_injection" + - "pii" + - "secrets" + - "toxic_language" + - "invisible_characters" + description: Scanners to use for content analysis + timeout: + type: number + description: Timeout in milliseconds + default: 5000 + + PatronusParameters: + title: Patronus Parameters + type: object + properties: + redact: + type: boolean + description: Whether to redact detected content + default: false + timeout: + type: number + description: Timeout in milliseconds + default: 5000 + + PatronusCustomParameters: + title: Patronus Custom Parameters + type: object + required: + - profile + properties: + profile: + type: string + description: Custom evaluator profile name (e.g., system:is-concise) + timeout: + type: number + description: Timeout in milliseconds + default: 15000 + + PortkeyModerationParameters: + title: Portkey Moderation Parameters + type: object + required: + - categories + properties: + categories: + type: array + items: + type: string + enum: + - "hate" + - "hate/threatening" + - "harassment" + - "harassment/threatening" + - "self-harm" + - "self-harm/intent" + - "self-harm/instructions" + - "sexual" + - "sexual/minors" + - "violence" + - "violence/graphic" + description: Categories that should NOT be allowed + timeout: + type: number + description: Timeout in milliseconds + default: 5000 + + PortkeyLanguageParameters: + title: Portkey Language Parameters + type: object + properties: + language: + type: string + enum: + - "eng_Latn" + - "zho_Hans" + - "spa_Latn" + - "ara_Arab" + - "por_Latn" + - "ind_Latn" + - "fra_Latn" + - "jpn_Jpan" + - "rus_Cyrl" + - "deu_Latn" + - "kor_Hang" + - "tur_Latn" + - "ita_Latn" + - "pes_Arab" + - "pol_Latn" + - "vie_Latn" + - "nld_Latn" + - "hin_Deva" + - "tha_Thai" + - "heb_Hebr" + - "ben_Beng" + - "swe_Latn" + - "ces_Latn" + - "ron_Latn" + - "ell_Grek" + - "ukr_Cyrl" + - "dan_Latn" + - "fin_Latn" + - "nor_Latn" + - "hun_Latn" + - "cat_Latn" + - "bul_Cyrl" + - "msa_Latn" + - "hrv_Latn" + - "arb_Latn" + - "slk_Latn" + - "lit_Latn" + - "lav_Latn" + - "srp_Cyrl" + - "slv_Latn" + - "est_Latn" + - "urd_Arab" + - "fil_Latn" + - "aze_Latn" + - "tam_Taml" + - "tel_Telu" + - "mar_Deva" + - "kan_Knda" + - "fas_Arab" + description: Language that should be allowed in content + not: + type: boolean + description: If true, the verdict will be inverted + default: false + timeout: + type: number + description: Timeout in milliseconds + default: 5000 + + PortkeyPIIParameters: + title: Portkey PII Parameters + type: object + required: + - categories + properties: + redact: + type: boolean + description: Whether to redact detected PII + default: false + categories: + type: array + items: + type: string + enum: + - "EMAIL_ADDRESS" + - "PHONE_NUMBER" + - "LOCATION_ADDRESS" + - "NAME" + - "IP_ADDRESS" + - "CREDIT_CARD" + - "SSN" + description: Types of PII that should NOT be allowed + timeout: + type: number + description: Timeout in milliseconds + default: 5000 + + MistralModerationParameters: + title: Mistral Moderation Parameters + type: object + required: + - categories + properties: + categories: + type: array + items: + type: string + enum: + - "sexual" + - "hate_and_discrimination" + - "violence_and_threats" + - "dangerous_and_criminal_content" + - "selfharm" + - "health" + - "financial" + - "law" + - "pii" + description: Categories that should NOT be allowed + timeout: + type: number + description: Timeout in milliseconds + default: 5000 + + BedrockGuardParameters: + title: Bedrock Guard Parameters + type: object + required: + - guardrailVersion + - guardrailId + properties: + guardrailVersion: + type: string + description: Version of the guardrail to use + guardrailId: + type: string + description: ID of the guardrail + redact: + type: boolean + description: Whether to redact detected PII + default: false + timeout: + type: number + description: Timeout in milliseconds + default: 5000 + + PromptfooParameters: + title: Promptfoo Parameters + type: object + properties: + redact: + type: boolean + description: Whether to redact detected content + default: false + timeout: + type: number + description: Timeout in milliseconds + default: 5000 + + AcuvityScanParameters: + title: Acuvity Scan Parameters + type: object + properties: + prompt_injection: + type: boolean + description: Enable prompt injection detection + default: true + prompt_injection_threshold: + type: number + minimum: 0 + maximum: 1 + multipleOf: 0.01 + description: Threshold for prompt injection detection + default: 0.5 + toxic: + type: boolean + description: Enable toxicity detection + default: true + toxic_threshold: + type: number + minimum: 0 + maximum: 1 + multipleOf: 0.01 + description: Threshold for toxicity detection + default: 0.5 + jail_break: + type: boolean + description: Enable jailbreak detection + default: true + jail_break_threshold: + type: number + minimum: 0 + maximum: 1 + multipleOf: 0.01 + description: Threshold for jailbreak detection + default: 0.5 + malicious_url: + type: boolean + description: Enable malicious URL detection + default: true + malicious_url_threshold: + type: number + minimum: 0 + maximum: 1 + multipleOf: 0.01 + description: Threshold for malicious URL detection + default: 0.5 + biased: + type: boolean + description: Enable bias detection + default: true + biased_threshold: + type: number + minimum: 0 + maximum: 1 + multipleOf: 0.01 + description: Threshold for bias detection + default: 0.5 + harmful: + type: boolean + description: Enable harmful content detection + default: true + harmful_threshold: + type: number + minimum: 0 + maximum: 1 + multipleOf: 0.01 + description: Threshold for harmful content detection + default: 0.5 + language: + type: boolean + description: Enable language check + default: true + language_values: + type: string + enum: + - "english" + - "chinese" + - "spanish" + - "french" + - "german" + - "japanese" + - "gibberish" + description: Language to check + default: "english" + pii: + type: boolean + description: Enable PII detection + default: true + pii_redact: + type: boolean + description: Enable PII redaction + default: false + pii_categories: + type: array + items: + type: string + enum: + - "email_address" + - "ssn" + - "person" + - "aba_routing_number" + - "address" + - "bank_account" + - "bitcoin_wallet" + - "credit_card" + - "driver_license" + - "itin_number" + - "location" + - "medical_license" + - "money_amount" + - "passport_number" + - "phone_number" + description: PII categories to detect + secrets: + type: boolean + description: Enable secrets detection + default: true + secrets_redact: + type: boolean + description: Enable secrets redaction + default: false + secrets_categories: + type: array + items: + type: string + enum: + - "credentials" + - "aws_secret_key" + - "github" + - "openai" + - "stripe" + - "jwt" + - "private_key" + description: Secret categories to detect + timeout: + type: number + description: Timeout in milliseconds + default: 5000 + + AzureContentSafetyParameters: + title: Azure Content Safety Parameters + type: object + properties: + blocklistNames: + type: array + items: + type: string + description: Array of blocklist names to check against + default: [] + apiVersion: + type: string + description: API version for the Content Safety API + default: "2024-09-01" + severity: + type: number + description: Severity threshold for the Content Safety API + default: 2 + categories: + type: array + items: + type: string + enum: ["Hate", "SelfHarm", "Sexual", "Violence"] + description: Categories to check against + timeout: + type: number + description: Timeout in milliseconds + default: 5000 + + AzurePIIParameters: + title: Azure PII Parameters + type: object + properties: + domain: + type: string + enum: ["none", "phi"] + description: Domain to check against + default: "none" + apiVersion: + type: string + description: API version for the Content Safety API + default: "2024-11-01" + modelVersion: + type: string + description: Version of the PII detection model to use + default: "latest" + redact: + type: boolean + description: Whether to redact detected PII + default: false + timeout: + type: number + description: Timeout in milliseconds + default: 5000 + + PANWPrismaParameters: + title: PANW Prisma Parameters + type: object + required: + - profile_name + properties: + profile_name: + type: string + description: Prisma profile name + ai_model: + type: string + description: AI model identifier + app_user: + type: string + description: Application user identifier + + BasicParameters: + title: Basic Parameters + type: object + description: Basic parameters with no specific requirements + additionalProperties: true + + BedrockBatchJob: + type: object + required: + - model + - role_arn + properties: + job_name: + type: string + description: Job name for the batch job + output_data_config: + type: string + description: Batch job's output storage location, will be constructed based on `input_file_id` if not provided + model: + type: string + description: Model to start batch job with + role_arn: + type: string + description: Role ARN for the bedrock batch job + allOf: + - $ref: "#/components/schemas/OpenAIBatchJob" + description: Gateway supported body params for bedrock fine-tuning. + title: Bedrock Params + BedrockBatchParams: + type: object + properties: + role_arn: + type: string + description: Role ARN for the bedrock batch job + CommonBatchParams: + type: object + required: + - model + properties: + job_name: + type: string + description: Job name for the batch job + output_data_config: + type: string + description: Batch job's output storage location, will be constructed based on `input_file_id` if not provided + model: + type: string + description: Model to start batch job with + + OpenAIBatchJob: + type: object + required: + - input_file_id + - completion_window + - endpoint + properties: + input_file_id: + type: string + description: The input file to use for the batch job + completion_window: + type: string + enum: + - immediate + - 24h + description: Completion window for the batch job, `immediate` is only supported with Portkey Managed Batching. + endpoint: + type: string + enum: + - /v1/chat/completions + - /v1/completions + - /v1/embeddings + description: Inference endpoint + metadata: + description: metadata related for the batch job + nullable: true + description: Gateway supported body params for OpenAI, Azure OpenAI and VertexAI. + title: OpenAI Params + + PortkeyBatchJob: + type: object + required: + - model + properties: + job_name: + type: string + description: Job name for the batch job + output_data_config: + type: string + description: Batch job's output storage location, will be constructed based on `input_file_id` if not provided + model: + type: string + description: Model to start batch job with + role_arn: + type: string + description: Role ARN for the bedrock batch job + portkey_options: + allOf: + - $ref: "#/components/schemas/PortkeyBatchOptions" + description: Portkey Gateway Provider specific headers to be passed to the provider, if portkey is used as a provider + provider_options: + anyOf: + - type: object + title: Bedrock Options + properties: + job_name: + type: string + description: Job name for the batch job + output_data_config: + type: string + description: Batch job's output storage location, will be constructed based on `input_file_id` if not provided + model: + type: string + description: Model to start batch job with + role_arn: + type: string + description: Role ARN for the bedrock batch job + required: + - model + - role_arn + - type: object + title: Vertex Options + properties: + job_name: + type: string + description: Job name for the batch job + output_data_config: + type: string + description: Batch job's output storage location, will be constructed based on `input_file_id` if not provided + model: + type: string + description: Model to start batch job with + required: + - model + description: Provider specific options to be passed to the provider, optional can be passed directly as well. + allOf: + - $ref: "#/components/schemas/OpenAIBatchJob" + description: Gateway supported body params for portkey managed batching. + title: Portkey Params + + PortkeyBatchOptions: + type: object + required: + - x-portkey-virtual-key + properties: + x-portkey-virtual-key: + type: string + description: The virtual key to communicate with the provider + x-portkey-aws-s3-bucket: + type: string + description: The AWS S3 bucket to use for file upload during finetune + x-portkey-vertex-storage-bucket-name: + type: string + description: Google Storage bucket to use for file upload during finetune + x-portkey-provider-model: + type: string + description: Model to use for the batch job also for file transformation for model specific inference input. + example: + x-portkey-virtual-key: vkey-1234567890 + x-portkey-aws-s3-bucket: my-bucket + x-portkey-provider-model: meta.llama3-1-8b-instruct-v1:0 + x-portkey-vertex-storage-bucket-name: my-bucket + description: Options to be passed to the provider, supports all options supported by the provider from gateway. + + VertexBatchJob: + type: object + required: + - model + properties: + job_name: + type: string + description: Job name for the batch job + output_data_config: + type: string + description: Batch job's output storage location, will be constructed based on `input_file_id` if not provided + model: + type: string + description: Model to start batch job with + allOf: + - $ref: "#/components/schemas/OpenAIBatchJob" + description: Gateway supported body params for Vertext fine-tuning. + title: Vertex Params + VertexBatchParams: + type: object + + Condition: + type: object + required: + - key + - value + properties: + key: + type: string + description: | + Condition key. Valid values: + - `api_key` - Apply to a specific API key + - `organisation_id` - Apply to an organization + - `workspace_id` - Apply to a workspace + - `metadata.*` - Apply based on custom metadata fields (e.g., `metadata.user_id`, `metadata.team`) + example: workspace_id + value: + type: string + description: Condition value + example: workspace-123 + + GroupBy: + type: object + required: + - key + properties: + key: + type: string + description: | + Group by key. Valid values: + - `api_key` - Group by API key + - `organisation_id` - Group by organization + - `workspace_id` - Group by workspace + - `metadata.*` - Group by custom metadata fields + example: api_key + + CreateUsageLimitsPolicyRequest: + type: object + required: + - conditions + - group_by + - type + - credit_limit + properties: + name: + type: string + maxLength: 255 + description: Policy name + example: Monthly Cost Limit + conditions: + type: array + minItems: 1 + items: + $ref: '#/components/schemas/Condition' + description: Array of conditions that define which requests the policy applies to + group_by: + type: array + minItems: 1 + items: + $ref: '#/components/schemas/GroupBy' + description: Array of group by fields that define how usage is aggregated + type: + type: string + enum: [cost, tokens] + description: Policy type + credit_limit: + type: number + minimum: 0 + description: Maximum usage allowed + alert_threshold: + type: number + nullable: true + minimum: 0 + description: Threshold at which to send alerts. Must be less than credit_limit. + periodic_reset: + type: string + nullable: true + enum: [monthly, weekly] + description: Reset period. If not provided, limit is cumulative. + workspace_id: + type: string + description: Workspace ID or slug. Required if not using API key authentication. + organisation_id: + type: string + format: uuid + description: Organization ID. Required if not using API key authentication. + + UpdateUsageLimitsPolicyRequest: + type: object + properties: + name: + type: string + maxLength: 255 + description: Policy name + credit_limit: + type: number + minimum: 0 + description: Maximum usage allowed + alert_threshold: + type: number + nullable: true + minimum: 0 + description: Threshold at which to send alerts. Must be less than credit_limit. + periodic_reset: + type: string + nullable: true + enum: [monthly, weekly] + description: Reset period. Set to null to remove periodic reset. + reset_usage_for_value: + type: string + description: Reset usage for a specific value key (e.g., API key). This will reset the usage counter for that key to 0. + + CreateRateLimitsPolicyRequest: + type: object + required: + - conditions + - group_by + - type + - unit + - value + properties: + name: + type: string + maxLength: 255 + description: Policy name + example: 100 Requests per Minute + conditions: + type: array + minItems: 1 + items: + $ref: '#/components/schemas/Condition' + description: Array of conditions that define which requests the policy applies to + group_by: + type: array + minItems: 1 + items: + $ref: '#/components/schemas/GroupBy' + description: Array of group by fields that define how usage is aggregated + type: + type: string + enum: [requests, tokens] + description: Policy type + unit: + type: string + enum: [rpm, rph, rpd] + description: | + Rate unit: + - `rpm` - Requests/Tokens per minute + - `rph` - Requests/Tokens per hour + - `rpd` - Requests/Tokens per day + value: + type: number + description: Rate limit value + workspace_id: + type: string + description: Workspace ID or slug. Required if not using API key authentication. + organisation_id: + type: string + format: uuid + description: Organization ID. Required if not using API key authentication. + + UpdateRateLimitsPolicyRequest: + type: object + properties: + name: + type: string + maxLength: 255 + description: Policy name + unit: + type: string + enum: [rpm, rph, rpd] + description: Rate unit + value: + type: number + description: Rate limit value + + UsageLimitsPolicy: + type: object + required: + - id + - type + - status + - workspace_id + - organisation_id + - created_at + - last_updated_at + properties: + id: + type: string + format: uuid + description: Policy UUID + name: + type: string + nullable: true + description: Policy name + conditions: + type: array + items: + $ref: '#/components/schemas/Condition' + description: Array of conditions + group_by: + type: array + items: + $ref: '#/components/schemas/GroupBy' + description: Array of group by fields + type: + type: string + enum: [cost, tokens] + description: Policy type + credit_limit: + type: number + description: Maximum usage allowed + alert_threshold: + type: number + nullable: true + description: Alert threshold + periodic_reset: + type: string + nullable: true + enum: [monthly, weekly] + description: Reset period + status: + type: string + enum: [active, archived] + description: Policy status + workspace_id: + type: string + format: uuid + description: Workspace UUID + organisation_id: + type: string + format: uuid + description: Organization UUID + created_at: + type: string + format: date-time + description: Creation timestamp + last_updated_at: + type: string + format: date-time + description: Last update timestamp + value_key_usage_map: + type: object + additionalProperties: + $ref: '#/components/schemas/ValueKeyUsage' + description: Map of value keys to usage information (only included when include_usage=true) + + ValueKeyUsage: + type: object + properties: + current_usage: + type: number + description: Current usage value + status: + type: string + enum: [active, exhausted] + description: Usage status + is_threshold_alerts_sent: + type: boolean + description: Whether threshold alerts have been sent + is_exhausted_alerts_sent: + type: boolean + description: Whether exhausted alerts have been sent + + RateLimitsPolicy: + type: object + required: + - id + - type + - unit + - value + - status + - workspace_id + - organisation_id + - created_at + - last_updated_at + properties: + id: + type: string + format: uuid + description: Policy UUID + name: + type: string + nullable: true + description: Policy name + conditions: + type: array + items: + $ref: '#/components/schemas/Condition' + description: Array of conditions + group_by: + type: array + items: + $ref: '#/components/schemas/GroupBy' + description: Array of group by fields + type: + type: string + enum: [requests, tokens] + description: Policy type + unit: + type: string + enum: [rpm, rph, rpd] + description: Rate unit + value: + type: number + description: Rate limit value + status: + type: string + enum: [active, archived] + description: Policy status + workspace_id: + type: string + format: uuid + description: Workspace UUID + organisation_id: + type: string + format: uuid + description: Organization UUID + created_at: + type: string + format: date-time + description: Creation timestamp + last_updated_at: + type: string + format: date-time + description: Last update timestamp + + CreatePolicyResponse: + type: object + properties: + id: + type: string + format: uuid + description: Created policy UUID + object: + type: string + description: Resource type + example: policy_usage_limits + + UsageLimitsPolicyListResponse: + type: object + properties: + object: + type: string + example: list + data: + type: array + items: + $ref: '#/components/schemas/UsageLimitsPolicy' + total: + type: integer + description: Total number of policies + + UsageLimitsPolicyResponse: + allOf: + - $ref: '#/components/schemas/UsageLimitsPolicy' + - type: object + properties: + object: + type: string + example: policy_usage_limits + + UsageLimitsPolicyEntity: + type: object + properties: + id: + type: string + description: Entity ID + value_key: + type: string + description: The value key identifying the entity (e.g. metadata._user:username) + current_usage: + type: number + description: Current usage value for this entity + + UsageLimitsPolicyEntityListResponse: + type: object + properties: + object: + type: string + example: list + data: + type: array + items: + $ref: '#/components/schemas/UsageLimitsPolicyEntity' + total: + type: integer + description: Total number of entities + + RateLimitsPolicyListResponse: + type: object + properties: + object: + type: string + example: list + data: + type: array + items: + $ref: '#/components/schemas/RateLimitsPolicy' + total: + type: integer + description: Total number of policies + + RateLimitsPolicyResponse: + allOf: + - $ref: '#/components/schemas/RateLimitsPolicy' + - type: object + properties: + object: + type: string + example: policy_rate_limits + + CreateMcpIntegration: + type: object + description: Only include optional fields (slug, description, configurations) when you have values for them. The example and code samples show required fields plus workspace_id and organisation_id when scoping. + required: + - name + - url + - auth_type + - transport + properties: + organisation_id: + type: string + format: uuid + description: Organisation ID (optional; required when using org admin API key without workspace_id) + workspace_id: + type: string + format: uuid + description: Workspace ID (optional; to create at workspace level) + slug: + type: string + pattern: '^[a-zA-Z0-9_-]+$' + description: Optional slug; must be unique within organisation + name: + type: string + description: Display name of the MCP integration + description: + type: string + nullable: true + configurations: + type: object + description: Auth/config key-value pairs (e.g. headers, client credentials) + properties: + custom_headers: + type: object + additionalProperties: true + description: Custom headers to send to the MCP server. + example: + Authorization: Bearer some-token + x-foo: bar + passthrough_header: + type: object + additionalProperties: true + description: Headers to pass through from the incoming request to the MCP server. + example: + x-user-id: + type: string + example: abc123 + x-request-id: + type: string + example: req-0001 + additionalProperties: true + url: + type: string + format: uri + description: MCP server URL + auth_type: + type: string + enum: + - oauth_auto + - headers + - none + transport: + type: string + enum: + - http + - sse + + McpIntegrationCreateResponse: + type: object + properties: + id: + type: string + format: uuid + slug: + type: string + + McpIntegration: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + description: + type: string + nullable: true + owner_id: + type: string + status: + type: string + created_at: + type: string + format: date-time + last_updated_at: + type: string + format: date-time + configurations: + type: object + nullable: true + global_workspace_access: + type: object + nullable: true + workspace_id: + type: string + nullable: true + description: Workspace ID or slug (when workspace-scoped) + slug: + type: string + url: + type: string + format: uri + auth_type: + type: string + enum: + - oauth_auto + - oauth_client_credentials + - headers + - none + transport: + type: string + enum: + - http + - sse + - interactive + type: + type: string + enum: + - workspace + - organisation + + McpIntegrationListItem: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + owner_id: + type: string + status: + type: string + type: + type: string + enum: + - workspace + - organisation + url: + type: string + format: uri + auth_type: + type: string + enum: + - oauth_auto + - headers + - none + transport: + type: string + enum: + - http + - sse + - interactive + configurations: + type: object + created_at: + type: string + format: date-time + last_updated_at: + type: string + format: date-time + slug: + type: string + workspace_id: + type: string + nullable: true + description: + type: string + nullable: true + workspaces_count: + type: number + nullable: true + + McpIntegrationListResponse: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/McpIntegrationListItem" + total: + type: integer + has_more: + type: boolean + + UpdateMcpIntegration: + type: object + minProperties: 1 + properties: + name: + type: string + description: + type: string + nullable: true + configurations: + type: object + description: Auth/config key-value pairs (e.g. headers, client credentials) + properties: + custom_headers: + type: object + additionalProperties: true + description: Custom headers to send to the MCP server. + example: + Authorization: Bearer some-token + x-foo: bar + passthrough_header: + type: object + additionalProperties: true + description: Headers to pass through from the incoming request to the MCP server. + example: + x-user-id: + type: string + example: abc123 + x-request-id: + type: string + example: req-0001 + additionalProperties: true + url: + type: string + format: uri + auth_type: + type: string + enum: + - oauth_auto + - headers + - none + transport: + type: string + enum: + - http + - sse + + McpIntegrationWorkspaceItem: + type: object + properties: + id: + type: string + description: Workspace ID or slug (slug when using workspace API key) + enabled: + type: boolean + status: + type: string + created_at: + type: string + format: date-time + last_updated_at: + type: string + format: date-time + + McpIntegrationWorkspacesListResponse: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/McpIntegrationWorkspaceItem" + global_workspace_access: + type: object + nullable: true + total: + type: integer + + McpIntegrationWorkspacesLegacyResponse: + type: object + properties: + workspaces: + type: array + items: + $ref: "#/components/schemas/McpIntegrationWorkspaceItem" + global_workspace_access: + type: object + nullable: true + + BulkUpdateMcpIntegrationWorkspaces: + type: object + required: + - workspaces + properties: + workspaces: + type: array + minItems: 0 + items: type: object - description: The per-line object of the batch input file + required: + - id + - enabled properties: - custom_id: - type: string - description: A developer-provided per-request id that will be used to match outputs to inputs. Must be unique for each request in a batch. - method: - type: string - enum: ["POST"] - description: The HTTP method to be used for the request. Currently only `POST` is supported. - url: - type: string - description: The OpenAI API relative URL to be used for the request. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. - x-oaiMeta: - name: The request input object - example: | - {"custom_id": "request-1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is 2+2?"}]}} - - BatchRequestOutput: + id: + type: string + description: Workspace ID or slug + enabled: + type: boolean + global_workspace_access: + type: object + nullable: true + properties: + enabled: + type: boolean + override_existing_workspace_access: + type: boolean + default: false + + McpIntegrationCapabilityItem: + type: object + properties: + name: + type: string + type: + type: string + enum: + - tool + - prompt + - resource + - resource_template + title: + type: string + nullable: true + description: + type: string + nullable: true + icons: + type: array + nullable: true + enabled: + type: boolean + created_at: + type: string + format: date-time + last_updated_at: + type: string + format: date-time + input_schema: + type: object + nullable: true + output_schema: + type: object + nullable: true + execution: + type: object + nullable: true + annotations: + type: object + nullable: true + arguments: + type: array + nullable: true + uri: + type: string + nullable: true + uri_template: + type: string + nullable: true + mime_type: + type: string + nullable: true + size: + type: number + nullable: true + + McpIntegrationCapabilitiesCounts: + type: object + properties: + tools: + type: object + properties: + total: + type: integer + enabled: + type: integer + prompts: + type: object + properties: + total: + type: integer + enabled: + type: integer + resources: + type: object + properties: + total: + type: integer + enabled: + type: integer + resource_templates: + type: object + properties: + total: + type: integer + enabled: + type: integer + + McpIntegrationCapabilitiesListResponse: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/McpIntegrationCapabilityItem" + counts: + $ref: "#/components/schemas/McpIntegrationCapabilitiesCounts" + total: + type: integer + has_more: + type: boolean + + BulkUpdateMcpIntegrationCapabilities: + type: object + required: + - capabilities + properties: + capabilities: + type: array + minItems: 1 + items: type: object - description: The per-line object of the batch output and error files + required: + - name + - type + - enabled properties: - id: - type: string - custom_id: - type: string - description: A developer-provided per-request id that will be used to match outputs to inputs. - response: - type: object - nullable: true - properties: - status_code: - type: integer - description: The HTTP status code of the response - request_id: - type: string - description: An unique identifier for the OpenAI API request. Please include this request ID when contacting support. - body: - type: object - x-oaiTypeLabel: map - description: The JSON body of the response - error: - type: object - nullable: true - description: For requests that failed with a non-HTTP error, this will contain more information on the cause of the failure. - properties: - code: - type: string - description: A machine-readable error code. - message: - type: string - description: A human-readable error message. - x-oaiMeta: - name: The request output object - example: | - {"id": "batch_req_wnaDys", "custom_id": "request-2", "response": {"status_code": 200, "request_id": "req_c187b3", "body": {"id": "chatcmpl-9758Iw", "object": "chat.completion", "created": 1711475054, "model": "gpt-3.5-turbo", "choices": [{"index": 0, "message": {"role": "assistant", "content": "2 + 2 equals 4."}, "finish_reason": "stop"}], "usage": {"prompt_tokens": 24, "completion_tokens": 15, "total_tokens": 39}, "system_fingerprint": null}}, "error": null} - - ListBatchesResponse: + name: + type: string + type: + type: string + enum: + - tool + - prompt + - resource + enabled: + type: boolean + + McpIntegrationCapabilitiesBulkUpdateResponse: + type: object + properties: + success: + type: boolean + example: true + + McpIntegrationMetadata: + type: object + properties: + server_name: + type: string + nullable: true + server_version: + type: string + nullable: true + protocol_version: + type: string + nullable: true + capability_flags: + type: object + nullable: true + sync_status: + type: string + nullable: true + example: pending + last_synced_at: + type: string + format: date-time + nullable: true + sync_error: + type: string + nullable: true + + CreateMcpServer: + type: object + description: Create an MCP Server (workspace instance of an MCP Integration). + required: + - name + - mcp_integration_id + properties: + workspace_id: + type: string + format: uuid + description: Workspace ID or slug (optional; required when using org admin API key) + name: + type: string + minLength: 1 + maxLength: 255 + description: Display name of the MCP server + description: + type: string + nullable: true + maxLength: 500 + mcp_integration_id: + type: string + description: MCP Integration ID (UUID) or slug + slug: + type: string + pattern: '^[a-zA-Z0-9_-]+$' + minLength: 3 + maxLength: 50 + description: Optional slug; must be unique within organisation + + McpServerCreateResponse: + type: object + properties: + id: + type: string + format: uuid + slug: + type: string + + McpServer: + type: object + properties: + id: + type: string + format: uuid + slug: + type: string + name: + type: string + status: + type: string + description: + type: string + nullable: true + created_at: + type: string + format: date-time + mcp_integration_id: + type: string + description: MCP Integration ID or slug + mcp_integration_details: + type: object + nullable: true + description: Present for system/service auth + properties: + id: + type: string + slug: + type: string + status: + type: string + configurations: + type: object + nullable: true + url: + type: string + format: uri + transport: + type: string + auth_type: + type: string + workspace_id: + type: string + nullable: true + description: Present for system/service auth + + McpServerListItem: + type: object + properties: + id: + type: string + format: uuid + organisation_id: + type: string + name: + type: string + description: + type: string + nullable: true + status: + type: string + created_at: + type: string + format: date-time + owner_id: + type: string + slug: + type: string + workspace_id: + type: string + nullable: true + mcp_integration_id: + type: string + mcp_integration_slug: + type: string + nullable: true + mcp_integration_url: + type: string + format: uri + nullable: true + auth_type: + type: string + workspace_name: + type: string + nullable: true + workspace_slug: + type: string + nullable: true + url: + type: string + format: uri + description: Gateway URL for this MCP server (e.g. {gateway_base}/{slug}/mcp) + + McpServerListResponse: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/McpServerListItem" + total: + type: integer + + UpdateMcpServer: + type: object + minProperties: 1 + properties: + name: + type: string + minLength: 1 + maxLength: 255 + description: + type: string + nullable: true + maxLength: 500 + + McpServerTestResponse: + type: object + properties: + success: + type: boolean + status_code: + type: integer + nullable: true + description: HTTP status from upstream (when success) + response_time_ms: + type: integer + nullable: true + url: + type: string + format: uri + nullable: true + server_name: + type: string + error: + type: string + nullable: true + description: Error message when success is false + + McpServerCapabilityItem: + type: object + properties: + name: + type: string + type: + type: string + enum: + - tool + - prompt + - resource + - resource_template + title: + type: string + nullable: true + description: + type: string + nullable: true + icons: + type: array + nullable: true + enabled: + type: boolean + integration_enabled: + type: boolean + nullable: true + description: Present for service users; indicates integration-level enabled state + input_schema: + type: object + nullable: true + output_schema: + type: object + nullable: true + execution: + type: object + nullable: true + annotations: + type: object + nullable: true + arguments: + type: array + nullable: true + uri: + type: string + nullable: true + uri_template: + type: string + nullable: true + mime_type: + type: string + nullable: true + size: + type: number + nullable: true + + McpServerCapabilitiesCounts: + type: object + properties: + tools: + type: object + properties: + total: + type: integer + enabled: + type: integer + prompts: + type: object + properties: + total: + type: integer + enabled: + type: integer + resources: + type: object + properties: + total: + type: integer + enabled: + type: integer + resource_templates: + type: object + properties: + total: + type: integer + enabled: + type: integer + + McpServerCapabilitiesListResponse: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/McpServerCapabilityItem" + counts: + $ref: "#/components/schemas/McpServerCapabilitiesCounts" + total: + type: integer + has_more: + type: boolean + + BulkUpdateMcpServerCapabilities: + type: object + required: + - capabilities + properties: + capabilities: + type: array + minItems: 1 + items: type: object + required: + - name + - type + - enabled 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] + name: + type: string + type: + type: string + enum: + - tool + - prompt + - resource + enabled: + type: boolean + + McpServerCapabilitiesBulkUpdateResponse: + type: object + properties: + success: + type: boolean + example: true + + McpServerUserAccessItem: + type: object + properties: + user_id: + type: string + description: Global user ID or user_org_map_id depending on auth + first_name: + type: string + nullable: true + last_name: + type: string + nullable: true + enabled: + type: boolean + has_override: + type: boolean + connection_status: + type: string + enum: + - connected + - not_connected + + McpServerUserAccessListResponse: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/McpServerUserAccessItem" + default_user_access: + type: string + enum: + - allow + - deny + total: + type: integer + has_more: + type: boolean + + BulkUpdateMcpServerUserAccess: + type: object + properties: + user_access: + type: array + items: + type: object required: - - object - - data - - has_more + - user_id + - enabled + properties: + user_id: + type: string + description: User ID (global user_id or user_org_map_id depending on API key) + enabled: + type: boolean + default_user_access: + type: string + enum: + - allow + - deny + description: Server default when user has no explicit override + + McpServerUserAccessBulkUpdateResponse: + type: object + properties: + success: + type: boolean + example: true security: - - ApiKeyAuth: [] - -x-oaiMeta: - navigationGroups: - - id: endpoints - title: Endpoints - - id: assistants - title: Assistants - - id: legacy - title: Legacy - groups: - # > General Notes - # The `groups` section is used to generate the API reference pages and navigation, in the same - # order listed below. Additionally, each `group` can have a list of `sections`, each of which - # will become a navigation subroute and subsection under the group. Each section has: - # - `type`: Currently, either an `endpoint` or `object`, depending on how the section needs to - # be rendered - # - `key`: The reference key that can be used to lookup the section definition - # - `path`: The path (url) of the section, which is used to generate the navigation link. - # - # > The `object` sections maps to a schema component and the following fields are read for rendering - # - `x-oaiMeta.name`: The name of the object, which will become the section title - # - `x-oaiMeta.example`: The example object, which will be used to generate the example sample (always JSON) - # - `description`: The description of the object, which will be used to generate the section description - # - # > The `endpoint` section maps to an operation path and the following fields are read for rendering: - # - `x-oaiMeta.name`: The name of the endpoint, which will become the section title - # - `x-oaiMeta.examples`: The endpoint examples, which can be an object (meaning a single variation, most - # endpoints, or an array of objects, meaning multiple variations, e.g. the - # chat completion and completion endpoints, with streamed and non-streamed examples. - # - `x-oaiMeta.returns`: text describing what the endpoint returns. - # - `summary`: The summary of the endpoint, which will be used to generate the section description - - id: audio - title: Audio - description: | - Learn how to turn audio into text or text into audio. - - Related guide: [Speech to text](/docs/guides/speech-to-text) - navigationGroup: endpoints - sections: - - type: endpoint - key: createSpeech - path: createSpeech - - type: endpoint - key: createTranscription - path: createTranscription - - type: endpoint - key: createTranslation - path: createTranslation - - type: object - key: CreateTranscriptionResponseJson - path: json-object - - type: object - key: CreateTranscriptionResponseVerboseJson - path: verbose-json-object - - id: chat - title: Chat - description: | - Given a list of messages comprising a conversation, the model will return a response. - - Related guide: [Chat Completions](/docs/guides/text-generation) - navigationGroup: endpoints - sections: - - type: endpoint - key: createChatCompletion - path: create - - type: object - key: CreateChatCompletionResponse - path: object - - type: object - key: CreateChatCompletionStreamResponse - path: streaming - - id: embeddings - title: Embeddings - description: | - Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. - - Related guide: [Embeddings](/docs/guides/embeddings) - navigationGroup: endpoints - sections: - - type: endpoint - key: createEmbedding - path: create - - type: object - key: Embedding - path: object - - id: fine-tuning - title: Fine-tuning - description: | - Manage fine-tuning jobs to tailor a model to your specific training data. - - Related guide: [Fine-tune models](/docs/guides/fine-tuning) - navigationGroup: endpoints - sections: - - type: endpoint - key: createFineTuningJob - path: create - - type: endpoint - key: listPaginatedFineTuningJobs - path: list - - type: endpoint - key: listFineTuningEvents - path: list-events - - type: endpoint - key: listFineTuningJobCheckpoints - path: list-checkpoints - - type: endpoint - key: retrieveFineTuningJob - path: retrieve - - type: endpoint - key: cancelFineTuningJob - path: cancel - - type: object - key: FinetuneChatRequestInput - path: chat-input - - type: object - key: FinetuneCompletionRequestInput - path: completions-input - - type: object - key: FineTuningJob - path: object - - type: object - key: FineTuningJobEvent - path: event-object - - type: object - key: FineTuningJobCheckpoint - path: checkpoint-object - - id: batch - title: Batch - description: | - Create large batches of API requests for asynchronous processing. The Batch API returns completions within 24 hours for a 50% discount. - - Related guide: [Batch](/docs/guides/batch) - navigationGroup: endpoints - sections: - - type: endpoint - key: createBatch - path: create - - type: endpoint - key: retrieveBatch - path: retrieve - - type: endpoint - key: cancelBatch - path: cancel - - type: endpoint - key: listBatches - path: list - - type: object - key: Batch - path: object - - type: object - key: BatchRequestInput - path: request-input - - type: object - key: BatchRequestOutput - path: request-output - - id: files - title: Files - description: | - Files are used to upload documents that can be used with features like [Assistants](/docs/api-reference/assistants), [Fine-tuning](/docs/api-reference/fine-tuning), and [Batch API](/docs/guides/batch). - navigationGroup: endpoints - sections: - - type: endpoint - key: createFile - path: create - - type: endpoint - key: listFiles - path: list - - type: endpoint - key: retrieveFile - path: retrieve - - type: endpoint - key: deleteFile - path: delete - - type: endpoint - key: downloadFile - path: retrieve-contents - - type: object - key: OpenAIFile - path: object - - id: images - title: Images - description: | - Given a prompt and/or an input image, the model will generate a new image. - - Related guide: [Image generation](/docs/guides/images) - navigationGroup: endpoints - sections: - - type: endpoint - key: createImage - path: create - - type: endpoint - key: createImageEdit - path: createEdit - - type: endpoint - key: createImageVariation - path: createVariation - - type: object - key: Image - path: object - - id: models - title: Models - description: | - List and describe the various models available in the API. You can refer to the [Models](/docs/models) documentation to understand what models are available and the differences between them. - navigationGroup: endpoints - sections: - - type: endpoint - key: listModels - path: list - - type: endpoint - key: retrieveModel - path: retrieve - - type: endpoint - key: deleteModel - path: delete - - type: object - key: Model - path: object - - id: moderations - title: Moderations - description: | - Given some input text, outputs if the model classifies it as potentially harmful across several categories. - - Related guide: [Moderations](/docs/guides/moderation) - navigationGroup: endpoints - sections: - - type: endpoint - key: createModeration - path: create - - type: object - key: CreateModerationResponse - path: object - - id: assistants - title: Assistants - beta: true - description: | - Build assistants that can call models and use tools to perform tasks. - - [Get started with the Assistants API](/docs/assistants) - navigationGroup: assistants - sections: - - type: endpoint - key: createAssistant - path: createAssistant - - type: endpoint - key: listAssistants - path: listAssistants - - type: endpoint - key: getAssistant - path: getAssistant - - type: endpoint - key: modifyAssistant - path: modifyAssistant - - type: endpoint - key: deleteAssistant - path: deleteAssistant - - type: object - key: AssistantObject - path: object - - id: threads - title: Threads - beta: true - description: | - Create threads that assistants can interact with. - - Related guide: [Assistants](/docs/assistants/overview) - navigationGroup: assistants - sections: - - type: endpoint - key: createThread - path: createThread - - type: endpoint - key: getThread - path: getThread - - type: endpoint - key: modifyThread - path: modifyThread - - type: endpoint - key: deleteThread - path: deleteThread - - type: object - key: ThreadObject - path: object - - id: messages - title: Messages - beta: true - description: | - Create messages within threads - - Related guide: [Assistants](/docs/assistants/overview) - navigationGroup: assistants - sections: - - type: endpoint - key: createMessage - path: createMessage - - type: endpoint - key: listMessages - path: listMessages - - type: endpoint - key: getMessage - path: getMessage - - type: endpoint - key: modifyMessage - path: modifyMessage - - type: endpoint - key: deleteMessage - path: deleteMessage - - type: object - key: MessageObject - path: object - - id: runs - title: Runs - beta: true - description: | - Represents an execution run on a thread. - - Related guide: [Assistants](/docs/assistants/overview) - navigationGroup: assistants - sections: - - type: endpoint - key: createRun - path: createRun - - type: endpoint - key: createThreadAndRun - path: createThreadAndRun - - type: endpoint - key: listRuns - path: listRuns - - type: endpoint - key: getRun - path: getRun - - type: endpoint - key: modifyRun - path: modifyRun - - type: endpoint - key: submitToolOuputsToRun - path: submitToolOutputs - - type: endpoint - key: cancelRun - path: cancelRun - - type: object - key: RunObject - path: object - - id: run-steps - title: Run Steps - beta: true - description: | - Represents the steps (model and tool calls) taken during the run. - - Related guide: [Assistants](/docs/assistants/overview) - navigationGroup: assistants - sections: - - type: endpoint - key: listRunSteps - path: listRunSteps - - type: endpoint - key: getRunStep - path: getRunStep - - type: object - key: RunStepObject - path: step-object - - id: vector-stores - title: Vector Stores - beta: true - description: | - Vector stores are used to store files for use by the `file_search` tool. - - Related guide: [File Search](/docs/assistants/tools/file-search) - navigationGroup: assistants - sections: - - type: endpoint - key: createVectorStore - path: create - - type: endpoint - key: listVectorStores - path: list - - type: endpoint - key: getVectorStore - path: retrieve - - type: endpoint - key: modifyVectorStore - path: modify - - type: endpoint - key: deleteVectorStore - path: delete - - type: object - key: VectorStoreObject - path: object - - id: vector-stores-files - title: Vector Store Files - beta: true - description: | - Vector store files represent files inside a vector store. - - Related guide: [File Search](/docs/assistants/tools/file-search) - navigationGroup: assistants - sections: - - type: endpoint - key: createVectorStoreFile - path: createFile - - type: endpoint - key: listVectorStoreFiles - path: listFiles - - type: endpoint - key: getVectorStoreFile - path: getFile - - type: endpoint - key: deleteVectorStoreFile - path: deleteFile - - type: object - key: VectorStoreFileObject - path: file-object - - id: vector-stores-file-batches - title: Vector Store File Batches - beta: true - description: | - Vector store file batches represent operations to add multiple files to a vector store. - - Related guide: [File Search](/docs/assistants/tools/file-search) - navigationGroup: assistants - sections: - - type: endpoint - key: createVectorStoreFileBatch - path: createBatch - - type: endpoint - key: getVectorStoreFileBatch - path: getBatch - - type: endpoint - key: cancelVectorStoreFileBatch - path: cancelBatch - - type: endpoint - key: listFilesInVectorStoreBatch - path: listBatchFiles - - type: object - key: VectorStoreFileBatchObject - path: batch-object - - id: assistants-streaming - title: Streaming - beta: true - description: | - Stream the result of executing a Run or resuming a Run after submitting tool outputs. - - You can stream events from the [Create Thread and Run](/docs/api-reference/runs/createThreadAndRun), - [Create Run](/docs/api-reference/runs/createRun), and [Submit Tool Outputs](/docs/api-reference/runs/submitToolOutputs) - endpoints by passing `"stream": true`. The response will be a [Server-Sent events](https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events) stream. - - Our Node and Python SDKs provide helpful utilities to make streaming easy. Reference the - [Assistants API quickstart](/docs/assistants/overview) to learn more. - navigationGroup: assistants - sections: - - type: object - key: MessageDeltaObject - path: message-delta-object - - type: object - key: RunStepDeltaObject - path: run-step-delta-object - - type: object - key: AssistantStreamEvent - path: events - - id: completions - title: Completions - legacy: true - navigationGroup: legacy - description: | - Given a prompt, the model will return one or more predicted completions along with the probabilities of alternative tokens at each position. Most developer should use our [Chat Completions API](/docs/guides/text-generation/text-generation-models) to leverage our best and newest models. - sections: - - type: endpoint - key: createCompletion - path: create - - type: object - key: CreateCompletionResponse - path: object + - Portkey-Key: [] + +x-code-samples: + navigationGroups: + - id: endpoints + title: Endpoints + - id: assistants + title: Assistants + - id: legacy + title: Legacy + groups: + # > General Notes + # The `groups` section is used to generate the API reference pages and navigation, in the same + # order listed below. Additionally, each `group` can have a list of `sections`, each of which + # will become a navigation subroute and subsection under the group. Each section has: + # - `type`: Currently, either an `endpoint` or `object`, depending on how the section needs to + # be rendered + # - `key`: The reference key that can be used to lookup the section definition + # - `path`: The path (url) of the section, which is used to generate the navigation link. + # + # > The `object` sections maps to a schema component and the following fields are read for rendering + # - `x-oaiMeta.name`: The name of the object, which will become the section title + # - `x-oaiMeta.example`: The example object, which will be used to generate the example sample (always JSON) + # - `description`: The description of the object, which will be used to generate the section description + # + # > The `endpoint` section maps to an operation path and the following fields are read for rendering: + # - `x-oaiMeta.name`: The name of the endpoint, which will become the section title + # - `x-oaiMeta.examples`: The endpoint examples, which can be an object (meaning a single variation, most + # endpoints, or an array of objects, meaning multiple variations, e.g. the + # chat completion and completion endpoints, with streamed and non-streamed examples. + # - `x-oaiMeta.returns`: text describing what the endpoint returns. + # - `summary`: The summary of the endpoint, which will be used to generate the section description + - id: audio + title: Audio + description: | + Learn how to turn audio into text or text into audio. + + Related guide: [Speech to text](https://platform.openai.com/docs/guides/speech-to-text) + navigationGroup: endpoints + sections: + - type: endpoint + key: createSpeech + path: createSpeech + - type: endpoint + key: createTranscription + path: createTranscription + - type: endpoint + key: createTranslation + path: createTranslation + - type: object + key: CreateTranscriptionResponseJson + path: json-object + - type: object + key: CreateTranscriptionResponseVerboseJson + path: verbose-json-object + - id: chat + title: Chat + description: | + Given a list of messages comprising a conversation, the model will return a response. + + Related guide: [Chat Completions](https://platform.openai.com/docs/guides/text-generation) + navigationGroup: endpoints + sections: + - type: endpoint + key: createChatCompletion + path: create + - type: object + key: CreateChatCompletionResponse + path: object + - type: object + key: CreateChatCompletionStreamResponse + path: streaming + - id: realtime + title: Realtime + description: | + WebSocket proxy for provider Realtime APIs (`GET` upgrade). Use `wss://` with the same `/v1` data-plane base as other gateway routes. + + Related guide: [OpenAI Realtime API](https://platform.openai.com/docs/guides/realtime) + navigationGroup: endpoints + sections: + - type: endpoint + key: connectRealtime + path: connect + - id: embeddings + title: Embeddings + description: | + Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. + + Related guide: [Embeddings](https://platform.openai.com/docs/guides/embeddings) + navigationGroup: endpoints + sections: + - type: endpoint + key: createEmbedding + path: create + - type: object + key: Embedding + path: object + - id: fine-tuning + title: Fine-tuning + description: | + Manage fine-tuning jobs to tailor a model to your specific training data. + + Related guide: [Fine-tune models](https://platform.openai.com/docs/guides/fine-tuning) + navigationGroup: endpoints + sections: + - type: endpoint + key: createFineTuningJob + path: create + - type: endpoint + key: listPaginatedFineTuningJobs + path: list + - type: endpoint + key: listFineTuningEvents + path: list-events + - type: endpoint + key: listFineTuningJobCheckpoints + path: list-checkpoints + - type: endpoint + key: retrieveFineTuningJob + path: retrieve + - type: endpoint + key: cancelFineTuningJob + path: cancel + - type: object + key: FinetuneChatRequestInput + path: chat-input + - type: object + key: FinetuneCompletionRequestInput + path: completions-input + - type: object + key: FineTuningJob + path: object + - type: object + key: FineTuningJobEvent + path: event-object + - type: object + key: FineTuningJobCheckpoint + path: checkpoint-object + - id: batch + title: Batch + description: | + Create large batches of API requests for asynchronous processing. The Batch API returns completions within 24 hours for a 50% discount. + + Related guide: [Batch](https://platform.openai.com/docs/guides/batch) + navigationGroup: endpoints + sections: + - type: endpoint + key: createBatch + path: create + - type: endpoint + key: retrieveBatch + path: retrieve + - type: endpoint + key: cancelBatch + path: cancel + - type: endpoint + key: listBatches + path: list + - type: object + key: Batch + path: object + - type: object + key: BatchRequestInput + path: request-input + - type: object + key: BatchRequestOutput + path: request-output + - id: files + title: Files + description: | + Files are used to upload documents that can be used with features like [Assistants](https://platform.openai.com/docs/api-reference/assistants), [Fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning), and [Batch API](https://platform.openai.com/docs/guides/batch). + navigationGroup: endpoints + sections: + - type: endpoint + key: createFile + path: create + - type: endpoint + key: listFiles + path: list + - type: endpoint + key: retrieveFile + path: retrieve + - type: endpoint + key: deleteFile + path: delete + - type: endpoint + key: downloadFile + path: retrieve-contents + - type: object + key: OpenAIFile + path: object + - id: images + title: Images + description: | + Given a prompt and/or an input image, the model will generate a new image. + + Related guide: [Image generation](https://platform.openai.com/docs/guides/images) + navigationGroup: endpoints + sections: + - type: endpoint + key: createImage + path: create + - type: endpoint + key: createImageEdit + path: createEdit + - type: endpoint + key: createImageVariation + path: createVariation + - type: object + key: Image + path: object + - id: models + title: Models + description: | + List and describe the various models available in the API. You can refer to the [Models](https://platform.openai.com/docs/models) documentation to understand what models are available and the differences between them. + navigationGroup: endpoints + sections: + - type: endpoint + key: listModels + path: list + - type: endpoint + key: retrieveModel + path: retrieve + - type: endpoint + key: deleteModel + path: delete + - type: object + key: Model + path: object + - id: moderations + title: Moderations + description: | + Given some input text, outputs if the model classifies it as potentially harmful across several categories. + + Related guide: [Moderations](https://platform.openai.com/docs/guides/moderation) + navigationGroup: endpoints + sections: + - type: endpoint + key: createModeration + path: create + - type: object + key: CreateModerationResponse + path: object + - id: assistants + title: Assistants + beta: true + description: | + Build assistants that can call models and use tools to perform tasks. + + [Get started with the Assistants API](https://platform.openai.com/docs/assistants) + navigationGroup: assistants + sections: + - type: endpoint + key: createAssistant + path: createAssistant + - type: endpoint + key: listAssistants + path: listAssistants + - type: endpoint + key: getAssistant + path: getAssistant + - type: endpoint + key: modifyAssistant + path: modifyAssistant + - type: endpoint + key: deleteAssistant + path: deleteAssistant + - type: object + key: AssistantObject + path: object + - id: threads + title: Threads + beta: true + description: | + Create threads that assistants can interact with. + + Related guide: [Assistants](https://platform.openai.com/docs/assistants/overview) + navigationGroup: assistants + sections: + - type: endpoint + key: createThread + path: createThread + - type: endpoint + key: getThread + path: getThread + - type: endpoint + key: modifyThread + path: modifyThread + - type: endpoint + key: deleteThread + path: deleteThread + - type: object + key: ThreadObject + path: object + - id: messages + title: Messages + beta: true + description: | + Create messages within threads + + Related guide: [Assistants](https://platform.openai.com/docs/assistants/overview) + navigationGroup: assistants + sections: + - type: endpoint + key: createMessage + path: createMessage + - type: endpoint + key: listMessages + path: listMessages + - type: endpoint + key: getMessage + path: getMessage + - type: endpoint + key: modifyMessage + path: modifyMessage + - type: endpoint + key: deleteMessage + path: deleteMessage + - type: object + key: MessageObject + path: object + - id: runs + title: Runs + beta: true + description: | + Represents an execution run on a thread. + + Related guide: [Assistants](https://platform.openai.com/docs/assistants/overview) + navigationGroup: assistants + sections: + - type: endpoint + key: createRun + path: createRun + - type: endpoint + key: createThreadAndRun + path: createThreadAndRun + - type: endpoint + key: listRuns + path: listRuns + - type: endpoint + key: getRun + path: getRun + - type: endpoint + key: modifyRun + path: modifyRun + - type: endpoint + key: submitToolOuputsToRun + path: submitToolOutputs + - type: endpoint + key: cancelRun + path: cancelRun + - type: object + key: RunObject + path: object + - id: run-steps + title: Run Steps + beta: true + description: | + Represents the steps (model and tool calls) taken during the run. + + Related guide: [Assistants](https://platform.openai.com/docs/assistants/overview) + navigationGroup: assistants + sections: + - type: endpoint + key: listRunSteps + path: listRunSteps + - type: endpoint + key: getRunStep + path: getRunStep + - type: object + key: RunStepObject + path: step-object + - id: vector-stores + title: Vector Stores + beta: true + description: | + Vector stores are used to store files for use by the `file_search` tool. + + Related guide: [File Search](https://platform.openai.com/docs/assistants/tools/file-search) + navigationGroup: assistants + sections: + - type: endpoint + key: createVectorStore + path: create + - type: endpoint + key: listVectorStores + path: list + - type: endpoint + key: getVectorStore + path: retrieve + - type: endpoint + key: modifyVectorStore + path: modify + - type: endpoint + key: deleteVectorStore + path: delete + - type: object + key: VectorStoreObject + path: object + - id: vector-stores-files + title: Vector Store Files + beta: true + description: | + Vector store files represent files inside a vector store. + + Related guide: [File Search](https://platform.openai.com/docs/assistants/tools/file-search) + navigationGroup: assistants + sections: + - type: endpoint + key: createVectorStoreFile + path: createFile + - type: endpoint + key: listVectorStoreFiles + path: listFiles + - type: endpoint + key: getVectorStoreFile + path: getFile + - type: endpoint + key: deleteVectorStoreFile + path: deleteFile + - type: object + key: VectorStoreFileObject + path: file-object + - id: vector-stores-file-batches + title: Vector Store File Batches + beta: true + description: | + Vector store file batches represent operations to add multiple files to a vector store. + + Related guide: [File Search](https://platform.openai.com/docs/assistants/tools/file-search) + navigationGroup: assistants + sections: + - type: endpoint + key: createVectorStoreFileBatch + path: createBatch + - type: endpoint + key: getVectorStoreFileBatch + path: getBatch + - type: endpoint + key: cancelVectorStoreFileBatch + path: cancelBatch + - type: endpoint + key: listFilesInVectorStoreBatch + path: listBatchFiles + - type: object + key: VectorStoreFileBatchObject + path: batch-object + - id: assistants-streaming + title: Streaming + beta: true + description: | + Stream the result of executing a Run or resuming a Run after submitting tool outputs. + + You can stream events from the [Create Thread and Run](https://platform.openai.com/docs/api-reference/runs/createThreadAndRun), + [Create Run](https://platform.openai.com/docs/api-reference/runs/createRun), and [Submit Tool Outputs](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs) + endpoints by passing `"stream": true`. The response will be a [Server-Sent events](https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events) stream. + + Our Node and Python SDKs provide helpful utilities to make streaming easy. Reference the + [Assistants API quickstart](https://platform.openai.com/docs/assistants/overview) to learn more. + navigationGroup: assistants + sections: + - type: object + key: MessageDeltaObject + path: message-delta-object + - type: object + key: RunStepDeltaObject + path: run-step-delta-object + - type: object + key: AssistantStreamEvent + path: events + - id: completions + title: Completions + legacy: true + navigationGroup: legacy + description: | + Given a prompt, the model will return one or more predicted completions along with the probabilities of alternative tokens at each position. Most developer should use our [Chat Completions API](https://platform.openai.com/docs/guides/text-generation/text-generation-models) to leverage our best and newest models. + sections: + - type: endpoint + key: createCompletion + path: create + - type: object + key: CreateCompletionResponse + path: object diff --git a/tags b/tags new file mode 100644 index 00000000..f078e22f --- /dev/null +++ b/tags @@ -0,0 +1,52 @@ + - 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: 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 a input text, outputs if the model classifies it as potentially harmful. + - name: Configs + description: Create, List, Retrieve, and Update your Portkey Configs. + - name: Feedback + description: Send and Update any feedback. + - name: Logs + description: Send a new log to Portkey. + - name: Prompts + description: Given a prompt ID saved on Portkey, return a response or render the prompt data. + - name: Virtual-keys + description: Create, List, Retrieve, Update, and Delete your Portkey Virtual keys. + - name: Users + description: Create and manage users. + - name: User-invites + description: Create and manage user invites. + - name: Workspaces + description: Create and manage workspaces. + - name: Workspaces > Members + description: Create and manage workspace members. + - name: Api-Keys + description: Create, List, Retrieve, Update, and Delete your Portkey Api keys. + - name: Logs Export + description: Exports logs service . + - name: Analytics + description: Get analytics over different data points like requests, costs, tokens, etc. + - name: Analytics > Graphs + description: Get data points for graphical representation. + - name: Analytics > Summary + description: Get overall summary for the selected time bucket. + - name: Analytics > Groups + description: Get grouped metrics for the selected time bucket. \ No newline at end of file