From b59128939ad87ffe2875bb47448f55560a40d4b2 Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Tue, 11 Jun 2024 14:25:23 +0530 Subject: [PATCH 001/124] Portkey OpenAPI YAML --- README.md | 4 +- backups/11-06-24.yaml | 13833 ++++++++++++++++++++++++++++++++++++++++ openapi.yaml | 2252 ++++--- 3 files changed, 15286 insertions(+), 803 deletions(-) create mode 100644 backups/11-06-24.yaml 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..42cd3dff 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1,17 +1,17 @@ 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. + 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://openai.com/policies/terms-of-use + termsOfService: https://portkey.ai/terms contact: - name: OpenAI Support - url: https://help.openai.com/ + name: Portkey Developer Forum + url: https://portkey.ai/community license: name: MIT - url: https://github.com/openai/openai-openapi/blob/master/LICENSE + url: https://github.com/Portkey-AI/portkey-openapi/blob/master/LICENSE servers: - - url: https://api.openai.com/v1 + - url: https://api.portkey.ai/v1 tags: - name: Assistants description: Build Assistants that can call models and use tools. @@ -62,15 +62,16 @@ paths: 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. + 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.openai.com/v1/chat/completions \ + curl https://api.portkey.ai/v1/chat/completions \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -d '{ "model": "VAR_model_id", "messages": [ @@ -85,8 +86,12 @@ paths: ] }' python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) completion = client.chat.completions.create( model="VAR_model_id", @@ -98,12 +103,15 @@ paths: print(completion.choices[0].message) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const completion = await openai.chat.completions.create({ + const completion = await client.chat.completions.create({ messages: [{ role: "system", content: "You are a helpful assistant." }], model: "VAR_model_id", }); @@ -137,9 +145,10 @@ paths: - title: Image input request: curl: | - curl https://api.openai.com/v1/chat/completions \ + curl https://api.portkey.ai/v1/chat/completions \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -d '{ "model": "gpt-4-turbo", "messages": [ @@ -162,9 +171,12 @@ paths: "max_tokens": 300 }' python: | - from openai import OpenAI + from portkey_ai import Portkey - client = OpenAI() + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) response = client.chat.completions.create( model="gpt-4-turbo", @@ -185,12 +197,15 @@ paths: print(response.choices[0]) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const response = await openai.chat.completions.create({ + const response = await client.chat.completions.create({ model: "gpt-4-turbo", messages: [ { @@ -234,9 +249,10 @@ paths: - title: Streaming request: curl: | - curl https://api.openai.com/v1/chat/completions \ + curl https://api.portkey.ai/v1/chat/completions \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -d '{ "model": "VAR_model_id", "messages": [ @@ -252,8 +268,12 @@ paths: "stream": true }' python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) completion = client.chat.completions.create( model="VAR_model_id", @@ -268,12 +288,15 @@ paths: print(chunk.choices[0].delta) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const completion = await openai.chat.completions.create({ + const completion = await client.chat.completions.create({ model: "VAR_model_id", messages: [ {"role": "system", "content": "You are a helpful assistant."}, @@ -299,9 +322,10 @@ paths: - title: Functions request: curl: | - curl https://api.openai.com/v1/chat/completions \ + curl https://api.portkey.ai/v1/chat/completions \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -d '{ "model": "gpt-4-turbo", "messages": [ @@ -336,8 +360,12 @@ paths: "tool_choice": "auto" }' python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) tools = [ { @@ -369,9 +397,12 @@ paths: print(completion) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { const messages = [{"role": "user", "content": "What's the weather like in Boston today?"}]; @@ -396,7 +427,7 @@ paths: } ]; - const response = await openai.chat.completions.create({ + const response = await client.chat.completions.create({ model: "gpt-4-turbo", messages: messages, tools: tools, @@ -443,9 +474,10 @@ paths: - title: Logprobs request: curl: | - curl https://api.openai.com/v1/chat/completions \ + curl https://api.portkey.ai/v1/chat/completions \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -d '{ "model": "VAR_model_id", "messages": [ @@ -458,8 +490,12 @@ paths: "top_logprobs": 2 }' python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) completion = client.chat.completions.create( model="VAR_model_id", @@ -473,12 +509,15 @@ paths: print(completion.choices[0].message) print(completion.choices[0].logprobs) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const completion = await openai.chat.completions.create({ + const completion = await client.chat.completions.create({ messages: [{ role: "user", content: "Hello!" }], model: "VAR_model_id", logprobs: true, @@ -698,15 +737,16 @@ paths: 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. + 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.openai.com/v1/completions \ + curl https://api.portkey.ai/v1/completions \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -d '{ "model": "VAR_model_id", "prompt": "Say this is a test", @@ -714,8 +754,12 @@ paths: "temperature": 0 }' python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) client.completions.create( model="VAR_model_id", @@ -724,12 +768,15 @@ paths: temperature=0 ) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const completion = await openai.completions.create({ + const completion = await client.completions.create({ model: "VAR_model_id", prompt: "Say this is a test.", max_tokens: 7, @@ -763,9 +810,10 @@ paths: - title: Streaming request: curl: | - curl https://api.openai.com/v1/completions \ + curl https://api.portkey.ai/v1/completions \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -d '{ "model": "VAR_model_id", "prompt": "Say this is a test", @@ -774,8 +822,12 @@ paths: "stream": true }' python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) for chunk in client.completions.create( model="VAR_model_id", @@ -786,12 +838,15 @@ paths: ): print(chunk.choices[0].text) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const stream = await openai.completions.create({ + const stream = await client.completions.create({ model: "VAR_model_id", prompt: "Say this is a test.", stream: true, @@ -841,13 +896,14 @@ paths: x-oaiMeta: name: Create image group: images - returns: Returns a list of [image](/docs/api-reference/images/object) objects. + returns: Returns a list of [image](https://platform.openai.com/docs/api-reference/images/object) objects. examples: request: curl: | - curl https://api.openai.com/v1/images/generations \ + curl https://api.portkey.ai/v1/images/generations \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -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", @@ -855,8 +911,12 @@ paths: "size": "1024x1024" }' python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) client.images.generate( model="dall-e-3", @@ -865,12 +925,15 @@ paths: size="1024x1024" ) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const image = await openai.images.generate({ model: "dall-e-3", prompt: "A cute baby sea otter" }); + const image = await client.images.generate({ model: "dall-e-3", prompt: "A cute baby sea otter" }); console.log(image.data); } @@ -909,20 +972,25 @@ paths: x-oaiMeta: name: Create image edit group: images - returns: Returns a list of [image](/docs/api-reference/images/object) objects. + returns: Returns a list of [image](https://platform.openai.com/docs/api-reference/images/object) objects. examples: request: curl: | - curl https://api.openai.com/v1/images/edits \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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" python: | - from openai import OpenAI - client = OpenAI() + 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"), @@ -933,12 +1001,15 @@ paths: ) node.js: |- import fs from "fs"; - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const image = await openai.images.edit({ + 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", @@ -981,18 +1052,23 @@ paths: x-oaiMeta: name: Create image variation group: images - returns: Returns a list of [image](/docs/api-reference/images/object) objects. + returns: Returns a list of [image](https://platform.openai.com/docs/api-reference/images/object) objects. examples: request: curl: | - curl https://api.openai.com/v1/images/variations \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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" python: | - from openai import OpenAI - client = OpenAI() + 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"), @@ -1001,12 +1077,15 @@ paths: ) node.js: |- import fs from "fs"; - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const image = await openai.images.createVariation({ + const image = await client.images.createVariation({ image: fs.createReadStream("otter.png"), }); @@ -1048,12 +1127,13 @@ paths: x-oaiMeta: name: Create embeddings group: embeddings - returns: A list of [embedding](/docs/api-reference/embeddings/object) objects. + returns: A list of [embedding](https://platform.openai.com/docs/api-reference/embeddings/object) objects. examples: request: curl: | - curl https://api.openai.com/v1/embeddings \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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...", @@ -1061,8 +1141,12 @@ paths: "encoding_format": "float" }' python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -1070,12 +1154,15 @@ paths: encoding_format="float" ) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const embedding = await openai.embeddings.create({ + const embedding = await client.embeddings.create({ model: "text-embedding-ada-002", input: "The quick brown fox jumped over the lazy dog", encoding_format: "float", @@ -1139,8 +1226,9 @@ paths: examples: request: curl: | - curl https://api.openai.com/v1/audio/speech \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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", @@ -1150,10 +1238,15 @@ paths: --output speech.mp3 python: | from pathlib import Path - import openai + 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 = openai.audio.speech.create( + response = client.audio.speech.create( model="tts-1", voice="alloy", input="The quick brown fox jumped over the lazy dog." @@ -1162,14 +1255,17 @@ paths: node: | import fs from "fs"; import path from "path"; - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); const speechFile = path.resolve("./speech.mp3"); async function main() { - const mp3 = await openai.audio.speech.create({ + const mp3 = await client.audio.speech.create({ model: "tts-1", voice: "alloy", input: "Today is a wonderful day to build something people love!", @@ -1203,19 +1299,24 @@ paths: 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). + 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.openai.com/v1/audio/transcriptions \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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" python: | - from openai import OpenAI - client = OpenAI() + 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( @@ -1224,12 +1325,15 @@ paths: ) node: | import fs from "fs"; - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const transcription = await openai.audio.transcriptions.create({ + const transcription = await client.audio.transcriptions.create({ file: fs.createReadStream("audio.mp3"), model: "whisper-1", }); @@ -1244,16 +1348,21 @@ paths: - title: Word timestamps request: curl: | - curl https://api.openai.com/v1/audio/transcriptions \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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 "timestamp_granularities[]=word" \ -F model="whisper-1" \ -F response_format="verbose_json" python: | - from openai import OpenAI - client = OpenAI() + 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( @@ -1266,12 +1375,15 @@ paths: print(transcript.words) node: | import fs from "fs"; - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const transcription = await openai.audio.transcriptions.create({ + const transcription = await client.audio.transcriptions.create({ file: fs.createReadStream("audio.mp3"), model: "whisper-1", response_format: "verbose_json", @@ -1304,16 +1416,21 @@ paths: - title: Segment timestamps request: curl: | - curl https://api.openai.com/v1/audio/transcriptions \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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 "timestamp_granularities[]=segment" \ -F model="whisper-1" \ -F response_format="verbose_json" python: | - from openai import OpenAI - client = OpenAI() + 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( @@ -1326,12 +1443,15 @@ paths: print(transcript.words) node: | import fs from "fs"; - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const transcription = await openai.audio.transcriptions.create({ + const transcription = await client.audio.transcriptions.create({ file: fs.createReadStream("audio.mp3"), model: "whisper-1", response_format: "verbose_json", @@ -1393,14 +1513,19 @@ paths: examples: request: curl: | - curl https://api.openai.com/v1/audio/translations \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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" python: | - from openai import OpenAI - client = OpenAI() + 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( @@ -1409,12 +1534,15 @@ paths: ) node: | import fs from "fs"; - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const translation = await openai.audio.translations.create({ + const translation = await client.audio.translations.create({ file: fs.createReadStream("speech.mp3"), model: "whisper-1", }); @@ -1450,24 +1578,32 @@ paths: x-oaiMeta: name: List files group: files - returns: A list of [File](/docs/api-reference/files/object) objects. + returns: A list of [File](https://platform.openai.com/docs/api-reference/files/object) objects. examples: request: curl: | - curl https://api.openai.com/v1/files \ - -H "Authorization: Bearer $OPENAI_API_KEY" + curl https://api.portkey.ai/v1/files \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) client.files.list() node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const list = await openai.files.list(); + const list = await client.files.list(); for await (const file of list) { console.log(file); @@ -1504,13 +1640,13 @@ paths: 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 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](/docs/api-reference/fine-tuning/chat-input) or [completions](/docs/api-reference/fine-tuning/completions-input) models. + 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](/docs/api-reference/batch/request-input). + 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 us](https://help.openai.com/) if you need to increase these storage limits. + Please [contact OpenAI](https://help.openai.com/) if you need to increase these storage limits. requestBody: required: true content: @@ -1527,17 +1663,22 @@ paths: x-oaiMeta: name: Upload file group: files - returns: The uploaded [File](/docs/api-reference/files/object) object. + returns: The uploaded [File](https://platform.openai.com/docs/api-reference/files/object) object. examples: request: curl: | - curl https://api.openai.com/v1/files \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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" python: | - from openai import OpenAI - client = OpenAI() + 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"), @@ -1545,12 +1686,15 @@ paths: ) node.js: |- import fs from "fs"; - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const file = await openai.files.create({ + const file = await client.files.create({ file: fs.createReadStream("mydata.jsonl"), purpose: "fine-tune", }); @@ -1595,21 +1739,29 @@ paths: examples: request: curl: | - curl https://api.openai.com/v1/files/file-abc123 \ + curl https://api.portkey.ai/v1/files/file-abc123 \ -X DELETE \ - -H "Authorization: Bearer $OPENAI_API_KEY" + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) client.files.delete("file-abc123") node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const file = await openai.files.del("file-abc123"); + const file = await client.files.del("file-abc123"); console.log(file); } @@ -1643,24 +1795,32 @@ paths: x-oaiMeta: name: Retrieve file group: files - returns: The [File](/docs/api-reference/files/object) object matching the specified ID. + returns: The [File](https://platform.openai.com/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" + 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" python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) client.files.retrieve("file-abc123") node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const file = await openai.files.retrieve("file-abc123"); + const file = await client.files.retrieve("file-abc123"); console.log(file); } @@ -1702,20 +1862,28 @@ paths: examples: request: curl: | - curl https://api.openai.com/v1/files/file-abc123/content \ - -H "Authorization: Bearer $OPENAI_API_KEY" > file.jsonl + 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 python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) content = client.files.content("file-abc123") node.js: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const file = await openai.files.content("file-abc123"); + const file = await client.files.content("file-abc123"); console.log(file); } @@ -1732,7 +1900,7 @@ paths: 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) + [Learn more about fine-tuning](https://platform.openai.com/docs/guides/fine-tuning) requestBody: required: true content: @@ -1749,33 +1917,41 @@ paths: x-oaiMeta: name: Create fine-tuning job group: fine-tuning - returns: A [fine-tuning.job](/docs/api-reference/fine-tuning/object) object. + returns: A [fine-tuning.job](https://platform.openai.com/docs/api-reference/fine-tuning/object) object. examples: - title: Default request: curl: | - curl https://api.openai.com/v1/fine_tuning/jobs \ + curl https://api.portkey.ai/v1/fine_tuning/jobs \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -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" }' python: | - from openai import OpenAI - client = OpenAI() + 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" ) node.js: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const fineTune = await openai.fineTuning.jobs.create({ + const fineTune = await client.fineTuning.jobs.create({ training_file: "file-abc123" }); @@ -1799,9 +1975,10 @@ paths: - title: Epochs request: curl: | - curl https://api.openai.com/v1/fine_tuning/jobs \ + curl https://api.portkey.ai/v1/fine_tuning/jobs \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -d '{ "training_file": "file-abc123", "model": "gpt-3.5-turbo", @@ -1810,8 +1987,12 @@ paths: } }' python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -1821,12 +2002,15 @@ paths: } ) node.js: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const fineTune = await openai.fineTuning.jobs.create({ + const fineTune = await client.fineTuning.jobs.create({ training_file: "file-abc123", model: "gpt-3.5-turbo", hyperparameters: { n_epochs: 2 } @@ -1853,17 +2037,22 @@ paths: - title: Validation file request: curl: | - curl https://api.openai.com/v1/fine_tuning/jobs \ + curl https://api.portkey.ai/v1/fine_tuning/jobs \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -d '{ "training_file": "file-abc123", "validation_file": "file-abc123", "model": "gpt-3.5-turbo" }' python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -1871,12 +2060,15 @@ paths: model="gpt-3.5-turbo" ) node.js: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const fineTune = await openai.fineTuning.jobs.create({ + const fineTune = await client.fineTuning.jobs.create({ training_file: "file-abc123", validation_file: "file-abc123" }); @@ -1901,9 +2093,10 @@ paths: - title: W&B Integration request: curl: | - curl https://api.openai.com/v1/fine_tuning/jobs \ + curl https://api.portkey.ai/v1/fine_tuning/jobs \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -d '{ "training_file": "file-abc123", "validation_file": "file-abc123", @@ -1974,24 +2167,32 @@ paths: 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. + 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.openai.com/v1/fine_tuning/jobs?limit=2 \ - -H "Authorization: Bearer $OPENAI_API_KEY" + 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" python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) client.fine_tuning.jobs.list() node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const list = await openai.fineTuning.jobs.list(); + const list = await client.fineTuning.jobs.list(); for await (const fineTune of list) { console.log(fineTune); @@ -2024,7 +2225,7 @@ paths: summary: | Get info about a fine-tuning job. - [Learn more about fine-tuning](/docs/guides/fine-tuning) + [Learn more about fine-tuning](https://platform.openai.com/docs/guides/fine-tuning) parameters: - in: path name: fine_tuning_job_id @@ -2044,24 +2245,32 @@ paths: 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. + 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.openai.com/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F \ - -H "Authorization: Bearer $OPENAI_API_KEY" + 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" python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) client.fine_tuning.jobs.retrieve("ftjob-abc123") node.js: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const fineTune = await openai.fineTuning.jobs.retrieve("ftjob-abc123"); + const fineTune = await client.fineTuning.jobs.retrieve("ftjob-abc123"); console.log(fineTune); } @@ -2135,23 +2344,31 @@ paths: examples: request: curl: | - curl https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/events \ - -H "Authorization: Bearer $OPENAI_API_KEY" + 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" python: | - from openai import OpenAI - client = OpenAI() + 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 ) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const list = await openai.fineTuning.list_events(id="ftjob-abc123", limit=2); + const list = await client.fineTuning.list_events(id="ftjob-abc123", limit=2); for await (const fineTune of list) { console.log(fineTune); @@ -2210,24 +2427,32 @@ paths: x-oaiMeta: name: Cancel fine-tuning group: fine-tuning - returns: The cancelled [fine-tuning](/docs/api-reference/fine-tuning/object) object. + returns: The cancelled [fine-tuning](https://platform.openai.com/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" + 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" python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) client.fine_tuning.jobs.cancel("ftjob-abc123") node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const fineTune = await openai.fineTuning.jobs.cancel("ftjob-abc123"); + const fineTune = await client.fineTuning.jobs.cancel("ftjob-abc123"); console.log(fineTune); } @@ -2287,12 +2512,13 @@ paths: 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. + 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.openai.com/v1/fine_tuning/jobs/ftjob-abc123/checkpoints \ - -H "Authorization: Bearer $OPENAI_API_KEY" + 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" response: | { "object": "list" @@ -2343,24 +2569,32 @@ paths: x-oaiMeta: name: List models group: models - returns: A list of [model](/docs/api-reference/models/object) objects. + returns: A list of [model](https://platform.openai.com/docs/api-reference/models/object) objects. examples: request: curl: | - curl https://api.openai.com/v1/models \ - -H "Authorization: Bearer $OPENAI_API_KEY" + curl https://api.portkey.ai/v1/models \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) client.models.list() node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const list = await openai.models.list(); + const list = await client.models.list(); for await (const model of list) { console.log(model); @@ -2417,24 +2651,32 @@ paths: x-oaiMeta: name: Retrieve model group: models - returns: The [model](/docs/api-reference/models/object) object matching the specified ID. + returns: The [model](https://platform.openai.com/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" + 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" \ python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) client.models.retrieve("VAR_model_id") node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const model = await openai.models.retrieve("VAR_model_id"); + const model = await client.models.retrieve("VAR_model_id"); console.log(model); } @@ -2474,21 +2716,29 @@ paths: examples: request: curl: | - curl https://api.openai.com/v1/models/ft:gpt-3.5-turbo:acemeco:suffix:abc123 \ + curl https://api.portkey.ai/v1/models/ft:gpt-3.5-turbo:acemeco:suffix:abc123 \ -X DELETE \ - -H "Authorization: Bearer $OPENAI_API_KEY" + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" python: | - from openai import OpenAI - client = OpenAI() + 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") node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const model = await openai.models.del("ft:gpt-3.5-turbo:acemeco:suffix:abc123"); + const model = await client.models.del("ft:gpt-3.5-turbo:acemeco:suffix:abc123"); console.log(model); } @@ -2522,29 +2772,37 @@ paths: x-oaiMeta: name: Create moderation group: moderations - returns: A [moderation](/docs/api-reference/moderations/object) object. + returns: A [moderation](https://platform.openai.com/docs/api-reference/moderations/object) object. examples: request: curl: | - curl https://api.openai.com/v1/moderations \ + curl https://api.portkey.ai/v1/moderations \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -d '{ "input": "I want to kill them." }' python: | - from openai import OpenAI - client = OpenAI() + 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) node.js: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const moderation = await openai.moderations.create({ input: "I want to kill them." }); + const moderation = await client.moderations.create({ input: "I want to kill them." }); console.log(moderation); } @@ -2632,17 +2890,22 @@ paths: name: List assistants group: assistants beta: true - returns: A list of [assistant](/docs/api-reference/assistants/object) objects. + returns: A list of [assistant](https://platform.openai.com/docs/api-reference/assistants/object) objects. examples: request: curl: | - curl "https://api.openai.com/v1/assistants?order=desc&limit=20" \ + curl "https://api.portkey.ai/v1/assistants?order=desc&limit=20" \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -H "OpenAI-Beta: assistants=v2" python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -2650,12 +2913,15 @@ paths: ) print(my_assistants.data) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const myAssistants = await openai.beta.assistants.list({ + const myAssistants = await client.beta.assistants.list({ order: "desc", limit: "20", }); @@ -2740,14 +3006,15 @@ paths: name: Create assistant group: assistants beta: true - returns: An [assistant](/docs/api-reference/assistants/object) object. + returns: An [assistant](https://platform.openai.com/docs/api-reference/assistants/object) object. examples: - title: Code Interpreter request: curl: | - curl "https://api.openai.com/v1/assistants" \ + curl "https://api.portkey.ai/v1/assistants" \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -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.", @@ -2757,8 +3024,12 @@ paths: }' python: | - from openai import OpenAI - client = OpenAI() + 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.", @@ -2768,12 +3039,15 @@ paths: ) print(my_assistant) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const myAssistant = await openai.beta.assistants.create({ + const myAssistant = await 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", @@ -2807,9 +3081,10 @@ paths: - title: Files request: curl: | - curl https://api.openai.com/v1/assistants \ + curl https://api.portkey.ai/v1/assistants \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -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.", @@ -2818,8 +3093,12 @@ paths: "model": "gpt-4-turbo" }' python: | - from openai import OpenAI - client = OpenAI() + 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 an HR bot, and you have access to files to answer employee questions about company policies.", @@ -2830,12 +3109,15 @@ paths: ) print(my_assistant) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const myAssistant = await openai.beta.assistants.create({ + const myAssistant = await 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", @@ -2901,27 +3183,35 @@ paths: name: Retrieve assistant group: assistants beta: true - returns: The [assistant](/docs/api-reference/assistants/object) object matching the specified ID. + returns: The [assistant](https://platform.openai.com/docs/api-reference/assistants/object) object matching the specified ID. examples: request: curl: | - curl https://api.openai.com/v1/assistants/asst_abc123 \ + curl https://api.portkey.ai/v1/assistants/asst_abc123 \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -H "OpenAI-Beta: assistants=v2" python: | - from openai import OpenAI - client = OpenAI() + 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) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const myAssistant = await openai.beta.assistants.retrieve( + const myAssistant = await client.beta.assistants.retrieve( "asst_abc123" ); @@ -2977,13 +3267,14 @@ paths: name: Modify assistant group: assistants beta: true - returns: The modified [assistant](/docs/api-reference/assistants/object) object. + returns: The modified [assistant](https://platform.openai.com/docs/api-reference/assistants/object) object. examples: request: curl: | - curl https://api.openai.com/v1/assistants/asst_abc123 \ + curl https://api.portkey.ai/v1/assistants/asst_abc123 \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -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.", @@ -2991,8 +3282,12 @@ paths: "model": "gpt-4-turbo" }' python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -3004,12 +3299,15 @@ paths: print(my_updated_assistant) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const myUpdatedAssistant = await openai.beta.assistants.update( + const myUpdatedAssistant = await client.beta.assistants.update( "asst_abc123", { instructions: @@ -3075,24 +3373,32 @@ paths: examples: request: curl: | - curl https://api.openai.com/v1/assistants/asst_abc123 \ + curl https://api.portkey.ai/v1/assistants/asst_abc123 \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -H "OpenAI-Beta: assistants=v2" \ -X DELETE python: | - from openai import OpenAI - client = OpenAI() + 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) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const response = await openai.beta.assistants.del("asst_abc123"); + const response = await client.beta.assistants.del("asst_abc123"); console.log(response); } @@ -3126,29 +3432,37 @@ paths: name: Create thread group: threads beta: true - returns: A [thread](/docs/api-reference/threads) object. + returns: A [thread](https://platform.openai.com/docs/api-reference/threads) object. examples: - title: Empty request: curl: | - curl https://api.openai.com/v1/threads \ + curl https://api.portkey.ai/v1/threads \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -H "OpenAI-Beta: assistants=v2" \ -d '' python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) empty_thread = client.beta.threads.create() print(empty_thread) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const emptyThread = await openai.beta.threads.create(); + const emptyThread = await client.beta.threads.create(); console.log(emptyThread); } @@ -3165,9 +3479,10 @@ paths: - title: Messages request: curl: | - curl https://api.openai.com/v1/threads \ + curl https://api.portkey.ai/v1/threads \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -H "OpenAI-Beta: assistants=v2" \ -d '{ "messages": [{ @@ -3179,8 +3494,12 @@ paths: }] }' python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) message_thread = client.beta.threads.create( messages=[ @@ -3197,12 +3516,15 @@ paths: print(message_thread) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const messageThread = await openai.beta.threads.create({ + const messageThread = await client.beta.threads.create({ messages: [ { role: "user", @@ -3252,27 +3574,35 @@ paths: name: Retrieve thread group: threads beta: true - returns: The [thread](/docs/api-reference/threads/object) object matching the specified ID. + returns: The [thread](https://platform.openai.com/docs/api-reference/threads/object) object matching the specified ID. examples: request: curl: | - curl https://api.openai.com/v1/threads/thread_abc123 \ + curl https://api.portkey.ai/v1/threads/thread_abc123 \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -H "OpenAI-Beta: assistants=v2" python: | - from openai import OpenAI - client = OpenAI() + 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) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const myThread = await openai.beta.threads.retrieve( + const myThread = await client.beta.threads.retrieve( "thread_abc123" ); @@ -3321,13 +3651,14 @@ paths: name: Modify thread group: threads beta: true - returns: The modified [thread](/docs/api-reference/threads/object) object matching the specified ID. + returns: The modified [thread](https://platform.openai.com/docs/api-reference/threads/object) object matching the specified ID. examples: request: curl: | - curl https://api.openai.com/v1/threads/thread_abc123 \ + curl https://api.portkey.ai/v1/threads/thread_abc123 \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -H "OpenAI-Beta: assistants=v2" \ -d '{ "metadata": { @@ -3336,8 +3667,12 @@ paths: } }' python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -3348,12 +3683,15 @@ paths: ) print(my_updated_thread) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const updatedThread = await openai.beta.threads.update( + const updatedThread = await client.beta.threads.update( "thread_abc123", { metadata: { modified: "true", user: "abc123" }, @@ -3402,24 +3740,32 @@ paths: examples: request: curl: | - curl https://api.openai.com/v1/threads/thread_abc123 \ + curl https://api.portkey.ai/v1/threads/thread_abc123 \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -H "OpenAI-Beta: assistants=v2" \ -X DELETE python: | - from openai import OpenAI - client = OpenAI() + 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) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const response = await openai.beta.threads.del("thread_abc123"); + const response = await client.beta.threads.del("thread_abc123"); console.log(response); } @@ -3443,7 +3789,7 @@ paths: required: true schema: type: string - description: The ID of the [thread](/docs/api-reference/threads) the messages belong to. + 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 @@ -3485,27 +3831,35 @@ paths: name: List messages group: threads beta: true - returns: A list of [message](/docs/api-reference/messages) objects. + returns: A list of [message](https://platform.openai.com/docs/api-reference/messages) objects. examples: request: curl: | - curl https://api.openai.com/v1/threads/thread_abc123/messages \ + curl https://api.portkey.ai/v1/threads/thread_abc123/messages \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -H "OpenAI-Beta: assistants=v2" python: | - from openai import OpenAI - client = OpenAI() + 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) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const threadMessages = await openai.beta.threads.messages.list( + const threadMessages = await client.beta.threads.messages.list( "thread_abc123" ); @@ -3573,7 +3927,7 @@ paths: required: true schema: type: string - description: The ID of the [thread](/docs/api-reference/threads) to create a message for. + description: The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) to create a message for. requestBody: required: true content: @@ -3591,21 +3945,26 @@ paths: name: Create message group: threads beta: true - returns: A [message](/docs/api-reference/messages/object) object. + returns: A [message](https://platform.openai.com/docs/api-reference/messages/object) object. examples: request: curl: | - curl https://api.openai.com/v1/threads/thread_abc123/messages \ + curl https://api.portkey.ai/v1/threads/thread_abc123/messages \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -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." }' python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -3614,12 +3973,15 @@ paths: ) print(thread_message) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const threadMessages = await openai.beta.threads.messages.create( + const threadMessages = await client.beta.threads.messages.create( "thread_abc123", { role: "user", content: "How does AI work? Explain it in simple terms." } ); @@ -3662,7 +4024,7 @@ paths: required: true schema: type: string - description: The ID of the [thread](/docs/api-reference/threads) to which this message belongs. + description: The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) to which this message belongs. - in: path name: message_id required: true @@ -3680,17 +4042,22 @@ paths: name: Retrieve message group: threads beta: true - returns: The [message](/docs/api-reference/threads/messages/object) object matching the specified ID. + returns: The [message](https://platform.openai.com/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 \ + curl https://api.portkey.ai/v1/threads/thread_abc123/messages/msg_abc123 \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -H "OpenAI-Beta: assistants=v2" python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -3698,12 +4065,15 @@ paths: ) print(message) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const message = await openai.beta.threads.messages.retrieve( + const message = await client.beta.threads.messages.retrieve( "thread_abc123", "msg_abc123" ); @@ -3768,13 +4138,14 @@ paths: name: Modify message group: threads beta: true - returns: The modified [message](/docs/api-reference/threads/messages/object) object. + returns: The modified [message](https://platform.openai.com/docs/api-reference/threads/messages/object) object. examples: request: curl: | - curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \ + curl https://api.portkey.ai/v1/threads/thread_abc123/messages/msg_abc123 \ -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -H "OpenAI-Beta: assistants=v2" \ -d '{ "metadata": { @@ -3783,8 +4154,12 @@ paths: } }' python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -3796,12 +4171,15 @@ paths: ) print(message) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const message = await openai.beta.threads.messages.update( + const message = await client.beta.threads.messages.update( "thread_abc123", "msg_abc123", { @@ -3868,13 +4246,18 @@ paths: examples: request: curl: | - curl -X DELETE https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \ + 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -H "OpenAI-Beta: assistants=v2" python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -3882,12 +4265,15 @@ paths: ) print(deleted_message) node.js: |- - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const deletedMessage = await openai.beta.threads.messages.del( + const deletedMessage = await client.beta.threads.messages.del( "thread_abc123", "msg_abc123" ); @@ -3924,13 +4310,14 @@ paths: name: Create thread and run group: threads beta: true - returns: A [run](/docs/api-reference/runs/object) object. + returns: A [run](https://platform.openai.com/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" \ + 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 '{ @@ -3942,8 +4329,12 @@ paths: } }' python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -3956,12 +4347,15 @@ paths: print(run) node.js: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const run = await openai.beta.threads.createAndRun({ + const run = await client.beta.threads.createAndRun({ assistant_id: "asst_abc123", thread: { messages: [ @@ -4012,8 +4406,9 @@ paths: - title: Streaming request: curl: | - curl https://api.openai.com/v1/threads/runs \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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 '{ @@ -4026,8 +4421,12 @@ paths: "stream": true }' python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) stream = client.beta.threads.create_and_run( assistant_id="asst_123", @@ -4042,12 +4441,15 @@ paths: for event in stream: print(event) node.js: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const stream = await openai.beta.threads.createAndRun({ + const stream = await client.beta.threads.createAndRun({ assistant_id: "asst_123", thread: { messages: [ @@ -4114,8 +4516,9 @@ paths: - title: Streaming with Functions request: curl: | - curl https://api.openai.com/v1/threads/runs \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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 '{ @@ -4151,8 +4554,12 @@ paths: "stream": true }' python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) tools = [ { @@ -4189,9 +4596,12 @@ paths: for event in stream: print(event) node.js: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); const tools = [ { @@ -4215,7 +4625,7 @@ paths: ]; async function main() { - const stream = await openai.beta.threads.createAndRun({ + const stream = await client.beta.threads.createAndRun({ assistant_id: "asst_123", thread: { messages: [ @@ -4322,17 +4732,22 @@ paths: name: List runs group: threads beta: true - returns: A list of [run](/docs/api-reference/runs/object) objects. + returns: A list of [run](https://platform.openai.com/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" \ + 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" python: | - from openai import OpenAI - client = OpenAI() + 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" @@ -4340,12 +4755,15 @@ paths: print(runs) node.js: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const runs = await openai.beta.threads.runs.list( + const runs = await client.beta.threads.runs.list( "thread_abc123" ); @@ -4485,21 +4903,26 @@ paths: name: Create run group: threads beta: true - returns: A [run](/docs/api-reference/runs/object) object. + returns: A [run](https://platform.openai.com/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" \ + 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" }' python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -4508,12 +4931,15 @@ paths: print(run) node.js: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const run = await openai.beta.threads.runs.create( + const run = await client.beta.threads.runs.create( "thread_abc123", { assistant_id: "asst_abc123" } ); @@ -4561,8 +4987,9 @@ paths: - title: Streaming request: curl: | - curl https://api.openai.com/v1/threads/thread_123/runs \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + curl https://api.portkey.ai/v1/threads/thread_123/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 '{ @@ -4570,8 +4997,12 @@ paths: "stream": true }' python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) stream = client.beta.threads.runs.create( thread_id="thread_123", @@ -4582,12 +5013,15 @@ paths: for event in stream: print(event) node.js: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const stream = await openai.beta.threads.runs.create( + const stream = await client.beta.threads.runs.create( "thread_123", { assistant_id: "asst_123", stream: true } ); @@ -4646,8 +5080,9 @@ paths: - title: Streaming with Functions request: curl: | - curl https://api.openai.com/v1/threads/thread_abc123/runs \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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 '{ @@ -4678,8 +5113,12 @@ paths: "stream": true }' python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) tools = [ { @@ -4712,9 +5151,12 @@ paths: for event in stream: print(event) node.js: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); const tools = [ { @@ -4738,7 +5180,7 @@ paths: ]; async function main() { - const stream = await openai.beta.threads.runs.create( + const stream = await client.beta.threads.runs.create( "thread_abc123", { assistant_id: "asst_abc123", @@ -4810,7 +5252,7 @@ paths: required: true schema: type: string - description: The ID of the [thread](/docs/api-reference/threads) that was run. + description: The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) that was run. - in: path name: run_id required: true @@ -4828,16 +5270,21 @@ paths: name: Retrieve run group: threads beta: true - returns: The [run](/docs/api-reference/runs/object) object matching the specified ID. + returns: The [run](https://platform.openai.com/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" \ + 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" python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -4846,12 +5293,15 @@ paths: print(run) node.js: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const run = await openai.beta.threads.runs.retrieve( + const run = await client.beta.threads.runs.retrieve( "thread_abc123", "run_abc123" ); @@ -4911,7 +5361,7 @@ paths: required: true schema: type: string - description: The ID of the [thread](/docs/api-reference/threads) that was run. + description: The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) that was run. - in: path name: run_id required: true @@ -4935,12 +5385,13 @@ paths: name: Modify run group: threads beta: true - returns: The modified [run](/docs/api-reference/runs/object) object matching the specified ID. + returns: The modified [run](https://platform.openai.com/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" \ + 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 '{ @@ -4949,8 +5400,12 @@ paths: } }' python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -4960,12 +5415,15 @@ paths: print(run) node.js: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const run = await openai.beta.threads.runs.update( + const run = await client.beta.threads.runs.update( "thread_abc123", "run_abc123", { @@ -5043,7 +5501,7 @@ paths: required: true schema: type: string - description: The ID of the [thread](/docs/api-reference/threads) to which this run belongs. + 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 @@ -5067,13 +5525,14 @@ paths: name: Submit tool outputs to run group: threads beta: true - returns: The modified [run](/docs/api-reference/runs/object) object matching the specified ID. + 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.openai.com/v1/threads/thread_123/runs/run_123/submit_tool_outputs \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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 '{ @@ -5085,8 +5544,12 @@ paths: ] }' python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -5101,12 +5564,15 @@ paths: print(run) node.js: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const run = await openai.beta.threads.runs.submitToolOutputs( + const run = await client.beta.threads.runs.submitToolOutputs( "thread_123", "run_123", { @@ -5180,8 +5646,9 @@ paths: - 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" \ + 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 '{ @@ -5194,8 +5661,12 @@ paths: "stream": true }' python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) stream = client.beta.threads.runs.submit_tool_outputs( thread_id="thread_123", @@ -5212,12 +5683,15 @@ paths: for event in stream: print(event) node.js: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const stream = await openai.beta.threads.runs.submitToolOutputs( + const stream = await client.beta.threads.runs.submitToolOutputs( "thread_123", "run_123", { @@ -5317,17 +5791,22 @@ paths: name: Cancel a run group: threads beta: true - returns: The modified [run](/docs/api-reference/runs/object) object matching the specified ID. + returns: The modified [run](https://platform.openai.com/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" \ + 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 python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -5336,12 +5815,15 @@ paths: print(run) node.js: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const run = await openai.beta.threads.runs.cancel( + const run = await client.beta.threads.runs.cancel( "thread_abc123", "run_abc123" ); @@ -5439,17 +5921,22 @@ paths: name: List run steps group: threads beta: true - returns: A list of [run step](/docs/api-reference/runs/step-object) objects. + returns: A list of [run step](https://platform.openai.com/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" \ + 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" python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -5458,11 +5945,15 @@ paths: print(run_steps) node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const runStep = await openai.beta.threads.runs.steps.list( + const runStep = await client.beta.threads.runs.steps.list( "thread_abc123", "run_abc123" ); @@ -5542,17 +6033,22 @@ paths: name: Retrieve run step group: threads beta: true - returns: The [run step](/docs/api-reference/runs/step-object) object matching the specified ID. + 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.openai.com/v1/threads/thread_abc123/runs/run_abc123/steps/step_abc123 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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" python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -5562,11 +6058,15 @@ paths: print(run_step) node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const runStep = await openai.beta.threads.runs.steps.retrieve( + const runStep = await client.beta.threads.runs.steps.retrieve( "thread_abc123", "run_abc123", "step_abc123" @@ -5645,26 +6145,35 @@ paths: name: List vector stores group: vector_stores beta: true - returns: A list of [vector store](/docs/api-reference/vector-stores/object) objects. + returns: A list of [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) objects. examples: request: curl: | - curl https://api.openai.com/v1/vector_stores \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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" python: | - from openai import OpenAI - client = OpenAI() + 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) node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const vectorStores = await openai.beta.vectorStores.list(); + const vectorStores = await client.beta.vectorStores.list(); console.log(vectorStores); } @@ -5728,31 +6237,40 @@ paths: name: Create vector store group: vector_stores beta: true - returns: A [vector store](/docs/api-reference/vector-stores/object) object. + returns: A [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) object. examples: request: curl: | - curl https://api.openai.com/v1/vector_stores \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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" }' python: | - from openai import OpenAI - client = OpenAI() + 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) node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const vectorStore = await openai.beta.vectorStores.create({ + const vectorStore = await client.beta.vectorStores.create({ name: "Support FAQ" }); console.log(vectorStore); @@ -5799,28 +6317,37 @@ paths: name: Retrieve vector store group: vector_stores beta: true - returns: The [vector store](/docs/api-reference/vector-stores/object) object matching the specified ID. + 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.openai.com/v1/vector_stores/vs_abc123 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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" python: | - from openai import OpenAI - client = OpenAI() + 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) node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const vectorStore = await openai.beta.vectorStores.retrieve( + const vectorStore = await client.beta.vectorStores.retrieve( "vs_abc123" ); console.log(vectorStore); @@ -5862,20 +6389,25 @@ paths: name: Modify vector store group: vector_stores beta: true - returns: The modified [vector store](/docs/api-reference/vector-stores/object) object. + returns: The modified [vector store](https://platform.openai.com/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" \ + 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" }' python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -5883,11 +6415,15 @@ paths: ) print(vector_store) node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const vectorStore = await openai.beta.vectorStores.update( + const vectorStore = await client.beta.vectorStores.update( "vs_abc123", { name: "Support FAQ" @@ -5940,25 +6476,34 @@ paths: examples: request: curl: | - curl https://api.openai.com/v1/vector_stores/vs_abc123 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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 python: | - from openai import OpenAI - client = OpenAI() + 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) node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const deletedVectorStore = await openai.beta.vectorStores.del( + const deletedVectorStore = await client.beta.vectorStores.del( "vs_abc123" ); console.log(deletedVectorStore); @@ -6026,28 +6571,37 @@ paths: 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. + 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.openai.com/v1/vector_stores/vs_abc123/files \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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" python: | - from openai import OpenAI - client = OpenAI() + 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) node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const vectorStoreFiles = await openai.beta.vectorStores.files.list( + const vectorStoreFiles = await client.beta.vectorStores.files.list( "vs_abc123" ); console.log(vectorStoreFiles); @@ -6079,7 +6633,7 @@ paths: 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). + 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 @@ -6106,20 +6660,25 @@ paths: name: Create vector store file group: vector_stores beta: true - returns: A [vector store file](/docs/api-reference/vector-stores-files/file-object) object. + returns: A [vector store file](https://platform.openai.com/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" \ + 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" }' python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -6127,11 +6686,15 @@ paths: ) print(vector_store_file) node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const myVectorStoreFile = await openai.beta.vectorStores.files.create( + const myVectorStoreFile = await client.beta.vectorStores.files.create( "vs_abc123", { file_id: "file-abc123" @@ -6184,17 +6747,22 @@ paths: name: Retrieve vector store file group: vector_stores beta: true - returns: The [vector store file](/docs/api-reference/vector-stores-files/file-object) object. + returns: The [vector store file](https://platform.openai.com/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" \ + 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" python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -6202,11 +6770,15 @@ paths: ) print(vector_store_file) node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const vectorStoreFile = await openai.beta.vectorStores.files.retrieve( + const vectorStoreFile = await client.beta.vectorStores.files.retrieve( "vs_abc123", "file-abc123" ); @@ -6227,7 +6799,7 @@ paths: 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. + 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 @@ -6256,14 +6828,19 @@ paths: examples: request: curl: | - curl https://api.openai.com/v1/vector_stores/vs_abc123/files/file-abc123 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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 python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -6271,11 +6848,15 @@ paths: ) print(deleted_vector_store_file) node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const deletedVectorStoreFile = await openai.beta.vectorStores.files.del( + const deletedVectorStoreFile = await client.beta.vectorStores.files.del( "vs_abc123", "file-abc123" ); @@ -6322,20 +6903,25 @@ paths: 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. + 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.openai.com/v1/vector_stores/vs_abc123/file_batches \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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"] }' python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -6343,11 +6929,15 @@ paths: ) print(vector_store_file_batch) node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const myVectorStoreFileBatch = await openai.beta.vectorStores.fileBatches.create( + const myVectorStoreFileBatch = await client.beta.vectorStores.fileBatches.create( "vs_abc123", { file_ids: ["file-abc123", "file-abc456"] @@ -6405,17 +6995,22 @@ paths: 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. + 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.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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" python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -6423,11 +7018,15 @@ paths: ) print(vector_store_file_batch) node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const vectorStoreFileBatch = await openai.beta.vectorStores.fileBatches.retrieve( + const vectorStoreFileBatch = await client.beta.vectorStores.fileBatches.retrieve( "vs_abc123", "vsfb_abc123" ); @@ -6485,14 +7084,19 @@ paths: examples: request: curl: | - curl https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/cancel \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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 python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -6500,11 +7104,15 @@ paths: ) print(deleted_vector_store_file_batch) node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const deletedVectorStoreFileBatch = await openai.vector_stores.fileBatches.cancel( + const deletedVectorStoreFileBatch = await client.vector_stores.fileBatches.cancel( "vs_abc123", "vsfb_abc123" ); @@ -6588,17 +7196,22 @@ paths: 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. + 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.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/files \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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" python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -6606,11 +7219,15 @@ paths: ) print(vector_store_files) node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const vectorStoreFiles = await openai.beta.vectorStores.fileBatches.listFiles( + const vectorStoreFiles = await client.beta.vectorStores.fileBatches.listFiles( "vs_abc123", "vsfb_abc123" ); @@ -6662,9 +7279,9 @@ paths: 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. + 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](/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. + 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: @@ -6694,12 +7311,13 @@ paths: x-oaiMeta: name: Create batch group: batch - returns: The created [Batch](/docs/api-reference/batch/object) object. + returns: The created [Batch](https://platform.openai.com/docs/api-reference/batch/object) object. examples: request: curl: | - curl https://api.openai.com/v1/batches \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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", @@ -6707,8 +7325,12 @@ paths: "completion_window": "24h" }' python: | - from openai import OpenAI - client = OpenAI() + 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", @@ -6716,12 +7338,15 @@ paths: completion_window="24h" ) node: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const batch = await openai.batches.create({ + const batch = await client.batches.create({ input_file_id: "file-abc123", endpoint: "/v1/chat/completions", completion_window: "24h" @@ -6790,25 +7415,33 @@ paths: x-oaiMeta: name: List batch group: batch - returns: A list of paginated [Batch](/docs/api-reference/batch/object) objects. + returns: A list of paginated [Batch](https://platform.openai.com/docs/api-reference/batch/object) objects. examples: request: curl: | - curl https://api.openai.com/v1/batches?limit=2 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ + 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" python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) client.batches.list() node: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const list = await openai.batches.list(); + const list = await client.batches.list(); for await (const batch of list) { console.log(batch); @@ -6879,25 +7512,33 @@ paths: x-oaiMeta: name: Retrieve batch group: batch - returns: The [Batch](/docs/api-reference/batch/object) object matching the specified ID. + returns: The [Batch](https://platform.openai.com/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" \ + 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" \ python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) client.batches.retrieve("batch_abc123") node: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const batch = await openai.batches.retrieve("batch_abc123"); + const batch = await client.batches.retrieve("batch_abc123"); console.log(batch); } @@ -6957,26 +7598,34 @@ paths: x-oaiMeta: name: Cancel batch group: batch - returns: The [Batch](/docs/api-reference/batch/object) object matching the specified ID. + returns: The [Batch](https://platform.openai.com/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" \ + 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 python: | - from openai import OpenAI - client = OpenAI() + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) client.batches.cancel("batch_abc123") node: | - import OpenAI from "openai"; + import Portkey from 'portkey-ai'; - const openai = new OpenAI(); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); async function main() { - const batch = await openai.batches.cancel("batch_abc123"); + const batch = await client.batches.cancel("batch_abc123"); console.log(batch); } @@ -7016,8 +7665,9 @@ paths: components: securitySchemes: ApiKeyAuth: - type: http - scheme: "bearer" + type: apiKey + in: header + name: x-portkey-api-key schemas: Error: @@ -7080,7 +7730,7 @@ components: 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. + 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 @@ -7142,7 +7792,7 @@ components: 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) + [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 @@ -7153,7 +7803,7 @@ components: 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. + 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 @@ -7173,7 +7823,7 @@ components: example: 16 nullable: true description: &completions_max_tokens_description | - The maximum number of [tokens](/tokenizer) that can be generated in the completion. + 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: @@ -7196,7 +7846,7 @@ components: 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) + [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 @@ -7224,7 +7874,7 @@ components: 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) + 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 @@ -7266,7 +7916,7 @@ components: 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). + 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 @@ -7394,7 +8044,7 @@ components: 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). + 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: @@ -7509,7 +8159,7 @@ components: - name required: - role - + # TODO(apeng): This is only because we don't support tools yet. Use allOf once we do. FineTuneChatCompletionRequestAssistantMessage: type: object @@ -7546,7 +8196,7 @@ components: enum: [0, 1] description: "Controls whether the assistant message is trained against (0 or 1)" required: - - role + - role ChatCompletionRequestToolMessage: type: object @@ -7587,7 +8237,7 @@ components: - role - content - name - + # TODO(apeng): This is only because we don't support tools yet. Add back deprecated once we do. FineTuneChatCompletionRequestFunctionMessage: allOf: @@ -7598,7 +8248,7 @@ components: 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." + 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: @@ -7694,7 +8344,7 @@ components: - function ParallelToolCalls: - description: Whether to enable [parallel function calling](/docs/guides/function-calling/parallel-function-calling) during tool use. + 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 @@ -7850,7 +8500,7 @@ components: 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. + 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 @@ -7911,7 +8561,7 @@ components: nullable: true max_tokens: description: | - The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. + 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 @@ -7934,7 +8584,7 @@ components: 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`. + 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. @@ -7971,7 +8621,7 @@ components: 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) + 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 @@ -8391,7 +9041,7 @@ components: Image: type: object - description: Represents the url or the content of an image generated by the OpenAI API. + description: Represents the url or the content of an image generated by the Portkey API. properties: b64_json: type: string @@ -8666,7 +9316,7 @@ components: 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). + 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: @@ -8694,7 +9344,7 @@ components: 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). + [supported models](https://platform.openai.com/docs/guides/fine-tuning/what-models-can-be-fine-tuned). example: "gpt-3.5-turbo" anyOf: - type: string @@ -8705,13 +9355,13 @@ components: 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. + 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](/docs/api-reference/fine-tuning/chat-input) or [completions](/docs/api-reference/fine-tuning/completions-input) format. + 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](/docs/guides/fine-tuning) for more details. + See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning) for more details. type: string example: "file-abc123" hyperparameters: @@ -8772,7 +9422,7 @@ components: 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. + See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning) for more details. type: string nullable: true example: "file-abc123" @@ -9007,7 +9657,7 @@ components: 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. + 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: | @@ -9173,7 +9823,7 @@ components: 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. + 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: | @@ -9223,7 +9873,7 @@ components: properties: model: description: | - One of the available [TTS models](/docs/models/tts): `tts-1` or `tts-1-hd` + One of the available [TTS models](https://platform.openai.com/docs/models/tts): `tts-1` or `tts-1-hd` anyOf: - type: string - type: string @@ -9234,7 +9884,7 @@ components: 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). + 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: @@ -9351,7 +10001,7 @@ components: 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). + 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: @@ -9417,7 +10067,7 @@ components: description: The Unix timestamp (in seconds) for when the fine-tuning job was finished. The value will be null if the fine-tuning job is still running. hyperparameters: type: object - description: The hyperparameters used for the fine-tuning job. See the [fine-tuning guide](/docs/guides/fine-tuning) for more details. + description: The hyperparameters used for the fine-tuning job. See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning) for more details. properties: n_epochs: oneOf: @@ -9445,7 +10095,7 @@ components: description: The organization that owns the fine-tuning job. result_files: type: array - description: The compiled results file ID(s) for the fine-tuning job. You can retrieve the results with the [Files API](/docs/api-reference/files/retrieve-contents). + description: The compiled results file ID(s) for the fine-tuning job. You can retrieve the results with the [Files API](https://platform.openai.com/docs/api-reference/files/retrieve-contents). items: type: string example: file-abc123 @@ -9467,11 +10117,11 @@ components: description: The total number of billable tokens processed by this fine-tuning job. The value will be null if the fine-tuning job is still running. training_file: type: string - description: The file ID used for training. You can retrieve the training data with the [Files API](/docs/api-reference/files/retrieve-contents). + description: The file ID used for training. You can retrieve the training data with the [Files API](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](/docs/api-reference/files/retrieve-contents). + 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 @@ -9684,7 +10334,7 @@ components: 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 @@ -9758,7 +10408,7 @@ components: 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`. + 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. @@ -9842,7 +10492,7 @@ components: 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. + 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: @@ -9853,7 +10503,7 @@ components: 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. + 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 @@ -9973,7 +10623,7 @@ components: 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. + 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: @@ -9984,14 +10634,14 @@ components: 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. + 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](/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. + 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 @@ -9999,7 +10649,7 @@ components: 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. + 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 @@ -10018,7 +10668,7 @@ components: description: Always `auto`. enum: ["auto"] required: - - type + - type - type: object title: Static Chunking Strategy additionalProperties: false @@ -10040,7 +10690,7 @@ components: 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 @@ -10134,7 +10784,7 @@ components: 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. + 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: @@ -10145,7 +10795,7 @@ components: 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. + 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 @@ -10253,7 +10903,7 @@ components: 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. + 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 @@ -10339,7 +10989,7 @@ components: RunObject: type: object title: A run on a thread - description: Represents an execution run on a [thread](/docs/api-reference/threads). + 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. @@ -10352,10 +11002,10 @@ components: description: The Unix timestamp (in seconds) for when the run was created. type: integer thread_id: - description: The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. + 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](/docs/api-reference/assistants) used for execution of this run. + 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`. @@ -10441,13 +11091,13 @@ components: type: string enum: ["max_completion_tokens", "max_prompt_tokens"] model: - description: The model that the [assistant](/docs/api-reference/assistants) used for this run. + 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](/docs/api-reference/assistants) used for this run. + 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](/docs/api-reference/assistants) used for this run. + 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 @@ -10565,10 +11215,10 @@ components: additionalProperties: false properties: assistant_id: - description: The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run. + 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](/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. + 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 @@ -10599,7 +11249,7 @@ components: 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. + 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: @@ -10742,7 +11392,7 @@ components: 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. + 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`. @@ -10770,13 +11420,13 @@ components: additionalProperties: false properties: assistant_id: - description: The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run. + 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](/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. + 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 @@ -10831,7 +11481,7 @@ components: 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. + 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: @@ -10842,7 +11492,7 @@ components: 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. + 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 @@ -10903,7 +11553,7 @@ components: ThreadObject: type: object title: Thread - description: Represents a thread that contains [messages](/docs/api-reference/messages). + 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. @@ -10926,7 +11576,7 @@ components: 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. + 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: @@ -10937,7 +11587,7 @@ components: 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. + 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 @@ -10969,7 +11619,7 @@ components: additionalProperties: false properties: messages: - description: A list of [messages](/docs/api-reference/messages) to start the thread with. + 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" @@ -10984,7 +11634,7 @@ components: 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. + 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: @@ -10995,14 +11645,14 @@ components: 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. + 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](/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. + 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 @@ -11010,7 +11660,7 @@ components: 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. + 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 @@ -11029,7 +11679,7 @@ components: description: Always `auto`. enum: ["auto"] required: - - type + - type - type: object title: Static Chunking Strategy additionalProperties: false @@ -11051,7 +11701,7 @@ components: 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 @@ -11091,7 +11741,7 @@ components: 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. + 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: @@ -11102,7 +11752,7 @@ components: 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. + 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 @@ -11156,7 +11806,7 @@ components: MessageObject: type: object title: The message object - description: Represents a message within a [thread](/docs/api-reference/threads). + 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. @@ -11169,7 +11819,7 @@ components: 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. + 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`. @@ -11215,11 +11865,11 @@ components: - $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. + 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](/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. + 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: @@ -11357,7 +12007,7 @@ components: 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). + 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: @@ -11447,7 +12097,7 @@ components: MessageContentImageFileObject: title: Image file type: object - description: References an image [File](/docs/api-reference/files) in the content of a message. + 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`. @@ -11457,7 +12107,7 @@ components: 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. + 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 @@ -11473,7 +12123,7 @@ components: MessageDeltaContentImageFileObject: title: Image file type: object - description: References an image [File](/docs/api-reference/files) in the content of a message. + description: References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message. properties: index: type: integer @@ -11486,7 +12136,7 @@ components: 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. + 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 @@ -11777,13 +12427,13 @@ components: 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. + 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](/docs/api-reference/threads) that was run. + 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](/docs/api-reference/runs) that this run step is a part of. + 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`. @@ -12137,7 +12787,7 @@ components: type: object properties: file_id: - description: The [file](/docs/api-reference/files) ID of the image. + description: The [file](https://platform.openai.com/docs/api-reference/files) ID of the image. type: string required: - file_id @@ -12160,7 +12810,7 @@ components: type: object properties: file_id: - description: The [file](/docs/api-reference/files) ID of the image. + description: The [file](https://platform.openai.com/docs/api-reference/files) ID of the image. type: string required: - index @@ -12232,7 +12882,7 @@ components: 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. + 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 @@ -12269,7 +12919,7 @@ components: 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. + 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 @@ -12395,7 +13045,7 @@ components: 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. + 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: @@ -12494,7 +13144,7 @@ components: 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. + 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. @@ -12598,7 +13248,7 @@ components: 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 @@ -12645,7 +13295,7 @@ components: 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. + 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" @@ -12708,7 +13358,7 @@ components: 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. + 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`. @@ -12769,7 +13419,7 @@ components: 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. + 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 @@ -12799,7 +13449,7 @@ components: `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 + 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" @@ -12824,9 +13474,9 @@ components: required: - event - data - description: Occurs when a new [thread](/docs/api-reference/threads/object) is created. + description: Occurs when a new [thread](https://platform.openai.com/docs/api-reference/threads/object) is created. x-oaiMeta: - dataDescription: "`data` is a [thread](/docs/api-reference/threads/object)" + dataDescription: "`data` is a [thread](https://platform.openai.com/docs/api-reference/threads/object)" RunStreamEvent: oneOf: @@ -12840,9 +13490,9 @@ components: required: - event - data - description: Occurs when a new [run](/docs/api-reference/runs/object) is created. + description: Occurs when a new [run](https://platform.openai.com/docs/api-reference/runs/object) is created. x-oaiMeta: - dataDescription: "`data` is a [run](/docs/api-reference/runs/object)" + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" - type: object properties: event: @@ -12853,9 +13503,9 @@ components: required: - event - data - description: Occurs when a [run](/docs/api-reference/runs/object) moves to a `queued` status. + 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](/docs/api-reference/runs/object)" + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" - type: object properties: event: @@ -12866,9 +13516,9 @@ components: required: - event - data - description: Occurs when a [run](/docs/api-reference/runs/object) moves to an `in_progress` status. + 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](/docs/api-reference/runs/object)" + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" - type: object properties: event: @@ -12879,9 +13529,9 @@ components: required: - event - data - description: Occurs when a [run](/docs/api-reference/runs/object) moves to a `requires_action` status. + 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](/docs/api-reference/runs/object)" + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" - type: object properties: event: @@ -12892,9 +13542,9 @@ components: required: - event - data - description: Occurs when a [run](/docs/api-reference/runs/object) is completed. + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) is completed. x-oaiMeta: - dataDescription: "`data` is a [run](/docs/api-reference/runs/object)" + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" - type: object properties: event: @@ -12905,9 +13555,9 @@ components: required: - event - data - description: Occurs when a [run](/docs/api-reference/runs/object) ends with status `incomplete`. + 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](/docs/api-reference/runs/object)" + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" - type: object properties: event: @@ -12918,9 +13568,9 @@ components: required: - event - data - description: Occurs when a [run](/docs/api-reference/runs/object) fails. + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) fails. x-oaiMeta: - dataDescription: "`data` is a [run](/docs/api-reference/runs/object)" + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" - type: object properties: event: @@ -12931,9 +13581,9 @@ components: required: - event - data - description: Occurs when a [run](/docs/api-reference/runs/object) moves to a `cancelling` status. + 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](/docs/api-reference/runs/object)" + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" - type: object properties: event: @@ -12944,9 +13594,9 @@ components: required: - event - data - description: Occurs when a [run](/docs/api-reference/runs/object) is cancelled. + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) is cancelled. x-oaiMeta: - dataDescription: "`data` is a [run](/docs/api-reference/runs/object)" + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" - type: object properties: event: @@ -12957,9 +13607,9 @@ components: required: - event - data - description: Occurs when a [run](/docs/api-reference/runs/object) expires. + description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) expires. x-oaiMeta: - dataDescription: "`data` is a [run](/docs/api-reference/runs/object)" + dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" RunStepStreamEvent: oneOf: @@ -12973,9 +13623,9 @@ components: required: - event - data - description: Occurs when a [run step](/docs/api-reference/runs/step-object) is created. + 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](/docs/api-reference/runs/step-object)" + dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" - type: object properties: event: @@ -12986,9 +13636,9 @@ components: required: - event - data - description: Occurs when a [run step](/docs/api-reference/runs/step-object) moves to an `in_progress` state. + 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](/docs/api-reference/runs/step-object)" + dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" - type: object properties: event: @@ -12999,9 +13649,9 @@ components: required: - event - data - description: Occurs when parts of a [run step](/docs/api-reference/runs/step-object) are being streamed. + 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](/docs/api-reference/assistants-streaming/run-step-delta-object)" + dataDescription: "`data` is a [run step delta](https://platform.openai.com/docs/api-reference/assistants-streaming/run-step-delta-object)" - type: object properties: event: @@ -13012,9 +13662,9 @@ components: required: - event - data - description: Occurs when a [run step](/docs/api-reference/runs/step-object) is completed. + 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](/docs/api-reference/runs/step-object)" + dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" - type: object properties: event: @@ -13025,9 +13675,9 @@ components: required: - event - data - description: Occurs when a [run step](/docs/api-reference/runs/step-object) fails. + 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](/docs/api-reference/runs/step-object)" + dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" - type: object properties: event: @@ -13038,9 +13688,9 @@ components: required: - event - data - description: Occurs when a [run step](/docs/api-reference/runs/step-object) is cancelled. + 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](/docs/api-reference/runs/step-object)" + dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" - type: object properties: event: @@ -13051,9 +13701,9 @@ components: required: - event - data - description: Occurs when a [run step](/docs/api-reference/runs/step-object) expires. + 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](/docs/api-reference/runs/step-object)" + dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" MessageStreamEvent: oneOf: @@ -13067,9 +13717,9 @@ components: required: - event - data - description: Occurs when a [message](/docs/api-reference/messages/object) is created. + description: Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) is created. x-oaiMeta: - dataDescription: "`data` is a [message](/docs/api-reference/messages/object)" + dataDescription: "`data` is a [message](https://platform.openai.com/docs/api-reference/messages/object)" - type: object properties: event: @@ -13080,9 +13730,9 @@ components: required: - event - data - description: Occurs when a [message](/docs/api-reference/messages/object) moves to an `in_progress` state. + 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](/docs/api-reference/messages/object)" + dataDescription: "`data` is a [message](https://platform.openai.com/docs/api-reference/messages/object)" - type: object properties: event: @@ -13093,9 +13743,9 @@ components: required: - event - data - description: Occurs when parts of a [Message](/docs/api-reference/messages/object) are being streamed. + 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](/docs/api-reference/assistants-streaming/message-delta-object)" + dataDescription: "`data` is a [message delta](https://platform.openai.com/docs/api-reference/assistants-streaming/message-delta-object)" - type: object properties: event: @@ -13106,9 +13756,9 @@ components: required: - event - data - description: Occurs when a [message](/docs/api-reference/messages/object) is completed. + description: Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) is completed. x-oaiMeta: - dataDescription: "`data` is a [message](/docs/api-reference/messages/object)" + dataDescription: "`data` is a [message](https://platform.openai.com/docs/api-reference/messages/object)" - type: object properties: event: @@ -13119,9 +13769,9 @@ components: required: - event - data - description: Occurs when a [message](/docs/api-reference/messages/object) ends before it is completed. + 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](/docs/api-reference/messages/object)" + dataDescription: "`data` is a [message](https://platform.openai.com/docs/api-reference/messages/object)" ErrorEvent: type: object @@ -13134,9 +13784,9 @@ components: 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. + 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](/docs/guides/error-codes/api-errors)" + dataDescription: "`data` is an [error](https://platform.openai.com/docs/guides/error-codes/api-errors)" DoneEvent: type: object @@ -13165,7 +13815,7 @@ components: description: The object type, which is always `batch`. endpoint: type: string - description: The OpenAI API endpoint used by the batch. + description: The Portkey API endpoint used by the batch. errors: type: object @@ -13290,7 +13940,7 @@ components: 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. + 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: | @@ -13314,7 +13964,7 @@ components: 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. + 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 @@ -13396,7 +14046,7 @@ x-oaiMeta: description: | Learn how to turn audio into text or text into audio. - Related guide: [Speech to text](/docs/guides/speech-to-text) + Related guide: [Speech to text](https://platform.openai.com/docs/guides/speech-to-text) navigationGroup: endpoints sections: - type: endpoint @@ -13419,7 +14069,7 @@ x-oaiMeta: description: | Given a list of messages comprising a conversation, the model will return a response. - Related guide: [Chat Completions](/docs/guides/text-generation) + Related guide: [Chat Completions](https://platform.openai.com/docs/guides/text-generation) navigationGroup: endpoints sections: - type: endpoint @@ -13436,7 +14086,7 @@ x-oaiMeta: 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) + Related guide: [Embeddings](https://platform.openai.com/docs/guides/embeddings) navigationGroup: endpoints sections: - type: endpoint @@ -13450,7 +14100,7 @@ x-oaiMeta: description: | Manage fine-tuning jobs to tailor a model to your specific training data. - Related guide: [Fine-tune models](/docs/guides/fine-tuning) + Related guide: [Fine-tune models](https://platform.openai.com/docs/guides/fine-tuning) navigationGroup: endpoints sections: - type: endpoint @@ -13491,7 +14141,7 @@ x-oaiMeta: 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) + Related guide: [Batch](https://platform.openai.com/docs/guides/batch) navigationGroup: endpoints sections: - type: endpoint @@ -13518,7 +14168,7 @@ x-oaiMeta: - 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). + 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 @@ -13544,7 +14194,7 @@ x-oaiMeta: description: | Given a prompt and/or an input image, the model will generate a new image. - Related guide: [Image generation](/docs/guides/images) + Related guide: [Image generation](https://platform.openai.com/docs/guides/images) navigationGroup: endpoints sections: - type: endpoint @@ -13562,7 +14212,7 @@ x-oaiMeta: - 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. + 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 @@ -13582,7 +14232,7 @@ x-oaiMeta: description: | Given some input text, outputs if the model classifies it as potentially harmful across several categories. - Related guide: [Moderations](/docs/guides/moderation) + Related guide: [Moderations](https://platform.openai.com/docs/guides/moderation) navigationGroup: endpoints sections: - type: endpoint @@ -13597,7 +14247,7 @@ x-oaiMeta: description: | Build assistants that can call models and use tools to perform tasks. - [Get started with the Assistants API](/docs/assistants) + [Get started with the Assistants API](https://platform.openai.com/docs/assistants) navigationGroup: assistants sections: - type: endpoint @@ -13624,7 +14274,7 @@ x-oaiMeta: description: | Create threads that assistants can interact with. - Related guide: [Assistants](/docs/assistants/overview) + Related guide: [Assistants](https://platform.openai.com/docs/assistants/overview) navigationGroup: assistants sections: - type: endpoint @@ -13648,7 +14298,7 @@ x-oaiMeta: description: | Create messages within threads - Related guide: [Assistants](/docs/assistants/overview) + Related guide: [Assistants](https://platform.openai.com/docs/assistants/overview) navigationGroup: assistants sections: - type: endpoint @@ -13675,7 +14325,7 @@ x-oaiMeta: description: | Represents an execution run on a thread. - Related guide: [Assistants](/docs/assistants/overview) + Related guide: [Assistants](https://platform.openai.com/docs/assistants/overview) navigationGroup: assistants sections: - type: endpoint @@ -13708,7 +14358,7 @@ x-oaiMeta: description: | Represents the steps (model and tool calls) taken during the run. - Related guide: [Assistants](/docs/assistants/overview) + Related guide: [Assistants](https://platform.openai.com/docs/assistants/overview) navigationGroup: assistants sections: - type: endpoint @@ -13726,7 +14376,7 @@ x-oaiMeta: description: | Vector stores are used to store files for use by the `file_search` tool. - Related guide: [File Search](/docs/assistants/tools/file-search) + Related guide: [File Search](https://platform.openai.com/docs/assistants/tools/file-search) navigationGroup: assistants sections: - type: endpoint @@ -13753,7 +14403,7 @@ x-oaiMeta: description: | Vector store files represent files inside a vector store. - Related guide: [File Search](/docs/assistants/tools/file-search) + Related guide: [File Search](https://platform.openai.com/docs/assistants/tools/file-search) navigationGroup: assistants sections: - type: endpoint @@ -13777,7 +14427,7 @@ x-oaiMeta: description: | Vector store file batches represent operations to add multiple files to a vector store. - Related guide: [File Search](/docs/assistants/tools/file-search) + Related guide: [File Search](https://platform.openai.com/docs/assistants/tools/file-search) navigationGroup: assistants sections: - type: endpoint @@ -13801,12 +14451,12 @@ x-oaiMeta: 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) + 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](/docs/assistants/overview) to learn more. + [Assistants API quickstart](https://platform.openai.com/docs/assistants/overview) to learn more. navigationGroup: assistants sections: - type: object @@ -13823,7 +14473,7 @@ x-oaiMeta: 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. + 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 From b6a7a4003b8c9509625db04752b90f906647eca9 Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Wed, 19 Jun 2024 21:29:43 +0530 Subject: [PATCH 002/124] Add Config API --- openapi.yaml | 277 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 277 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 42cd3dff..90df5503 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -35,6 +35,16 @@ tags: 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. 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 @@ -7662,6 +7672,273 @@ paths: } } + /configs: + get: + summary: List all configs + operationId: listConfigs + responses: + "200": + description: A list of configs + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + data: + type: array + items: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + 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 + 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", + "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", + }, + ], + } + post: + summary: Create a config + operationId: createConfig + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + name: + type: string + config: + type: object + isDefault: + type: integer + examples: + example-1: + value: + { + "name": "New config", + "config": { "retry": { "attempts": 3 } }, + "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", + }, + } + + /configs/{slug}: + get: + summary: Get a config + 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 + properties: + config: + type: object + properties: + retry: + type: object + properties: + attempts: + type: integer + on_status_codes: + type: array + items: + type: integer + cache: + type: object + properties: + 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", + }, + ], + }, + }, + } + put: + summary: Update a config + 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 + data: + type: object + properties: + version_id: + type: string + format: uuid + examples: + example-1: + value: + { + "success": true, + "data": + { + "version_id": "abe447e2-f6aa-4229-93b7-8ee3183b6667", + }, + } + components: securitySchemes: ApiKeyAuth: From 0351dda87a42c5ae96d2a58642e295bd35b09be9 Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Wed, 19 Jun 2024 21:50:12 +0530 Subject: [PATCH 003/124] Add feedback API --- openapi.yaml | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 90df5503..713eeefc 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -7939,6 +7939,82 @@ paths: }, } + /feedback: + post: + summary: Create new feedback + description: > + This endpoint allows users to submit feedback for a particular interaction or response. + operationId: createFeedback + tags: + - Feedback + security: + - apiKeyAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/FeedbackRequest" + examples: + thumbsUpExample: + summary: Thumbs Up Feedback + value: + trace_id: "REQUEST_TRACE_ID" + value: 1 + thumbsDownExample: + summary: Thumbs Down Feedback + value: + trace_id: "REQUEST_TRACE_ID" + value: 0 + responses: + "200": + description: Feedback successfully saved + content: + application/json: + schema: + $ref: "#/components/schemas/FeedbackResponse" + + /feedback/{id}: + 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 + security: + - apiKeyAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/FeedbackUpdateRequest" + examples: + thumbsUpExample: + summary: Thumbs Up Feedback + value: + value: 1 + thumbsDownExample: + summary: Thumbs Down Feedback + value: + value: 0 + responses: + "200": + description: Feedback successfully updated + content: + application/json: + schema: + $ref: "#/components/schemas/FeedbackResponse" + components: securitySchemes: ApiKeyAuth: @@ -14285,6 +14361,69 @@ components: - 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 + + 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. + security: - ApiKeyAuth: [] From 03dd9b048b972312f0a87ab0479a79d038e48999 Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Wed, 19 Jun 2024 21:58:04 +0530 Subject: [PATCH 004/124] minor changes to feedback doc --- openapi.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 713eeefc..d7e58bd9 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -7942,8 +7942,7 @@ paths: /feedback: post: summary: Create new feedback - description: > - This endpoint allows users to submit feedback for a particular interaction or response. + description: This endpoint allows users to submit feedback for a particular interaction or response. operationId: createFeedback tags: - Feedback @@ -7977,8 +7976,7 @@ paths: /feedback/{id}: put: summary: Updates existing feedback - description: > - This endpoint allows users to update existing feedback . + description: This endpoint allows users to update existing feedback . operationId: updateFeedback parameters: - name: id From 45d4bba3f42dd9a05662a70611c806f1e0d8510c Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Wed, 19 Jun 2024 22:08:33 +0530 Subject: [PATCH 005/124] minor changes --- openapi.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index d7e58bd9..4fe87574 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -7946,8 +7946,6 @@ paths: operationId: createFeedback tags: - Feedback - security: - - apiKeyAuth: [] requestBody: required: true content: @@ -7976,7 +7974,7 @@ paths: /feedback/{id}: put: summary: Updates existing feedback - description: This endpoint allows users to update existing feedback . + description: This endpoint allows users to update existing feedback. operationId: updateFeedback parameters: - name: id @@ -7988,8 +7986,6 @@ paths: format: uuid tags: - Feedback - security: - - apiKeyAuth: [] requestBody: required: true content: From 071b9e85657ae4d8331cc44607a48026bbdfabe4 Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Thu, 20 Jun 2024 02:05:39 +0530 Subject: [PATCH 006/124] add virtual keys api --- openapi.yaml | 352 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 352 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 4fe87574..ca1e675b 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8009,6 +8009,358 @@ paths: schema: $ref: "#/components/schemas/FeedbackResponse" + /virtual-keys: + get: + summary: List All Virtual Keys + responses: + '200': + description: Successful response + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + data: + type: array + items: + type: object + properties: + name: + type: string + note: + type: string + status: + type: string + created_at: + type: string + format: date-time + slug: + type: string + model_config: + type: object + credit_limit: + type: string + nullable: true + provider: + type: string + example: + success: true + data: + - + name: "My Virtual Key" + note: "This is my first virtual key's description" + status: "active" + created_at: "2024-05-13T23:17:36.000Z" + slug: "ayush-test-budg-e07aed" + model_config: {} + credit_limit: 1 + provider: "openai" + '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" + + post: + summary: Create a Virtual Key + 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 + examples: + generic: + value: + name: "My first virtual key" + provider: "openai" + key: "sk-jhkfkjs8d9f7jksfghkjhfg" + note: "Virtual key description" + azure-openai: + value: + provider: "azure-openai" + key: "openai-test" + name: "Key 1 Azure Open AI" + note: "description" + apiVersion: "a" + deploymentName: "b" + 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 + properties: + slug: + type: string + '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" + + /virtual-keys/{slug}: + get: + summary: Get a Virtual Key + parameters: + - in: path + name: slug + required: true + schema: + type: string + responses: + '200': + description: Successful response + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + data: + type: object + properties: + model_config: + type: object + key: + type: string + name: + type: string + credit_limit: + type: string + nullable: true + status: + type: string + note: + type: string + created_at: + type: string + format: date-time + provider: + type: string + '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" + + put: + summary: Update a Virtual Key + 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 + responses: + '200': + description: Successful response + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + data: + 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" + + delete: + summary: Delete a Virtual Key + parameters: + - in: path + name: slug + required: true + schema: + type: string + responses: + '200': + description: Successful response + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + data: + 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" + components: securitySchemes: ApiKeyAuth: From f7c1e68279c20e2c3dc5d60022462c5441575b06 Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Thu, 20 Jun 2024 23:01:23 +0530 Subject: [PATCH 007/124] User API --- openapi.yaml | 263 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 263 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index ca1e675b..69afda59 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -45,6 +45,10 @@ tags: 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. 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 @@ -8361,6 +8365,265 @@ paths: data: message: "Unauthorised Request" + /admin/users/invites: + post: + tags: + - User-invites + summary: Invite User + description: Send an invite to user for your organization + requestBody: + content: + application/json: + schema: + type: object + example: + email: horace.slughorn@example.com + role: member + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + example: + id: 8dcfa174-c5ed-42c7-8a63-be755cc6e391 + invite_link: https://app.portkey.ai/some-invite-link + + 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' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + example: + object: list + total: 2 + data: + - object: invite + id: 8dcfa174-c5ed-42c7-8a63-be755cc6e391 + 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-be755cc6e40 + + /admin/users/invites/{inviteId}: + 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: + type: object + example: + object: invite + id: 8dcfa174-c5ed-42c7-8a63-be755cc6e391 + 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 + + 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: {} + + /admin/users: + get: + tags: + - Users + summary: Get users + parameters: + - name: pageSize + in: query + schema: + type: integer + example: '1' + - name: currentPage + in: query + schema: + type: integer + example: '0' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + example: + total: 2 + object: list + data: + - object: user + id: 389c0cbc-08a4-481f-a419-f408c234a89a + 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' + + /admin/users/{userId}: + 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: + type: object + example: + object: user + id: 389c0cbc-08a4-481f-a419-f408c234a89a + 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' + + 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: {} + + put: + tags: + - Users + summary: Update user + requestBody: + content: + application/json: + schema: + type: object + 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: {} + components: securitySchemes: ApiKeyAuth: From 5ca066873a8887abbddd8c5c39de4d47bfd374d8 Mon Sep 17 00:00:00 2001 From: Rohit Agarwal Date: Sat, 22 Jun 2024 23:28:02 +0530 Subject: [PATCH 008/124] Update openapi.yaml --- openapi.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/openapi.yaml b/openapi.yaml index 69afda59..bbbd3186 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -49,6 +49,7 @@ tags: description: Create and manage users. - name: User-invites description: Create and manage user invites. +x-codeSamples: false 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 From 86b66d8a0430c37b9c8d1a53221e975e0f8b9bdf Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Mon, 24 Jun 2024 16:01:25 +0530 Subject: [PATCH 009/124] feat: virtual keys limits 2.0 --- openapi.yaml | 57 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index bbbd3186..7c116441 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8045,9 +8045,8 @@ paths: type: string model_config: type: object - credit_limit: - type: string - nullable: true + usage_limits: + $ref: "#/components/schemas/UsageLimits" provider: type: string example: @@ -8060,7 +8059,7 @@ paths: created_at: "2024-05-13T23:17:36.000Z" slug: "ayush-test-budg-e07aed" model_config: {} - credit_limit: 1 + usage_limits: {"credit_limit": 10,"periodic_reset": "monthly","alert_threshold": 9} provider: "openai" '401': description: Unauthorized response @@ -8141,6 +8140,8 @@ paths: deploymentName: type: string nullable: true + usage_limits: + $ref: "#/components/schemas/UsageLimits" examples: generic: value: @@ -8148,6 +8149,7 @@ paths: provider: "openai" key: "sk-jhkfkjs8d9f7jksfghkjhfg" note: "Virtual key description" + usage_limits: {"credit_limit": 10,"periodic_reset": "monthly","alert_threshold": 9} azure-openai: value: provider: "azure-openai" @@ -8243,9 +8245,8 @@ paths: type: string name: type: string - credit_limit: - type: string - nullable: true + usage_limits: + $ref: "#/components/schemas/UsageLimits" status: type: string note: @@ -8296,6 +8297,8 @@ paths: note: type: string nullable: true + usage_limits: + $ref: "#/components/schemas/UsageLimits" responses: '200': description: Successful response @@ -11677,8 +11680,7 @@ components: 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. + description: *run_temperature_description type: number minimum: 0 maximum: 2 @@ -11692,10 +11694,7 @@ components: 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. + description: *run_top_p_description response_format: $ref: "#/components/schemas/AssistantsApiResponseFormatOption" nullable: true @@ -11783,10 +11782,7 @@ components: 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. + description: *run_top_p_description response_format: $ref: "#/components/schemas/AssistantsApiResponseFormatOption" nullable: true @@ -12256,10 +12252,7 @@ components: 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. + description: *run_top_p_description stream: type: boolean nullable: true @@ -15034,6 +15027,28 @@ components: additionalProperties: true description: Additional metadata for the feedback. + UsageLimits: + type: object + properties: + credit_limit: + type: integer + description: Credit Limit. Used for tracking usage + minimum: 1 + default: null + 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"] + example: + credit_limit: 10 + periodic_reset: monthly + alert_threshold: 8 + security: - ApiKeyAuth: [] From e11ba9a378b32896fcd0310a16b7b2eb405b7b5f Mon Sep 17 00:00:00 2001 From: visargD Date: Mon, 24 Jun 2024 21:21:54 +0530 Subject: [PATCH 010/124] feat: add workspaces admin api openapi spec and update user api specs --- openapi.yaml | 365 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 340 insertions(+), 25 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 7c116441..a58d5e1f 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -49,6 +49,10 @@ tags: 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. x-codeSamples: false paths: # Note: When adding an endpoint, make sure you also add it in the `groups` section, in the end of this file, @@ -8369,10 +8373,10 @@ paths: data: message: "Unauthorised Request" - /admin/users/invites: + /v1/admin/users/invites: post: tags: - - User-invites + - Users-invites summary: Invite User description: Send an invite to user for your organization requestBody: @@ -8396,12 +8400,11 @@ paths: schema: type: object example: - id: 8dcfa174-c5ed-42c7-8a63-be755cc6e391 + id: 419641fb-1458-47d6-94d0-e308159b3ec2 invite_link: https://app.portkey.ai/some-invite-link - get: tags: - - User-invites + - Users-invites summary: Get All Invites parameters: - name: pageSize @@ -8431,19 +8434,19 @@ paths: total: 2 data: - object: invite - id: 8dcfa174-c5ed-42c7-8a63-be755cc6e391 + 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-be755cc6e40 - - /admin/users/invites/{inviteId}: + invited_by: a90e74fb-269e-457b-8b59-9426cdd8907e + + /v1/admin/users/invites/{inviteId}: get: tags: - - User-invites + - Users-invites summary: Get Invite parameters: - name: inviteId @@ -8466,7 +8469,7 @@ paths: type: object example: object: invite - id: 8dcfa174-c5ed-42c7-8a63-be755cc6e391 + id: 419641fb-1458-47d6-94d0-e308159b3ec2 email: horace.slughorn@example.com role: member created_at: '2023-12-12 13:56:32' @@ -8474,10 +8477,9 @@ paths: accepted_at: '2023-12-12 13:56:32' status: pending invited_by: 8dcfa174-c5ed-42c7-8a63-be755cc6e3123 - delete: tags: - - User-invites + - Users-invites summary: Delete Invite By ID parameters: - name: inviteId @@ -8498,13 +8500,18 @@ paths: schema: type: object example: {} - - /admin/users: + + /v1/admin/users: 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: @@ -8532,15 +8539,15 @@ paths: object: list data: - object: user - id: 389c0cbc-08a4-481f-a419-f408c234a89a - first_name: Horace - last_name: Slughorn + 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' - - /admin/users/{userId}: + + /v1/admin/users/{userId}: get: tags: - Users @@ -8565,14 +8572,13 @@ paths: type: object example: object: user - id: 389c0cbc-08a4-481f-a419-f408c234a89a - first_name: Horace - last_name: Slughorn + 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' - delete: tags: - Users @@ -8596,7 +8602,6 @@ paths: schema: type: object example: {} - put: tags: - Users @@ -8627,6 +8632,316 @@ paths: schema: type: object example: {} + + /v1/admin/workspaces/{workspaceId}/users: + post: + tags: + - Workspaces > Members + summary: Add workspace member + requestBody: + content: + application/json: + schema: + type: object + example: + users: + - user_id: 419641fb-1458-47d6-94d0-e308159b3ec2 + role: member + - user_id: 419641fb-1458-47d6-94d0-e308159b3ec3 + role: member + parameters: + - name: workspaceId + in: path + schema: + type: string + required: true + responses: + '200': + description: OK + content: + text/plain: + schema: + type: string + example: '{}' + get: + tags: + - Workspaces > Members + summary: Get all members + 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: + total: 2 + object: list + data: + - 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' + + /v1/admin/workspaces/{workspaceId}/users/{userId}: + put: + tags: + - Workspaces > Members + summary: Update workspace member + requestBody: + content: + application/json: + schema: + type: object + 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: {} + 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: {} + 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: + type: object + 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' + + /v1/admin/workspaces: + post: + tags: + - Workspaces + summary: Create Workspace + requestBody: + content: + application/json: + schema: + type: object + 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: + type: object + example: + id: test-prod-ws-12345 + get: + tags: + - Workspaces + summary: Get All + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + 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' + defaults: + metadata: + foo: bar + 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' + defaults: + metadata: + foo: bar + object: workspace + + /v1/admin/workspaces/{workspaceId}: + put: + tags: + - Workspaces + summary: Update Workspace + requestBody: + content: + application/json: + schema: + type: object + 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: {} + 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: + type: object + example: + 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' + defaults: + metadata: + foo: bar + object: workspace components: securitySchemes: From 85964792ead2d6368f889c43daad8dc1a0a3b846 Mon Sep 17 00:00:00 2001 From: visargD Date: Mon, 24 Jun 2024 21:36:42 +0530 Subject: [PATCH 011/124] fix: remove v1 from admin routes --- openapi.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index a58d5e1f..dcae9254 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8373,7 +8373,7 @@ paths: data: message: "Unauthorised Request" - /v1/admin/users/invites: + /admin/users/invites: post: tags: - Users-invites @@ -8443,7 +8443,7 @@ paths: status: pending invited_by: a90e74fb-269e-457b-8b59-9426cdd8907e - /v1/admin/users/invites/{inviteId}: + /admin/users/invites/{inviteId}: get: tags: - Users-invites @@ -8501,7 +8501,7 @@ paths: type: object example: {} - /v1/admin/users: + /admin/users: get: tags: - Users @@ -8547,7 +8547,7 @@ paths: created_at: '2024-01-25 11:35:07' last_updated_at: '2024-01-25 11:35:07' - /v1/admin/users/{userId}: + /admin/users/{userId}: get: tags: - Users @@ -8633,7 +8633,7 @@ paths: type: object example: {} - /v1/admin/workspaces/{workspaceId}/users: + /admin/workspaces/{workspaceId}/users: post: tags: - Workspaces > Members @@ -8701,7 +8701,7 @@ paths: created_at: '2024-01-25 11:35:07' last_updated_at: '2024-01-25 11:35:07' - /v1/admin/workspaces/{workspaceId}/users/{userId}: + /admin/workspaces/{workspaceId}/users/{userId}: put: tags: - Workspaces > Members @@ -8805,7 +8805,7 @@ paths: created_at: '2024-01-25 11:35:07' last_updated_at: '2024-01-25 11:35:07' - /v1/admin/workspaces: + /admin/workspaces: post: tags: - Workspaces @@ -8875,7 +8875,7 @@ paths: foo: bar object: workspace - /v1/admin/workspaces/{workspaceId}: + /admin/workspaces/{workspaceId}: put: tags: - Workspaces From 746face40afd749baff5d6575f49ccbc76d2a0d3 Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Mon, 24 Jun 2024 22:15:39 +0530 Subject: [PATCH 012/124] Update openapi.yaml --- openapi.yaml | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index dcae9254..9c388d0d 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8376,7 +8376,7 @@ paths: /admin/users/invites: post: tags: - - Users-invites + - User-invites summary: Invite User description: Send an invite to user for your organization requestBody: @@ -8404,7 +8404,7 @@ paths: invite_link: https://app.portkey.ai/some-invite-link get: tags: - - Users-invites + - User-invites summary: Get All Invites parameters: - name: pageSize @@ -8442,11 +8442,11 @@ paths: accepted_at: '2023-12-12 13:56:32' status: pending invited_by: a90e74fb-269e-457b-8b59-9426cdd8907e - + /admin/users/invites/{inviteId}: get: tags: - - Users-invites + - User-invites summary: Get Invite parameters: - name: inviteId @@ -8479,7 +8479,7 @@ paths: invited_by: 8dcfa174-c5ed-42c7-8a63-be755cc6e3123 delete: tags: - - Users-invites + - User-invites summary: Delete Invite By ID parameters: - name: inviteId @@ -8500,7 +8500,7 @@ paths: schema: type: object example: {} - + /admin/users: get: tags: @@ -8546,7 +8546,7 @@ paths: email: horace.slughorn@example.com created_at: '2024-01-25 11:35:07' last_updated_at: '2024-01-25 11:35:07' - + /admin/users/{userId}: get: tags: @@ -8632,7 +8632,7 @@ paths: schema: type: object example: {} - + /admin/workspaces/{workspaceId}/users: post: tags: @@ -8663,6 +8663,7 @@ paths: schema: type: string example: '{}' + get: tags: - Workspaces > Members @@ -8700,7 +8701,7 @@ paths: role: admin created_at: '2024-01-25 11:35:07' last_updated_at: '2024-01-25 11:35:07' - + /admin/workspaces/{workspaceId}/users/{userId}: put: tags: @@ -8737,6 +8738,7 @@ paths: schema: type: object example: {} + delete: tags: - Workspaces > Members @@ -8765,6 +8767,7 @@ paths: schema: type: object example: {} + get: tags: - Workspaces > Members @@ -8804,7 +8807,7 @@ paths: role: admin created_at: '2024-01-25 11:35:07' last_updated_at: '2024-01-25 11:35:07' - + /admin/workspaces: post: tags: @@ -8836,6 +8839,7 @@ paths: type: object example: id: test-prod-ws-12345 + get: tags: - Workspaces @@ -8874,7 +8878,7 @@ paths: metadata: foo: bar object: workspace - + /admin/workspaces/{workspaceId}: put: tags: @@ -8910,6 +8914,7 @@ paths: schema: type: object example: {} + get: tags: - Workspaces From 60e7828e81214dca452fa4ed2795c41d8369181d Mon Sep 17 00:00:00 2001 From: visargD Date: Mon, 24 Jun 2024 23:23:22 +0530 Subject: [PATCH 013/124] feat: add req and res schema for admin apis --- openapi.yaml | 310 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 302 insertions(+), 8 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 9c388d0d..b2ad6002 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8021,6 +8021,8 @@ paths: /virtual-keys: get: summary: List All Virtual Keys + tags: + - Virtual-keys responses: '200': description: Successful response @@ -8384,6 +8386,14 @@ paths: application/json: schema: type: object + properties: + email: + type: string + role: + type: string + enum: + - admin + - member example: email: horace.slughorn@example.com role: member @@ -8399,6 +8409,13 @@ paths: application/json: schema: type: object + properties: + id: + type: string + format: uuid + invite_link: + type: string + format: uri example: id: 419641fb-1458-47d6-94d0-e308159b3ec2 invite_link: https://app.portkey.ai/some-invite-link @@ -8417,6 +8434,30 @@ paths: 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 @@ -8428,7 +8469,7 @@ paths: content: application/json: schema: - type: object + $ref: "#/components/schemas/InviteList" example: object: list total: 2 @@ -8466,7 +8507,7 @@ paths: content: application/json: schema: - type: object + $ref: "#/components/schemas/Invite" example: object: invite id: 419641fb-1458-47d6-94d0-e308159b3ec2 @@ -8522,6 +8563,21 @@ paths: 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 @@ -8533,7 +8589,7 @@ paths: content: application/json: schema: - type: object + $ref: "#/components/schemas/UserList" example: total: 2 object: list @@ -8569,7 +8625,8 @@ paths: content: application/json: schema: - type: object + schema: + $ref: "#/components/schemas/User" example: object: user id: 61e08f60-4822-465e-ba23-39f85cd741cb @@ -8611,6 +8668,12 @@ paths: application/json: schema: type: object + properties: + role: + type: string + enum: + - admin + - member example: role: admin parameters: @@ -8643,6 +8706,19 @@ paths: application/json: schema: type: object + properties: + users: + type: array + items: + type: object + properties: + user_id: + type: string + role: + type: string + enum: + - admin + - member example: users: - user_id: 419641fb-1458-47d6-94d0-e308159b3ec2 @@ -8685,7 +8761,7 @@ paths: content: application/json: schema: - type: object + $ref: "#/components/schemas/WorkspaceMemberList" example: total: 2 object: list @@ -8712,6 +8788,12 @@ paths: application/json: schema: type: object + properties: + role: + type: string + enum: + - admin + - member example: role: member parameters: @@ -8794,7 +8876,7 @@ paths: content: application/json: schema: - type: object + $ref: "#/components/schemas/WorkspaceMember" example: object: workspace_member user_id: 61e08f60-4822-465e-ba23-39f85cd741cb @@ -8818,6 +8900,18 @@ paths: application/json: schema: type: object + properties: + name: + type: string + description: + type: string + defaults: + type: object + properties: + metadata: + type: object + additionalProperties: + type: string example: name: My Workspace description: My Description @@ -8844,6 +8938,17 @@ paths: tags: - Workspaces summary: Get All + parameters: + - name: pageSize + in: query + schema: + type: integer + example: '1' + - name: currentPage + in: query + schema: + type: integer + example: '0' responses: '200': description: OK @@ -8855,7 +8960,7 @@ paths: content: application/json: schema: - type: object + $ref: "#/components/schemas/WorkspaceList" example: total: 2 object: list @@ -8889,6 +8994,18 @@ paths: application/json: schema: type: object + properties: + name: + type: string + description: + type: string + defaults: + type: object + properties: + metadata: + type: object + additionalProperties: + type: string example: name: My Workspace description: My Description @@ -8936,7 +9053,7 @@ paths: content: application/json: schema: - type: object + $ref: "#/components/schemas/Workspace" example: id: test-prod-ws-12345 name: Test prod workspace @@ -15369,6 +15486,183 @@ components: periodic_reset: monthly alert_threshold: 8 + 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 + 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 + enum: + - workspace_member + user_id: + type: string + format: uuid + user: + $ref: '#/components/schemas/User' + role: + type: string + enum: + - admin + - member + created_at: + type: string + format: date-time + last_updated_at: + type: string + format: date-time + WorkspaceMemberList: + type: object + properties: + total: + type: integer + example: 2 + object: + type: string + enum: + - list + data: + type: array + items: + $ref: '#/components/schemas/WorkspaceMember' + + Workspace: + type: object + properties: + id: + type: string + name: + type: string + description: + type: string + created_at: + type: string + format: date-time + last_updated_at: + type: string + format: date-time + defaults: + type: object + properties: + metadata: + type: object + additionalProperties: + type: string + example: + foo: bar + object: + type: string + enum: + - workspace + + WorkspaceList: + type: object + properties: + total: + type: integer + example: 2 + object: + type: string + enum: + - list + data: + type: array + items: + $ref: '#/components/schemas/Workspace' + + security: - ApiKeyAuth: [] From 013c714caafa1b2c993fdbe459ed8d36d08af9e0 Mon Sep 17 00:00:00 2001 From: visargD Date: Mon, 24 Jun 2024 23:26:21 +0530 Subject: [PATCH 014/124] minor fix --- openapi.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index b2ad6002..6b7c3076 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8625,8 +8625,7 @@ paths: content: application/json: schema: - schema: - $ref: "#/components/schemas/User" + $ref: "#/components/schemas/User" example: object: user id: 61e08f60-4822-465e-ba23-39f85cd741cb From 6d965106ff99e4a2f15c5e6f9cba956347ab33a3 Mon Sep 17 00:00:00 2001 From: visargD Date: Mon, 24 Jun 2024 23:35:14 +0530 Subject: [PATCH 015/124] fix: minor fixes for admin api schemas --- openapi.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 6b7c3076..a9665319 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8734,10 +8734,10 @@ paths: '200': description: OK content: - text/plain: + application/json: schema: - type: string - example: '{}' + type: object + example: {} get: tags: @@ -8930,6 +8930,9 @@ paths: application/json: schema: type: object + properties: + id: + type: string example: id: test-prod-ws-12345 From 58a8861825ce04f617460750995d63c1f17da3c5 Mon Sep 17 00:00:00 2001 From: Rohit Agarwal Date: Thu, 27 Jun 2024 21:28:07 +0530 Subject: [PATCH 016/124] Added workspace mappings --- openapi.yaml | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index a9665319..08783544 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -7684,6 +7684,8 @@ paths: /configs: get: summary: List all configs + tags: + - Configs operationId: listConfigs responses: "200": @@ -7710,6 +7712,9 @@ paths: organisation_id: type: string format: uuid + workspace_id: + type: string + format: uuid is_default: type: integer status: @@ -7738,6 +7743,7 @@ paths: "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", @@ -7749,6 +7755,8 @@ paths: } post: summary: Create a config + tags: + - Configs operationId: createConfig requestBody: required: true @@ -7763,12 +7771,17 @@ paths: 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: @@ -7805,6 +7818,8 @@ paths: /configs/{slug}: get: summary: Get a config + tags: + - Configs operationId: getConfig parameters: - name: slug @@ -7890,6 +7905,8 @@ paths: } put: summary: Update a config + tags: + - Configs operationId: updateConfig parameters: - name: slug @@ -8055,6 +8072,9 @@ paths: $ref: "#/components/schemas/UsageLimits" provider: type: string + workspace_id: + type: string + format: uuid example: success: true data: @@ -8067,6 +8087,7 @@ paths: model_config: {} usage_limits: {"credit_limit": 10,"periodic_reset": "monthly","alert_threshold": 9} provider: "openai" + workspace_id: "" '401': description: Unauthorized response content: @@ -8088,6 +8109,8 @@ paths: post: summary: Create a Virtual Key + tags: + - Virtual-keys requestBody: required: true content: @@ -8146,6 +8169,10 @@ paths: deploymentName: type: string nullable: true + workspace_id: + type: string + format: uuid + description: optional, needed when using organisation admin API keys usage_limits: $ref: "#/components/schemas/UsageLimits" examples: @@ -8156,6 +8183,7 @@ paths: key: "sk-jhkfkjs8d9f7jksfghkjhfg" note: "Virtual key description" usage_limits: {"credit_limit": 10,"periodic_reset": "monthly","alert_threshold": 9} + workspace_id: "" azure-openai: value: provider: "azure-openai" @@ -8226,6 +8254,8 @@ paths: /virtual-keys/{slug}: get: summary: Get a Virtual Key + tags: + - Virtual-keys parameters: - in: path name: slug @@ -8283,6 +8313,8 @@ paths: put: summary: Update a Virtual Key + tags: + - Virtual-keys parameters: - in: path name: slug @@ -8338,6 +8370,8 @@ paths: delete: summary: Delete a Virtual Key + tags: + - Virtual-keys parameters: - in: path name: slug @@ -8394,9 +8428,24 @@ paths: enum: - admin - member + workspaces: + type: array + items: + type: object + properties: + workspace_id: + type: string + role: + type: string + enum: + - admin + - member example: email: horace.slughorn@example.com role: member + workspaces: + - workspace_id: "" + role: "" responses: '200': description: OK @@ -8483,6 +8532,9 @@ paths: accepted_at: '2023-12-12 13:56:32' status: pending invited_by: a90e74fb-269e-457b-8b59-9426cdd8907e + workspaces: + - workspace_id: "" + role: "" /admin/users/invites/{inviteId}: get: @@ -8518,6 +8570,9 @@ paths: accepted_at: '2023-12-12 13:56:32' status: pending invited_by: 8dcfa174-c5ed-42c7-8a63-be755cc6e3123 + workspaces: + - workspace_id: "" + role: "" delete: tags: - User-invites From 42d6e6cded936f92acf15be8803983b21c55f997 Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Wed, 31 Jul 2024 01:14:56 +0530 Subject: [PATCH 017/124] chore: update workspace api --- openapi.yaml | 137 +++++++++++++++++++++++++++------------------------ 1 file changed, 73 insertions(+), 64 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 08783544..2b4f0aa6 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8794,44 +8794,6 @@ paths: type: object example: {} - get: - tags: - - Workspaces > Members - summary: Get all members - 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/WorkspaceMemberList" - example: - total: 2 - object: list - data: - - 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' - /admin/workspaces/{workspaceId}/users/{userId}: put: tags: @@ -8966,6 +8928,10 @@ paths: type: object additionalProperties: type: string + users: + type: array + items: + type: string example: name: My Workspace description: My Description @@ -8984,24 +8950,19 @@ paths: content: application/json: schema: - type: object - properties: - id: - type: string - example: - id: test-prod-ws-12345 + $ref: '#/components/schemas/Workspace' get: tags: - Workspaces summary: Get All parameters: - - name: pageSize + - name: page_size in: query schema: type: integer example: '1' - - name: currentPage + - name: current_page in: query schema: type: integer @@ -9086,8 +9047,7 @@ paths: content: application/json: schema: - type: object - example: {} + $ref: '#/components/schemas/Workspace' get: tags: @@ -9110,17 +9070,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Workspace" - example: - 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' - defaults: - metadata: - foo: bar - object: workspace + $ref: "#/components/schemas/WorkspaceWithUsers" components: securitySchemes: @@ -15680,29 +15630,42 @@ components: 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: + example: foo: bar - object: - type: string - enum: - - workspace + is_default: + type: integer + example: 0 + object: + type: string + enum: + - workspace WorkspaceList: type: object @@ -15719,6 +15682,52 @@ components: 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 + object: + type: string + enum: + - workspace + users: + type: array + items: + type: object + $ref: '#/components/schemas/User' security: - ApiKeyAuth: [] From 8a196b20a8577caa4b8642e69ad56e2ec732f87c Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Thu, 1 Aug 2024 17:17:53 +0530 Subject: [PATCH 018/124] feat: workspace users api --- openapi.yaml | 74 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 9 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 2b4f0aa6..8f83b322 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8766,18 +8766,21 @@ paths: items: type: object properties: - user_id: + id: type: string + format: uuid + example: 25afb7bd-f98a-11ee-85fe-0e27d7367987 role: type: string + example: member enum: - admin - member example: users: - - user_id: 419641fb-1458-47d6-94d0-e308159b3ec2 + - id: 419641fb-1458-47d6-94d0-e308159b3ec2 role: member - - user_id: 419641fb-1458-47d6-94d0-e308159b3ec3 + - id: 419641fb-1458-47d6-94d0-e308159b3ec3 role: member parameters: - name: workspaceId @@ -8793,6 +8796,36 @@ paths: schema: type: object example: {} + 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 + required: false + default: 50 + - name: page_size + in: query + schema: + type: number + required: false + default: 0 + + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/WorkspaceMemberList" /admin/workspaces/{workspaceId}/users/{userId}: put: @@ -15592,24 +15625,46 @@ components: properties: object: type: string + example: workspace-user enum: - - workspace_member - user_id: - type: string + - workspace-user + id: + type: + example: 25afb7bd-f98a-11ee-85fe-0e27d7367987 format: uuid - user: - $ref: '#/components/schemas/User' + 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: @@ -15618,6 +15673,7 @@ components: example: 2 object: type: string + example: list enum: - list data: @@ -15727,7 +15783,7 @@ components: type: array items: type: object - $ref: '#/components/schemas/User' + $ref: '#/components/schemas/WorkspaceMember' security: - ApiKeyAuth: [] From ef0309508a9decc12c147d2a5d7bffe030ac909d Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Wed, 7 Aug 2024 19:38:32 +0530 Subject: [PATCH 019/124] chore: open api key routes --- openapi.yaml | 367 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 367 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 8f83b322..5f6291d0 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -9105,6 +9105,169 @@ paths: schema: $ref: "#/components/schemas/WorkspaceWithUsers" + /admin/api-keys/{type}/{sub-type}: + post: + tags: + - Api Keys + summary: Create Api Keys + 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 + example: "abssofjosfjs" + object: + type: string + enum: ["api-key"] + example: "api-key" + + /admin/api-keys: + 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: role + in: query + schema: + type: string + enum: ["admin","manager","member"] + example: 'admin' + - name: email + in: query + schema: + type: string + example: 'test@test.com' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + $ref: "#/components/schemas/ApiKeyObjectList" + + /admin/api-keys/{id}: + put: + tags: + - Api Keys + summary: Update Api Keys + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateApiKeyObject" + 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' + + 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" + + delete: + tags: + - Api Keys + summary: Remove a 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: {} + components: securitySchemes: ApiKeyAuth: @@ -15785,6 +15948,210 @@ components: type: object $ref: '#/components/schemas/WorkspaceMember' + ApiKeyObject: + type: object + properties: + id: + type: string + format: uuid + example: "f47ac10b-58cc-4372-a567-0e02b2c3d479" + key: + type: string + example: "XkLm9pQ8rT7yU6vW5zS4" + name: + type: string + example: "Development API Key" + description: + type: string + example: "API key for development environment" + type: + type: string + enum: ["organisation-service", "worksapce-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" + created_by: + type: string + format: uuid + example: "d4e5f6a7-b8c9-7d0e-1f2a-3b4c5d6e7f8g" + last_updated_by: + type: string + format: uuid + example: "e5f6a7b8-c9d0-8e1f-2a3b-4c5d6e7f8g9h" + rate_limits: + type: array + items: + type: object + properties: + 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 + 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 + 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 + example: "c3d4e5f6-a7b8-6c7d-0e1f-2a3b4c5d6e7f" + rate_limits: + type: array + items: + type: object + properties: + 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 + + 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: + 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 + security: - ApiKeyAuth: [] From bb86175ca690fcbd78491d75cbdabb59cdecab4e Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Wed, 7 Aug 2024 19:55:02 +0530 Subject: [PATCH 020/124] fix: get api key details --- openapi.yaml | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 5f6291d0..80aa8719 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8818,6 +8818,17 @@ paths: type: number required: false default: 0 + - name: role + in: query + schema: + type: string + enum: ["admin","manager","member"] + example: 'admin' + - name: email + in: query + schema: + type: string + example: 'test@test.com' responses: '200': @@ -9142,6 +9153,10 @@ paths: type: object properties: id: + type: string + format: uuid + example: "183f497a-2a7f-4f47-992e-26213fa863we" + key: type: string example: "abssofjosfjs" object: @@ -9165,17 +9180,6 @@ paths: schema: type: integer example: '0' - - name: role - in: query - schema: - type: string - enum: ["admin","manager","member"] - example: 'admin' - - name: email - in: query - schema: - type: string - example: 'test@test.com' responses: '200': description: OK @@ -15957,7 +15961,7 @@ components: example: "f47ac10b-58cc-4372-a567-0e02b2c3d479" key: type: string - example: "XkLm9pQ8rT7yU6vW5zS4" + example: "Xk*******S4" name: type: string example: "Development API Key" From 6f9142c698c9c735154915cd59212f69c947c945 Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Wed, 7 Aug 2024 20:02:41 +0530 Subject: [PATCH 021/124] chore: use v1/api-keys are route pattern --- openapi.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 80aa8719..64670121 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -9116,7 +9116,7 @@ paths: schema: $ref: "#/components/schemas/WorkspaceWithUsers" - /admin/api-keys/{type}/{sub-type}: + /v1/api-keys/{type}/{sub-type}: post: tags: - Api Keys @@ -9164,7 +9164,7 @@ paths: enum: ["api-key"] example: "api-key" - /admin/api-keys: + /v1/api-keys: get: tags: - Api Keys @@ -9193,7 +9193,7 @@ paths: schema: $ref: "#/components/schemas/ApiKeyObjectList" - /admin/api-keys/{id}: + /v1/api-keys/{id}: put: tags: - Api Keys From c24d34dc8d2c0b67cb05708144bab4b9e306ec4e Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Wed, 7 Aug 2024 20:04:12 +0530 Subject: [PATCH 022/124] chore: use api-keys are route pattern --- openapi.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 64670121..4a2e93b8 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -9116,7 +9116,7 @@ paths: schema: $ref: "#/components/schemas/WorkspaceWithUsers" - /v1/api-keys/{type}/{sub-type}: + /api-keys/{type}/{sub-type}: post: tags: - Api Keys @@ -9164,7 +9164,7 @@ paths: enum: ["api-key"] example: "api-key" - /v1/api-keys: + /api-keys: get: tags: - Api Keys @@ -9193,7 +9193,7 @@ paths: schema: $ref: "#/components/schemas/ApiKeyObjectList" - /v1/api-keys/{id}: + /api-keys/{id}: put: tags: - Api Keys From 7154d3369526ef1e5993650d923eda24312b5987 Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Wed, 7 Aug 2024 20:07:33 +0530 Subject: [PATCH 023/124] chore: tag api-key --- openapi.yaml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 4a2e93b8..2a5332ac 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -53,6 +53,8 @@ tags: 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. x-codeSamples: false paths: # Note: When adding an endpoint, make sure you also add it in the `groups` section, in the end of this file, @@ -9119,7 +9121,7 @@ paths: /api-keys/{type}/{sub-type}: post: tags: - - Api Keys + - Api-Keys summary: Create Api Keys parameters: - name: type @@ -9167,7 +9169,7 @@ paths: /api-keys: get: tags: - - Api Keys + - Api-Keys summary: Get All parameters: - name: page_size @@ -9196,7 +9198,7 @@ paths: /api-keys/{id}: put: tags: - - Api Keys + - Api-Keys summary: Update Api Keys requestBody: content: @@ -9225,7 +9227,7 @@ paths: get: tags: - - Api Keys + - Api-Keys summary: Get Api Keys parameters: - name: id @@ -9249,7 +9251,7 @@ paths: delete: tags: - - Api Keys + - Api-Keys summary: Remove a Api Key parameters: - name: id From 39b23017ec3285acfb1f6e563f28de51bf965e68 Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Wed, 7 Aug 2024 20:36:13 +0530 Subject: [PATCH 024/124] fix: update api key response schema --- openapi.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index 2a5332ac..224972e5 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -9223,7 +9223,8 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ApiKeyObject' + type: object + example: {} get: tags: From 772d6e27296df77b890fd2c02b00348abf78841b Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Thu, 8 Aug 2024 01:12:37 +0530 Subject: [PATCH 025/124] fix: workspace_id in query param --- openapi.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 224972e5..8cda36e4 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -9182,6 +9182,11 @@ paths: schema: type: integer example: '0' + - name: workspace_id + in: query + schema: + type: string + example: 'ws-shared-123' responses: '200': description: OK From bf785909ed8f10a43720b07f014282d9ef7b6386 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Thu, 8 Aug 2024 12:12:29 +0530 Subject: [PATCH 026/124] feat: adding log export routes --- openapi.yaml | 282 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 282 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 8f83b322..0c9cae10 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -9105,6 +9105,288 @@ paths: schema: $ref: "#/components/schemas/WorkspaceWithUsers" + /v2/logs/exports/{exportId}: + get: + 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: + type: object + put: + 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: + type: object + properties: + organisation_id: + type: string + time_of_generation_min: + type: string + format: date-time + time_of_generation_max: + type: string + format: date-time + external_user: + type: string + total_units_min: + type: integer + total_units_max: + type: integer + cost_min: + type: number + cost_max: + type: number + prompt: + type: string + ai_model: + type: array + items: + 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: array + items: + type: integer + environment: + type: string + metadata_user: + type: string + metadata: + type: object + additionalProperties: + type: string + prompt_id: + type: array + items: + type: string + ai_org_model: + type: object + additionalProperties: + type: string + weighted_feedback_min: + type: number + weighted_feedback_max: + type: number + virtual_keys: + type: array + items: + type: string + trace_id: + type: array + items: + type: string + configs: + type: array + items: + type: string + workspace_slug: + type: array + items: + type: string + required: + - workspace_id + - filters + responses: + '200': + description: Successful response + content: + application/json: + schema: + type: object + + /v2/logs/exports: + get: + summary: Get all logs exports + parameters: + - name: workspace_id + in: query + schema: + type: string + responses: + '200': + description: Successful response + content: + application/json: + schema: + type: object + post: + summary: Create log export + requestBody: + content: + application/json: + schema: + type: object + properties: + workspace_id: + type: string + filters: + type: object + properties: + organisation_id: + type: string + time_of_generation_min: + type: string + format: date-time + time_of_generation_max: + type: string + format: date-time + external_user: + type: string + total_units_min: + type: integer + total_units_max: + type: integer + cost_min: + type: number + cost_max: + type: number + prompt: + type: string + ai_model: + type: array + items: + 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: array + items: + type: integer + environment: + type: string + metadata_user: + type: string + metadata: + type: object + additionalProperties: + type: string + prompt_id: + type: array + items: + type: string + ai_org_model: + type: object + additionalProperties: + type: string + weighted_feedback_min: + type: number + weighted_feedback_max: + type: number + virtual_keys: + type: array + items: + type: string + trace_id: + type: array + items: + type: string + configs: + type: array + items: + type: string + workspace_slug: + type: array + items: + type: string + requested_data: + type: array + items: + type: string + required: + - workspace_id + - filters + - requested_data + responses: + '200': + description: Successful response + content: + application/json: + schema: + type: object + /v2/logs/exports/{exportId}/start: + post: + summary: Start log export + parameters: + - name: exportId + in: path + required: true + schema: + type: string + responses: + '200': + description: Successful response + content: + application/json: + schema: + type: object + /v2/logs/exports/{exportId}/cancel: + post: + summary: Cancel log export + parameters: + - name: exportId + in: path + required: true + schema: + type: string + responses: + '200': + description: Successful response + content: + application/json: + schema: + type: object + /v2/logs/exports/{exportId}/download: + get: + summary: Download log export + parameters: + - name: exportId + in: path + required: true + schema: + type: string + responses: + '200': + description: Successful response + content: + application/json: + schema: + type: object + components: securitySchemes: ApiKeyAuth: From 82c2386324f87ede6fb301fb5e2b236bb80eb6c4 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Thu, 8 Aug 2024 13:44:11 +0530 Subject: [PATCH 027/124] feat: added response type --- openapi.yaml | 572 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 382 insertions(+), 190 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 0c9cae10..b88a972e 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -53,6 +53,8 @@ tags: description: Create and manage workspaces. - name: Workspaces > Members description: Create and manage workspace members. + - name: Logs Export + description: Exports logs service . x-codeSamples: false paths: # Note: When adding an endpoint, make sure you also add it in the `groups` section, in the end of this file, @@ -9107,6 +9109,8 @@ paths: /v2/logs/exports/{exportId}: get: + tags: + - Logs Export summary: Get a specific logs export parameters: - name: exportId @@ -9118,10 +9122,12 @@ paths: '200': description: Successful response content: - application/json: - schema: - type: object + application/json: + schema: + $ref: "#/components/schemas/ExportItem" put: + tags: + - Logs Export summary: Update a logs export parameters: - name: exportId @@ -9129,102 +9135,104 @@ paths: required: true schema: type: string - requestBody: - content: - application/json: - schema: - type: object - properties: - workspace_id: - type: string - filters: - type: object - properties: - organisation_id: + requestBody: + content: + application/json: + schema: + type: object + properties: + workspace_id: + type: string + filters: + type: object + properties: + organisation_id: + type: string + time_of_generation_min: + type: string + format: date-time + time_of_generation_max: + type: string + format: date-time + external_user: + type: string + total_units_min: + type: integer + total_units_max: + type: integer + cost_min: + type: number + cost_max: + type: number + prompt: + type: string + ai_model: + type: array + items: type: string - time_of_generation_min: + prompt_token_min: + type: integer + prompt_token_max: + type: integer + completion_token_min: + type: integer + completion_token_max: + type: integer + status_code: + type: array + items: + type: integer + environment: + type: string + metadata_user: + type: string + metadata: + type: object + additionalProperties: type: string - format: date-time - time_of_generation_max: + prompt_id: + type: array + items: type: string - format: date-time - external_user: + ai_org_model: + type: object + additionalProperties: type: string - total_units_min: - type: integer - total_units_max: - type: integer - cost_min: - type: number - cost_max: - type: number - prompt: + weighted_feedback_min: + type: number + weighted_feedback_max: + type: number + virtual_keys: + type: array + items: type: string - ai_model: - type: array - items: - 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: array - items: - type: integer - environment: + trace_id: + type: array + items: type: string - metadata_user: + configs: + type: array + items: type: string - metadata: - type: object - additionalProperties: - type: string - prompt_id: - type: array - items: - type: string - ai_org_model: - type: object - additionalProperties: - type: string - weighted_feedback_min: - type: number - weighted_feedback_max: - type: number - virtual_keys: - type: array - items: - type: string - trace_id: - type: array - items: - type: string - configs: - type: array - items: - type: string - workspace_slug: - type: array - items: - type: string - required: - - workspace_id - - filters + workspace_slug: + type: array + items: + type: string + required: + - workspace_id + - filters responses: '200': description: Successful response content: application/json: schema: - type: object + $ref: "#/components/schemas/UpdateExportResponse" /v2/logs/exports: get: + tags: + - Logs Export summary: Get all logs exports parameters: - name: workspace_id @@ -9237,109 +9245,114 @@ paths: content: application/json: schema: - type: object + $ref: "#/components/schemas/ExportListResponse" post: + tags: + - Logs Export summary: Create log export - requestBody: - content: - application/json: - schema: - type: object - properties: - workspace_id: - type: string - filters: - type: object - properties: - organisation_id: + requestBody: + content: + application/json: + schema: + type: object + properties: + workspace_id: + type: string + filters: + type: object + properties: + organisation_id: + type: string + time_of_generation_min: + type: string + format: date-time + time_of_generation_max: + type: string + format: date-time + external_user: + type: string + total_units_min: + type: integer + total_units_max: + type: integer + cost_min: + type: number + cost_max: + type: number + prompt: + type: string + ai_model: + type: array + items: type: string - time_of_generation_min: + prompt_token_min: + type: integer + prompt_token_max: + type: integer + completion_token_min: + type: integer + completion_token_max: + type: integer + status_code: + type: array + items: + type: integer + environment: + type: string + metadata_user: + type: string + metadata: + type: object + additionalProperties: type: string - format: date-time - time_of_generation_max: + prompt_id: + type: array + items: type: string - format: date-time - external_user: + ai_org_model: + type: object + additionalProperties: type: string - total_units_min: - type: integer - total_units_max: - type: integer - cost_min: - type: number - cost_max: - type: number - prompt: + weighted_feedback_min: + type: number + weighted_feedback_max: + type: number + virtual_keys: + type: array + items: type: string - ai_model: - type: array - items: - 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: array - items: - type: integer - environment: + trace_id: + type: array + items: type: string - metadata_user: + configs: + type: array + items: type: string - metadata: - type: object - additionalProperties: - type: string - prompt_id: - type: array - items: - type: string - ai_org_model: - type: object - additionalProperties: - type: string - weighted_feedback_min: - type: number - weighted_feedback_max: - type: number - virtual_keys: - type: array - items: - type: string - trace_id: - type: array - items: - type: string - configs: - type: array - items: - type: string - workspace_slug: - type: array - items: - type: string - requested_data: - type: array - items: - type: string - required: - - workspace_id - - filters - - requested_data - responses: - '200': - description: Successful response - content: - application/json: - schema: - type: object + workspace_slug: + type: array + items: + type: string + requested_data: + type: array + items: + type: string + required: + - workspace_id + - filters + - requested_data + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateExportResponse" + /v2/logs/exports/{exportId}/start: post: + tags: + - Logs Export summary: Start log export parameters: - name: exportId @@ -9347,15 +9360,18 @@ paths: required: true schema: type: string - responses: - '200': - description: Successful response - content: - application/json: - schema: - type: object + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: "#/components/schemas/ExportTaskResponse" + /v2/logs/exports/{exportId}/cancel: post: + tags: + - Logs Export summary: Cancel log export parameters: - name: exportId @@ -9363,15 +9379,18 @@ paths: required: true schema: type: string - responses: - '200': - description: Successful response - content: - application/json: - schema: - type: object + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: "#/components/schemas/ExportTaskResponse" + /v2/logs/exports/{exportId}/download: get: + tags: + - Logs Export summary: Download log export parameters: - name: exportId @@ -9385,7 +9404,7 @@ paths: content: application/json: schema: - type: object + $ref: "#/components/schemas/DownloadLogsResponse" components: securitySchemes: @@ -16066,6 +16085,179 @@ components: items: type: object $ref: '#/components/schemas/WorkspaceMember' + 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: + type: object + properties: + organisation_id: + type: string + time_of_generation_min: + type: string + format: date-time + time_of_generation_max: + type: string + format: date-time + external_user: + type: string + total_units_min: + type: integer + total_units_max: + type: integer + cost_min: + type: number + cost_max: + type: number + prompt: + type: string + ai_model: + type: array + items: + 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: array + items: + type: integer + environment: + type: string + metadata_user: + type: string + metadata: + type: object + additionalProperties: + type: string + prompt_id: + type: array + items: + type: string + ai_org_model: + type: object + additionalProperties: + type: string + weighted_feedback_min: + type: number + weighted_feedback_max: + type: number + virtual_keys: + type: array + items: + type: string + trace_id: + type: array + items: + type: string + configs: + type: array + items: + type: string + workspace_slug: + type: array + items: + type: string + requested_data: + type: array + items: + type: string + status: + type: string + enum: [draft] + 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 + security: - ApiKeyAuth: [] From 01c1b6f2c9a3e547ee5a2f875fe3276f798ed064 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Thu, 8 Aug 2024 14:00:39 +0530 Subject: [PATCH 028/124] fix: removing v2 prefix --- openapi.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index b88a972e..32d454d1 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -9107,7 +9107,7 @@ paths: schema: $ref: "#/components/schemas/WorkspaceWithUsers" - /v2/logs/exports/{exportId}: + /logs/exports/{exportId}: get: tags: - Logs Export @@ -9229,7 +9229,7 @@ paths: schema: $ref: "#/components/schemas/UpdateExportResponse" - /v2/logs/exports: + /logs/exports: get: tags: - Logs Export @@ -9349,7 +9349,7 @@ paths: schema: $ref: "#/components/schemas/UpdateExportResponse" - /v2/logs/exports/{exportId}/start: + /logs/exports/{exportId}/start: post: tags: - Logs Export @@ -9368,7 +9368,7 @@ paths: schema: $ref: "#/components/schemas/ExportTaskResponse" - /v2/logs/exports/{exportId}/cancel: + /logs/exports/{exportId}/cancel: post: tags: - Logs Export @@ -9387,7 +9387,7 @@ paths: schema: $ref: "#/components/schemas/ExportTaskResponse" - /v2/logs/exports/{exportId}/download: + /logs/exports/{exportId}/download: get: tags: - Logs Export From a66a05f0cd226c245291ebf824d60e4985a7919b Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Thu, 8 Aug 2024 16:25:07 +0530 Subject: [PATCH 029/124] fix: open api spec format --- openapi.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 8cda36e4..890268bb 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8812,14 +8812,14 @@ paths: in: query schema: type: number + default: 50 required: false - default: 50 - name: page_size in: query schema: type: number + default: 0 required: false - default: 0 - name: role in: query schema: @@ -15804,9 +15804,9 @@ components: enum: - workspace-user id: - type: - example: 25afb7bd-f98a-11ee-85fe-0e27d7367987 + type: string format: uuid + example: 25afb7bd-f98a-11ee-85fe-0e27d7367987 first_name: type: string example: John @@ -15978,7 +15978,7 @@ components: example: "API key for development environment" type: type: string - enum: ["organisation-service", "worksapce-service", "workspace-user"] + enum: ["organisation-service", "workspace-service", "workspace-user"] example: "organisation-service" organisation_id: type: string From b5c57ff341542556de05ca5dca0d53c4a39aa81c Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Thu, 8 Aug 2024 18:47:17 +0530 Subject: [PATCH 030/124] fix: ref filter as schema --- openapi.yaml | 300 ++++++++++++++------------------------------------- 1 file changed, 78 insertions(+), 222 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 32d454d1..9fdc2b5a 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -9144,80 +9144,7 @@ paths: workspace_id: type: string filters: - type: object - properties: - organisation_id: - type: string - time_of_generation_min: - type: string - format: date-time - time_of_generation_max: - type: string - format: date-time - external_user: - type: string - total_units_min: - type: integer - total_units_max: - type: integer - cost_min: - type: number - cost_max: - type: number - prompt: - type: string - ai_model: - type: array - items: - 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: array - items: - type: integer - environment: - type: string - metadata_user: - type: string - metadata: - type: object - additionalProperties: - type: string - prompt_id: - type: array - items: - type: string - ai_org_model: - type: object - additionalProperties: - type: string - weighted_feedback_min: - type: number - weighted_feedback_max: - type: number - virtual_keys: - type: array - items: - type: string - trace_id: - type: array - items: - type: string - configs: - type: array - items: - type: string - workspace_slug: - type: array - items: - type: string + $ref: "#/components/schemas/FilterSchema" required: - workspace_id - filters @@ -9259,80 +9186,7 @@ paths: workspace_id: type: string filters: - type: object - properties: - organisation_id: - type: string - time_of_generation_min: - type: string - format: date-time - time_of_generation_max: - type: string - format: date-time - external_user: - type: string - total_units_min: - type: integer - total_units_max: - type: integer - cost_min: - type: number - cost_max: - type: number - prompt: - type: string - ai_model: - type: array - items: - 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: array - items: - type: integer - environment: - type: string - metadata_user: - type: string - metadata: - type: object - additionalProperties: - type: string - prompt_id: - type: array - items: - type: string - ai_org_model: - type: object - additionalProperties: - type: string - weighted_feedback_min: - type: number - weighted_feedback_max: - type: number - virtual_keys: - type: array - items: - type: string - trace_id: - type: array - items: - type: string - configs: - type: array - items: - type: string - workspace_slug: - type: array - items: - type: string + $ref: "#/components/schemas/FilterSchema" requested_data: type: array items: @@ -16107,80 +15961,7 @@ components: type: string format: uuid filters: - type: object - properties: - organisation_id: - type: string - time_of_generation_min: - type: string - format: date-time - time_of_generation_max: - type: string - format: date-time - external_user: - type: string - total_units_min: - type: integer - total_units_max: - type: integer - cost_min: - type: number - cost_max: - type: number - prompt: - type: string - ai_model: - type: array - items: - 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: array - items: - type: integer - environment: - type: string - metadata_user: - type: string - metadata: - type: object - additionalProperties: - type: string - prompt_id: - type: array - items: - type: string - ai_org_model: - type: object - additionalProperties: - type: string - weighted_feedback_min: - type: number - weighted_feedback_max: - type: number - virtual_keys: - type: array - items: - type: string - trace_id: - type: array - items: - type: string - configs: - type: array - items: - type: string - workspace_slug: - type: array - items: - type: string + $ref: '#/components/schemas/FilterSchema' requested_data: type: array items: @@ -16257,6 +16038,81 @@ components: description: A pre-signed URL for downloading the exported logs required: - signed_url + FilterSchema: + type: object + properties: + organisation_id: + type: string + time_of_generation_min: + type: string + format: date-time + time_of_generation_max: + type: string + format: date-time + external_user: + type: string + total_units_min: + type: integer + total_units_max: + type: integer + cost_min: + type: number + cost_max: + type: number + prompt: + type: string + ai_model: + type: array + items: + 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: array + items: + type: integer + environment: + type: string + metadata_user: + type: string + metadata: + type: object + additionalProperties: + type: string + prompt_id: + type: array + items: + type: string + ai_org_model: + type: object + additionalProperties: + type: string + weighted_feedback_min: + type: number + weighted_feedback_max: + type: number + virtual_keys: + type: array + items: + type: string + trace_id: + type: array + items: + type: string + configs: + type: array + items: + type: string + workspace_slug: + type: array + items: + type: string security: From 4f84713314a1ac7c9298735e3de98fa80f93472a Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 9 Aug 2024 17:03:11 +0530 Subject: [PATCH 031/124] fix: ai_org_model to string type --- openapi.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 74723053..e799ab91 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -16265,9 +16265,7 @@ components: items: type: string ai_org_model: - type: object - additionalProperties: - type: string + type: string weighted_feedback_min: type: number weighted_feedback_max: From 796124a3f7ec516b6ace373b0c71d07c954e6405 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 9 Aug 2024 18:26:14 +0530 Subject: [PATCH 032/124] fix: array type to string --- openapi.yaml | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index e799ab91..b792f83b 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -16237,9 +16237,7 @@ components: prompt: type: string ai_model: - type: array - items: - type: string + type: string prompt_token_min: type: integer prompt_token_max: @@ -16249,21 +16247,16 @@ components: completion_token_max: type: integer status_code: - type: array - items: - type: integer + type: string environment: type: string metadata_user: type: string metadata: type: object - additionalProperties: - type: string + additionalProperties: true prompt_id: - type: array - items: - type: string + type: string ai_org_model: type: string weighted_feedback_min: @@ -16271,21 +16264,13 @@ components: weighted_feedback_max: type: number virtual_keys: - type: array - items: - type: string + type: string trace_id: - type: array - items: - type: string + type: string configs: - type: array - items: - type: string + type: string workspace_slug: - type: array - items: - type: string + type: string ApiKeyObject: From 5245ee7ce663830fc2ecf115d9dc5a0f9cb5f7c6 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 9 Aug 2024 20:16:21 +0530 Subject: [PATCH 033/124] fix: removing keys from filter schema --- openapi.yaml | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index b792f83b..f0a33875 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -16216,16 +16216,12 @@ components: FilterSchema: type: object properties: - organisation_id: - type: string time_of_generation_min: type: string format: date-time time_of_generation_max: type: string format: date-time - external_user: - type: string total_units_min: type: integer total_units_max: @@ -16234,8 +16230,6 @@ components: type: number cost_max: type: number - prompt: - type: string ai_model: type: string prompt_token_min: @@ -16248,17 +16242,12 @@ components: type: integer status_code: type: string - environment: - type: string - metadata_user: - type: string metadata: type: object additionalProperties: true - prompt_id: - type: string ai_org_model: type: string + example: "openai__gpt-3.5-turbo, anthropic__claude-2.1" weighted_feedback_min: type: number weighted_feedback_max: From e1af2f87933b889c2c150143f4aa6ee754353f28 Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Tue, 13 Aug 2024 20:46:19 +0530 Subject: [PATCH 034/124] chore: add workspace_ids to users and remove created_by and updated_by from api-keys object --- openapi.yaml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index f0a33875..e176fb71 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8694,6 +8694,7 @@ paths: 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'] delete: tags: - Users @@ -15935,6 +15936,11 @@ components: last_updated_at: type: string format: date-time + workspace_ids: + type: array + + items: + type: string UserList: type: object properties: @@ -16309,14 +16315,6 @@ components: type: string enum : ["ui", "api", "auto"] example: "ui" - created_by: - type: string - format: uuid - example: "d4e5f6a7-b8c9-7d0e-1f2a-3b4c5d6e7f8g" - last_updated_by: - type: string - format: uuid - example: "e5f6a7b8-c9d0-8e1f-2a3b-4c5d6e7f8g9h" rate_limits: type: array items: From 603bf08922d62c0dc620aed8146ad86cedfe9439 Mon Sep 17 00:00:00 2001 From: Mahesh Date: Mon, 9 Sep 2024 17:55:10 +0530 Subject: [PATCH 035/124] feat: workspace delete spec --- openapi.yaml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index e176fb71..73d450f0 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -9121,6 +9121,32 @@ paths: schema: $ref: "#/components/schemas/WorkspaceWithUsers" + delete: + tags: + - Workspaces + summary: Delete a workspace + parameters: + - name: workspaceId + in: path + schema: + type: string + required: true + requestBody: + content: + application/json: + schema: + type: object + properties: + name: + type: string + required: + - name + responses: + '200': + description: OK + + + /logs/exports/{exportId}: get: tags: From 59d813c71fd7159bb2c3cffdc6df74e21cb4312c Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Tue, 10 Sep 2024 12:37:37 +0530 Subject: [PATCH 036/124] chore: log exports spec changes - make workspace optional --- openapi.yaml | 52 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index e176fb71..147b55af 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -9158,9 +9158,10 @@ paths: workspace_id: type: string filters: - $ref: "#/components/schemas/FilterSchema" + $ref: "#/components/schemas/GenerationsFilterSchema" + requested_data: + $ref: "#/components/schemas/LogExportsRequestedData" required: - - workspace_id - filters responses: '200': @@ -9200,13 +9201,10 @@ paths: workspace_id: type: string filters: - $ref: "#/components/schemas/FilterSchema" + $ref: "#/components/schemas/GenerationsFilterSchema" requested_data: - type: array - items: - type: string + $ref: "#/components/schemas/LogExportsRequestedData" required: - - workspace_id - filters - requested_data responses: @@ -16142,14 +16140,17 @@ components: type: string format: uuid filters: - $ref: '#/components/schemas/FilterSchema' + $ref: '#/components/schemas/GenerationsFilterSchema' requested_data: - type: array - items: - type: string + $ref: '#/components/schemas/LogExportsRequestedData' status: type: string - enum: [draft] + enum: + - draft + - in_progress + - success + - failed + - stopped description: type: string created_at: @@ -16219,7 +16220,7 @@ components: description: A pre-signed URL for downloading the exported logs required: - signed_url - FilterSchema: + GenerationsFilterSchema: type: object properties: time_of_generation_min: @@ -16267,6 +16268,31 @@ components: workspace_slug: type: string + 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 ApiKeyObject: type: object From c238e3ac7c287c4ce50dbee7f4710c6878cd0e44 Mon Sep 17 00:00:00 2001 From: visargD Date: Tue, 24 Sep 2024 20:48:41 +0530 Subject: [PATCH 037/124] feat: add spec for analytics apis --- openapi.yaml | 1689 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1689 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 4ed840a8..a5c0da8c 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -57,6 +57,15 @@ tags: 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 + - 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 list for the selected time bucket. + x-codeSamples: false paths: # Note: When adding an endpoint, make sure you also add it in the `groups` section, in the end of this file, @@ -9460,12 +9469,1692 @@ paths: type: object example: {} + /analytics/graphs/requests: + get: + tags: + - Analytics > Graphs + summary: Get requests 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' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: + type: object + properties: + total: + type: integer + description: Total requests 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 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: + get: + tags: + - Analytics > Graphs + summary: Get cost 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' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: + type: object + properties: + 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: + 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: + get: + tags: + - Analytics > Graphs + summary: Get latency 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' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: + type: object + properties: + 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 + + required: + - avg + - p50 + - p90 + - p99 + 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 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: + get: + tags: + - Analytics > Graphs + summary: Get tokens 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' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: + type: object + properties: + total: + type: integer + description: Total tokens across all data points + avg: + type: integer + description: Average tokens per request across all data points + required: + - total + - avg + 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 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: + get: + tags: + - Analytics > Graphs + summary: Get users graph. Returns unique user count across different time buckets + 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' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: + type: object + properties: + total: + type: integer + description: Total unique users 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 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: + get: + tags: + - Analytics > Graphs + summary: Get users requests graph. Returns average requests per user across different time buckets + 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' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: + type: object + properties: + 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: + get: + tags: + - Analytics > Graphs + summary: Get errors 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' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: + type: object + properties: + total: + type: integer + description: Total errors 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 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: + get: + tags: + - Analytics > Graphs + summary: Get percentage error rate 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' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: + type: object + properties: + 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: + get: + tags: + - Analytics > Graphs + summary: Get status code wise stacked 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' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: + type: object + properties: + total: + type: integer + description: Total errors 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 + 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: + 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' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: + type: object + properties: + 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: + - 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: + get: + tags: + - Analytics > Graphs + summary: Get retry and fallback rescued requests 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' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: + type: object + properties: + 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: + - 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: + get: + tags: + - Analytics > Graphs + summary: Get cache hit rate 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' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: + type: object + properties: + 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: + get: + tags: + - Analytics > Graphs + summary: Get cache hit latency 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' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: + type: object + 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: + get: + tags: + - Analytics > Graphs + summary: Get feedbacks 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' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: + type: object + properties: + 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: + get: + tags: + - Analytics > Graphs + summary: Get score-wise feedbacks distribution 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' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: + type: object + 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: + get: + tags: + - Analytics > Graphs + summary: Get weighted feedbacks graph. Weighted feedback is (value * score) + 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' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: + type: object + properties: + avg: + type: integer + description: Average weighted feedback across all data points + required: + - 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: + get: + tags: + - Analytics > Graphs + summary: Get feedbacks per ai_models 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' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: + type: object + 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: + get: + tags: + - Analytics > Summary + summary: Get cache summary data for the selected time period + 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' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + summary: + type: object + properties: + 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: + get: + tags: + - Analytics > Groups + summary: Get metadata users grouped data. + 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/CurrentPage' + - $ref: '#/components/parameters/PageSize' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + object: + type: string + enum: [list] + total: + type: integer + description: Total records present across all pages + data: + type: array + items: + 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: + get: + tags: + - Analytics > Groups + summary: Get ai model grouped data. + 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/CurrentPage' + - $ref: '#/components/parameters/PageSize' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + object: + type: string + 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}: + get: + tags: + - Analytics > Groups + summary: Get metadata key based grouped data. + parameters: + - name: metadataKey + in: path + schema: + type: string + required: true + - $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/CurrentPage' + - $ref: '#/components/parameters/PageSize' + responses: + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json + content: + application/json: + schema: + type: object + properties: + object: + type: string + 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 + components: securitySchemes: ApiKeyAuth: type: apiKey in: header name: x-portkey-api-key + + parameters: + TimeOfGenerationMin: + in: query + name: time_of_generation_min + required: true + schema: + type: string + format: date-time + description: Minimum time of generation (ISO8601 format) + TimeOfGenerationMax: + in: query + name: time_of_generation_max + required: true + schema: + type: string + format: date-time + description: Maximum time of generation (ISO8601 format) + TotalUnitsMin: + in: query + name: total_units_min + schema: + type: integer + minimum: 0 + description: Minimum total units + TotalUnitsMax: + in: query + name: total_units_max + schema: + type: integer + minimum: 0 + description: Maximum total units + CostMin: + in: query + name: cost_min + schema: + type: number + minimum: 0 + description: Minimum cost + CostMax: + in: query + name: cost_max + schema: + type: number + minimum: 0 + description: Maximum cost + 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: Status code filter + 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: Virtual keys filter + Configs: + in: query + name: configs + schema: + type: string + description: Configuration filter + WorkspaceSlug: + in: query + name: workspace_slug + schema: + type: string + description: Workspace slug filter + ApiKeyIds: + in: query + name: api_key_ids + schema: + type: string + description: API key IDs filter schemas: Error: From 83e88c2f723400f8ae8f18af4fb0e8fca44dd01e Mon Sep 17 00:00:00 2001 From: visargD Date: Tue, 24 Sep 2024 21:02:06 +0530 Subject: [PATCH 038/124] chore: minor description updates for analytics api --- openapi.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index a5c0da8c..b32303f9 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -58,13 +58,13 @@ tags: - name: Logs Export description: Exports logs service . - name: Analytics - description: Get analytics over different data points + 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 list for the selected time bucket. + description: Get grouped metrics for the selected time bucket. x-codeSamples: false paths: From 0d3cfc9b9dd7542fc16d803d4a20a86ace621aa8 Mon Sep 17 00:00:00 2001 From: visargD Date: Tue, 24 Sep 2024 21:12:26 +0530 Subject: [PATCH 039/124] feat: add metadata filter in analytics api --- openapi.yaml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index b32303f9..697f80f8 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -9492,6 +9492,7 @@ paths: - $ref: '#/components/parameters/Configs' - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -9561,6 +9562,7 @@ paths: - $ref: '#/components/parameters/Configs' - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -9638,6 +9640,7 @@ paths: - $ref: '#/components/parameters/Configs' - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -9732,6 +9735,7 @@ paths: - $ref: '#/components/parameters/Configs' - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -9809,6 +9813,7 @@ paths: - $ref: '#/components/parameters/Configs' - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -9878,6 +9883,7 @@ paths: - $ref: '#/components/parameters/Configs' - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -9955,6 +9961,7 @@ paths: - $ref: '#/components/parameters/Configs' - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -10024,6 +10031,7 @@ paths: - $ref: '#/components/parameters/Configs' - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -10093,6 +10101,7 @@ paths: - $ref: '#/components/parameters/Configs' - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -10170,6 +10179,7 @@ paths: - $ref: '#/components/parameters/Configs' - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -10242,6 +10252,7 @@ paths: - $ref: '#/components/parameters/Configs' - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -10327,6 +10338,7 @@ paths: - $ref: '#/components/parameters/Configs' - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -10416,6 +10428,7 @@ paths: - $ref: '#/components/parameters/Configs' - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -10479,6 +10492,7 @@ paths: - $ref: '#/components/parameters/Configs' - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -10548,6 +10562,7 @@ paths: - $ref: '#/components/parameters/Configs' - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -10616,6 +10631,7 @@ paths: - $ref: '#/components/parameters/Configs' - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -10685,6 +10701,7 @@ paths: - $ref: '#/components/parameters/Configs' - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -10751,6 +10768,7 @@ paths: - $ref: '#/components/parameters/Configs' - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -10812,6 +10830,7 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/CurrentPage' - $ref: '#/components/parameters/PageSize' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -10879,6 +10898,7 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/CurrentPage' - $ref: '#/components/parameters/PageSize' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -10948,6 +10968,7 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/CurrentPage' - $ref: '#/components/parameters/PageSize' + - $ref: '#/components/parameters/Metadata' responses: '200': description: OK @@ -11155,6 +11176,13 @@ components: schema: type: string description: API key IDs filter + Metadata: + in: query + name: metadata + schema: + type: string + description: Stringifed json object with key value metadata pairs + example: '{"_user":"user_1", "env": "staging"}' schemas: Error: From b915ee6f682a5727cb4c1e608ef252caf47735a1 Mon Sep 17 00:00:00 2001 From: visargD Date: Tue, 24 Sep 2024 21:33:18 +0530 Subject: [PATCH 040/124] feat: add ai_org_model filter in analytics apis --- openapi.yaml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 697f80f8..d4260b98 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -9493,6 +9493,7 @@ paths: - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -9563,6 +9564,7 @@ paths: - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -9641,6 +9643,7 @@ paths: - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -9736,6 +9739,7 @@ paths: - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -9814,6 +9818,7 @@ paths: - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -9884,6 +9889,7 @@ paths: - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -9962,6 +9968,7 @@ paths: - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -10032,6 +10039,7 @@ paths: - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -10102,6 +10110,7 @@ paths: - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -10180,6 +10189,7 @@ paths: - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -10253,6 +10263,7 @@ paths: - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -10339,6 +10350,7 @@ paths: - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -10429,6 +10441,7 @@ paths: - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -10493,6 +10506,7 @@ paths: - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -10563,6 +10577,7 @@ paths: - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -10632,6 +10647,7 @@ paths: - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -10702,6 +10718,7 @@ paths: - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -10769,6 +10786,7 @@ paths: - $ref: '#/components/parameters/WorkspaceSlug' - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -10831,6 +10849,7 @@ paths: - $ref: '#/components/parameters/CurrentPage' - $ref: '#/components/parameters/PageSize' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -10899,6 +10918,7 @@ paths: - $ref: '#/components/parameters/CurrentPage' - $ref: '#/components/parameters/PageSize' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -10969,6 +10989,7 @@ paths: - $ref: '#/components/parameters/CurrentPage' - $ref: '#/components/parameters/PageSize' - $ref: '#/components/parameters/Metadata' + - $ref: '#/components/parameters/AiOrgModel' responses: '200': description: OK @@ -11183,6 +11204,13 @@ components: 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 separate 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 schemas: Error: From ae55dbcfa704a06cff4b45d30f76ef81f79777ed Mon Sep 17 00:00:00 2001 From: visargD Date: Tue, 24 Sep 2024 21:37:12 +0530 Subject: [PATCH 041/124] chore: update description of comma separated analytics filters --- openapi.yaml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index d4260b98..f392d7ce 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -11075,28 +11075,28 @@ components: schema: type: integer minimum: 0 - description: Minimum total units + description: Minimum total units (tokens) TotalUnitsMax: in: query name: total_units_max schema: type: integer minimum: 0 - description: Maximum total units + description: Maximum total units (tokens) CostMin: in: query name: cost_min schema: type: number minimum: 0 - description: Minimum cost + description: Minimum cost (in cents) CostMax: in: query name: cost_max schema: type: number minimum: 0 - description: Maximum cost + description: Maximum cost (in cents) PromptTokenMin: in: query name: prompt_token_min @@ -11130,7 +11130,8 @@ components: name: status_code schema: type: string - description: Status code filter + description: Comma separated response status codes + example: 401,403 PageSize: in: query name: page_size @@ -11178,13 +11179,15 @@ components: name: virtual_keys schema: type: string - description: Virtual keys filter + description: Comma separated virtual key slugs + example: vk-slug-1,vk-slug-2 Configs: in: query name: configs schema: type: string - description: Configuration filter + description: Comma separated config slugs + example: pc-config-slug-1,pc-config-slug-2 WorkspaceSlug: in: query name: workspace_slug @@ -11196,7 +11199,8 @@ components: name: api_key_ids schema: type: string - description: API key IDs filter + description: Comma separated API key UUIDs + example: 765768a9-b4ec-4694-962c-d55f40cdb0dc,7c22af5a-8119-46b8-8d9b-bad3ad382387 Metadata: in: query name: metadata From 2fc481eef5a65d7e6ee5a33da89bd8f0c4c0f464 Mon Sep 17 00:00:00 2001 From: visargD Date: Tue, 24 Sep 2024 21:45:03 +0530 Subject: [PATCH 042/124] feat: add trace_id and span_id filters in analytics api --- openapi.yaml | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index f392d7ce..3c411583 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -9494,6 +9494,8 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -9565,6 +9567,8 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -9644,6 +9648,8 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -9740,6 +9746,8 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -9819,6 +9827,8 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -9890,6 +9900,8 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -9969,6 +9981,8 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -10040,6 +10054,8 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -10111,6 +10127,8 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -10190,6 +10208,8 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -10264,6 +10284,8 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -10351,6 +10373,8 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -10442,6 +10466,8 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -10507,6 +10533,8 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -10578,6 +10606,8 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -10648,6 +10678,8 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -10719,6 +10751,8 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -10787,6 +10821,8 @@ paths: - $ref: '#/components/parameters/ApiKeyIds' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -10850,6 +10886,8 @@ paths: - $ref: '#/components/parameters/PageSize' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -10919,6 +10957,8 @@ paths: - $ref: '#/components/parameters/PageSize' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -10990,6 +11030,8 @@ paths: - $ref: '#/components/parameters/PageSize' - $ref: '#/components/parameters/Metadata' - $ref: '#/components/parameters/AiOrgModel' + - $ref: '#/components/parameters/TraceId' + - $ref: '#/components/parameters/SpanId' responses: '200': description: OK @@ -11213,8 +11255,22 @@ components: name: ai_org_model schema: type: string - description: Comma separate ai provider and model combination. Double underscore (__) should be used as a separator for each provider and model combination + 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 schemas: Error: From aaf1613f380df955fc2da5f54a35a767b91082b0 Mon Sep 17 00:00:00 2001 From: visargD Date: Tue, 24 Sep 2024 21:49:40 +0530 Subject: [PATCH 043/124] chore: add example for timestamp filters --- openapi.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 3c411583..e906a33e 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -11103,6 +11103,7 @@ components: type: string format: date-time description: Minimum time of generation (ISO8601 format) + example: '2024-08-23T15:50:23+05:30' TimeOfGenerationMax: in: query name: time_of_generation_max @@ -11111,6 +11112,7 @@ components: type: string format: date-time description: Maximum time of generation (ISO8601 format) + example: '2024-08-23T15:50:23+05:30' TotalUnitsMin: in: query name: total_units_min From 33746b31b26425b71aee9cff9aadf32e4b0cccb0 Mon Sep 17 00:00:00 2001 From: visargD Date: Tue, 24 Sep 2024 22:04:39 +0530 Subject: [PATCH 044/124] chore: update description of workspace slug analytics filter --- openapi.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index e906a33e..c2ba728b 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -11237,7 +11237,7 @@ components: name: workspace_slug schema: type: string - description: Workspace slug filter + 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 From 26b1ea1f87e86a07cd75bf9443d54f5f88617e83 Mon Sep 17 00:00:00 2001 From: visargD Date: Fri, 27 Sep 2024 01:09:16 +0530 Subject: [PATCH 045/124] feat: update post invites spec with latest changes --- openapi.yaml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index c2ba728b..5bcc136b 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8443,21 +8443,35 @@ paths: - member workspaces: type: array + description: Array of workspaces and roles that the user should be assigned to, if provided, once the invite is accepted. By default, the user will only be added in the shared workspace. items: type: object properties: - workspace_id: + id: type: string + description: Slug of the workspace to which the user will be added after invite acceptance. role: type: string + description: Role to be assigned in the specified workspace. enum: - admin - - member + - member + required: [id, role] + workspace_api_key_details: + type: object + description: If provided, a default user API key will be created with the specified settings for each workspace in the `workspaces` array. + properties: + scopes: + type: array + items: + type: string + required: [scopes] + required: [email, role] example: email: horace.slughorn@example.com role: member workspaces: - - workspace_id: "" + - id: "" role: "" responses: '200': From e3c4560c02fe8f6333ded20079660113140eaa23 Mon Sep 17 00:00:00 2001 From: vrushankportkey <134934501+vrushankportkey@users.noreply.github.com> Date: Tue, 1 Oct 2024 15:45:38 +0530 Subject: [PATCH 046/124] Change summary for createFile operation --- openapi.yaml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 5bcc136b..5625f38c 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1671,14 +1671,8 @@ paths: - 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 Assistants API supports files up to 2M tokens and of specific file types. 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: From 84bc28911c567406730b4c7b95920d02a742a6ef Mon Sep 17 00:00:00 2001 From: vrushankportkey <134934501+vrushankportkey@users.noreply.github.com> Date: Tue, 1 Oct 2024 15:51:49 +0530 Subject: [PATCH 047/124] Further changes createFile summary --- openapi.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 5625f38c..48740d88 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1670,9 +1670,7 @@ paths: 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 2M tokens and of specific file types. 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). + Upload a file to be used across various endpoints. Each file can be up to 512 MB, and the total size of your bucket is 100 GB. Assistants API accepts files with <2M tokens and of specific file types. The Fine-tuning API only supports `.jsonl` files, with specific formats. More: https://platform.openai.com/docs/api-reference/fine-tuning/chat-input. Batch API supports `.jsonl` files up to 100 MB. Required format: https://platform.openai.com/docs/api-reference/batch/request-input). requestBody: required: true content: From 00ba7e42ee239b6868b77b289c1522ec218a6a61 Mon Sep 17 00:00:00 2001 From: vrushankportkey <134934501+vrushankportkey@users.noreply.github.com> Date: Tue, 1 Oct 2024 15:55:05 +0530 Subject: [PATCH 048/124] Update summary further --- openapi.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index 48740d88..9e87b531 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1670,7 +1670,7 @@ paths: tags: - Files summary: | - Upload a file to be used across various endpoints. Each file can be up to 512 MB, and the total size of your bucket is 100 GB. Assistants API accepts files with <2M tokens and of specific file types. The Fine-tuning API only supports `.jsonl` files, with specific formats. More: https://platform.openai.com/docs/api-reference/fine-tuning/chat-input. Batch API supports `.jsonl` files up to 100 MB. Required format: https://platform.openai.com/docs/api-reference/batch/request-input). + 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: From f58896aac4de513c5231fad2758809ffcb2d692e Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Tue, 1 Oct 2024 18:39:43 +0530 Subject: [PATCH 049/124] update with truncated summary for fine-tuning --- openapi.yaml | 56 ++++++++++++++++++++-------------------------------- 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 9e87b531..47ae6eb6 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -66,7 +66,7 @@ tags: - name: Analytics > Groups description: Get grouped metrics for the selected time bucket. -x-codeSamples: false +x-codeSamples: true 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 @@ -1921,10 +1921,6 @@ paths: - 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: @@ -8849,7 +8845,7 @@ paths: schema: type: string example: 'test@test.com' - + responses: '200': description: OK @@ -9146,20 +9142,10 @@ paths: schema: type: string required: true - requestBody: - content: - application/json: - schema: - type: object - properties: - name: - type: string - required: - - name responses: '200': description: OK - + /logs/exports/{exportId}: @@ -9203,7 +9189,7 @@ paths: requested_data: $ref: "#/components/schemas/LogExportsRequestedData" required: - - filters + - filters responses: '200': description: Successful response @@ -9212,7 +9198,7 @@ paths: schema: $ref: "#/components/schemas/UpdateExportResponse" - /logs/exports: + /logs/exports: get: tags: - Logs Export @@ -9255,7 +9241,7 @@ paths: application/json: schema: $ref: "#/components/schemas/UpdateExportResponse" - + /logs/exports/{exportId}/start: post: tags: @@ -9274,7 +9260,7 @@ paths: application/json: schema: $ref: "#/components/schemas/ExportTaskResponse" - + /logs/exports/{exportId}/cancel: post: tags: @@ -9293,7 +9279,7 @@ paths: application/json: schema: $ref: "#/components/schemas/ExportTaskResponse" - + /logs/exports/{exportId}/download: get: tags: @@ -9312,7 +9298,7 @@ paths: application/json: schema: $ref: "#/components/schemas/DownloadLogsResponse" - + /api-keys/{type}/{sub-type}: post: tags: @@ -9348,7 +9334,7 @@ paths: application/json: schema: type: object - properties: + properties: id: type: string format: uuid @@ -9360,7 +9346,7 @@ paths: type: string enum: ["api-key"] example: "api-key" - + /api-keys: get: tags: @@ -11099,7 +11085,7 @@ components: type: apiKey in: header name: x-portkey-api-key - + parameters: TimeOfGenerationMin: in: query @@ -17775,7 +17761,7 @@ components: format: date-time workspace_ids: type: array - + items: type: string UserList: @@ -17853,7 +17839,7 @@ components: type: array items: $ref: '#/components/schemas/WorkspaceMember' - + Workspace: type: object properties: @@ -17886,14 +17872,14 @@ components: type: object additionalProperties: type: string - example: + example: foo: bar is_default: type: integer example: 0 object: type: string - enum: + enum: - workspace WorkspaceList: @@ -17910,7 +17896,7 @@ components: type: array items: $ref: '#/components/schemas/Workspace' - + WorkspaceWithUsers: type: object properties: @@ -17943,14 +17929,14 @@ components: type: object additionalProperties: type: string - example: + example: foo: bar is_default: type: integer example: 0 object: type: string - enum: + enum: - workspace users: type: array @@ -17984,7 +17970,7 @@ components: $ref: '#/components/schemas/LogExportsRequestedData' status: type: string - enum: + enum: - draft - in_progress - success @@ -18106,7 +18092,7 @@ components: type: string workspace_slug: type: string - + LogExportsRequestedData: type: array items: From d6a08eb998514d1a3652d9767b5899e0cb0ef3da Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Mon, 7 Oct 2024 09:40:00 +0530 Subject: [PATCH 050/124] fix some descriptions --- openapi.yaml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 47ae6eb6..55c00644 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -75,7 +75,7 @@ paths: operationId: createChatCompletion tags: - Chat - summary: Creates a model response for the given chat conversation. + summary: Chat requestBody: required: true content: @@ -751,7 +751,7 @@ paths: operationId: createCompletion tags: - Completions - summary: Creates a completion for the provided prompt and parameters. + summary: Completions requestBody: required: true content: @@ -911,7 +911,7 @@ paths: operationId: createImage tags: - Images - summary: Creates an image given a prompt. + summary: Create Image requestBody: required: true content: @@ -987,7 +987,7 @@ paths: operationId: createImageEdit tags: - Images - summary: Creates an edited or extended image given an original image and a prompt. + summary: Create Image Edit requestBody: required: true content: @@ -1067,7 +1067,7 @@ paths: operationId: createImageVariation tags: - Images - summary: Creates a variation of a given image. + summary: Creates Image Variation requestBody: required: true content: @@ -1142,7 +1142,7 @@ paths: operationId: createEmbedding tags: - Embeddings - summary: Creates an embedding vector representing the input text. + summary: Embeddings requestBody: required: true content: @@ -1231,7 +1231,7 @@ paths: operationId: createSpeech tags: - Audio - summary: Generates audio from the input text. + summary: Create Speech requestBody: required: true content: @@ -1312,7 +1312,7 @@ paths: operationId: createTranscription tags: - Audio - summary: Transcribes audio into the input language. + summary: Create Transcription requestBody: required: true content: @@ -1522,7 +1522,7 @@ paths: operationId: createTranslation tags: - Audio - summary: Translates audio into English. + summary: Create Translation requestBody: required: true content: @@ -1592,7 +1592,7 @@ paths: operationId: listFiles tags: - Files - summary: Returns a list of files that belong to the user's organization. + summary: List Files parameters: - in: query name: purpose @@ -1741,7 +1741,7 @@ paths: operationId: deleteFile tags: - Files - summary: Delete a file. + summary: Delete File parameters: - in: path name: file_id From 6d2d9b5bc8280011d4ac3fdd1523f98504ab1afa Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Wed, 9 Oct 2024 15:45:19 +0530 Subject: [PATCH 051/124] feat: invite resend and revoke paths --- openapi.yaml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 47ae6eb6..4bcea2cb 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8611,6 +8611,36 @@ paths: schema: type: object example: {} + /admin/users/invites/{inviteId}/resend: + 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 /admin/users: get: From 139d960497a1c78ef40e1a3099e7c950c33df6f8 Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Thu, 10 Oct 2024 13:50:57 +0530 Subject: [PATCH 052/124] add virtual key auth --- openapi.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 0c5bc46b..308d2a7b 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -11115,6 +11115,10 @@ components: type: apiKey in: header name: x-portkey-api-key + VirtualKeyAuth: + type: apiKey + in: header + name: x-portkey-virtual-key parameters: TimeOfGenerationMin: From a0223a385e0c3d8a990f8be153e838cb277e3d2e Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Tue, 15 Oct 2024 10:21:00 +0530 Subject: [PATCH 053/124] update security schemas for inference APIs --- openapi.yaml | 916 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 911 insertions(+), 5 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 308d2a7b..75c90cad 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1,4 +1,4 @@ -openapi: 3.0.0 +openapi: 3.1.0 info: title: Portkey API description: The Portkey REST API. Please see https://portkey.ai/docs/api-reference for more details. @@ -6,7 +6,7 @@ info: termsOfService: https://portkey.ai/terms contact: name: Portkey Developer Forum - url: https://portkey.ai/community + url: https://portkey.wiki/community license: name: MIT url: https://github.com/Portkey-AI/portkey-openapi/blob/master/LICENSE @@ -82,6 +82,7 @@ paths: application/json: schema: $ref: "#/components/schemas/CreateChatCompletionRequest" + responses: "200": description: OK @@ -89,6 +90,18 @@ paths: 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-oaiMeta: name: Create chat completion @@ -765,6 +778,19 @@ paths: 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-oaiMeta: name: Create completion group: completions @@ -925,6 +951,19 @@ paths: 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-oaiMeta: name: Create image group: images @@ -982,6 +1021,7 @@ paths: } ] } + /images/edits: post: operationId: createImageEdit @@ -1001,6 +1041,19 @@ paths: 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-oaiMeta: name: Create image edit group: images @@ -1081,6 +1134,19 @@ paths: 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-oaiMeta: name: Create image variation group: images @@ -1156,6 +1222,19 @@ paths: 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-oaiMeta: name: Create embeddings group: embeddings @@ -1251,6 +1330,20 @@ paths: 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-oaiMeta: name: Create speech group: audio @@ -1328,6 +1421,20 @@ paths: 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-oaiMeta: name: Create transcription group: audio @@ -1538,6 +1645,20 @@ paths: 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-oaiMeta: name: Create translation group: audio @@ -1607,6 +1728,20 @@ paths: 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-oaiMeta: name: List files group: files @@ -1684,6 +1819,20 @@ paths: 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-oaiMeta: name: Upload file group: files @@ -1756,6 +1905,20 @@ paths: 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-oaiMeta: name: Delete file group: files @@ -1816,6 +1979,20 @@ paths: 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-oaiMeta: name: Retrieve file group: files @@ -1879,6 +2056,20 @@ paths: 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-oaiMeta: name: Retrieve file content group: files @@ -1934,6 +2125,20 @@ paths: 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-oaiMeta: name: Create fine-tuning job group: fine-tuning @@ -2184,6 +2389,20 @@ paths: 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-oaiMeta: name: List fine-tuning jobs group: fine-tuning @@ -2262,6 +2481,20 @@ paths: 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-oaiMeta: name: Retrieve fine-tuning job group: fine-tuning @@ -2357,6 +2590,20 @@ paths: 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-oaiMeta: name: List fine-tuning events group: fine-tuning @@ -2444,6 +2691,20 @@ paths: 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-oaiMeta: name: Cancel fine-tuning group: fine-tuning @@ -2529,6 +2790,20 @@ paths: 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-oaiMeta: name: List fine-tuning checkpoints group: fine-tuning @@ -2586,6 +2861,20 @@ paths: application/json: schema: $ref: "#/components/schemas/ListModelsResponse" + + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] + x-oaiMeta: name: List models group: models @@ -2668,6 +2957,20 @@ paths: 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-oaiMeta: name: Retrieve model group: models @@ -2729,6 +3032,20 @@ paths: 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-oaiMeta: name: Delete a fine-tuned model group: models @@ -2789,6 +3106,20 @@ paths: 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-oaiMeta: name: Create moderation group: moderations @@ -2906,6 +3237,20 @@ paths: 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-oaiMeta: name: List assistants group: assistants @@ -3022,6 +3367,20 @@ paths: 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-oaiMeta: name: Create assistant group: assistants @@ -3199,6 +3558,20 @@ paths: 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-oaiMeta: name: Retrieve assistant group: assistants @@ -3283,6 +3656,20 @@ paths: 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-oaiMeta: name: Modify assistant group: assistants @@ -3385,6 +3772,20 @@ paths: 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-oaiMeta: name: Delete assistant group: assistants @@ -3448,6 +3849,20 @@ paths: 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-oaiMeta: name: Create thread group: threads @@ -3590,6 +4005,20 @@ paths: 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-oaiMeta: name: Retrieve thread group: threads @@ -3667,6 +4096,20 @@ paths: 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-oaiMeta: name: Modify thread group: threads @@ -3752,6 +4195,20 @@ paths: 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-oaiMeta: name: Delete thread group: threads @@ -3847,6 +4304,20 @@ paths: 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-oaiMeta: name: List messages group: threads @@ -3961,6 +4432,20 @@ paths: 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-oaiMeta: name: Create message group: threads @@ -4058,6 +4543,20 @@ paths: 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-oaiMeta: name: Retrieve message group: threads @@ -4154,6 +4653,20 @@ paths: 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-oaiMeta: name: Modify message group: threads @@ -4258,6 +4771,20 @@ paths: 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-oaiMeta: name: Delete message group: threads @@ -4326,6 +4853,20 @@ paths: 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-oaiMeta: name: Create thread and run group: threads @@ -4748,6 +5289,20 @@ paths: 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-oaiMeta: name: List runs group: threads @@ -4912,6 +5467,20 @@ paths: 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 @@ -5286,6 +5855,20 @@ paths: 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-oaiMeta: name: Retrieve run group: threads @@ -5401,6 +5984,20 @@ paths: 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-oaiMeta: name: Modify run group: threads @@ -5541,6 +6138,20 @@ paths: 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-oaiMeta: name: Submit tool outputs to run group: threads @@ -5807,6 +6418,20 @@ paths: 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-oaiMeta: name: Cancel a run group: threads @@ -5937,6 +6562,20 @@ paths: 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-oaiMeta: name: List run steps group: threads @@ -6049,6 +6688,20 @@ paths: 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-oaiMeta: name: Retrieve run step group: threads @@ -6161,6 +6814,20 @@ paths: 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-oaiMeta: name: List vector stores group: vector_stores @@ -6253,6 +6920,20 @@ paths: 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-oaiMeta: name: Create vector store group: vector_stores @@ -6333,6 +7014,20 @@ paths: 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-oaiMeta: name: Retrieve vector store group: vector_stores @@ -6405,6 +7100,20 @@ paths: 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-oaiMeta: name: Modify vector store group: vector_stores @@ -6488,6 +7197,20 @@ paths: 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-oaiMeta: name: Delete vector store group: vector_stores @@ -6587,6 +7310,20 @@ paths: 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-oaiMeta: name: List vector store files group: vector_stores @@ -6676,6 +7413,20 @@ paths: 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-oaiMeta: name: Create vector store file group: vector_stores @@ -6763,6 +7514,20 @@ paths: 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-oaiMeta: name: Retrieve vector store file group: vector_stores @@ -6840,6 +7605,20 @@ paths: 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-oaiMeta: name: Delete vector store file group: vector_stores @@ -6919,6 +7698,20 @@ paths: 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-oaiMeta: name: Create vector store file batch group: vector_stores @@ -7011,6 +7804,20 @@ paths: 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-oaiMeta: name: Retrieve vector store file batch group: vector_stores @@ -7096,6 +7903,20 @@ paths: 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-oaiMeta: name: Cancel vector store file batch group: vector_stores @@ -7212,6 +8033,20 @@ paths: 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-oaiMeta: name: List vector store files in a batch group: vector_stores @@ -7328,6 +8163,20 @@ paths: 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-oaiMeta: name: Create batch group: batch @@ -7432,6 +8281,20 @@ paths: 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-oaiMeta: name: List batch group: batch @@ -7529,6 +8392,20 @@ paths: 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-oaiMeta: name: Retrieve batch group: batch @@ -7615,6 +8492,20 @@ paths: 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-oaiMeta: name: Cancel batch group: batch @@ -11111,14 +12002,29 @@ paths: components: securitySchemes: - ApiKeyAuth: + Portkey-Key: type: apiKey in: header name: x-portkey-api-key - VirtualKeyAuth: + 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: @@ -18350,7 +19256,7 @@ components: example: config-abc security: - - ApiKeyAuth: [] + - Portkey-Key: [] x-oaiMeta: navigationGroups: From babb356129ef147b1ed188163940b1752481b52c Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Tue, 15 Oct 2024 11:26:34 +0530 Subject: [PATCH 054/124] feat: custom logger endpoint --- openapi.yaml | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 75c90cad..620e5947 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -40,7 +40,7 @@ tags: - name: Feedback description: Send and Update any feedback. - name: Logs - description: Send a new log to Portkey. + description: Custom Logger to add external logs to Portkey. - name: Prompts description: Given a prompt ID saved on Portkey, return a response or render the prompt data. - name: Virtual-keys @@ -10067,7 +10067,25 @@ paths: '200': description: OK - + /logs: + post: + summary: Submit 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 /logs/exports/{exportId}: get: @@ -18883,6 +18901,56 @@ components: items: type: object $ref: '#/components/schemas/WorkspaceMember' + + 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: From ede2fbaa7fc4e5f16f3d09d4034aa3da0240ff65 Mon Sep 17 00:00:00 2001 From: sk-portkey <163991861+sk-portkey@users.noreply.github.com> Date: Tue, 15 Oct 2024 11:32:41 +0530 Subject: [PATCH 055/124] Revert "feat: custom logger endpoint" --- openapi.yaml | 72 ++-------------------------------------------------- 1 file changed, 2 insertions(+), 70 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 620e5947..75c90cad 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -40,7 +40,7 @@ tags: - name: Feedback description: Send and Update any feedback. - name: Logs - description: Custom Logger to add external logs to Portkey. + 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 @@ -10067,25 +10067,7 @@ paths: '200': description: OK - /logs: - post: - summary: Submit 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 + /logs/exports/{exportId}: get: @@ -18901,56 +18883,6 @@ components: items: type: object $ref: '#/components/schemas/WorkspaceMember' - - 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: From c6f6cdf7b62a0bc7a16395a8274fba36c4d138a6 Mon Sep 17 00:00:00 2001 From: sk-portkey <163991861+sk-portkey@users.noreply.github.com> Date: Tue, 15 Oct 2024 11:40:45 +0530 Subject: [PATCH 056/124] Revert "Revert "feat: custom logger endpoint"" --- openapi.yaml | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 75c90cad..620e5947 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -40,7 +40,7 @@ tags: - name: Feedback description: Send and Update any feedback. - name: Logs - description: Send a new log to Portkey. + description: Custom Logger to add external logs to Portkey. - name: Prompts description: Given a prompt ID saved on Portkey, return a response or render the prompt data. - name: Virtual-keys @@ -10067,7 +10067,25 @@ paths: '200': description: OK - + /logs: + post: + summary: Submit 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 /logs/exports/{exportId}: get: @@ -18883,6 +18901,56 @@ components: items: type: object $ref: '#/components/schemas/WorkspaceMember' + + 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: From f35f4a7af25bca75ce59c52b8067147d481d3852 Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Sat, 19 Oct 2024 12:14:25 +0530 Subject: [PATCH 057/124] make one change for chat api --- openapi.yaml | 705 ++++----------------------------------------------- tags | 52 ++++ 2 files changed, 105 insertions(+), 652 deletions(-) create mode 100644 tags diff --git a/openapi.yaml b/openapi.yaml index 620e5947..7fa0187f 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -66,7 +66,6 @@ tags: - name: Analytics > Groups description: Get grouped metrics for the selected time bucket. -x-codeSamples: true 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 @@ -103,661 +102,63 @@ paths: Provider-Name: [] Custom-Host: [] - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -d '{ - "model": "VAR_model_id", - "messages": [ - { - "role": "system", - "content": "You are a helpful assistant." - }, - { - "role": "user", - "content": "Hello!" - } - ] - }' - python: | - from portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) - - 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 Portkey from 'portkey-ai'; - - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); - - async function main() { - const completion = await client.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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_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 portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) - - 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 Portkey from 'portkey-ai'; - - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); - - async function main() { - const response = await 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", - }, - ], - }, - ], - }); - console.log(response.choices[0]); - } - main(); - response: &chat_completion_image_example | + x-code-samples: + - lang: curl + 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": "VAR_model_id", + "messages": [ { - "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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -d '{ - "model": "VAR_model_id", - "messages": [ - { - "role": "system", - "content": "You are a helpful assistant." - }, - { - "role": "user", - "content": "Hello!" - } - ], - "stream": true - }' - python: | - from portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) - - 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 Portkey from 'portkey-ai'; - - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); - - async function main() { - const completion = await client.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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_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 portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) - - 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 Portkey from 'portkey-ai'; - - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); - - 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 client.chat.completions.create({ - model: "gpt-4-turbo", - messages: messages, - tools: tools, - tool_choice: "auto", - }); - - console.log(response); - } - - main(); - response: &chat_completion_function_example | + "role": "system", + "content": "You are a helpful assistant." + }, { - "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 - } + "role": "user", + "content": "Hello!" } - - title: Logprobs - request: - curl: | - 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": "VAR_model_id", - "messages": [ - { - "role": "user", - "content": "Hello!" - } - ], - "logprobs": true, - "top_logprobs": 2 - }' - python: | - from portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) - - 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 Portkey from 'portkey-ai'; - - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); - - async function main() { - const completion = await client.chat.completions.create({ - messages: [{ role: "user", content: "Hello!" }], - model: "VAR_model_id", - logprobs: true, - top_logprobs: 2, - }); - - console.log(completion.choices[0]); - } + ] + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + 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) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const completion = await client.chat.completions.create({ + messages: [{ role: "system", content: "You are a helpful assistant." }], + model: "VAR_model_id", + }); + + console.log(completion.choices[0]); + } - main(); - response: | - { - "id": "chatcmpl-123", - "object": "chat.completion", - "created": 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 - } + main(); /completions: post: 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 From 34618e7e2f25dfd227f780f5df7ce9d5629d2e57 Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Mon, 21 Oct 2024 12:03:25 +0530 Subject: [PATCH 058/124] showing code snippets --- openapi.yaml | 1556 +++++++++++++++++++------------------------------- 1 file changed, 590 insertions(+), 966 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 7fa0187f..3c670d29 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1,4 +1,4 @@ -openapi: 3.1.0 +openapi: 3.0.0 info: title: Portkey API description: The Portkey REST API. Please see https://portkey.ai/docs/api-reference for more details. @@ -110,7 +110,7 @@ paths: -H "x-portkey-api-key: $PORTKEY_API_KEY" \ -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -d '{ - "model": "VAR_model_id", + "model": "gpt-4o", "messages": [ { "role": "system", @@ -126,36 +126,36 @@ paths: source: | from portkey_ai import Portkey - client = Portkey( + portkey = Portkey( api_key = "PORTKEY_API_KEY", virtual_key = "PROVIDER_VIRTUAL_KEY" ) - completion = client.chat.completions.create( - model="VAR_model_id", + response = portkey.chat.completions.create( + model="gpt-4o", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"} ] ) - print(completion.choices[0].message) + print(response.choices[0].message) - lang: javascript source: | import Portkey from 'portkey-ai'; - const client = new Portkey({ + const portkey = new Portkey({ apiKey: 'PORTKEY_API_KEY', virtualKey: 'PROVIDER_VIRTUAL_KEY' }); async function main() { - const completion = await client.chat.completions.create({ + const response = await client.chat.completions.create({ messages: [{ role: "system", content: "You are a helpful assistant." }], - model: "VAR_model_id", + model: "gpt-4o", }); - console.log(completion.choices[0]); + console.log(response.choices[0]); } main(); @@ -192,146 +192,57 @@ paths: Provider-Name: [] Custom-Host: [] - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -d '{ - "model": "VAR_model_id", - "prompt": "Say this is a test", - "max_tokens": 7, - "temperature": 0 - }' - python: | - from portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) - - client.completions.create( - model="VAR_model_id", - prompt="Say this is a test", - max_tokens=7, - temperature=0 - ) - node.js: |- - import Portkey from 'portkey-ai'; - - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + x-code-samples: + - lang: curl + 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 + source: | + from portkey_ai import Portkey - async function main() { - const completion = await client.completions.create({ - model: "VAR_model_id", - prompt: "Say this is a test.", - max_tokens: 7, - temperature: 0, - }); + portkey = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -d '{ - "model": "VAR_model_id", - "prompt": "Say this is a test", - "max_tokens": 7, - "temperature": 0, - "stream": true - }' - python: | - from portkey_ai import Portkey + response = portkey.completions.create( + model="gpt-3.5-turbo-instruct", + prompt="Say this is a test", + max_tokens=7, + temperature=0 + ) - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + print(response) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - 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 Portkey from 'portkey-ai'; + const portkey = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - const client = 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, + }); - async function main() { - const stream = await client.completions.create({ - model: "VAR_model_id", - prompt: "Say this is a test.", - stream: true, - }); + console.log(response); + } - 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", - } + main(); /images/generations: post: @@ -365,63 +276,49 @@ paths: Provider-Name: [] Custom-Host: [] - 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 "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" - }' - python: | - from portkey_ai import Portkey + x-code-samples: + - lang: curl + 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 + source: | + from portkey_ai import Portkey - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + 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" - ) - node.js: |- - import Portkey from 'portkey-ai'; + client.images.generate( + model="dall-e-3", + prompt="A cute baby sea otter", + n=1, + size="1024x1024" + ) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + 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" }); + async function main() { + const image = await client.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://..." - } - ] - } + console.log(image.data); + } + main(); /images/edits: post: @@ -455,67 +352,54 @@ paths: Provider-Name: [] Custom-Host: [] - 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 "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" - python: | - from portkey_ai import Portkey + x-code-samples: + - lang: curl + 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 + source: | + from portkey_ai import Portkey - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + 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" - ) - node.js: |- - import fs from "fs"; - import Portkey from 'portkey-ai'; + 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 + source: | + import fs from "fs"; + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + 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", - }); + 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(); - console.log(image.data); - } - main(); - response: | - { - "created": 1589478378, - "data": [ - { - "url": "https://..." - }, - { - "url": "https://..." - } - ] - } /images/variations: post: operationId: createImageVariation @@ -548,61 +432,47 @@ paths: Provider-Name: [] Custom-Host: [] - 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 "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" - python: | - from portkey_ai import Portkey + x-code-samples: + - lang: curl + 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 + source: | + from portkey_ai import Portkey - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + 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" - ) - node.js: |- - import fs from "fs"; - import Portkey from 'portkey-ai'; + response = client.images.create_variation( + image=open("image_edit_original.png", "rb"), + n=2, + size="1024x1024" + ) + - lang: javascript + source: | + import fs from "fs"; + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + 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"), - }); + async function main() { + const image = await client.images.createVariation({ + image: fs.createReadStream("otter.png"), + }); - console.log(image.data); - } - main(); - response: | - { - "created": 1589478378, - "data": [ - { - "url": "https://..." - }, - { - "url": "https://..." - } - ] - } + console.log(image.data); + } + main(); /embeddings: post: @@ -636,75 +506,52 @@ paths: Provider-Name: [] Custom-Host: [] - 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 "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" - }' - python: | - from portkey_ai import Portkey + x-code-samples: + - lang: curl + 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 + source: | + from portkey_ai import Portkey - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + 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" - ) - node.js: |- - import Portkey from 'portkey-ai'; + client.embeddings.create( + model="text-embedding-ada-002", + input="The food was delicious and the waiter...", + encoding_format="float" + ) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + 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", - }); + 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); - } + 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 - } - } + main(); /audio/speech: post: @@ -745,62 +592,61 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: - name: Create speech - group: audio - returns: The audio file content. - examples: - request: - curl: | - 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 - python: | - from pathlib import Path - from portkey_ai import Portkey + x-code-samples: + - lang: curl + 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 + source: | + from pathlib import Path + from portkey_ai import Portkey - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + 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) - node: | - import fs from "fs"; - import path from "path"; - import Portkey from 'portkey-ai'; + 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 + 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 client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - const speechFile = path.resolve("./speech.mp3"); + 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(); - 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: post: operationId: createTranscription @@ -836,195 +682,49 @@ paths: Provider-Name: [] Custom-Host: [] - 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 "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" - python: | - 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 - ) - node: | - 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(); - 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 "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 "timestamp_granularities[]=word" \ - -F model="whisper-1" \ - -F response_format="verbose_json" - python: | - 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( - file=audio_file, - model="whisper-1", - response_format="verbose_json", - timestamp_granularities=["word"] - ) - - print(transcript.words) - node: | - 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", - 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 "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 "timestamp_granularities[]=segment" \ - -F model="whisper-1" \ - -F response_format="verbose_json" - python: | - from portkey_ai import Portkey + x-code-samples: + - lang: curl + 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 + source: | + from portkey_ai import Portkey - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - audio_file = open("speech.mp3", "rb") - transcript = client.audio.transcriptions.create( - file=audio_file, - model="whisper-1", - response_format="verbose_json", - timestamp_granularities=["segment"] - ) + audio_file = open("speech.mp3", "rb") + transcript = client.audio.transcriptions.create( + model="whisper-1", + file=audio_file + ) + - lang: javascript + source: | + import fs from "fs"; + import Portkey from 'portkey-ai'; - print(transcript.words) - node: | - import fs from "fs"; - import Portkey from 'portkey-ai'; + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - 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", + }); - async function main() { - const transcription = await client.audio.transcriptions.create({ - file: fs.createReadStream("audio.mp3"), - model: "whisper-1", - response_format: "verbose_json", - timestamp_granularities: ["segment"] - }); + console.log(transcription.text); + } + main(); - 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 @@ -1060,54 +760,48 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: - name: Create translation - group: audio - returns: The translated text. - examples: - request: - curl: | - 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" - python: | - from portkey_ai import Portkey + x-code-samples: + - lang: curl + 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 + source: | + from portkey_ai import Portkey - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + 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 - ) - node: | - import fs from "fs"; - import Portkey from 'portkey-ai'; + audio_file = open("speech.mp3", "rb") + transcript = client.audio.translations.create( + model="whisper-1", + file=audio_file + ) + - lang: javascript + source: | + import fs from "fs"; + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + 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", - }); + async function main() { + const translation = await client.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?" - } + console.log(translation.text); + } + main(); /files: get: @@ -1143,64 +837,41 @@ paths: Provider-Name: [] Custom-Host: [] - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - python: | - from portkey_ai import Portkey + 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 = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - client.files.list() - node.js: |- - import Portkey from 'portkey-ai'; + client.files.list() + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - async function main() { - const list = await client.files.list(); + async function main() { + const list = await client.files.list(); - for await (const file of list) { - console.log(file); - } - } + for await (const file of list) { + console.log(file); + } + } + + main(); - 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: @@ -1234,58 +905,48 @@ paths: Provider-Name: [] Custom-Host: [] - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -F purpose="fine-tune" \ - -F file="@mydata.jsonl" - python: | - from portkey_ai import Portkey + 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 = 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'; - client.files.create( - file=open("mydata.jsonl", "rb"), - purpose="fine-tune" - ) - node.js: |- - import fs from "fs"; - import Portkey from 'portkey-ai'; + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - 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", + }); - async function main() { - const file = await client.files.create({ - file: fs.createReadStream("mydata.jsonl"), - purpose: "fine-tune", - }); + console.log(file); + } - console.log(file); - } + main(); - main(); - response: | - { - "id": "file-abc123", - "object": "file", - "bytes": 120000, - "created_at": 1677610602, - "filename": "mydata.jsonl", - "purpose": "fine-tune", - } /files/{file_id}: delete: operationId: deleteFile @@ -1320,47 +981,40 @@ paths: Provider-Name: [] Custom-Host: [] - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - python: | - from portkey_ai import Portkey + 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 = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - client.files.delete("file-abc123") - node.js: |- - import Portkey from 'portkey-ai'; + 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' - }); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - async function main() { - const file = await client.files.del("file-abc123"); + async function main() { + const file = await client.files.del("file-abc123"); - console.log(file); - } + console.log(file); + } + + main(); - main(); - response: | - { - "id": "file-abc123", - "object": "file", - "deleted": true - } get: operationId: retrieveFile tags: @@ -1394,49 +1048,39 @@ paths: Provider-Name: [] Custom-Host: [] - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" - python: | - from portkey_ai import Portkey + 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 = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - client.files.retrieve("file-abc123") - node.js: |- - import Portkey from 'portkey-ai'; + 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' - }); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - async function main() { - const file = await client.files.retrieve("file-abc123"); + async function main() { + const file = await client.files.retrieve("file-abc123"); - console.log(file); - } + console.log(file); + } + + main(); - 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 @@ -1471,40 +1115,38 @@ paths: Provider-Name: [] Custom-Host: [] - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" > file.jsonl - python: | - from portkey_ai import Portkey + 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" - ) + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - content = client.files.content("file-abc123") - node.js: | - import Portkey from 'portkey-ai'; + 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' - }); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - async function main() { - const file = await client.files.content("file-abc123"); + async function main() { + const file = await client.files.content("file-abc123"); - console.log(file); - } + console.log(file); + } - main(); + main(); /fine_tuning/jobs: post: @@ -1540,7 +1182,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Create fine-tuning job group: fine-tuning returns: A [fine-tuning.job](https://platform.openai.com/docs/api-reference/fine-tuning/object) object. @@ -1804,7 +1446,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: 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. @@ -1896,7 +1538,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: 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. @@ -2005,7 +1647,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: List fine-tuning events group: fine-tuning returns: A list of fine-tuning event objects. @@ -2106,7 +1748,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Cancel fine-tuning group: fine-tuning returns: The cancelled [fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning/object) object. @@ -2205,7 +1847,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: 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. @@ -2276,7 +1918,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: List models group: models returns: A list of [model](https://platform.openai.com/docs/api-reference/models/object) objects. @@ -2372,7 +2014,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Retrieve model group: models returns: The [model](https://platform.openai.com/docs/api-reference/models/object) object matching the specified ID. @@ -2447,7 +2089,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Delete a fine-tuned model group: models returns: Deletion status. @@ -2521,7 +2163,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Create moderation group: moderations returns: A [moderation](https://platform.openai.com/docs/api-reference/moderations/object) object. @@ -2652,7 +2294,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: List assistants group: assistants beta: true @@ -2782,7 +2424,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Create assistant group: assistants beta: true @@ -2973,7 +2615,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Retrieve assistant group: assistants beta: true @@ -3071,7 +2713,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Modify assistant group: assistants beta: true @@ -3187,7 +2829,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Delete assistant group: assistants beta: true @@ -3264,7 +2906,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Create thread group: threads beta: true @@ -3420,7 +3062,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Retrieve thread group: threads beta: true @@ -3511,7 +3153,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Modify thread group: threads beta: true @@ -3610,7 +3252,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Delete thread group: threads beta: true @@ -3719,7 +3361,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: List messages group: threads beta: true @@ -3847,7 +3489,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Create message group: threads beta: true @@ -3958,7 +3600,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Retrieve message group: threads beta: true @@ -4068,7 +3710,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Modify message group: threads beta: true @@ -4186,7 +3828,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Delete message group: threads beta: true @@ -4268,7 +3910,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Create thread and run group: threads beta: true @@ -4704,7 +4346,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: List runs group: threads beta: true @@ -4889,7 +4531,7 @@ paths: application/json: schema: $ref: "#/components/schemas/RunObject" - x-oaiMeta: + x-code-samples: name: Create run group: threads beta: true @@ -5270,7 +4912,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Retrieve run group: threads beta: true @@ -5399,7 +5041,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Modify run group: threads beta: true @@ -5553,7 +5195,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Submit tool outputs to run group: threads beta: true @@ -5833,7 +5475,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Cancel a run group: threads beta: true @@ -5977,7 +5619,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: List run steps group: threads beta: true @@ -6103,7 +5745,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Retrieve run step group: threads beta: true @@ -6229,7 +5871,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: List vector stores group: vector_stores beta: true @@ -6335,7 +5977,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Create vector store group: vector_stores beta: true @@ -6429,7 +6071,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Retrieve vector store group: vector_stores beta: true @@ -6515,7 +6157,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Modify vector store group: vector_stores beta: true @@ -6612,7 +6254,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Delete vector store group: vector_stores beta: true @@ -6725,7 +6367,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: List vector store files group: vector_stores beta: true @@ -6828,7 +6470,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Create vector store file group: vector_stores beta: true @@ -6929,7 +6571,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Retrieve vector store file group: vector_stores beta: true @@ -7020,7 +6662,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Delete vector store file group: vector_stores beta: true @@ -7113,7 +6755,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Create vector store file batch group: vector_stores beta: true @@ -7219,7 +6861,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Retrieve vector store file batch group: vector_stores beta: true @@ -7318,7 +6960,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Cancel vector store file batch group: vector_stores beta: true @@ -7448,7 +7090,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: List vector store files in a batch group: vector_stores beta: true @@ -7578,7 +7220,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Create batch group: batch returns: The created [Batch](https://platform.openai.com/docs/api-reference/batch/object) object. @@ -7696,7 +7338,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: List batch group: batch returns: A list of paginated [Batch](https://platform.openai.com/docs/api-reference/batch/object) objects. @@ -7807,7 +7449,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Retrieve batch group: batch returns: The [Batch](https://platform.openai.com/docs/api-reference/batch/object) object matching the specified ID. @@ -7907,7 +7549,7 @@ paths: Provider-Name: [] Custom-Host: [] - x-oaiMeta: + x-code-samples: name: Cancel batch group: batch returns: The [Batch](https://platform.openai.com/docs/api-reference/batch/object) object matching the specified ID. @@ -11953,7 +11595,7 @@ components: - created - model - choices - x-oaiMeta: + x-code-samples: name: The completion object legacy: true example: | @@ -12561,7 +12203,7 @@ components: 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: + x-code-samples: beta: true stop: description: | @@ -12722,10 +12364,7 @@ components: - id - model - object - x-oaiMeta: - name: The chat completion object - group: chat - example: *chat_completion_example + CreateChatCompletionFunctionResponse: type: object @@ -12781,10 +12420,7 @@ components: - id - model - object - x-oaiMeta: - name: The chat completion object - group: chat - example: *chat_completion_function_example + ChatCompletionTokenLogprob: type: object @@ -12914,18 +12550,12 @@ components: - 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 @@ -13008,7 +12638,7 @@ components: revised_prompt: type: string description: The prompt that was used to generate the image, if there was any revision to the prompt. - x-oaiMeta: + x-code-samples: name: The image object example: | { @@ -13241,7 +12871,7 @@ components: - id - model - results - x-oaiMeta: + x-code-samples: name: The moderation object example: *moderation_example @@ -13655,10 +13285,7 @@ components: description: The transcribed text. required: - text - x-oaiMeta: - name: The transcription object (JSON) - group: audio - example: *basic_transcription_response_example + TranscriptionSegment: type: object @@ -13753,10 +13380,7 @@ components: 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 @@ -13881,7 +13505,7 @@ components: - object - created - owned_by - x-oaiMeta: + x-code-samples: name: The model object example: *retrieve_model_response @@ -13935,7 +13559,7 @@ components: - filename - purpose - status - x-oaiMeta: + x-code-samples: name: The file object example: | { @@ -13968,7 +13592,7 @@ components: - index - object - embedding - x-oaiMeta: + x-code-samples: name: The embedding object example: | { @@ -14110,7 +13734,7 @@ components: - training_file - validation_file - seed - x-oaiMeta: + x-code-samples: name: The fine-tuning job object example: *fine_tuning_example @@ -14181,7 +13805,7 @@ components: - created_at - level - message - x-oaiMeta: + x-code-samples: name: The fine-tuning job event object example: | { @@ -14243,7 +13867,7 @@ components: - metrics - object - step_number - x-oaiMeta: + x-code-samples: name: The fine-tuning job checkpoint object example: | { @@ -14286,7 +13910,7 @@ components: maxItems: 128 items: $ref: "#/components/schemas/ChatCompletionFunctions" - x-oaiMeta: + 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"]}}]} @@ -14301,7 +13925,7 @@ components: completion: type: string description: The desired completion for this training example. - x-oaiMeta: + x-code-samples: name: Training format for completions models example: | {"prompt": "What is the answer to 2+2", "completion": "4"} @@ -14503,7 +14127,7 @@ components: - instructions - tools - metadata - x-oaiMeta: + x-code-samples: name: The assistant object beta: true example: *create_assistants_example @@ -14817,7 +14441,7 @@ components: - first_id - last_id - has_more - x-oaiMeta: + x-code-samples: name: List assistants response object group: chat example: *list_assistants_example @@ -15120,7 +14744,7 @@ components: - tool_choice - parallel_tool_calls - response_format - x-oaiMeta: + x-code-samples: name: The run object beta: true example: | @@ -15549,7 +15173,7 @@ components: - created_at - tool_resources - metadata - x-oaiMeta: + x-code-samples: name: The thread object beta: true example: | @@ -15856,7 +15480,7 @@ components: - run_id - attachments - metadata - x-oaiMeta: + x-code-samples: name: The message object beta: true example: | @@ -15915,7 +15539,7 @@ components: - id - object - delta - x-oaiMeta: + x-code-samples: name: The message delta object beta: true example: | @@ -16451,7 +16075,7 @@ components: - completed_at - metadata - usage - x-oaiMeta: + x-code-samples: name: The run step object beta: true example: *run_step_object_example @@ -16484,7 +16108,7 @@ components: - id - object - delta - x-oaiMeta: + x-code-samples: name: The run step delta object beta: true example: | @@ -16963,7 +16587,7 @@ components: - name - file_counts - metadata - x-oaiMeta: + x-code-samples: name: The vector store object beta: true example: | @@ -17132,7 +16756,7 @@ components: - vector_store_id - status - last_error - x-oaiMeta: + x-code-samples: name: The vector store file object beta: true example: | @@ -17341,7 +16965,7 @@ components: - vector_store_id - status - file_counts - x-oaiMeta: + x-code-samples: name: The vector store files batch object beta: true example: | @@ -17404,7 +17028,7 @@ components: - $ref: "#/components/schemas/MessageStreamEvent" - $ref: "#/components/schemas/ErrorEvent" - $ref: "#/components/schemas/DoneEvent" - x-oaiMeta: + x-code-samples: name: Assistant stream events beta: true @@ -17421,7 +17045,7 @@ components: - event - data description: Occurs when a new [thread](https://platform.openai.com/docs/api-reference/threads/object) is created. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [thread](https://platform.openai.com/docs/api-reference/threads/object)" RunStreamEvent: @@ -17437,7 +17061,7 @@ components: - event - data description: Occurs when a new [run](https://platform.openai.com/docs/api-reference/runs/object) is created. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" - type: object properties: @@ -17450,7 +17074,7 @@ components: - event - data description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `queued` status. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" - type: object properties: @@ -17463,7 +17087,7 @@ components: - event - data description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to an `in_progress` status. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" - type: object properties: @@ -17476,7 +17100,7 @@ components: - event - data description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `requires_action` status. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" - type: object properties: @@ -17489,7 +17113,7 @@ components: - event - data description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) is completed. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" - type: object properties: @@ -17502,7 +17126,7 @@ components: - event - data description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) ends with status `incomplete`. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" - type: object properties: @@ -17515,7 +17139,7 @@ components: - event - data description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) fails. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" - type: object properties: @@ -17528,7 +17152,7 @@ components: - event - data description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `cancelling` status. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" - type: object properties: @@ -17541,7 +17165,7 @@ components: - event - data description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) is cancelled. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" - type: object properties: @@ -17554,7 +17178,7 @@ components: - event - data description: Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) expires. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [run](https://platform.openai.com/docs/api-reference/runs/object)" RunStepStreamEvent: @@ -17570,7 +17194,7 @@ components: - event - data description: Occurs when a [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is created. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" - type: object properties: @@ -17583,7 +17207,7 @@ components: - 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: + x-code-samples: dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" - type: object properties: @@ -17596,7 +17220,7 @@ components: - 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: + 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: @@ -17609,7 +17233,7 @@ components: - event - data description: Occurs when a [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is completed. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" - type: object properties: @@ -17622,7 +17246,7 @@ components: - event - data description: Occurs when a [run step](https://platform.openai.com/docs/api-reference/runs/step-object) fails. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" - type: object properties: @@ -17635,7 +17259,7 @@ components: - event - data description: Occurs when a [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is cancelled. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" - type: object properties: @@ -17648,7 +17272,7 @@ components: - event - data description: Occurs when a [run step](https://platform.openai.com/docs/api-reference/runs/step-object) expires. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [run step](https://platform.openai.com/docs/api-reference/runs/step-object)" MessageStreamEvent: @@ -17664,7 +17288,7 @@ components: - event - data description: Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) is created. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [message](https://platform.openai.com/docs/api-reference/messages/object)" - type: object properties: @@ -17677,7 +17301,7 @@ components: - event - data description: Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) moves to an `in_progress` state. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [message](https://platform.openai.com/docs/api-reference/messages/object)" - type: object properties: @@ -17690,7 +17314,7 @@ components: - event - data description: Occurs when parts of a [Message](https://platform.openai.com/docs/api-reference/messages/object) are being streamed. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [message delta](https://platform.openai.com/docs/api-reference/assistants-streaming/message-delta-object)" - type: object properties: @@ -17703,7 +17327,7 @@ components: - event - data description: Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) is completed. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [message](https://platform.openai.com/docs/api-reference/messages/object)" - type: object properties: @@ -17716,7 +17340,7 @@ components: - event - data description: Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) ends before it is completed. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is a [message](https://platform.openai.com/docs/api-reference/messages/object)" ErrorEvent: @@ -17731,7 +17355,7 @@ components: - 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: + x-code-samples: dataDescription: "`data` is an [error](https://platform.openai.com/docs/guides/error-codes/api-errors)" DoneEvent: @@ -17747,7 +17371,7 @@ components: - event - data description: Occurs when a stream ends. - x-oaiMeta: + x-code-samples: dataDescription: "`data` is `[DONE]`" Batch: @@ -17869,7 +17493,7 @@ components: - completion_window - status - created_at - x-oaiMeta: + x-code-samples: name: The batch object example: *batch_object @@ -17887,7 +17511,7 @@ components: 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: + 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?"}]}} @@ -17926,7 +17550,7 @@ components: message: type: string description: A human-readable error message. - x-oaiMeta: + 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} @@ -18727,7 +18351,7 @@ components: security: - Portkey-Key: [] -x-oaiMeta: +x-code-samples: navigationGroups: - id: endpoints title: Endpoints From b62e079df9b6b49f975b9ae8aad839581fae1da3 Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Mon, 21 Oct 2024 12:39:34 +0530 Subject: [PATCH 059/124] more code samples --- openapi.yaml | 1342 +++++++++++++++----------------------------------- 1 file changed, 409 insertions(+), 933 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 3c670d29..128a1ddb 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1183,228 +1183,48 @@ paths: Custom-Host: [] x-code-samples: - 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 "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" - }' - python: | - 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" - ) - node.js: | - 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(); - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -d '{ - "training_file": "file-abc123", - "model": "gpt-3.5-turbo", - "hyperparameters": { - "n_epochs": 2 - } - }' - python: | - 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", - hyperparameters={ - "n_epochs":2 - } - ) - node.js: | - 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", - model: "gpt-3.5-turbo", - hyperparameters: { n_epochs: 2 } - }); - - console.log(fineTune); - } + - lang: curl + 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 + source: | + from portkey_ai import Portkey - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -d '{ - "training_file": "file-abc123", - "validation_file": "file-abc123", - "model": "gpt-3.5-turbo" - }' - python: | - from portkey_ai import Portkey + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - 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 + source: | + import Portkey from 'portkey-ai'; - client.fine_tuning.jobs.create( - training_file="file-abc123", - validation_file="file-def456", - model="gpt-3.5-turbo" - ) - node.js: | - import Portkey from 'portkey-ai'; + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - 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" + }); - async function main() { - const fineTune = await client.fineTuning.jobs.create({ - training_file: "file-abc123", - validation_file: "file-abc123" - }); + console.log(fineTune); + } - console.log(fineTune); - } + main(); - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_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: @@ -1447,58 +1267,40 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" - python: | - from portkey_ai import Portkey + - lang: curl + 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 + source: | + from portkey_ai import Portkey - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - client.fine_tuning.jobs.list() - node.js: |- - import Portkey from 'portkey-ai'; + client.fine_tuning.jobs.list() + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - async function main() { - const list = await client.fineTuning.jobs.list(); + async function main() { + const list = await client.fineTuning.jobs.list(); - for await (const fineTune of list) { - console.log(fineTune); - } - } + for await (const fineTune of list) { + console.log(fineTune); + } + } + + main(); - 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 @@ -1539,64 +1341,38 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" - python: | - from portkey_ai import Portkey + - lang: curl + 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 + source: | + from portkey_ai import Portkey - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - client.fine_tuning.jobs.retrieve("ftjob-abc123") - node.js: | - import Portkey from 'portkey-ai'; + client.fine_tuning.jobs.retrieve("ftjob-abc123") + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - async function main() { - const fineTune = await client.fineTuning.jobs.retrieve("ftjob-abc123"); + async function main() { + const fineTune = await client.fineTuning.jobs.retrieve("ftjob-abc123"); - console.log(fineTune); - } + console.log(fineTune); + } + + main(); - 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 @@ -1648,69 +1424,43 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" - python: | - from portkey_ai import Portkey + - lang: curl + 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 + source: | + from portkey_ai import Portkey - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + 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 - ) - node.js: |- - import Portkey from 'portkey-ai'; + client.fine_tuning.jobs.list_events( + fine_tuning_job_id="ftjob-abc123", + limit=2 + ) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + 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); + async function main() { + const list = await client.fineTuning.list_events(id="ftjob-abc123", limit=2); - for await (const fineTune of list) { - console.log(fineTune); - } - } + for await (const fineTune of list) { + console.log(fineTune); + } + } + + main(); - 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 @@ -1749,54 +1499,37 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" - python: | - from portkey_ai import Portkey + - lang: curl + 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 + source: | + from portkey_ai import Portkey - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - client.fine_tuning.jobs.cancel("ftjob-abc123") - node.js: |- - import Portkey from 'portkey-ai'; + client.fine_tuning.jobs.cancel("ftjob-abc123") + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - async function main() { - const fineTune = await client.fineTuning.jobs.cancel("ftjob-abc123"); + async function main() { + const fineTune = await client.fineTuning.jobs.cancel("ftjob-abc123"); + + console.log(fineTune); + } + main(); - 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 @@ -1848,48 +1581,17 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_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 - } + - lang: curl + 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: python + source: | + Reach out to us on portkey.wiki/community + - lang: javascript + source: | + Reach out to us on portkey.wiki/community /models: get: @@ -1919,65 +1621,39 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" - python: | - from portkey_ai import Portkey + - lang: curl + source: | + curl https://api.portkey.ai/v1/models \ + -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 = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - client.models.list() - node.js: |- - import Portkey from 'portkey-ai'; + client.models.list() + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - async function main() { - const list = await client.models.list(); + async function main() { + const list = await client.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" + for await (const model of list) { + console.log(model); } + } + main(); + /models/{model}: get: operationId: retrieveModel @@ -2015,46 +1691,38 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - python: | - from portkey_ai import Portkey + - 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 = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - client.models.retrieve("VAR_model_id") - node.js: |- - import Portkey from 'portkey-ai'; + 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' - }); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - async function main() { - const model = await client.models.retrieve("VAR_model_id"); + async function main() { + const model = await client.models.retrieve("VAR_model_id"); - console.log(model); - } + console.log(model); + } + + main(); - main(); - response: &retrieve_model_response | - { - "id": "VAR_model_id", - "object": "model", - "created": 1686935002, - "owned_by": "openai" - } delete: operationId: deleteModel tags: @@ -2090,45 +1758,37 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" - python: | - from portkey_ai import Portkey + - 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 = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - client.models.delete("ft:gpt-3.5-turbo:acemeco:suffix:abc123") - node.js: |- - import Portkey from 'portkey-ai'; + 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' - }); + 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"); + async function main() { + const model = await client.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 - } + console.log(model); + } + main(); /moderations: post: @@ -2147,96 +1807,58 @@ paths: 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: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -d '{ - "input": "I want to kill them." - }' - python: | - 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) - node.js: | - import Portkey from 'portkey-ai'; - - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + schema: + $ref: "#/components/schemas/CreateModerationResponse" - async function main() { - const moderation = await client.moderations.create({ input: "I want to kill them." }); + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] - 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, - } - } - ] - } + x-code-samples: + - lang: curl + 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 + 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 + 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(); /assistants: get: @@ -7221,83 +6843,52 @@ paths: Custom-Host: [] x-code-samples: - 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 "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" - }' - python: | - from portkey_ai import Portkey + - lang: curl + 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 + source: | + from portkey_ai import Portkey - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + 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" - ) - node: | - import Portkey from 'portkey-ai'; + client.batches.create( + input_file_id="file-abc123", + endpoint="/v1/chat/completions", + completion_window="24h" + ) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + 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" - }); + async function main() { + const batch = await client.batches.create({ + input_file_id: "file-abc123", + endpoint: "/v1/chat/completions", + completion_window: "24h" + }); - console.log(batch); - } + console.log(batch); + } + + main(); - 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: @@ -7339,81 +6930,40 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -H "Content-Type: application/json" - python: | - from portkey_ai import Portkey + - lang: curl + 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 + source: | + from portkey_ai import Portkey - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - client.batches.list() - node: | - import Portkey from 'portkey-ai'; + client.batches.list() + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - async function main() { - const list = await client.batches.list(); + async function main() { + const list = await client.batches.list(); - for await (const batch of list) { - console.log(batch); - } - } + 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 - } + main(); /batches/{batch_id}: get: @@ -7450,70 +7000,38 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -H "Content-Type: application/json" \ - python: | - from portkey_ai import Portkey + - lang: curl + 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 + source: | + from portkey_ai import Portkey - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - client.batches.retrieve("batch_abc123") - node: | - import Portkey from 'portkey-ai'; + client.batches.retrieve("batch_abc123") + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - async function main() { - const batch = await client.batches.retrieve("batch_abc123"); + async function main() { + const batch = await client.batches.retrieve("batch_abc123"); - console.log(batch); - } + 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", - } - } + main(); /batches/{batch_id}/cancel: post: @@ -7550,71 +7068,39 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -H "Content-Type: application/json" \ - -X POST - python: | - from portkey_ai import Portkey + - lang: curl + 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 + source: | + from portkey_ai import Portkey - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - client.batches.cancel("batch_abc123") - node: | - import Portkey from 'portkey-ai'; + client.batches.cancel("batch_abc123") + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - async function main() { - const batch = await client.batches.cancel("batch_abc123"); + async function main() { + const batch = await client.batches.cancel("batch_abc123"); - console.log(batch); - } + 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", - } - } + main(); /configs: get: @@ -12871,9 +12357,7 @@ components: - id - model - results - x-code-samples: - name: The moderation object - example: *moderation_example + ListFilesResponse: type: object @@ -13505,9 +12989,6 @@ components: - object - created - owned_by - x-code-samples: - name: The model object - example: *retrieve_model_response OpenAIFile: title: OpenAIFile @@ -13734,9 +13215,7 @@ components: - training_file - validation_file - seed - x-code-samples: - name: The fine-tuning job object - example: *fine_tuning_example + FineTuningIntegration: type: object @@ -17493,9 +16972,6 @@ components: - completion_window - status - created_at - x-code-samples: - name: The batch object - example: *batch_object BatchRequestInput: type: object From a0ffdc873414749ad21c8c923c2a8863f9cc64e9 Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Wed, 23 Oct 2024 12:12:48 +0530 Subject: [PATCH 060/124] Update Virtual Key response structure --- openapi.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 128a1ddb..44f7755f 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -7766,10 +7766,12 @@ paths: schema: type: object properties: - success: - type: boolean - data: - type: object + id: + type: string + slug: + type: string + object: + type: string '401': description: Unauthorized response content: From 1aae310839cb7784b9a48599013d61e86a93fcab Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Thu, 24 Oct 2024 01:16:30 +0530 Subject: [PATCH 061/124] chore: update virtual key spec --- openapi.yaml | 129 +++++++++++++++++++++++---------------------------- 1 file changed, 58 insertions(+), 71 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 128a1ddb..1cdab8fe 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -7469,46 +7469,16 @@ paths: schema: type: object properties: - success: - type: boolean + object: + type: string + enum: [list] + total: + type: integer + description: Total number of virtual keys data: type: array items: - type: object - properties: - name: - type: string - note: - type: string - status: - type: string - created_at: - type: string - format: date-time - slug: - type: string - model_config: - type: object - usage_limits: - $ref: "#/components/schemas/UsageLimits" - provider: - type: string - workspace_id: - type: string - format: uuid - example: - success: true - data: - - - name: "My Virtual Key" - note: "This is my first virtual key's description" - status: "active" - created_at: "2024-05-13T23:17:36.000Z" - slug: "ayush-test-budg-e07aed" - model_config: {} - usage_limits: {"credit_limit": 10,"periodic_reset": "monthly","alert_threshold": 9} - provider: "openai" - workspace_id: "" + $ref: '#/components/schemas/VirtualKeys' '401': description: Unauthorized response content: @@ -7596,6 +7566,8 @@ paths: description: optional, needed when using organisation admin API keys usage_limits: $ref: "#/components/schemas/UsageLimits" + rate_limits: + $ref: "#/components/schemas/RateLimits" examples: generic: value: @@ -7689,30 +7661,7 @@ paths: content: application/json: schema: - type: object - properties: - success: - type: boolean - data: - type: object - properties: - model_config: - type: object - key: - type: string - name: - type: string - usage_limits: - $ref: "#/components/schemas/UsageLimits" - status: - type: string - note: - type: string - created_at: - type: string - format: date-time - provider: - type: string + $ref: "#/components/schemas/VirtualKeys" '401': description: Unauthorized response content: @@ -7765,11 +7714,7 @@ paths: application/json: schema: type: object - properties: - success: - type: boolean - data: - type: object + '401': description: Unauthorized response content: @@ -7806,11 +7751,7 @@ paths: application/json: schema: type: object - properties: - success: - type: boolean - data: - type: object + '401': description: Unauthorized response content: @@ -17117,6 +17058,17 @@ components: additionalProperties: true description: Additional metadata for the feedback. + RateLimits: + type: object + properties: + type: + type: string + enum: ["requests"] + unit: + type: string + enum: ["rpm"] + value: + type: integer UsageLimits: type: object properties: @@ -17139,6 +17091,41 @@ components: periodic_reset: monthly alert_threshold: 8 + 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 + object: + type: string + enum: [virtual-key] + Invite: type: object properties: From c0ac40cbd35802726e6ca1eece725e9b731c3499 Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Thu, 24 Oct 2024 20:19:03 +0530 Subject: [PATCH 062/124] Prompts Completions API spec --- openapi.yaml | 132 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 123 insertions(+), 9 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 44f7755f..5cc2cdfe 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1,4 +1,4 @@ -openapi: 3.0.0 +openapi: 3.1.0 info: title: Portkey API description: The Portkey REST API. Please see https://portkey.ai/docs/api-reference for more details. @@ -19,6 +19,8 @@ tags: 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: Prompts + description: Given a prompt template ID and variables, will run the saved prompt template and 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 @@ -41,8 +43,6 @@ tags: description: Send and Update any feedback. - name: Logs description: Custom Logger to add external logs 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 @@ -244,6 +244,122 @@ paths: main(); + /prompts/{promptId}/completions: + post: + operationId: createPromptCompletion + tags: + - Prompts + summary: Prompts Completions + description: | + Execute your saved prompt templates on Portkey using this API + 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' + 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 + 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' + 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); + /images/generations: post: operationId: createImage @@ -7766,12 +7882,10 @@ paths: schema: type: object properties: - id: - type: string - slug: - type: string - object: - type: string + success: + type: boolean + data: + type: object '401': description: Unauthorized response content: From aceda757322bc680c9576a55ddaf73f3e2dc5671 Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Thu, 24 Oct 2024 20:51:07 +0530 Subject: [PATCH 063/124] Prompts Render API --- openapi.yaml | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index 5cc2cdfe..f32e3a76 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -251,7 +251,7 @@ paths: - Prompts summary: Prompts Completions description: | - Execute your saved prompt templates on Portkey using this API + Execute your saved prompt templates on Portkey parameters: - in: path name: promptId @@ -360,6 +360,104 @@ paths: console.log(completion); + /prompts/{promptId}/render: + 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' + 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 + 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' + 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); + /images/generations: post: operationId: createImage @@ -17940,6 +18038,22 @@ components: type: string example: config-abc + 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" + security: - Portkey-Key: [] From 8f8bc9fc24a9495fd95e45ff4f0ed995fea50c9f Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Thu, 7 Nov 2024 23:33:45 +0530 Subject: [PATCH 064/124] add parameters & fine-tuning description update --- openapi.yaml | 65 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 4 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index f32e3a76..1928601e 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -72,9 +72,20 @@ paths: /chat/completions: post: operationId: createChatCompletion + servers: + - url: https://api.portkey.ai/v1 + - url: http://localhost:8080/v1 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: @@ -1367,8 +1378,8 @@ paths: operationId: createFineTuningJob tags: - Fine-tuning - summary: | - Creates a fine-tuning job which begins the process of creating a new model from a given dataset. + description: | + Creates a fine-tuning job on [OpenAI](https://platform.openai.com/docs/guides/fine-tuning), [AWS Bedrock](https://aws.amazon.com/blogs/aws/customize-models-in-amazon-bedrock-with-your-own-data-using-fine-tuning-and-continued-pre-training/), or [Fireworks](https://docs.fireworks.ai/fine-tuning/fine-tuning-models). requestBody: required: true content: @@ -10966,6 +10977,53 @@ components: type: string description: Comma separated span IDs example: my-unique-span-1,my-unique-span-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](/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 schemas: Error: @@ -12627,8 +12685,7 @@ components: 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). + The name of the model to fine-tune. Choose from supported models by [OpenAI](https://platform.openai.com/docs/guides/fine-tuning#which-models-can-be-fine-tuned), [Bedrock](https://aws.amazon.com/blogs/aws/customize-models-in-amazon-bedrock-with-your-own-data-using-fine-tuning-and-continued-pre-training/), or [Fireworks](https://docs.fireworks.ai/fine-tuning/fine-tuning-models#supported-base-models). example: "gpt-3.5-turbo" anyOf: - type: string From 718a1139c8a9091a593de1b7c6041c561d8b6874 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Mon, 11 Nov 2024 21:56:16 +0530 Subject: [PATCH 065/124] feat: SDK example for log export endpoints --- openapi.yaml | 276 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 275 insertions(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index 1928601e..1bafc2d9 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8859,6 +8859,38 @@ paths: application/json: schema: $ref: "#/components/schemas/ExportItem" + x-code-samples: + - lang: python + source: | + from portkey_ai import Portkey + + # Initialize Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Retrieve specific logs export + res = portkey.logs.exports.retrieve( + export_id="EXPORT_ID" + ) + + # Print the result + print(res) + - lang: javascript + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + }) + + const res= await portkey.logs.exports.retrieve({ + exportId:"EXPORT_ID" + }) + + console.log(res); + + put: tags: - Logs Export @@ -8890,7 +8922,44 @@ paths: application/json: schema: $ref: "#/components/schemas/UpdateExportResponse" + x-code-samples: + - lang: python + source: | + from portkey_ai import Portkey + + # Initialize Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Update logs export + res = portkey.logs.exports.update( + export_id="EXPORT_ID", + workspace_id="WORKSPACE_ID", + filters={ + "time_of_generation_max": "2024-07-25" + } + ) + + # Print the result + print(res) + - lang: javascript + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"/8sziEodbWDg6vUA0oy+G6aOquSA", + }) + + const res = await portkey.logs.exports.update({ + exportId:"7ef9f738-a93a-4bbd-85a8-53fcbffb603c", + workspaceId: "ws-shared-0uwqmn", + filters: { + "time_of_generation_max": "2024-07-25" + } + }) + console.log(res); /logs/exports: get: tags: @@ -8908,6 +8977,37 @@ paths: application/json: schema: $ref: "#/components/schemas/ExportListResponse" + x-code-samples: + - lang: python + source: | + from portkey_ai import Portkey + + # Initialize Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # List logs export + res = portkey.logs.exports.list( + workspace_id="WORKSPACE_ID" + ) + + # Print the result + print(res) + - lang: javascript + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + }) + + const res = await portkey.logs.exports.list({ + workspaceId:"WORKSPACE_ID" + }) + + console.log(res); + post: tags: - Logs Export @@ -8934,6 +9034,90 @@ paths: application/json: schema: $ref: "#/components/schemas/UpdateExportResponse" + x-code-samples: + - lang: python + source: | + from portkey_ai import Portkey + + # Initialize Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Create logs export + 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 the result + print(res) + - lang: javascript + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + }) + + 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); /logs/exports/{exportId}/start: post: @@ -8953,6 +9137,36 @@ paths: application/json: schema: $ref: "#/components/schemas/ExportTaskResponse" + x-code-samples: + - lang: python + source: | + from portkey_ai import Portkey + + # Initialize Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Start logs export + res = portkey.logs.exports.start( + export_id='EXPORT_ID' + ) + + # Print the result + print(res) + - lang: javascript + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + }) + + const res = await portkey.logs.exports.start({ + exportId:'EXPORT_ID' + }) + + console.log(res); /logs/exports/{exportId}/cancel: post: @@ -8972,6 +9186,36 @@ paths: application/json: schema: $ref: "#/components/schemas/ExportTaskResponse" + x-code-samples: + - lang: python + source: | + from portkey_ai import Portkey + + # Initialize Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Cancel logs export + res = portkey.logs.exports.cancel( + export_id='EXPORT_ID' + ) + + # Print the result + print(res) + - lang: javascript + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + }) + + const res = await portkey.logs.exports.cancel({ + exportId:'EXPORT_ID' + }) + + console.log(res); /logs/exports/{exportId}/download: get: @@ -8991,7 +9235,37 @@ paths: application/json: schema: $ref: "#/components/schemas/DownloadLogsResponse" - + x-code-samples: + - lang: python + source: | + from portkey_ai import Portkey + + # Initialize Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Download logs export + res = portkey.logs.exports.download( + export_id='EXPORT_ID' + ) + + # Print the result + print(res) + - lang: javascript + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + }) + + const config=await portkey.logs.exports.download({ + exportId:'EXPORT_ID' + }) + + console.log(config); + /api-keys/{type}/{sub-type}: post: tags: From b9ec2576f047e2f23ff4d86d5f06cccb7b7cfd41 Mon Sep 17 00:00:00 2001 From: vrushankportkey <134934501+vrushankportkey@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:33:21 +0530 Subject: [PATCH 066/124] version to 3.0.0 --- openapi.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index 1bafc2d9..ecc1277b 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1,4 +1,4 @@ -openapi: 3.1.0 +openapi: 3.0.0 info: title: Portkey API description: The Portkey REST API. Please see https://portkey.ai/docs/api-reference for more details. From 8e3479b7179140eaade24dae9a2f517271a6b6a9 Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Tue, 12 Nov 2024 11:50:27 +0530 Subject: [PATCH 067/124] formatting changes --- openapi.yaml | 231 ++++++++++++++++++++++++++------------------------- 1 file changed, 116 insertions(+), 115 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index ecc1277b..ec359cdd 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8864,33 +8864,32 @@ paths: source: | from portkey_ai import Portkey - # Initialize Portkey client portkey = Portkey( - api_key="PORTKEY_API_KEY", + api_key="PORTKEY_API_KEY" ) - # Retrieve specific logs export res = portkey.logs.exports.retrieve( - export_id="EXPORT_ID" + export_id="EXPORT_ID" ) - # Print the result print(res) - lang: javascript source: | - import { Portkey } from "portkey-ai"; + import Portkey from "portkey-ai"; const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", + apiKey:"PORTKEY_API_KEY" }) - const res= await portkey.logs.exports.retrieve({ + async function main() { + const res= await portkey.logs.exports.retrieve({ exportId:"EXPORT_ID" - }) - - console.log(res); + }); + console.log(res); + } + main(); put: tags: - Logs Export @@ -8927,39 +8926,40 @@ paths: source: | from portkey_ai import Portkey - # Initialize Portkey client portkey = Portkey( - api_key="PORTKEY_API_KEY", + api_key="PORTKEY_API_KEY" ) - # Update logs export res = portkey.logs.exports.update( - export_id="EXPORT_ID", - workspace_id="WORKSPACE_ID", - filters={ - "time_of_generation_max": "2024-07-25" - } + export_id="EXPORT_ID", + workspace_id="WORKSPACE_ID", + filters={ + "time_of_generation_max": "2024-07-25" + } ) - # Print the result print(res) - lang: javascript source: | - import { Portkey } from "portkey-ai"; + import Portkey from "portkey-ai"; const portkey = new Portkey({ - apiKey:"/8sziEodbWDg6vUA0oy+G6aOquSA", + apiKey:"PORTKEY_API_KEY" }) - const res = await portkey.logs.exports.update({ - exportId:"7ef9f738-a93a-4bbd-85a8-53fcbffb603c", - workspaceId: "ws-shared-0uwqmn", + 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" + "time_of_generation_max": "2024-07-25" } - }) + }); + + console.log(res); + } - console.log(res); + main(); /logs/exports: get: tags: @@ -8982,32 +8982,32 @@ paths: source: | from portkey_ai import Portkey - # Initialize Portkey client portkey = Portkey( - api_key="PORTKEY_API_KEY", + api_key="PORTKEY_API_KEY" ) - # List logs export res = portkey.logs.exports.list( - workspace_id="WORKSPACE_ID" + workspace_id="WORKSPACE_ID" ) - # Print the result print(res) - lang: javascript source: | - import { Portkey } from "portkey-ai"; + import Portkey from "portkey-ai"; - const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", - }) + async function main() { + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY" + }) - const res = await portkey.logs.exports.list({ + const res = await portkey.logs.exports.list({ workspaceId:"WORKSPACE_ID" - }) + }); + + console.log(res); + } - console.log(res); - + main(); post: tags: - Logs Export @@ -9039,61 +9039,59 @@ paths: source: | from portkey_ai import Portkey - # Initialize Portkey client portkey = Portkey( - api_key="PORTKEY_API_KEY", + api_key="PORTKEY_API_KEY" ) - # Create logs export 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" - ] + 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 the result print(res) - lang: javascript source: | - import { Portkey } from "portkey-ai"; + import Portkey from "portkey-ai"; const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", + apiKey:"PORTKEY_API_KEY" }) - const res = await portkey.logs.exports.create({ - filters: { + 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": [ + }, + "workspaceId": "WORKSPACE_ID",", + "description": "This is random description", + "requestedData": [ "id", "trace_id", "created_at", @@ -9114,11 +9112,13 @@ paths: "config", "prompt_slug", "metadata" - ] - }) + ] + }); - console.log(res); + console.log(res); + } + main(); /logs/exports/{exportId}/start: post: tags: @@ -9142,32 +9142,32 @@ paths: source: | from portkey_ai import Portkey - # Initialize Portkey client portkey = Portkey( - api_key="PORTKEY_API_KEY", + api_key="PORTKEY_API_KEY" ) - # Start logs export res = portkey.logs.exports.start( - export_id='EXPORT_ID' + export_id='EXPORT_ID' ) - # Print the result print(res) - lang: javascript source: | - import { Portkey } from "portkey-ai"; + import Portkey from "portkey-ai"; const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", + apiKey:"PORTKEY_API_KEY" }) - const res = await portkey.logs.exports.start({ + async function main() { + const res = await portkey.logs.exports.start({ exportId:'EXPORT_ID' - }) + }); - console.log(res); + console.log(res); + } + main(); /logs/exports/{exportId}/cancel: post: tags: @@ -9191,32 +9191,32 @@ paths: source: | from portkey_ai import Portkey - # Initialize Portkey client portkey = Portkey( - api_key="PORTKEY_API_KEY", + api_key="PORTKEY_API_KEY" ) - # Cancel logs export res = portkey.logs.exports.cancel( - export_id='EXPORT_ID' + export_id='EXPORT_ID' ) - # Print the result print(res) - lang: javascript source: | - import { Portkey } from "portkey-ai"; + import Portkey from "portkey-ai"; const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", + apiKey:"PORTKEY_API_KEY", }) - const res = await portkey.logs.exports.cancel({ + async function main() { + const res = await portkey.logs.exports.cancel({ exportId:'EXPORT_ID' - }) + }); - console.log(res); + console.log(res); + } + main(); /logs/exports/{exportId}/download: get: tags: @@ -9240,32 +9240,33 @@ paths: source: | from portkey_ai import Portkey - # Initialize Portkey client portkey = Portkey( - api_key="PORTKEY_API_KEY", + api_key="PORTKEY_API_KEY" ) - # Download logs export res = portkey.logs.exports.download( - export_id='EXPORT_ID' + export_id='EXPORT_ID' ) - # Print the result print(res) - lang: javascript source: | - import { Portkey } from "portkey-ai"; + import Portkey from "portkey-ai"; const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", + apiKey:"PORTKEY_API_KEY" }) - const config=await portkey.logs.exports.download({ + async function main() { + const config=await portkey.logs.exports.download({ exportId:'EXPORT_ID' - }) + });; + + console.log(config); + } + + main() - console.log(config); - /api-keys/{type}/{sub-type}: post: tags: From b2280d7288a6715f264bf9b18436fd3f7afefe7e Mon Sep 17 00:00:00 2001 From: Mahesh Date: Tue, 3 Dec 2024 22:21:21 +0530 Subject: [PATCH 068/124] fix: add azure config spec --- openapi.yaml | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index ec359cdd..37951d61 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -7819,6 +7819,24 @@ paths: type: string format: uuid description: optional, needed when using organisation admin API keys + deploymentConfig: + type: array + items: + type: object + properties: + apiVersion: + name: apiVersion + type: string + alias: + name: alias + type: string + is_default: + name: is_default + type: boolean + deploymentName: + name: deploymentName + type: string + required: ['apiVersion','deploymentName'] usage_limits: $ref: "#/components/schemas/UsageLimits" examples: @@ -7836,8 +7854,7 @@ paths: key: "openai-test" name: "Key 1 Azure Open AI" note: "description" - apiVersion: "a" - deploymentName: "b" + deploymentConfig: [{"apiVersion":"a","alias":"b","deploymentName":"c", is_default: true},{"apiVersion":"a","alias":"b","deploymentName":"c", is_default: false}] resourceName: "c" bedrock: value: @@ -7981,6 +7998,24 @@ paths: note: type: string nullable: true + deploymentConfig: + type: array + items: + type: object + properties: + apiVersion: + name: apiVersion + type: string + alias: + name: alias + type: string + is_default: + name: is_default + type: boolean + deploymentName: + name: deploymentName + type: string + required: ['apiVersion','deploymentName'] usage_limits: $ref: "#/components/schemas/UsageLimits" responses: From 7eb807d6c4ba7ba533bec8dcd6b31ac38ed8bb33 Mon Sep 17 00:00:00 2001 From: Mahesh Date: Wed, 4 Dec 2024 02:26:44 +0530 Subject: [PATCH 069/124] fix: spec --- openapi.yaml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 37951d61..7240ad9b 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -7825,16 +7825,12 @@ paths: type: object properties: apiVersion: - name: apiVersion type: string alias: - name: alias type: string is_default: - name: is_default type: boolean deploymentName: - name: deploymentName type: string required: ['apiVersion','deploymentName'] usage_limits: @@ -8004,16 +8000,12 @@ paths: type: object properties: apiVersion: - name: apiVersion type: string alias: - name: alias type: string is_default: - name: is_default type: boolean deploymentName: - name: deploymentName type: string required: ['apiVersion','deploymentName'] usage_limits: From 11cbfad734a7f46c265cf9f1a23188e65dae5b80 Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Fri, 6 Dec 2024 10:15:49 +0530 Subject: [PATCH 070/124] moderations --- openapi.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 7240ad9b..33c3afd3 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -2020,7 +2020,8 @@ paths: operationId: createModeration tags: - Moderations - summary: Classifies if text is potentially harmful. + 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: @@ -7823,7 +7824,7 @@ paths: type: array items: type: object - properties: + properties: apiVersion: type: string alias: @@ -7998,7 +7999,7 @@ paths: type: array items: type: object - properties: + properties: apiVersion: type: string alias: From b89afcf19f4412eeffde6630836afe7bd5d184b8 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Tue, 10 Dec 2024 19:24:45 +0530 Subject: [PATCH 071/124] feat/insertLogExample --- openapi.yaml | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 33c3afd3..b630acfa 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8868,6 +8868,69 @@ paths: responses: '200': description: Successful response + x-code-samples: + - lang: python + 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 + 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); + + } /logs/exports/{exportId}: get: From 8f85c63152bb40b454b53df1bcece185c5b98cd9 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Tue, 10 Dec 2024 19:27:31 +0530 Subject: [PATCH 072/124] chore: example correction --- openapi.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index b630acfa..438d36f8 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8929,8 +8929,8 @@ paths: metadata: metadata, }); console.log(result); - } + main(); /logs/exports/{exportId}: get: From 72e9f62dd34af9ee2259dea8ee4fd452bc87390f Mon Sep 17 00:00:00 2001 From: Mahesh Date: Wed, 11 Dec 2024 16:10:20 +0530 Subject: [PATCH 073/124] chore: update invite api spec --- openapi.yaml | 145 +++++++++++++++++++++++++++++---------------------- 1 file changed, 82 insertions(+), 63 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index ec359cdd..d7b7c8a6 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8057,77 +8057,25 @@ paths: /admin/users/invites: post: - tags: - - User-invites + operationId: Invites_create summary: Invite User description: Send an invite to user for your organization - requestBody: - content: - application/json: - schema: - type: object - properties: - email: - type: string - role: - type: string - enum: - - admin - - member - workspaces: - type: array - description: Array of workspaces and roles that the user should be assigned to, if provided, once the invite is accepted. By default, the user will only be added in the shared workspace. - items: - type: object - properties: - id: - type: string - description: Slug of the workspace to which the user will be added after invite acceptance. - role: - type: string - description: Role to be assigned in the specified workspace. - enum: - - admin - - member - required: [id, role] - workspace_api_key_details: - type: object - description: If provided, a default user API key will be created with the specified settings for each workspace in the `workspaces` array. - properties: - scopes: - type: array - items: - type: string - required: [scopes] - required: [email, role] - example: - email: horace.slughorn@example.com - role: member - workspaces: - - id: "" - role: "" + parameters: [] 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 - invite_link: - type: string - format: uri - example: - id: 419641fb-1458-47d6-94d0-e308159b3ec2 - invite_link: https://app.portkey.ai/some-invite-link + $ref: '#/components/schemas/SuccessInvite' + tags: + - User-invites + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateInvite' get: tags: - User-invites @@ -11329,6 +11277,77 @@ components: 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: From f186c05807d251929c8ea209ac2569299698f86f Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 13 Dec 2024 15:19:13 +0530 Subject: [PATCH 074/124] feat: SDK examples for Virtual keys --- openapi.yaml | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 5945875b..46ff0dc0 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -7753,6 +7753,31 @@ paths: success: false data: message: "Unauthorised Request" + x-code-samples: + - lang: python + 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 + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const virtualKeys=await portkey.virtualKeys.list({}) + console.log(virtualKeys); + post: summary: Create a Virtual Key @@ -7910,6 +7935,38 @@ paths: success: false data: message: "Unauthorised Request" + x-code-samples: + - lang: python + 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 + 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); /virtual-keys/{slug}: get: @@ -7970,6 +8027,34 @@ paths: success: false data: message: "Unauthorised Request" + x-code-samples: + - lang: python + 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 + 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); put: summary: Update a Virtual Key @@ -8041,6 +8126,40 @@ paths: success: false data: message: "Unauthorised Request" + x-code-samples: + - lang: python + 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 + 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); delete: summary: Delete a Virtual Key @@ -8082,6 +8201,34 @@ paths: success: false data: message: "Unauthorised Request" + x-code-samples: + - lang: python + 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 + 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); /admin/users/invites: post: From 054481b9ca5a489d114c201f5a6c31ceb7fdf2dc Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 13 Dec 2024 16:25:21 +0530 Subject: [PATCH 075/124] feat: SDK examples for Workspace Members --- openapi.yaml | 167 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 5945875b..72a4fad0 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8463,6 +8463,46 @@ paths: schema: type: object example: {} + x-code-samples: + - lang: python + 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 + 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); + + get: tags: - Workspaces > Members @@ -8504,6 +8544,36 @@ paths: application/json: schema: $ref: "#/components/schemas/WorkspaceMemberList" + x-code-samples: + - lang: python + 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 + 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); + + /admin/workspaces/{workspaceId}/users/{userId}: put: @@ -8547,6 +8617,39 @@ paths: schema: type: object example: {} + x-code-samples: + - lang: python + 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 + 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); + delete: tags: @@ -8576,6 +8679,40 @@ paths: schema: type: object example: {} + x-code-samples: + - lang: python + 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 + 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) + + get: tags: @@ -8616,6 +8753,36 @@ paths: role: admin created_at: '2024-01-25 11:35:07' last_updated_at: '2024-01-25 11:35:07' + x-code-samples: + - lang: python + 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 + 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); /admin/workspaces: post: From f11638f903117797793b0bcd6bc908427615c9e9 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 13 Dec 2024 16:48:25 +0530 Subject: [PATCH 076/124] feat: SDK examples for Workspace --- openapi.yaml | 164 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 46ff0dc0..c376ceb5 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8809,6 +8809,48 @@ paths: application/json: schema: $ref: '#/components/schemas/Workspace' + x-code-samples: + - lang: python + 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 + 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); get: tags: @@ -8859,6 +8901,31 @@ paths: metadata: foo: bar object: workspace + x-code-samples: + - lang: python + 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 + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const workspaces=await portkey.admin.workspaces.list({}) + console.log(workspaces); + /admin/workspaces/{workspaceId}: put: @@ -8906,6 +8973,45 @@ paths: application/json: schema: $ref: '#/components/schemas/Workspace' + x-code-samples: + - lang: python + 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 + 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); + get: tags: @@ -8929,6 +9035,34 @@ paths: application/json: schema: $ref: "#/components/schemas/WorkspaceWithUsers" + x-code-samples: + - lang: python + 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 + 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); delete: tags: @@ -8943,6 +9077,36 @@ paths: responses: '200': description: OK + x-code-samples: + - lang: python + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Delete workspace + result = portkey.admin.workspaces.delete( + name='WORKSPACE_NAME_0909', + workspace_id='WORKSPACE_SLUG' + ) + + print(result) + - lang: javascript + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const workspace=await portkey.admin.workspaces.delete({ + name: 'WORKSPACE_NAME_0909', + workspaceId: 'WORKSPACE_SLUG', + }) + console.log(workspace); /logs: post: From c099316ab119ad9c2e385edc2cebf673f4c7c54b Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 13 Dec 2024 17:08:05 +0530 Subject: [PATCH 077/124] feat: SDK examples for Configs --- openapi.yaml | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index a57f7b41..59838aeb 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -7400,6 +7400,35 @@ paths: }, ], } + x-code-samples: + - lang: python + 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 + 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); + post: summary: Create a config tags: @@ -7461,6 +7490,52 @@ paths: "version_id": "0db4065b-ead2-4daa-bf5e-7e9106585133", }, } + x-code-samples: + - lang: python + 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 + 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); /configs/{slug}: get: @@ -7550,6 +7625,36 @@ paths: }, }, } + x-code-samples: + - lang: python + 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 + 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); + put: summary: Update a config tags: @@ -7611,6 +7716,50 @@ paths: "version_id": "abe447e2-f6aa-4229-93b7-8ee3183b6667", }, } + x-code-samples: + - lang: python + 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 + 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); /feedback: post: From 62f1681408780109835f0198bae5a2f35a55ef6c Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 13 Dec 2024 18:16:40 +0530 Subject: [PATCH 078/124] feat: SDK examples for Users --- openapi.yaml | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index 59838aeb..3393580a 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8619,6 +8619,32 @@ paths: 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 + 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 + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const users=await portkey.admin.users.list({}) + + console.log(users); + /admin/users/{userId}: get: @@ -8653,6 +8679,36 @@ paths: 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 + 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 + 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); + delete: tags: - Users @@ -8676,6 +8732,35 @@ paths: schema: type: object example: {} + x-code-samples: + - lang: python + 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 + 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); put: tags: - Users @@ -8712,6 +8797,37 @@ paths: schema: type: object example: {} + x-code-samples: + - lang: python + 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 + 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); /admin/workspaces/{workspaceId}/users: post: @@ -8869,7 +8985,6 @@ paths: }) console.log(user); - /admin/workspaces/{workspaceId}/users/{userId}: put: From f76daf42e4daaaf0128159213b732a8d68bdb307 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 13 Dec 2024 18:34:06 +0530 Subject: [PATCH 079/124] feat: SDK examples for Users Invite --- openapi.yaml | 148 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 59838aeb..4412cd73 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8400,6 +8400,66 @@ paths: application/json: schema: $ref: '#/components/schemas/CreateInvite' + x-code-samples: + - lang: python + 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 + 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); + + get: tags: - User-invites @@ -8467,6 +8527,34 @@ paths: workspaces: - workspace_id: "" role: "" + x-code-samples: + - lang: python + 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 + 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); /admin/users/invites/{inviteId}: get: @@ -8505,6 +8593,34 @@ paths: workspaces: - workspace_id: "" role: "" + x-code-samples: + - lang: python + 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 + 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); delete: tags: - User-invites @@ -8528,6 +8644,38 @@ paths: schema: type: object example: {} + x-code-samples: + - lang: python + 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 + 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); + /admin/users/invites/{inviteId}/resend: post: tags: From 4b64f027a7b3d4dae694d7bab3b1679ffd9823b1 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 13 Dec 2024 21:42:23 +0530 Subject: [PATCH 080/124] feat: SDK examples for Api Keys --- openapi.yaml | 266 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 266 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index e6bde7aa..9ce3c70c 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -10243,6 +10243,73 @@ paths: type: string enum: ["api-key"] example: "api-key" + x-code-samples: + - lang: python + 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 + 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); + /api-keys: get: @@ -10277,6 +10344,35 @@ paths: application/json: schema: $ref: "#/components/schemas/ApiKeyObjectList" + x-code-samples: + - lang: python + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # List API keys + api_keys = portkey.api_keys.list( + workspace_id="WORKSPACE_SLUG" + ) + + print(api_keys) + - lang: javascript + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const apiKey=await portkey.apiKeys.list({ + workspace_id:"WORKSPACE_SLUG" + }) + + console.log(apiKey); /api-keys/{id}: put: @@ -10308,6 +10404,117 @@ paths: schema: type: object example: {} + x-code-samples: + - lang: python + 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 + 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); + get: tags: @@ -10332,6 +10539,36 @@ paths: application/json: schema: $ref: "#/components/schemas/ApiKeyObject" + x-code-samples: + - lang: python + 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 + 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); + delete: tags: @@ -10357,6 +10594,35 @@ paths: schema: type: object example: {} + x-code-samples: + - lang: python + 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 + 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); + /analytics/graphs/requests: get: From bc6eef7c3d1dac8bdb7de61fa1d58182057594e5 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Sat, 14 Dec 2024 13:23:26 +0530 Subject: [PATCH 081/124] feat: SDK examples for User Invite Resend --- openapi.yaml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 9ce3c70c..3ba04781 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -8706,6 +8706,37 @@ paths: format: uri example: inviteLink: https://app.portkey.ai/invite/some-invite-link + x-code-samples: + - lang: python + 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 + 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); /admin/users: get: From 42c1b9331ca41cea32f8b0fe6b76421b44c802e8 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Mon, 16 Dec 2024 17:01:35 +0530 Subject: [PATCH 082/124] feat: adding promptSlug as a filter --- openapi.yaml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 9ce3c70c..58dfab6b 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -10651,6 +10651,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -10724,6 +10725,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -10805,6 +10807,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -10903,6 +10906,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -10984,6 +10988,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -11057,6 +11062,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -11138,6 +11144,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -11211,6 +11218,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -11284,6 +11292,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -11365,6 +11374,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -11441,6 +11451,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -11530,6 +11541,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -11623,6 +11635,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -11690,6 +11703,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -11763,6 +11777,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -11835,6 +11850,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -11908,6 +11924,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -11978,6 +11995,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -12043,6 +12061,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -12114,6 +12133,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -12187,6 +12207,7 @@ paths: - $ref: '#/components/parameters/AiOrgModel' - $ref: '#/components/parameters/TraceId' - $ref: '#/components/parameters/SpanId' + - $ref: '#/components/parameters/PromptSlug' responses: '200': description: OK @@ -12447,6 +12468,13 @@ components: 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 From 83b7e09d08dbf2734b268e50acb6322ef8223263 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Mon, 16 Dec 2024 17:05:00 +0530 Subject: [PATCH 083/124] feat: prompt_slug for log exports example --- openapi.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 58dfab6b..692d3a8b 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -19441,6 +19441,8 @@ components: type: string workspace_slug: type: string + prompt_slug: + type: string LogExportsRequestedData: type: array From e00daacbf8d6570fe6dfa47752996c3fca96529b Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Wed, 15 Jan 2025 12:35:35 +0530 Subject: [PATCH 084/124] fix: support for alert emails --- openapi.yaml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index a673d17b..33a74567 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -9067,7 +9067,7 @@ paths: in: query schema: type: string - example: 'test@test.com' + example: 'foo@bar.com' responses: '200': @@ -19541,6 +19541,12 @@ components: config_id: type: string example: config-abc + alert_emails: + type: array + items: + type: string + format: email + example: "foo@bar.com" object: type: string enum : ["api-key"] @@ -19610,6 +19616,12 @@ components: config_id: type: string example: config-abc + alert_emails: + type: array + items: + type: string + format: email + example: "foo@bar.com" UpdateApiKeyObject: type: object @@ -19653,6 +19665,12 @@ components: config_id: type: string example: config-abc + alert_emails: + type: array + items: + type: string + format: email + example: "foo@bar.com" PromptRenderResponse: type: object From 33e74fe802696f6d8d6aa79ce4c7976ddb29244c Mon Sep 17 00:00:00 2001 From: Vrushank Vyas <134934501+vrushankportkey@users.noreply.github.com> Date: Wed, 15 Jan 2025 13:02:03 +0530 Subject: [PATCH 085/124] GH action to trigger Mintlify update --- .github/workflows/mintlify-update.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/mintlify-update.yml diff --git a/.github/workflows/mintlify-update.yml b/.github/workflows/mintlify-update.yml new file mode 100644 index 00000000..2eee34ff --- /dev/null +++ b/.github/workflows/mintlify-update.yml @@ -0,0 +1,20 @@ +name: Trigger Mintlify Update + +on: + pull_request: + types: + - closed + branches: + - master + +jobs: + trigger-update: + if: github.event.pull_request.merged == true + 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 }}' From 15e10eaae960dde266cb8d9e9dc2c5b1adb18c54 Mon Sep 17 00:00:00 2001 From: Vrushank Vyas <134934501+vrushankportkey@users.noreply.github.com> Date: Mon, 27 Jan 2025 17:47:36 +0530 Subject: [PATCH 086/124] update link to traces doc --- openapi.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index 33a74567..4446e164 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -12424,7 +12424,7 @@ components: 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](/product/observability/traces) + 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 From d27bed46081f4d90d0b97018c69cea3a6400e6d8 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Wed, 12 Feb 2025 23:32:30 +0530 Subject: [PATCH 087/124] fix: x-code-sample syntax --- openapi.yaml | 5659 +++++++++++++++++++++++++------------------------- 1 file changed, 2788 insertions(+), 2871 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 4446e164..0f7c3821 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -2143,103 +2143,101 @@ paths: Custom-Host: [] x-code-samples: - 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" \ + - 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" - python: | - from portkey_ai import Portkey + - lang: python + source: | + from portkey_ai import Portkey - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + 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) - node.js: |- - import Portkey from 'portkey-ai'; + 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' - }); + 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", - }); + async function main() { + const myAssistants = await client.beta.assistants.list({ + order: "desc", + limit: "20", + }); - console.log(myAssistants.data); - } + 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 - } + 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: @@ -2273,138 +2271,136 @@ paths: Custom-Host: [] x-code-samples: - 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 "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" - }' - - python: | - 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) - node.js: |- - 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: - "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); - } + - 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: + "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 | + 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": [ { - "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" + "type": "code_interpreter" } - - title: Files - request: - curl: | - 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 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 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 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 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: - "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" - }); + ], + "metadata": {}, + "top_p": 1.0, + "temperature": 1.0, + "response_format": "auto" + } + - title: Files + 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 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" + }' + - 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 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) + - 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: + "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); - } + console.log(myAssistant); + } - main(); - response: | + main(); + response: | { "id": "asst_abc123", "object": "assistant", @@ -2464,64 +2460,61 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from portkey_ai import Portkey + - 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" - ) + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - my_assistant = client.beta.assistants.retrieve("asst_abc123") - print(my_assistant) - node.js: |- - import Portkey from 'portkey-ai'; + 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' - }); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - async function main() { - const myAssistant = await client.beta.assistants.retrieve( - "asst_abc123" - ); + async function main() { + const myAssistant = await client.beta.assistants.retrieve( + "asst_abc123" + ); - console.log(myAssistant); - } + 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" - } + 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: @@ -2562,65 +2555,62 @@ paths: Custom-Host: [] x-code-samples: - 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 "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" - }' - python: | - from portkey_ai import Portkey + - 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" - ) + 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" - ) + 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 Portkey from 'portkey-ai'; + print(my_updated_assistant) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + 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" - } - ); + 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); - } + console.log(myUpdatedAssistant); + } - main(); - response: | + main(); + response: | { "id": "asst_123", "object": "assistant", @@ -2678,49 +2668,46 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -H "OpenAI-Beta: assistants=v2" \ - -X DELETE - python: | - from portkey_ai import Portkey + - 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" - ) + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - response = client.beta.assistants.delete("asst_abc123") - print(response) - node.js: |- - import Portkey from 'portkey-ai'; + 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' - }); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - async function main() { - const response = await client.beta.assistants.del("asst_abc123"); + 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 - } + console.log(response); + } + main(); + response: | + { + "id": "asst_abc123", + "object": "assistant.deleted", + "deleted": true + } /threads: post: @@ -2755,45 +2742,43 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -H "OpenAI-Beta: assistants=v2" \ - -d '' - python: | - from portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) - - empty_thread = client.beta.threads.create() - print(empty_thread) - node.js: |- - import Portkey from 'portkey-ai'; - - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); - - async function main() { - const emptyThread = await client.beta.threads.create(); - - console.log(emptyThread); - } + - title: Empty + 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 '' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + empty_thread = client.beta.threads.create() + print(empty_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 emptyThread = await client.beta.threads.create(); + + console.log(emptyThread); + } - main(); + main(); response: | { "id": "thread_abc123", @@ -2802,72 +2787,75 @@ paths: "metadata": {}, "tool_resources": {} } - - title: Messages - request: - curl: | - 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." - }] - }' - python: | - 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) - node.js: |- - import Portkey from 'portkey-ai'; + - title: Messages + 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 - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "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.", - }, - ], - }); + 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); - } + console.log(messageThread); + } - main(); - response: | + main(); + response: | { "id": "thread_abc123", "object": "thread", @@ -2911,57 +2899,54 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from portkey_ai import Portkey + - 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" - ) + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - my_thread = client.beta.threads.retrieve("thread_abc123") - print(my_thread) - node.js: |- - import Portkey from 'portkey-ai'; + 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' - }); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - async function main() { - const myThread = await client.beta.threads.retrieve( - "thread_abc123" - ); + async function main() { + const myThread = await client.beta.threads.retrieve( + "thread_abc123" + ); - console.log(myThread); - } + console.log(myThread); + } - main(); - response: | - { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699014083, - "metadata": {}, - "tool_resources": { - "code_interpreter": { - "file_ids": [] - } - } + main(); + response: | + { + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, + "metadata": {}, + "tool_resources": { + "code_interpreter": { + "file_ids": [] } + } + } post: operationId: modifyThread tags: @@ -3002,71 +2987,68 @@ paths: Custom-Host: [] x-code-samples: - 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 "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" - } - }' - python: | - 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) - node.js: |- - import Portkey from 'portkey-ai'; + - 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 - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - async function main() { - const updatedThread = await client.beta.threads.update( - "thread_abc123", - { - metadata: { modified: "true", user: "abc123" }, - } - ); + 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'; - console.log(updatedThread); - } + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - main(); - response: | + async function main() { + const updatedThread = await client.beta.threads.update( + "thread_abc123", { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699014083, - "metadata": { - "modified": "true", - "user": "abc123" - }, - "tool_resources": {} + 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: @@ -3101,49 +3083,46 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -H "OpenAI-Beta: assistants=v2" \ - -X DELETE - python: | - from portkey_ai import Portkey + - 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" - ) + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - response = client.beta.threads.delete("thread_abc123") - print(response) - node.js: |- - import Portkey from 'portkey-ai'; + 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' - }); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - async function main() { - const response = await client.beta.threads.del("thread_abc123"); + 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 - } + console.log(response); + } + main(); + response: | + { + "id": "thread_abc123", + "object": "thread.deleted", + "deleted": true + } /threads/{thread_id}/messages: get: @@ -3210,94 +3189,91 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from portkey_ai import Portkey + - 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" - ) + 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) - node.js: |- - import Portkey from 'portkey-ai'; + 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' - }); + 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" - ); + async function main() { + const threadMessages = await client.beta.threads.messages.list( + "thread_abc123" + ); - console.log(threadMessages.data); - } + 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": [] - } + 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": {} + }, + { + "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 - } + } + ], + "attachments": [], + "metadata": {} + } + ], + "first_id": "msg_abc123", + "last_id": "msg_abc456", + "has_more": false + } post: operationId: createMessage tags: @@ -3338,75 +3314,72 @@ paths: Custom-Host: [] x-code-samples: - 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 "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." - }' - python: | - from portkey_ai import Portkey + - 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" - ) + 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) - node.js: |- - import Portkey from 'portkey-ai'; + 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' - }); + 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." } - ); + 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); - } + 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": [] - } + 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": {} - } + } + ], + "attachments": [], + "metadata": {} + } /threads/{thread_id}/messages/{message_id}: get: @@ -3449,70 +3422,67 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from portkey_ai import Portkey + - 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" - ) + 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) - node.js: |- - import Portkey from 'portkey-ai'; + 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' - }); + 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" - ); + async function main() { + const message = await client.beta.threads.messages.retrieve( + "thread_abc123", + "msg_abc123" + ); - console.log(message); - } + 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": [] - } + 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": {} - } + } + ], + "attachments": [], + "metadata": {} + } post: operationId: modifyMessage tags: @@ -3559,84 +3529,81 @@ paths: Custom-Host: [] x-code-samples: - 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 "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" - } - }' - python: | - from portkey_ai import Portkey + - 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" - ) + 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) - node.js: |- - import Portkey from 'portkey-ai'; + 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' - }); + 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: | + async function main() { + const message = await client.beta.threads.messages.update( + "thread_abc123", + "msg_abc123", { - "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": [] - } + 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" } + ], + "file_ids": [], + "metadata": { + "modified": "true", + "user": "abc123" } + } delete: operationId: deleteMessage tags: @@ -3677,53 +3644,50 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from portkey_ai import Portkey + - 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" - ) + 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) - node.js: |- - import Portkey from 'portkey-ai'; + 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' - }); + 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" - ); + 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 - } + console.log(deletedMessage); + } + response: | + { + "id": "msg_abc123", + "object": "thread.message.deleted", + "deleted": true + } /threads/runs: post: @@ -3759,164 +3723,165 @@ paths: Custom-Host: [] x-code-samples: - 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 "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."} - ] - } - }' - python: | - 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={ + - title: Default + 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."} ] } - ) - - print(run) - node.js: | - 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." }, - ], - }, - }); + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - console.log(run); + run = client.beta.threads.create_and_run( + assistant_id="asst_abc123", + thread={ + "messages": [ + {"role": "user", "content": "Explain deep learning to a 5 year old."} + ] } + ) - 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 + 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); } - - title: Streaming - request: - curl: | - 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_123", - "thread": { - "messages": [ - {"role": "user", "content": "Hello"} - ] - }, - "stream": true - }' - python: | - from portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) - - 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 Portkey from 'portkey-ai'; - - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); - - async function main() { - const stream = await client.beta.threads.createAndRun({ - assistant_id: "asst_123", - thread: { - messages: [ - { role: "user", content: "Hello" }, - ], - }, - stream: true - }); + 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 + } - for await (const event of stream) { - console.log(event); - } - } + - title: Streaming + 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_123", + "thread": { + "messages": [ + {"role": "user", "content": "Hello"} + ] + }, + "stream": true + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + 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) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const stream = await client.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(); + main(); response: | event: thread.created data: {"id":"thread_123","object":"thread","created_at":1710348075,"metadata":{}} @@ -3965,55 +3930,23 @@ paths: event: done data: [DONE] - - title: Streaming with Functions - request: - curl: | - 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": "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 portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) - - tools = [ + - title: Streaming with Functions + 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": "What is the weather like in San Francisco?"} + ] + }, + "tools": [ { "type": "function", "function": { @@ -4024,117 +3957,152 @@ paths: "properties": { "location": { "type": "string", - "description": "The city and state, e.g. San Francisco, CA", + "description": "The city and state, e.g. San Francisco, CA" }, - "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}, + "unit": { + "type": "string", + "enum": ["celsius", "fahrenheit"] + } }, - "required": ["location"], - }, + "required": ["location"] + } } } - ] - - stream = client.beta.threads.create_and_run( - thread={ - "messages": [ - {"role": "user", "content": "What is the weather like in San Francisco?"} - ] + ], + "stream": true + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + 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"], }, - assistant_id="asst_abc123", - tools=tools, - stream=True - ) - - for event in stream: - print(event) - node.js: | - import Portkey from 'portkey-ai'; - - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); - - 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"], + } + } + ] + + 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) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + 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", }, - } - } - ]; - - async function main() { - const stream = await client.beta.threads.createAndRun({ - assistant_id: "asst_123", - thread: { - messages: [ - { role: "user", content: "What is the weather like in San Francisco?" }, - ], + "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}, + }, + "required": ["location"], }, - tools: tools, - stream: true - }); - - for await (const event of stream) { - console.log(event); } } + ]; + + async function main() { + const stream = await client.beta.threads.createAndRun({ + assistant_id: "asst_123", + thread: { + messages: [ + { role: "user", content: "What is the weather like in San Francisco?" }, + ], + }, + tools: tools, + stream: true + }); - main(); - response: | - event: thread.created - data: {"id":"thread_123","object":"thread","created_at":1710351818,"metadata":{}} + for await (const event of stream) { + console.log(event); + } + } - 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}} + main(); + response: | + event: thread.created + data: {"id":"thread_123","object":"thread","created_at":1710351818,"metadata":{}} - 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.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.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.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.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.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.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.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.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.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,"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,"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":"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":"{\""}}]}}} - ... + 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.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.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: 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: done - data: [DONE] + 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: @@ -4195,151 +4163,148 @@ paths: Custom-Host: [] x-code-samples: - 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 "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" - python: | - from portkey_ai import Portkey + - 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" - ) + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - runs = client.beta.threads.runs.list( - "thread_abc123" - ) + runs = client.beta.threads.runs.list( + "thread_abc123" + ) - print(runs) - node.js: | - import Portkey from 'portkey-ai'; + print(runs) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + 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" - ); + async function main() { + const runs = await client.beta.threads.runs.list( + "thread_abc123" + ); - console.log(runs); - } + 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 + 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" + ] + } }, - { - "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 - } + "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: @@ -4380,227 +4345,196 @@ paths: schema: $ref: "#/components/schemas/RunObject" x-code-samples: - 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 "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" - }' - python: | - 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) - node.js: | - 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); - } + - title: Default + 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" } + ); - 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 + console.log(run); } - - title: Streaming - request: - curl: | - curl https://api.portkey.ai/v1/threads/thread_123/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_123", - "stream": true - }' - python: | - from portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) - - 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 Portkey from 'portkey-ai'; - - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); - - async function main() { - const stream = await client.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}} + 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 + x-code-samples: + - lang: curl + source: | + curl https://api.portkey.ai/v1/threads/thread_123/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_123", + "stream": true + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + stream = client.beta.threads.runs.create( + thread_id="thread_123", + assistant_id="asst_123", + stream=True + ) + + for event in stream: + print(event) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const stream = await client.beta.threads.runs.create( + "thread_123", + { assistant_id: "asst_123", stream: true } + ); + + for await (const event of stream) { + console.log(event); + } + } - 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}} + 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.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.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.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.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.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.run.step.created + data: {"id":"step_001","object":"thread.run.step","created_at":1710330641,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710331240,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} - event: thread.message.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.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.delta - data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}} + event: thread.message.created + data: {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} - ... + event: thread.message.in_progress + data: {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} - event: thread.message.delta - data: {"id":"msg_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":"Hello","annotations":[]}}]}} - 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.message.delta + data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" today"}}]}} - 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.message.delta + data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}} - 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: 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: done - data: [DONE] + 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}} - - title: Streaming with Functions - request: - curl: | - 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", - "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 portkey_ai import Portkey + 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}} - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + event: done + data: [DONE] - tools = [ + - title: Streaming with Functions + 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", + "tools": [ { "type": "function", "function": { @@ -4611,114 +4545,149 @@ paths: "properties": { "location": { "type": "string", - "description": "The city and state, e.g. San Francisco, CA", + "description": "The city and state, e.g. San Francisco, CA" }, - "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}, + "unit": { + "type": "string", + "enum": ["celsius", "fahrenheit"] + } }, - "required": ["location"], - }, + "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 Portkey from 'portkey-ai'; - - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + ], + "stream": true + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + 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 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) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + 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", }, - } - } - ]; - - async function main() { - const stream = await client.beta.threads.runs.create( - "thread_abc123", - { - assistant_id: "asst_abc123", - tools: tools, - stream: true - } - ); - - for await (const event of stream) { - console.log(event); + "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}, + }, + "required": ["location"], + }, } } + ]; - 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}} + async function main() { + const stream = await client.beta.threads.runs.create( + "thread_abc123", + { + assistant_id: "asst_abc123", + tools: tools, + stream: 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}} + for await (const event of stream) { + console.log(event); + } + } - 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}} + 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.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.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.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.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.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.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.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.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.delta - data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}} + 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":" today"}}]}} + 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":"?"}}]}} + ... - 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.message.delta + data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" today"}}]}} - 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.message.delta + data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}} - 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: 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] + event: done + data: [DONE] /threads/{thread_id}/runs/{run_id}: get: @@ -4761,89 +4730,86 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -H "OpenAI-Beta: assistants=v2" - python: | - from portkey_ai import Portkey + - 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" - ) + 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" - ) + run = client.beta.threads.runs.retrieve( + thread_id="thread_abc123", + run_id="run_abc123" + ) - print(run) - node.js: | - import Portkey from 'portkey-ai'; + print(run) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + 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" - ); + async function main() { + const run = await client.beta.threads.runs.retrieve( + "thread_abc123", + "run_abc123" + ); - console.log(run); - } + 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 - } + 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: @@ -4890,111 +4856,108 @@ paths: Custom-Host: [] x-code-samples: - 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 "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" - } - }' - python: | - 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"}, - ) + - 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 - print(run) - node.js: | - import Portkey from 'portkey-ai'; + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + run = client.beta.threads.runs.update( + thread_id="thread_abc123", + run_id="run_abc123", + metadata={"user_id": "user_abc123"}, + ) - async function main() { - const run = await client.beta.threads.runs.update( - "thread_abc123", - "run_abc123", - { - metadata: { - user_id: "user_abc123", - }, - } - ); + print(run) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - console.log(run); - } + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - main(); - response: | + async function main() { + const run = await client.beta.threads.runs.update( + "thread_abc123", + "run_abc123", { - "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 + metadata: { + user_id: "user_abc123", }, - "response_format": "auto", - "tool_choice": "auto", - "parallel_tool_calls": true } + ); + + 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: @@ -5044,244 +5007,246 @@ paths: Custom-Host: [] x-code-samples: - 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 "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." - } - ] - }' - python: | - 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." - } - ] - ) + - title: Default + 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 - print(run) - node.js: | - import Portkey from 'portkey-ai'; + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: '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." + } + ] + ) - async function main() { - const run = await client.beta.threads.runs.submitToolOutputs( - "thread_123", - "run_123", + 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_outputs: [ - { - tool_call_id: "call_001", - output: "70 degrees and sunny.", - }, - ], - } - ); - - console.log(run); + tool_call_id: "call_001", + output: "70 degrees and sunny.", + }, + ], } + ); - 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" + 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"] + } }, - "unit": { - "type": "string", - "enum": ["celsius", "fahrenheit"] - } - }, - "required": ["location"] + "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 + 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." + } + ], + "stream": true + }' + - lang: python + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + 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." } ], - "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 "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." - } - ], - "stream": true - }' - python: | - from portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) - - stream = client.beta.threads.runs.submit_tool_outputs( - thread_id="thread_123", - run_id="run_123", - tool_outputs=[ + stream=True + ) + + for event in stream: + print(event) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; + + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const stream = await client.beta.threads.runs.submitToolOutputs( + "thread_123", + "run_123", + { + tool_outputs: [ { - "tool_call_id": "call_001", - "output": "70 degrees and sunny." - } + tool_call_id: "call_001", + output: "70 degrees and sunny.", + }, ], - stream=True - ) - - for event in stream: - print(event) - node.js: | - import Portkey from 'portkey-ai'; - - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); - - async function main() { - const stream = await client.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}} + for await (const event of stream) { + console.log(event); + } + } - 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}} + 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.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.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.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.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.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.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.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.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.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.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":"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":" 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":" 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":" sunny"}}]}} - event: thread.message.delta - data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"."}}]}} + 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.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.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: 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] + event: done + data: [DONE] /threads/{thread_id}/runs/{run_id}/cancel: post: @@ -5324,84 +5289,81 @@ paths: Custom-Host: [] x-code-samples: - 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 "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -H "OpenAI-Beta: assistants=v2" \ - -X POST - python: | - from portkey_ai import Portkey + - 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" - ) + 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" - ) + run = client.beta.threads.runs.cancel( + thread_id="thread_abc123", + run_id="run_abc123" + ) - print(run) - node.js: | - import Portkey from 'portkey-ai'; + print(run) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + 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" - ); + async function main() { + const run = await client.beta.threads.runs.cancel( + "thread_abc123", + "run_abc123" + ); - console.log(run); - } + 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 - } + 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: @@ -5468,84 +5430,81 @@ paths: Custom-Host: [] x-code-samples: - 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 "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" - python: | - from portkey_ai import Portkey + - 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" - ) + 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" - ) + run_steps = client.beta.threads.runs.steps.list( + thread_id="thread_abc123", + run_id="run_abc123" + ) - print(run_steps) - node.js: | - import Portkey from 'portkey-ai'; + print(run_steps) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + 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); - } + 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", + 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", - "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 + "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 - } + } + ], + "first_id": "step_abc123", + "last_id": "step_abc456", + "has_more": false + } /threads/{thread_id}/runs/{run_id}/steps/{step_id}: get: @@ -5594,78 +5553,75 @@ paths: Custom-Host: [] x-code-samples: - 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 "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" - python: | - from portkey_ai import Portkey + - 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" - ) + 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" - ) + 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 Portkey from 'portkey-ai'; + print(run_step) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + 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); - } + 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", + 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", - "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 + "message_creation": { + "message_id": "msg_abc123" } + }, + "usage": { + "prompt_tokens": 123, + "completion_tokens": 456, + "total_tokens": 579 } + } /vector_stores: get: @@ -5720,79 +5676,76 @@ paths: Custom-Host: [] x-code-samples: - 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 "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" - python: | - from portkey_ai import Portkey + - 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" - ) + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - vector_stores = client.beta.vector_stores.list() - print(vector_stores) - node.js: | - import Portkey from 'portkey-ai'; + 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' - }); + 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); - } + 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 - } + 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 } - ], - "first_id": "vs_abc123", - "last_id": "vs_abc456", - "has_more": false - } + }, + { + "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: @@ -5826,64 +5779,61 @@ paths: Custom-Host: [] x-code-samples: - 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 "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" - }' - python: | - from portkey_ai import Portkey + - 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" - ) + 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) - node.js: | - import Portkey from 'portkey-ai'; + 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' - }); + 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); - } + 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 - } - } + 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: @@ -5920,52 +5870,49 @@ paths: Custom-Host: [] x-code-samples: - 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 "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" - python: | - from portkey_ai import Portkey + - 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" - ) + 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) - node.js: | - import Portkey from 'portkey-ai'; + 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' - }); + 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); - } + 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 - } + main(); + response: | + { + "id": "vs_abc123", + "object": "vector_store", + "created_at": 1699061776 + } post: operationId: modifyVectorStore tags: @@ -6006,68 +5953,65 @@ paths: Custom-Host: [] x-code-samples: - 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 "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" - }' - python: | - from portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + - 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 - vector_store = client.beta.vector_stores.update( - vector_store_id="vs_abc123", - name="Support FAQ" - ) - print(vector_store) - node.js: | - import Portkey from 'portkey-ai'; + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: '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'; - async function main() { - const vectorStore = await client.beta.vectorStores.update( - "vs_abc123", - { - name: "Support FAQ" - } - ); - console.log(vectorStore); - } + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - main(); - response: | + async function main() { + const vectorStore = await client.beta.vectorStores.update( + "vs_abc123", { - "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 - } + 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 @@ -6103,53 +6047,50 @@ paths: Custom-Host: [] x-code-samples: - 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 "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 - python: | - from portkey_ai import Portkey + - 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" - ) + 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) - node.js: | - import Portkey from 'portkey-ai'; + 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' - }); + 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); - } + 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 - } + main(); + response: | + { + "id": "vs_abc123", + "object": "vector_store.deleted", + "deleted": true + } /vector_stores/{vector_store_id}/files: get: @@ -6216,67 +6157,64 @@ paths: Custom-Host: [] x-code-samples: - 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 "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" - python: | - from portkey_ai import Portkey + - 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" - ) + 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) - node.js: | - import Portkey from 'portkey-ai'; + 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' - }); + 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); - } + async function main() { + const vectorStoreFiles = await client.beta.vectorStores.files.list( + "vs_abc123" + ); + console.log(vectorStoreFiles); + } - main(); - response: | + main(); + response: | + { + "object": "list", + "data": [ { - "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 + "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: @@ -6319,63 +6257,60 @@ paths: Custom-Host: [] x-code-samples: - 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 "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" - }' - python: | - from portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + - 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 - 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 Portkey from 'portkey-ai'; + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: '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'; - async function main() { - const myVectorStoreFile = await client.beta.vectorStores.files.create( - "vs_abc123", - { - file_id: "file-abc123" - } - ); - console.log(myVectorStoreFile); - } + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - main(); - response: | + async function main() { + const myVectorStoreFile = await client.beta.vectorStores.files.create( + "vs_abc123", { - "id": "file-abc123", - "object": "vector_store.file", - "created_at": 1699061776, - "usage_bytes": 1234, - "vector_store_id": "vs_abcd", - "status": "completed", - "last_error": null + 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: @@ -6420,57 +6355,54 @@ paths: Custom-Host: [] x-code-samples: - 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 "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" - python: | - from portkey_ai import Portkey + - 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" - ) + 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) - node.js: | - import Portkey from 'portkey-ai'; + 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' - }); + 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); - } + 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 - } + 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: @@ -6511,55 +6443,52 @@ paths: Custom-Host: [] x-code-samples: - 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 "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 - python: | - from portkey_ai import Portkey + - 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" - ) + 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) - node.js: | - import Portkey from 'portkey-ai'; + 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' - }); + 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); - } + 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 - } + main(); + response: | + { + "id": "file-abc123", + "object": "vector_store.file.deleted", + "deleted": true + } /vector_stores/{vector_store_id}/file_batches: post: @@ -6604,68 +6533,65 @@ paths: Custom-Host: [] x-code-samples: - 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 "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"] - }' - python: | - from portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + - 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 - 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 Portkey from 'portkey-ai'; + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: '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'; - async function main() { - const myVectorStoreFileBatch = await client.beta.vectorStores.fileBatches.create( - "vs_abc123", - { - file_ids: ["file-abc123", "file-abc456"] - } - ); - console.log(myVectorStoreFileBatch); - } + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - main(); - response: | + async function main() { + const myVectorStoreFileBatch = await client.beta.vectorStores.fileBatches.create( + "vs_abc123", { - "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, - } + 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: @@ -6710,63 +6636,60 @@ paths: Custom-Host: [] x-code-samples: - 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 "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" - python: | - from portkey_ai import Portkey + - 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" - ) + 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) - node.js: | - import Portkey from 'portkey-ai'; + 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' - }); + 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); - } + 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, - } + 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: @@ -6809,64 +6732,61 @@ paths: Custom-Host: [] x-code-samples: - 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 "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 - python: | - from portkey_ai import Portkey + - 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" - ) + 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) - node.js: | - import Portkey from 'portkey-ai'; + 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' - }); + 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); - } + 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, - } - } + 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: @@ -6939,69 +6859,66 @@ paths: Custom-Host: [] x-code-samples: - 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 "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" - python: | - from portkey_ai import Portkey + - 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" - ) + 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) - node.js: | - import Portkey from 'portkey-ai'; + 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' - }); + 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); - } + 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 - } + 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: From 0852a9158fde88fa67de777b2677516299dfd152 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Wed, 12 Feb 2025 23:55:47 +0530 Subject: [PATCH 088/124] fix: titles from code sample removed --- openapi.yaml | 1733 +++++++++++++++----------------------------------- 1 file changed, 505 insertions(+), 1228 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 0f7c3821..d007a477 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -2742,127 +2742,80 @@ paths: Custom-Host: [] x-code-samples: - - title: Empty - 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 '' - - lang: python - source: | - from portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) - - empty_thread = client.beta.threads.create() - print(empty_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 emptyThread = await client.beta.threads.create(); - - console.log(emptyThread); - } - - main(); - response: | - { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699012949, - "metadata": {}, - "tool_resources": {} - } - - title: Messages - 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 + - 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" - ) + 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." - }, - ] - ) + 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'; + print(message_thread) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + 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.", - }, - ], - }); + 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); - } + console.log(messageThread); + } - main(); - response: | - { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699014083, - "metadata": {}, - "tool_resources": {} - } + main(); + response: | + { + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, + "metadata": {}, + "tool_resources": {} + } /threads/{thread_id}: get: @@ -3723,431 +3676,142 @@ paths: Custom-Host: [] x-code-samples: - - title: Default - 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 - } - - - title: Streaming - 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_123", - "thread": { - "messages": [ - {"role": "user", "content": "Hello"} - ] - }, - "stream": true - }' - - lang: python - source: | - from portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) - - stream = client.beta.threads.create_and_run( - assistant_id="asst_123", - thread={ + - 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": "Hello"} + {"role": "user", "content": "Explain deep learning to a 5 year old."} ] - }, - stream=True - ) - - for event in stream: - print(event) - - lang: javascript - source: | - import Portkey from 'portkey-ai'; - - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); - - async function main() { - const stream = await client.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} + }' + - lang: python + source: | + from portkey_ai import Portkey - 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} + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - 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} + run = client.beta.threads.create_and_run( + assistant_id="asst_abc123", + thread={ + "messages": [ + {"role": "user", "content": "Explain deep learning to a 5 year old."} + ] + } + ) - 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":{}} + print(run) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - 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":{}} + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - event: thread.message.delta - data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}} + 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); + } - event: thread.message.delta - data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" today"}}]}} + 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 + } - 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 - 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": "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 - }' - - lang: python - source: | - from portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) - - 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) - - lang: javascript - source: | - import Portkey from 'portkey-ai'; - - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); - - 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 client.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" + /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" security: - Portkey-Key: [] @@ -4203,491 +3867,228 @@ paths: 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: - - title: Default - 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 | + { + "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": [ { - "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 + "type": "code_interpreter" } - - title: Streaming - x-code-samples: - - lang: curl - source: | - curl https://api.portkey.ai/v1/threads/thread_123/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_123", - "stream": true - }' - - lang: python - source: | - from portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) - - stream = client.beta.threads.runs.create( - thread_id="thread_123", - assistant_id="asst_123", - stream=True - ) - - for event in stream: - print(event) - - lang: javascript - source: | - import Portkey from 'portkey-ai'; - - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); - - async function main() { - const stream = await client.beta.threads.runs.create( - "thread_123", - { assistant_id: "asst_123", stream: true } - ); - - for await (const event of stream) { - console.log(event); + ], + "tool_resources": { + "code_interpreter": { + "file_ids": [ + "file-abc123", + "file-abc456" + ] } - } - - 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 - 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", - "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 - }' - - lang: python - source: | - from portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) - - tools = [ + }, + "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": "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"], - }, - } + "type": "code_interpreter" } - ] - - stream = client.beta.threads.runs.create( - thread_id="thread_abc123", - assistant_id="asst_abc123", - tools=tools, - stream=True - ) - - for event in stream: - print(event) - - lang: javascript - source: | - import Portkey from 'portkey-ai'; - - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); - - 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 client.beta.threads.runs.create( - "thread_abc123", - { - assistant_id: "asst_abc123", - tools: tools, - stream: true - } - ); - - for await (const event of stream) { - console.log(event); + ], + "tool_resources": { + "code_interpreter": { + "file_ids": [ + "file-abc123", + "file-abc456" + ] } - } - - 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":{}} + }, + "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" - 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":{}} + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] - event: thread.message.delta - data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}} + 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" + ) - event: thread.message.delta - data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" today"}}]}} + run = client.beta.threads.runs.create( + thread_id="thread_abc123", + assistant_id="asst_abc123" + ) - event: thread.message.delta - data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}} + print(run) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - 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":{}} + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - 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}} + async function main() { + const run = await client.beta.threads.runs.create( + "thread_abc123", + { assistant_id: "asst_abc123" } + ); - 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}} + console.log(run); + } - event: done - data: [DONE] + 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}: get: @@ -5007,246 +4408,122 @@ paths: Custom-Host: [] x-code-samples: - - title: Default - 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 + - 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." - } - ] - ) + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - print(run) - - lang: javascript - source: | - import Portkey from 'portkey-ai'; + 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." + } + ] + ) - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + print(run) + - lang: javascript + source: | + import Portkey from 'portkey-ai'; - 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.", - }, - ], - } - ); + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - console.log(run); - } + 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.", + }, + ], + } + ); - 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 - } + console.log(run); + } - - title: Streaming - 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." + 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"] } - ], - "stream": true - }' - - lang: python - source: | - from portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) - - 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) - - lang: javascript - source: | - import Portkey from 'portkey-ai'; - - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); - - async function main() { - const stream = await client.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); + }, + "required": ["location"] } } - - 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] + } + ], + "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: post: From d95b84fb4cd7d3945ae0dec6e921f7b48831bfa4 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Wed, 12 Feb 2025 23:59:29 +0530 Subject: [PATCH 089/124] fix: create assistants fixed --- openapi.yaml | 84 ---------------------------------------------------- 1 file changed, 84 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index d007a477..66bad64f 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -2341,90 +2341,6 @@ paths: "temperature": 1.0, "response_format": "auto" } - - title: Files - 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 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" - }' - - 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 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) - - 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: - "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 From cd8a27fbf5b5e08c9fa14f647ff62e1b67a01f71 Mon Sep 17 00:00:00 2001 From: Mahesh Date: Tue, 25 Feb 2025 18:24:00 +0530 Subject: [PATCH 090/124] feat: add openapi spec for fine-tuning and batches api --- openapi.yaml | 548 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 353 insertions(+), 195 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 66bad64f..b638128f 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1376,23 +1376,27 @@ paths: /fine_tuning/jobs: 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: - - Fine-tuning - description: | - Creates a fine-tuning job on [OpenAI](https://platform.openai.com/docs/guides/fine-tuning), [AWS Bedrock](https://aws.amazon.com/blogs/aws/customize-models-in-amazon-bedrock-with-your-own-data-using-fine-tuning-and-continued-pre-training/), or [Fireworks](https://docs.fireworks.ai/fine-tuning/fine-tuning-models). + - Finetune requestBody: - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/CreateFineTuningJobRequest" - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/FineTuningJob" + required: true + content: + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/OpenAIFinetuneJob' + - $ref: '#/components/schemas/BedrockFinetuneJob' + - $ref: '#/components/schemas/PortkeyFinetuneJob' security: - Portkey-Key: [] @@ -6120,43 +6124,15 @@ paths: 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 + 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. @@ -13303,155 +13279,160 @@ components: - object - deleted - CreateFineTuningJobRequest: - type: object - properties: - model: - description: | - The name of the model to fine-tune. Choose from supported models by [OpenAI](https://platform.openai.com/docs/guides/fine-tuning#which-models-can-be-fine-tuned), [Bedrock](https://aws.amazon.com/blogs/aws/customize-models-in-amazon-bedrock-with-your-own-data-using-fine-tuning-and-continued-pre-training/), or [Fireworks](https://docs.fireworks.ai/fine-tuning/fine-tuning-models#supported-base-models). - 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. + 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' - 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 + 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: - 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 + 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: - 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. + 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 - Your dataset must be formatted as a JSONL file. You must upload your file with the purpose `fine-tune`. + 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 - 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" + 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. - 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 + VertexFinetuneJob: + type: object + allOf: + - $ref: '#/components/schemas/OpenAIFinetuneJob' ListFineTuningJobEventsResponse: type: object @@ -18798,6 +18779,183 @@ components: - title: Completions $ref: "#/components/schemas/CreateCompletionRequest" + 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 + - metadata + 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 + 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 security: - Portkey-Key: [] From 08f07eb4268eb23a161ed5284c4dd46681661772 Mon Sep 17 00:00:00 2001 From: Mahesh Date: Tue, 25 Feb 2025 18:27:32 +0530 Subject: [PATCH 091/124] chore: make metadata optional --- openapi.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index b638128f..a107acc1 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -18828,7 +18828,6 @@ components: - input_file_id - completion_window - endpoint - - metadata properties: input_file_id: type: string @@ -18848,6 +18847,7 @@ components: 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 From f4db75c2f31743da7be79ea0df9f07425cf7e8fd Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Sat, 15 Mar 2025 18:46:38 +0530 Subject: [PATCH 092/124] update with response objects --- openapi.yaml | 38026 +++++++++++++++++++++++++------------------------ 1 file changed, 19049 insertions(+), 18977 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index fadb11f9..8bae0843 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1,19461 +1,19533 @@ 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.wiki/community - license: - name: MIT - url: https://github.com/Portkey-AI/portkey-openapi/blob/master/LICENSE + 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 servers: - - url: https://api.portkey.ai/v1 + - 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: Prompts - description: Given a prompt template ID and variables, will run the saved prompt template and 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: Custom Logger to add external logs to Portkey. - - 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. + - 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: Prompts + description: Given a prompt template ID and variables, will run the saved prompt template and 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: Custom Logger to add external logs to Portkey. + - 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. 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 - servers: - - url: https://api.portkey.ai/v1 - - url: http://localhost:8080/v1 - 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 - 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: python - 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: javascript - source: | - import Portkey from 'portkey-ai'; - - const portkey = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); - - async function main() { - const response = await client.chat.completions.create({ - messages: [{ role: "system", content: "You are a helpful assistant." }], - model: "gpt-4o", - }); + # 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 + servers: + - url: https://api.portkey.ai/v1 + - url: http://localhost:8080/v1 + 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" - console.log(response.choices[0]); - } + 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 + 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: python + 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: javascript + source: | + import Portkey from 'portkey-ai'; + + const portkey = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); + + async function main() { + const response = await client.chat.completions.create({ + messages: [{ role: "system", content: "You are a helpful assistant." }], + model: "gpt-4o", + }); - main(); + console.log(response.choices[0]); + } - /completions: - 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 - 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 - 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 - 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(); - main(); + /completions: + 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 + 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 + 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 + 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, + }); - /prompts/{promptId}/completions: - 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: + console.log(response); + } + + main(); + + /prompts/{promptId}/completions: + 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 - 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' - 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 - 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' - 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); - - /prompts/{promptId}/render: - 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' - 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 - 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' - 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); - - /images/generations: - 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 - 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 - 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 - 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(); - - /images/edits: - 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 - 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 - 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 - 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(); - - /images/variations: - 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 - 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 - 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 - 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(); - - /embeddings: - 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 - 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 - 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 - 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(); + 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" + 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 + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key="PORTKEY_API_KEY" + ) - /audio/speech: - 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 - 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 - 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 - 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(); + 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" + 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); + + /prompts/{promptId}/render: + 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" + 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 + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key="PORTKEY_API_KEY" + ) - /audio/transcriptions: - 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 - 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 - 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 - 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(); + 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" + 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); + + /images/generations: + 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 + 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 + 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 + 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(); + + /images/edits: + 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 + 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 + 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 + 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", + }); - /audio/translations: - 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 - 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 - 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 - 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(); + console.log(image.data); + } + main(); + + /images/variations: + 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 + 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 + 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 + 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"), + }); - /files: - 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); - } - } + console.log(image.data); + } + main(); + + /embeddings: + 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 + 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 + 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 + 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", + }); - main(); + console.log(embedding); + } - 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(); - main(); + /audio/speech: + 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 + 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 + 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 + 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(); + + /audio/transcriptions: + 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 + 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 + 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 + 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", + }); - /files/{file_id}: - 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 + console.log(transcription.text); + } + main(); + + /audio/translations: + 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 + 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 + 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 + 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", + }); - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + console.log(translation.text); + } + main(); + + /files: + 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); + } + } - client.files.delete("file-abc123") - - lang: javascript - source: | - import Portkey from 'portkey-ai'; + main(); - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + 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", + }); - async function main() { - const file = await client.files.del("file-abc123"); + console.log(file); + } - console.log(file); - } + main(); - main(); + /files/{file_id}: + 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: + 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 - 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); - } + 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: + 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 + 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 + 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 + 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" + }); - main(); + console.log(fineTune); + } - /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 + main(); - 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: - 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 - source: | - curl https://api.portkey.ai/v1/fine_tuning/jobs \ + 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 + 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 + 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 + 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(); + + /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" + + 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/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F \ + -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.fine_tuning.jobs.retrieve("ftjob-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 fineTune = await client.fineTuning.jobs.retrieve("ftjob-abc123"); + + console.log(fineTune); + } + + main(); + + /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" + + 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/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 + 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 + 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(); + + /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" + + 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 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 + 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 + 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(); + + /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" + + 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/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 + source: | + Reach out to us on portkey.wiki/community + - lang: javascript + source: | + Reach out to us on portkey.wiki/community + + /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" + + 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 \ + -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.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.models.list(); + + for await (const model of list) { + console.log(model); + } + } + 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: + 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 + 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 + 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 + 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(); + + /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" + + 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" \ - -d '{ - "training_file": "file-BK7bzQj3FfZFXr7DbL6xJwfo", - "model": "gpt-3.5-turbo" - }' - - lang: python - 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 - 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(); - - 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 - 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 - 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 - 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(); + -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", + }); - /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" - - 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/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F \ - -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.fine_tuning.jobs.retrieve("ftjob-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 fineTune = await client.fineTuning.jobs.retrieve("ftjob-abc123"); - - console.log(fineTune); - } + 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: + "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", + }); - main(); + 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}: + 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 + } + + /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" + + 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.", + }, + ], + }); - /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" - - 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/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 - 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 - 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); + 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" + + 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: + 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": [] } } - - main(); - - /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" - - 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 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 - 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 - 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(); - - /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" - - 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/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 - source: | - Reach out to us on portkey.wiki/community - - lang: javascript - source: | - Reach out to us on portkey.wiki/community - - /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" - - 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 \ - -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.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.models.list(); - - for await (const model of list) { - console.log(model); - } + ], + "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": [] } - 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: - 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 - 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 - 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 - 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); + ], + "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": [] } - main(); - - /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" - - 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: - "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}: - 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); - } + } + ], + "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" + + 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: + 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" + ) - 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" - } - ); + run = client.beta.threads.create_and_run( + assistant_id="asst_abc123", + thread={ + "messages": [ + {"role": "user", "content": "Explain deep learning to a 5 year old."} + ] + } + ) - console.log(myUpdatedAssistant); - } + 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." }, + ], + }, + }); - 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); + 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: + 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" } - 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" - - 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." - }, + ], + "tool_resources": { + "code_interpreter": { + "file_ids": [ + "file-abc123", + "file-abc456" ] - ) - - 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: | + }, + "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": [ { - "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" - - 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); + "type": "code_interpreter" } - - main(); - response: | - { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699014083, - "metadata": {}, - "tool_resources": { - "code_interpreter": { - "file_ids": [] - } - } + ], + "tool_resources": { + "code_interpreter": { + "file_ids": [ + "file-abc123", + "file-abc456" + ] } - 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" }, - } - ); + }, + "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}: + 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: + 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" + ) - console.log(updatedThread); - } + 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." + } + ] + ) - main(); - response: | + 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: [ { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699014083, - "metadata": { - "modified": "true", - "user": "abc123" + 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"] + } }, - "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); + "required": ["location"] } - 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" - - 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}: - 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: - 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: - 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}: - 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: - 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: - 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: - 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}: - 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); + } + ], + "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: + 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: + 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" } - - 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: - 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 - 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 - 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 - 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(); - - 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 - 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 - source: | - from portkey_ai import Portkey - - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) - - client.batches.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.batches.list(); - - for await (const batch of list) { - console.log(batch); - } - } - - main(); - - /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" - - 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/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 - 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 - 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(); - - /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" - - 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/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 - 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 - 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(); - - /configs: - 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 - items: - 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 - 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 - 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); - - post: - summary: Create a config - tags: - - Configs - operationId: createConfig - requestBody: + }, + "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: - 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 - 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 - 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); - - /configs/{slug}: - get: - summary: Get a config - tags: - - Configs - operationId: getConfig - parameters: - - name: slug - in: path - required: true + $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: - type: string - responses: - "200": - description: Config details - content: - application/json: - schema: - type: object - properties: - success: - type: boolean - data: - type: object - properties: - config: - type: object - properties: - retry: - type: object - properties: - attempts: - type: integer - on_status_codes: - type: array - items: - type: integer - cache: - type: object - properties: - 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 - 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 - 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); - - put: - summary: Update a config - tags: - - Configs - operationId: updateConfig - parameters: - - name: slug - in: path - required: true + $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: - type: string - requestBody: + $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: - 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 - data: - type: object - properties: - 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 - 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 - 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); - - /feedback: - post: - summary: Create new feedback - description: This endpoint allows users to submit feedback for a particular interaction or response. - operationId: createFeedback - tags: - - Feedback - requestBody: + $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/FeedbackRequest" - examples: - thumbsUpExample: - summary: Thumbs Up Feedback - value: - trace_id: "REQUEST_TRACE_ID" - value: 1 - thumbsDownExample: - summary: Thumbs Down Feedback - value: - trace_id: "REQUEST_TRACE_ID" - value: 0 - responses: - "200": - description: Feedback successfully saved - content: - application/json: - schema: - $ref: "#/components/schemas/FeedbackResponse" - - /feedback/{id}: - 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 + $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: - type: string - format: uuid - tags: - - Feedback - requestBody: + $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/FeedbackUpdateRequest" - examples: - thumbsUpExample: - summary: Thumbs Up Feedback - value: - value: 1 - thumbsDownExample: - summary: Thumbs Down Feedback - value: - value: 0 - responses: - "200": - description: Feedback successfully updated - content: - application/json: - schema: - $ref: "#/components/schemas/FeedbackResponse" - - /virtual-keys: - get: - summary: List All Virtual Keys - tags: - - Virtual-keys - responses: - '200': - description: Successful response - content: - application/json: - schema: - type: object - properties: - object: - type: string - enum: [list] - total: - type: integer - description: Total number of virtual keys - data: - type: array - items: - $ref: '#/components/schemas/VirtualKeys' - '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 - 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 - source: | - import { Portkey } from "portkey-ai"; - - const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", - }) - - const virtualKeys=await portkey.virtualKeys.list({}) - console.log(virtualKeys); - - - post: - summary: Create a Virtual Key - tags: - - Virtual-keys - requestBody: + $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: - 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" - examples: - generic: - value: - name: "My first virtual key" - provider: "openai" - key: "sk-jhkfkjs8d9f7jksfghkjhfg" - note: "Virtual key description" - usage_limits: {"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},{"apiVersion":"a","alias":"b","deploymentName":"c", is_default: false}] - 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 - properties: - slug: - type: string - '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 - 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 - 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); - - /virtual-keys/{slug}: - 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 - data: - type: object - properties: - message: - type: string - example: - success: false - data: - message: "Unauthorised Request" - x-code-samples: - - lang: python - 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 - 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); - - put: - summary: Update a Virtual Key - tags: - - Virtual-keys - parameters: - - in: path - name: slug - required: true - schema: - type: string - requestBody: + $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: - 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" - 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 - 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 - 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); - - 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 - 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 - 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); - - /admin/users/invites: - 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: + $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/CreateInvite' - x-code-samples: - - lang: python - 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 - 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); - - - 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 - 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 - 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); - - /admin/users/invites/{inviteId}: - 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 - 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 - 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); - 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 - 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 - 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); - - /admin/users/invites/{inviteId}/resend: - 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 - 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 - 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); - - /admin/users: - 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 - 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 - source: | - import { Portkey } from "portkey-ai"; - - const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", - }) - - const users=await portkey.admin.users.list({}) - - console.log(users); - - - /admin/users/{userId}: - 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 - 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 - 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); - - 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 - 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 - 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); - 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 - 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 - 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); - - /admin/workspaces/{workspaceId}/users: - 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 - 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 - 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 - 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); - - - 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 - 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 - 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); - - - /admin/workspaces/{workspaceId}/users/{userId}: - put: - tags: - - Workspaces > Members - summary: Update workspace member - requestBody: - content: - application/json: - schema: - type: object - properties: - role: - type: string - enum: - - admin - - member - 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 - 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 - 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); - - - 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 - 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 - 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) - - - - 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 - 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 - 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); - - /admin/workspaces: - 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 - 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 - 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 - 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); - - get: - tags: - - Workspaces - summary: Get All - parameters: - - name: page_size - in: query - schema: - type: integer - example: '1' - - name: current_page - in: query - schema: - type: integer - example: '0' - 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' - defaults: - metadata: - foo: bar - 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' - defaults: - metadata: - foo: bar - object: workspace - x-code-samples: - - lang: python - 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 - source: | - import { Portkey } from "portkey-ai"; - - const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", - }) - - const workspaces=await portkey.admin.workspaces.list({}) - console.log(workspaces); - - - /admin/workspaces/{workspaceId}: - 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 - 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: - $ref: '#/components/schemas/Workspace' - x-code-samples: - - lang: python - 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 - 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); - - - 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 - 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 - 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); - - 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 - source: | - from portkey_ai import Portkey - - # Initialize the Portkey client - portkey = Portkey( - api_key="PORTKEY_API_KEY", - ) - - # Delete workspace - result = portkey.admin.workspaces.delete( - name='WORKSPACE_NAME_0909', - workspace_id='WORKSPACE_SLUG' - ) - - print(result) - - lang: javascript - source: | - import { Portkey } from "portkey-ai"; - - const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", - }) - - const workspace=await portkey.admin.workspaces.delete({ - name: 'WORKSPACE_NAME_0909', - workspaceId: 'WORKSPACE_SLUG', - }) - console.log(workspace); - - /logs: - post: - summary: Submit 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 - 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 - 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(); - - /logs/exports/{exportId}: - 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 - 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 - 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(); - 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 - 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 - 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(); - /logs/exports: - 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 - 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 - 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(); - 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 - 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 - 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(); - /logs/exports/{exportId}/start: - 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 - 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 - 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(); - /logs/exports/{exportId}/cancel: - 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 - 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 - 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(); - /logs/exports/{exportId}/download: - 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 - 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 - 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() - - /api-keys/{type}/{sub-type}: - post: - tags: - - Api-Keys - summary: Create Api Keys - 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 - 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 - 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); - - - /api-keys: - 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 - source: | - from portkey_ai import Portkey - - # Initialize the Portkey client - portkey = Portkey( - api_key="PORTKEY_API_KEY", - ) - - # List API keys - api_keys = portkey.api_keys.list( - workspace_id="WORKSPACE_SLUG" - ) - - print(api_keys) - - lang: javascript - source: | - import { Portkey } from "portkey-ai"; - - const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", - }) - - const apiKey=await portkey.apiKeys.list({ - workspace_id:"WORKSPACE_SLUG" - }) - - console.log(apiKey); - - /api-keys/{id}: - put: - tags: - - Api-Keys - summary: Update Api Keys - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/UpdateApiKeyObject" - 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 - 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 - 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); - - - 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 - 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 - 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); - - - delete: - tags: - - Api-Keys - summary: Remove a 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 - 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 - 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); - - - /analytics/graphs/requests: - get: - tags: - - Analytics > Graphs - summary: Get requests 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: - total: - type: integer - description: Total requests 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 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: - get: - tags: - - Analytics > Graphs - summary: Get cost 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: - 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: - 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: - get: - tags: - - Analytics > Graphs - summary: Get latency 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: - 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 - - required: - - avg - - p50 - - p90 - - p99 - 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 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: - get: - tags: - - Analytics > Graphs - summary: Get tokens 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: - total: - type: integer - description: Total tokens across all data points - avg: - type: integer - description: Average tokens per request across all data points - required: - - total - - avg - 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 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: - get: - tags: - - Analytics > Graphs - summary: Get users graph. Returns unique user count across different time buckets - 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: - total: - type: integer - description: Total unique users 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 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: - get: - tags: - - Analytics > Graphs - summary: Get users requests graph. Returns average requests per user across different time buckets - 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: - 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: - get: - tags: - - Analytics > Graphs - summary: Get errors 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: - total: - type: integer - description: Total errors 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 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: - get: - tags: - - Analytics > Graphs - summary: Get percentage error rate 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: - 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: - get: - tags: - - Analytics > Graphs - summary: Get status code wise stacked 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: - total: - type: integer - description: Total errors 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 - 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: - 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: - 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: - - 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: - get: - tags: - - Analytics > Graphs - summary: Get retry and fallback rescued requests 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: - 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: - - 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: - get: - tags: - - Analytics > Graphs - summary: Get cache hit rate 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: - 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: - get: - tags: - - Analytics > Graphs - summary: Get cache hit latency 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 - 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: - get: - tags: - - Analytics > Graphs - summary: Get feedbacks 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: - 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: - get: - tags: - - Analytics > Graphs - summary: Get score-wise feedbacks distribution 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: - 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: - get: - tags: - - Analytics > Graphs - summary: Get weighted feedbacks graph. Weighted feedback is (value * score) - 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: - avg: - type: integer - description: Average weighted feedback across all data points - required: - - 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: - get: - tags: - - Analytics > Graphs - summary: Get feedbacks per ai_models 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 - 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: - get: - tags: - - Analytics > Summary - summary: Get cache summary data for the selected time period - 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: - 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: - get: - tags: - - Analytics > Groups - summary: Get metadata users grouped data. - 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/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 - enum: [list] - total: - type: integer - description: Total records present across all pages - data: - type: array - items: - 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: - get: - tags: - - Analytics > Groups - summary: Get ai model grouped data. - 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/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 - 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}: - get: - tags: - - Analytics > Groups - summary: Get metadata key based grouped data. - parameters: - - name: metadataKey - in: path - schema: - type: string - required: true - - $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/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 - 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 - -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 - description: Minimum time of generation (ISO8601 format) - example: '2024-08-23T15:50:23+05:30' - TimeOfGenerationMax: - in: query - name: time_of_generation_max - required: true - schema: - type: string - format: date-time - description: Maximum time of generation (ISO8601 format) - example: '2024-08-23T15:50:23+05:30' - 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 - 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 - - 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 - - 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 - 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-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 - - 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-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" - 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 - - - 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 - - - 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 - - - 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 - - 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": "..." - } - - 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 + $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: + 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 + 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 + 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 + 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" + }); - 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 + console.log(batch); + } + main(); - ListFilesResponse: - type: object - properties: - data: + 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 + 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 + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) + + client.batches.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.batches.list(); + + for await (const batch of list) { + console.log(batch); + } + } + + main(); + + /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" + + 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/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 + 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 + 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(); + + /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" + + 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/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 + 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 + 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(); + + /configs: + 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 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. + 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 + source: | + from portkey_ai import Portkey - 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 + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) - DeleteFileResponse: - type: object - properties: - id: - type: string - object: - type: string - enum: [file] - deleted: - type: boolean - required: - - id - - object - - deleted + # Retrieve the configuration + config = portkey.configs.list( + workspace_id="WORKSPACE_ID" + ) - 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' + print(config) + - lang: javascript + source: | + import { Portkey } from "portkey-ai"; - 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: + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + }) + + 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: - type: + name: 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: + config: 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: + 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 - 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: + data: 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: + id: type: string - enum: - - word - - segment - default: [segment] - required: - - file - - model + 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 + source: | + from portkey_ai import Portkey - # 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 + 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 + source: | + import { Portkey } from "portkey-ai"; - 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] + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + }) - 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] + 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}: + get: + 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 + properties: + config: + type: object + properties: + retry: + type: object + properties: + attempts: + type: integer + on_status_codes: + type: array + items: + type: integer + cache: + type: object + properties: + 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 + source: | + from portkey_ai import Portkey + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) - 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 + # Retrieve the configuration + config = portkey.configs.retrieve( + slug='CONFIG_SLUG' + ) - # Note: This does not currently support the non-default response format types. - CreateTranslationResponseJson: - type: object - properties: - text: - type: string - required: - - text + print(config) + - lang: javascript + source: | + import { Portkey } from "portkey-ai"; - 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] + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY", + }) - 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 + const config=await portkey.configs.retrieve({ + slug:'CONFIG_SLUG' + }) - 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 - - 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", - ] + console.log(config); + + put: + 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 - 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: | + 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 + data: + type: object + properties: + version_id: + type: string + format: uuid + examples: + example-1: + value: { - "id": "file-abc123", - "object": "file", - "bytes": 120000, - "created_at": 1677610602, - "filename": "salesOverview.pdf", - "purpose": "assistants", + "success": true, + "data": + { + "version_id": "abe447e2-f6aa-4229-93b7-8ee3183b6667", + }, } - 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 + x-code-samples: + - lang: python + 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 + source: | + import { Portkey } from "portkey-ai"; - 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: + 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); + + /feedback: + 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" + examples: + thumbsUpExample: + summary: Thumbs Up Feedback + value: + trace_id: "REQUEST_TRACE_ID" + value: 1 + thumbsDownExample: + summary: Thumbs Down Feedback + value: + trace_id: "REQUEST_TRACE_ID" + value: 0 + responses: + "200": + description: Feedback successfully saved + content: + application/json: + schema: + $ref: "#/components/schemas/FeedbackResponse" + + /feedback/{id}: + 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" + examples: + thumbsUpExample: + summary: Thumbs Up Feedback + value: + value: 1 + thumbsDownExample: + summary: Thumbs Down Feedback + value: + value: 0 + responses: + "200": + description: Feedback successfully updated + content: + application/json: + schema: + $ref: "#/components/schemas/FeedbackResponse" + + /virtual-keys: + get: + summary: List All Virtual Keys + tags: + - Virtual-keys + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + properties: + object: 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: + enum: [list] + total: 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: + description: Total number of virtual keys + data: 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 + $ref: "#/components/schemas/VirtualKeys" + "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 + 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() - 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: + print(virtual_keys) + - lang: javascript + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const virtualKeys=await portkey.virtualKeys.list({}) + console.log(virtualKeys); + + 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 - 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: | + 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" + examples: + generic: + value: + name: "My first virtual key" + provider: "openai" + key: "sk-jhkfkjs8d9f7jksfghkjhfg" + note: "Virtual key description" + usage_limits: { - "object": "fine_tuning.job.event", - "id": "ftevent-abc123" - "created_at": 1677610602, - "level": "info", - "message": "Created fine-tuning job" + "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, + }, + { + "apiVersion": "a", + "alias": "b", + "deploymentName": "c", + is_default: false, + }, + ] + 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 + properties: + slug: + type: string + "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 + 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 + 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); + + /virtual-keys/{slug}: + 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 + data: + type: object + properties: + message: + type: string + example: + success: false + data: + message: "Unauthorised Request" + x-code-samples: + - lang: python + 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 + 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); + + 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" + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object - 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: + "401": + description: Unauthorized response + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + data: 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: | + message: + type: string + example: + success: false + data: + message: "Unauthorised Request" + x-code-samples: + - lang: python + 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 + 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); + + 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 + 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 + 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); + + /admin/users/invites: + 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 + 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=[ { - "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 + "id": "WORKSPACE_SLUG", + "role": "admin" } + ], + workspace_api_key_details={ + "scopes": [ + "workspaces.list", + "logs.export", + "logs.list", + "logs.view", + ] + } + ) + + print(user) + - lang: javascript + 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); + + 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 + 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 + 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); + + /admin/users/invites/{inviteId}: + 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 + 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 + 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); + 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 + 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 + 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" + }) - 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"]}}]} + console.log(user); - 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: + /admin/users/invites/{inviteId}/resend: + 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 - 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"} + format: uri + example: + inviteLink: https://app.portkey.ai/invite/some-invite-link + x-code-samples: + - lang: python + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) - 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 + # Delete a user invite + user = portkey.admin.users.invites.resend( + invite_id="INVITE_ID" + ) - 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`. + print(user) + - lang: javascript + source: | + import { Portkey } from "portkey-ai"; - Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) - **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 + const user=await portkey.admin.users.invites.resend({ + inviteId:"INVITE_ID" + }); - 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`. + console.log(user); - 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: + /admin/users: + 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 + 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 + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const users=await portkey.admin.users.list({}) + + console.log(users); + + /admin/users/{userId}: + 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 + 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 + 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); + + 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 + 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 + 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); + 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 + 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 + 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); + + /admin/workspaces/{workspaceId}/users: + post: + tags: + - Workspaces > Members + summary: Add workspace member + requestBody: + content: + application/json: + schema: + type: object + properties: + users: + 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](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. + id: + type: string + format: uuid + example: 25afb7bd-f98a-11ee-85fe-0e27d7367987 + role: + type: string + example: member + enum: + - admin + - member + 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 + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) - 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 + # Add user to workspace + user = portkey.admin.workspaces.users.create( + workspace_id="WORKSPACE_SLUG", + users=[ + { + "id": "USER_ID", + "role": "member" + } + ] + ) + + print(user) + - lang: javascript + 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); + + 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 + 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 + 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); + + /admin/workspaces/{workspaceId}/users/{userId}: + put: + tags: + - Workspaces > Members + summary: Update workspace member + requestBody: + content: + application/json: + schema: + type: object + properties: + role: + type: string + enum: + - admin + - member + 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 + 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 + 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); + + 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 + 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 + 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) + + 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 + 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 + 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); + + /admin/workspaces: + post: + tags: + - Workspaces + summary: Create Workspace + requestBody: + content: + application/json: + schema: + type: object + properties: name: - description: *assistant_name_param_description - type: string - nullable: true - maxLength: 256 + type: string description: - description: *assistant_description_param_description - type: string - nullable: true - maxLength: 512 - instructions: - description: *assistant_instructions_param_description + type: string + defaults: + type: object + properties: + metadata: + type: object + additionalProperties: + type: string + users: + type: array + items: 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 - 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 - - ModifyAssistantRequest: - type: object - additionalProperties: false - properties: - model: - description: *model_description - anyOf: - - type: string + 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 + 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 + 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); + + get: + tags: + - Workspaces + summary: Get All + parameters: + - name: page_size + in: query + schema: + type: integer + example: "1" + - name: current_page + in: query + schema: + type: integer + example: "0" + 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" + defaults: + metadata: + foo: bar + 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" + defaults: + metadata: + foo: bar + object: workspace + x-code-samples: + - lang: python + 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 + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const workspaces=await portkey.admin.workspaces.list({}) + console.log(workspaces); + + /admin/workspaces/{workspaceId}: + put: + tags: + - Workspaces + summary: Update Workspace + requestBody: + content: + application/json: + schema: + type: object + properties: name: - description: *assistant_name_param_description - type: string - nullable: true - maxLength: 256 + type: string 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 - response_format: - $ref: "#/components/schemas/AssistantsApiResponseFormatOption" - nullable: true + type: string + defaults: + type: object + properties: + metadata: + type: object + additionalProperties: + type: string + 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: + $ref: "#/components/schemas/Workspace" + x-code-samples: + - lang: python + 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 + 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); + + 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 + 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 + 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); + + 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 + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # Delete workspace + result = portkey.admin.workspaces.delete( + name='WORKSPACE_NAME_0909', + workspace_id='WORKSPACE_SLUG' + ) + + print(result) + - lang: javascript + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const workspace=await portkey.admin.workspaces.delete({ + name: 'WORKSPACE_NAME_0909', + workspaceId: 'WORKSPACE_SLUG', + }) + console.log(workspace); + + /logs: + post: + summary: Submit 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 + 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 + 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(); + + /logs/exports/{exportId}: + 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 + 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 + 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" + }); - DeleteAssistantResponse: - type: object - properties: - id: - type: string - deleted: - type: boolean - object: - type: string - enum: [assistant.deleted] - required: - - id - - object - - deleted + console.log(res); + } - 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 + 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 + 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 + 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" + } + }); - 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 + console.log(res); + } - AssistantToolsFileSearchTypeOnly: - type: object - title: FileSearch tool - properties: - type: - type: string - description: "The type of tool being defined: `file_search`" - enum: ["file_search"] - required: - - type + main(); + /logs/exports: + 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 + 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 + source: | + import Portkey from "portkey-ai"; + + async function main() { + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY" + }) - 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 + 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 + 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 + 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(); + /logs/exports/{exportId}/start: + 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 + 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 + 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(); + /logs/exports/{exportId}/cancel: + 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 + 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 + 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' + }); - 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 + console.log(res); + } - 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. + main(); + /logs/exports/{exportId}/download: + 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 + 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 + 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' + });; - 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 + console.log(config); + } - 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 + main() - 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: + /api-keys/{type}/{sub-type}: + post: + tags: + - Api-Keys + summary: Create Api Keys + 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 - 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: + format: uuid + example: "183f497a-2a7f-4f47-992e-26213fa863we" + key: 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: + example: "abssofjosfjs" + object: 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 + enum: ["api-key"] + example: "api-key" + x-code-samples: + - lang: python + source: | + from portkey_ai import Portkey - 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 + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) - 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: | + # 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 + 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); + + /api-keys: + 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 + source: | + from portkey_ai import Portkey + + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) + + # List API keys + api_keys = portkey.api_keys.list( + workspace_id="WORKSPACE_SLUG" + ) + + print(api_keys) + - lang: javascript + source: | + import { Portkey } from "portkey-ai"; + + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) + + const apiKey=await portkey.apiKeys.list({ + workspace_id:"WORKSPACE_SLUG" + }) + + console.log(apiKey); + + /api-keys/{id}: + put: + tags: + - Api-Keys + summary: Update Api Keys + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateApiKeyObject" + 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 + 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=[ { - "id": "thread_abc123", - "object": "thread", - "created_at": 1698107661, - "metadata": {} + "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 + 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" + ], - 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 + }) + console.log(apiKey); - ModifyThreadRequest: - type: object - additionalProperties: false - properties: - tool_resources: + 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 + 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 + 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); + + delete: + tags: + - Api-Keys + summary: Remove a 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 + 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 + 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); + + /analytics/graphs/requests: + get: + tags: + - Analytics > Graphs + summary: Get requests 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 - 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: + total: + type: integer + description: Total requests across all data points + required: + - total + 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](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: 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 - enum: ["in_progress", "incomplete", "completed"] - incomplete_details: - description: On an incomplete message, details about why the message is incomplete. + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/cost: + get: + tags: + - Analytics > Graphs + summary: Get cost 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: - 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 cost in cents across all data points + avg: + type: integer + description: Average cost 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. + - total + - avg + data_points: 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-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: 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 - enum: ["thread.message.delta"] - delta: - description: The delta containing the fields that have changed on the Message. + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/latency: + get: + tags: + - Analytics > Graphs + summary: Get latency 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: - 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": [] } - } - ] - } - } + 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 - 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: + - avg + - p50 + - p90 + - p99 + 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](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: + 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: + get: + tags: + - Analytics > Graphs + summary: Get tokens 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: - 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 tokens across all data points + avg: + type: integer + description: Average tokens per request 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: - 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`. + - total + - avg + 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 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 - enum: ["text"] - text: + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/users: + get: + tags: + - Analytics > Graphs + summary: Get users graph. Returns unique user count across different time buckets + 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: - 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 unique users 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. + - 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 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 - file_citation: + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/users/requests: + get: + tags: + - Analytics > Graphs + summary: Get users requests graph. Returns average requests per user across different time buckets + 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: + 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: - - 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. + - 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 - file_path: + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/errors: + get: + tags: + - Analytics > Graphs + summary: Get errors 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 file that was generated. - type: string + total: + type: integer + description: Total errors 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`. + - 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 - enum: ["text"] - text: + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/errors/rate: + get: + tags: + - Analytics > Graphs + summary: Get percentage error rate 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: - 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. + 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 - file_citation: + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/errors/stacks: + get: + tags: + - Analytics > Graphs + summary: Get status code wise stacked 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 - 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. + total: + type: integer + description: Total errors 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 + 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 - file_path: + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/errors/status-codes: + 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 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`. + 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: + - 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 - 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: + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/requests/rescued: + get: + tags: + - Analytics > Graphs + summary: Get retry and fallback rescued requests 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 - 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. + 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: - - 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. + - 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: + get: + tags: + - Analytics > Graphs + summary: Get cache hit rate 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: - 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: + 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: + get: + tags: + - Analytics > Graphs + summary: Get cache hit latency 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 + data_points: 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: 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 - enum: ["message_creation"] - message_creation: + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/feedbacks: + get: + tags: + - Analytics > Graphs + summary: Get feedbacks 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: - message_id: - type: string - description: The ID of the message that was created by this run step. + total: + type: integer + description: Total feedbacks across all data points 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`. + - 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 - enum: ["message_creation"] - message_creation: + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/feedbacks/scores: + get: + tags: + - Analytics > Graphs + summary: Get score-wise feedbacks distribution 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: - 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: + total: + type: integer + description: Total feedbacks across all data points + required: + - total + data_points: 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: 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 - enum: ["tool_calls"] - tool_calls: + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/feedbacks/weighted: + get: + tags: + - Analytics > Graphs + summary: Get weighted feedbacks graph. Weighted feedback is (value * score) + 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: + avg: + type: integer + description: Average weighted feedback across all data points + required: + - avg + data_points: 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: 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 tool call. This is always going to be `code_interpreter` for this type of tool call. - enum: ["code_interpreter"] - code_interpreter: + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/graphs/feedbacks/ai-models: + get: + tags: + - Analytics > Graphs + summary: Get feedbacks per ai_models 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 - 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: + 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 tool call. This is always going to be `code_interpreter` for this type of tool call. - enum: ["code_interpreter"] - code_interpreter: + description: The type of object being returned + enum: [analytics-graph] + required: + - summary + - data_points + - object + + /analytics/summary/cache: + get: + tags: + - Analytics > Summary + summary: Get cache summary data for the selected time period + 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 - 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`. + 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 - enum: ["logs"] - logs: + description: The type of object being returned + enum: [analytics-summary] + required: + - summary + - object + + /analytics/groups/users: + get: + tags: + - Analytics > Groups + summary: Get metadata users grouped data. + 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/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 - 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: + enum: [list] + total: 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`. + description: Total records present across all pages + data: + type: array + items: + 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: + get: + tags: + - Analytics > Groups + summary: Get ai model grouped data. + 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/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 - 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: + enum: [list] + total: type: integer - description: The index of the output in the outputs array. - type: - description: Always `image`. + 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}: + get: + tags: + - Analytics > Groups + summary: Get metadata key based grouped data. + parameters: + - name: metadataKey + in: path + schema: + type: string + required: true + - $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/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 - 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 + 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 - 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 +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 + description: Minimum time of generation (ISO8601 format) + example: "2024-08-23T15:50:23+05:30" + TimeOfGenerationMax: + in: query + name: time_of_generation_max + required: true + schema: + type: string + format: date-time + description: Maximum time of generation (ISO8601 format) + example: "2024-08-23T15:50:23+05:30" + 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 + 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 + + 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 + + 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. - 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 + 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`. - 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 + **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. - 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 + 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. - 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 + 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. - VectorStoreObject: + 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 - 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 - } - - CreateVectorStoreRequest: - type: object - additionalProperties: false + - finish_reason + - index + - logprobs + - text 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. + 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 - 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: integer + token_logprobs: type: array items: - $ref: "#/components/schemas/VectorStoreObject" - first_id: - type: string - example: "vs_abc123" - last_id: - type: string - example: "vs_abc456" - has_more: - type: boolean - example: false - required: - - object - - data - - first_id - - last_id - - has_more + type: 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. - DeleteVectorStoreResponse: - type: object - properties: - id: - type: string - deleted: - type: boolean - object: - type: string - enum: [vector_store.deleted] - required: - - id - - object - - deleted + 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 + + 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. - 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 - } - } - } + 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. - 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 + 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. - 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 + 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. - 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`. + 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). - Note that the overlap must not exceed half of `max_chunk_size_tokens`. - required: - - max_chunk_size_tokens - - chunk_overlap_tokens + Setting to `{ "type": "json_object" }` enables the older JSON mode, which ensures the message the model generates is valid JSON. - 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 + 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" + 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`. - 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 + A list of functions the model may generate JSON inputs for. + type: array + minItems: 1 + maxItems: 128 + items: + $ref: "#/components/schemas/ChatCompletionFunctions" - 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 + required: + - model + - messages - CreateVectorStoreFileRequest: + 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 - 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: + - finish_reason + - index + - message + - logprobs properties: - object: - type: string - example: "list" - data: + 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/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 + $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. - DeleteVectorStoreFileResponse: + 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: - id: - type: string - deleted: - type: boolean - object: - type: string - enum: [vector_store.file.deleted] required: - - id - - object - - deleted + - 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. - VectorStoreFileBatchObject: + 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 - 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 + token: *chat_completion_response_logprobs_token + logprob: *chat_completion_response_logprobs_token_logprob + bytes: *chat_completion_response_logprobs_bytes 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: + - 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 - additionalProperties: false + required: + - delta + - finish_reason + - index 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" + 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 + + 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": "..." + } + + 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: - - 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)" - - 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)" + - flagged + - categories + - category_scores + required: + - id + - model + - results + + 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. - 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 + 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: - event: - type: string - enum: ["thread.run.step.cancelled"] - data: - $ref: "#/components/schemas/RunStepObject" + n_epochs: + type: integer + format: int32 + learning_rate_multiplier: + type: number + format: float + batch_size: + type: integer + format: int32 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 + - n_epochs + - learning_rate_multiplier + - batch_size + required: + - hyperparameters + dpo: + type: object + properties: + hyperparameters: + type: object properties: - event: - type: string - enum: ["thread.run.step.expired"] - data: - $ref: "#/components/schemas/RunStepObject" + n_epochs: + type: integer + format: int32 + learning_rate_multiplier: + type: number + format: float + batch_size: + type: integer + format: int32 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)" + - n_epochs + - learning_rate_multiplier + - batch_size + required: + - hyperparameters + required: + - type + description: Hyperparameters for the finetune job - 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)" + 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 - 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)" + 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. 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 + + 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. 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 + + 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", + } + 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" - DoneEvent: - type: object - properties: - event: - type: string - enum: ["done"] - data: + 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"} + + 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 - enum: ["[DONE]"] - required: - - event - - data - description: Occurs when a stream ends. - x-code-samples: - dataDescription: "`data` is `[DONE]`" - - Batch: - type: object - properties: - id: + 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 - object: + 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 - enum: [batch] - description: The object type, which is always `batch`. - endpoint: + 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 - description: The Portkey API endpoint used by the batch. - - errors: + 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: - object: - type: string - description: The object type, which is always `list`. - data: - type: array - items: + 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: - 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 - - 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?"}]}} + 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`. - BatchRequestOutput: - type: object - description: The per-line object of the batch output and error files - properties: - id: + Note that the overlap must not exceed half of `max_chunk_size_tokens`. + required: + - max_chunk_size_tokens + - chunk_overlap_tokens + required: + - type + - static + x-oaiExpandable: true + metadata: + type: object + description: | + Set of 16 key-value pairs that can be attached to a vector store. This can be useful for storing additional information about the vector store in a structured format. Keys can be a maximum of 64 characters long and values can be a 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 + + 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 - custom_id: + 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 - 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: + 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 + + 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 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: + 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 - required: - - trace_id - - value + description: The function definition. properties: - trace_id: + name: 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: + 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 - additionalProperties: true - description: Additional metadata for the feedback. - - FeedbackResponse: + 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: - 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 - - FeedbackUpdateRequest: + 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 - required: - - value + 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: - 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: + code_interpreter: type: object - additionalProperties: true - description: Additional metadata for the feedback. + 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`. - RateLimits: - type: object - properties: - type: - type: string - enum: ["requests"] - unit: - type: string - enum: ["rpm"] - value: - type: integer - UsageLimits: + 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 - properties: - credit_limit: - type: integer - description: Credit Limit. Used for tracking usage - minimum: 1 - default: null - 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"] - example: - credit_limit: 10 - periodic_reset: monthly - alert_threshold: 8 - - VirtualKeys: + 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: - 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: + code_interpreter: type: object - rate_limits: - type: array - items: - $ref: '#/components/schemas/RateLimits' - nullable: true - object: - type: string - enum: [virtual-key] + 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 - Invite: + 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: - 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: + reason: type: string + description: The reason the message is incomplete. enum: - - pending - - cancelled - - accepted - - expired - invited_by: - type: string - format: uuid - InviteList: + [ + "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-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: - object: + role: + description: The entity that produced the message. One of `user` or `assistant`. type: string - enum: - - list - total: - type: integer - data: + enum: ["user", "assistant"] + content: + description: The content of the message in array of text and/or images. type: array items: - $ref: '#/components/schemas/Invite' + 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 + 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 - User: + 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: - object: + 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 - enum: - - user - id: + detail: type: string - format: uuid - first_name: + 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 - last_name: + detail: type: string - role: + 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 - enum: - - admin - - member - - owner - email: + description: "The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp." + format: uri + detail: type: string - format: email - created_at: + 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 - format: date-time - last_updated_at: + detail: type: string - format: date-time - workspace_ids: - type: array - - items: - type: string - UserList: + 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: - total: - type: integer - example: 2 - object: + value: + description: The data that makes up the text. type: string - enum: - - list - data: + annotations: type: array items: - $ref: '#/components/schemas/User' - - WorkspaceMember: + 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: - object: - type: string - example: workspace-user - enum: - - workspace-user - id: - type: string - format: uuid - example: 25afb7bd-f98a-11ee-85fe-0e27d7367987 - first_name: + file_id: + description: The ID of the specific File the citation is from. type: string - example: John - last_name: + quote: + description: The specific quote in the file. 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: + 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 - example: active - enum: - - active - WorkspaceMemberList: + 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: - total: - type: integer - example: 2 - object: + value: + description: The data that makes up the text. type: string - example: list - enum: - - list - data: + annotations: type: array items: - $ref: '#/components/schemas/WorkspaceMember' - - Workspace: + 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: - id: + file_id: + description: The ID of the specific File the citation is from. type: string - example: ws-test-a-174eb1 - slug: + quote: + description: The specific quote in the file. type: string - example: ws-test-a-174eb1 - name: - type: string - example: New Workspace - description: + 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 - nullable: true - example: null - created_at: + 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 - format: date-time - example: 2024-07-30T13:27:29.000Z - last_updated_at: + description: One of `server_error` or `rate_limit_exceeded`. + enum: ["server_error", "rate_limit_exceeded"] + message: type: string - format: date-time - example: 2024-07-30T13:27:29.000Z - defaults: + 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 - nullable: true - properties: - metadata: - type: object - additionalProperties: - type: string - example: - foo: bar - is_default: - type: integer - example: 0 - object: - type: string - enum: - - workspace + 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": [] } + } + ] + } + } + } - WorkspaceList: + 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: - total: - type: integer - example: 2 - object: + message_id: type: string - enum: - - list - data: - type: array - items: - $ref: '#/components/schemas/Workspace' - - WorkspaceWithUsers: + 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: - 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: + message_id: type: string - format: date-time - example: 2024-07-30T13:27:29.000Z - last_updated_at: + 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 - 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 - users: + 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 - $ref: '#/components/schemas/WorkspaceMember' - - 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: + 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: - object: + input: type: string - enum: [list] - total: - type: integer - data: + 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: - $ref: '#/components/schemas/ExportItem' - ExportItem: + 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: - id: + file_id: + description: The [file](https://platform.openai.com/docs/api-reference/files) ID of the image. type: string - format: uuid - organisation_id: - type: string - format: uuid - filters: - $ref: '#/components/schemas/GenerationsFilterSchema' - requested_data: - $ref: '#/components/schemas/LogExportsRequestedData' - status: + 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 - enum: - - draft - - in_progress - - success - - failed - - stopped - description: + 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 - created_at: + description: The name of the function. + arguments: type: string - format: date-time - last_updated_at: + description: The arguments passed to the function. + output: type: string - format: date-time - created_by: + 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 - format: uuid - workspace_id: + description: The name of the function. + arguments: type: string - format: uuid - object: + description: The arguments passed to the function. + output: type: string - enum: [export] - required: - - id - - organisation_id - - filters - - requested_data - - status - - description - - created_at - - last_updated_at - - created_by - - workspace_id - - object - UpdateExportResponse: + 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: - id: - type: string - format: uuid - description: The unique identifier of the updated export + 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 - description: The total number of items in the export - object: - type: string - enum: [export] - description: The type of the object required: - - id + - in_progress + - completed + - failed + - cancelled - total - - object - ExportTaskResponse: + 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 + } + + 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: - message: + code: type: string - description: A message indicating the status of the export task - object: + description: One of `server_error` or `rate_limit_exceeded`. + enum: + [ + "internal_error", + "file_not_found", + "parsing_error", + "unhandled_mime_type", + ] + message: type: string - enum: [export] - description: The type of the object + description: A human-readable description of the error. required: + - code - message - - object - DownloadLogsResponse: + chunking_strategy: type: object - properties: - signed_url: - type: string - format: uri - description: A pre-signed URL for downloading the exported logs - required: - - signed_url - GenerationsFilterSchema: + 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 + + 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: - time_of_generation_min: - type: string - format: date-time - time_of_generation_max: - type: string - format: date-time - total_units_min: + in_progress: + description: The number of files that are currently being processed. type: integer - total_units_max: - type: integer - cost_min: - type: number - cost_max: - type: number - ai_model: - type: string - prompt_token_min: + completed: + description: The number of files that have been processed. type: integer - prompt_token_max: + failed: + description: The number of files that have failed to process. type: integer - completion_token_min: + cancelled: + description: The number of files that where cancelled. type: integer - completion_token_max: + total: + description: The total number of files. type: integer - status_code: + 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 - metadata: - type: object - additionalProperties: true - ai_org_model: + 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)" + + RunStreamEvent: + oneOf: + - type: object + properties: + event: type: string - example: "openai__gpt-3.5-turbo, anthropic__claude-2.1" - weighted_feedback_min: - type: number - weighted_feedback_max: - type: number - virtual_keys: + 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 - trace_id: + 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 - configs: + 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 - workspace_slug: + 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 - prompt_slug: + 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 - - 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 - - ApiKeyObject: - type: object + 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: - id: + event: type: string - format: uuid - example: "f47ac10b-58cc-4372-a567-0e02b2c3d479" - key: + 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 - example: "Xk*******S4" - name: + 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 - example: "Development API Key" - description: + 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 - example: "API key for development environment" - type: + 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: ["organisation-service", "workspace-service", "workspace-user"] - example: "organisation-service" - organisation_id: + 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 - format: uuid - example: "a1b2c3d4-e5f6-4a5b-8c7d-9e0f1a2b3c4d" - workspace_id: + 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 - example: "ws-myworkspace" - user_id: + 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 - format: uuid - example: "c3d4e5f6-a7b8-6c7d-0e1f-2a3b4c5d6e7f" - status: + 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: ["active", "exhausted"] - example: "active" - created_at: + 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 - format: date-time - example: "2023-09-15T10:30:00Z" - last_updated_at: + 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 - format: date-time - example: "2023-09-15T10:30:00Z" - creation_mode: + 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 : ["ui", "api", "auto"] - example: "ui" - rate_limits: - type: array - items: - type: object - properties: - 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" - object: + 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 : ["api-key"] - example: "api-key" - - ApiKeyObjectList: - type: object + 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: - total: - type: integer - example: 2 - object: + event: type: string - enum: - - list + enum: ["thread.message.incomplete"] data: - type: array - items: - $ref: '#/components/schemas/ApiKeyObject' + $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)" + + 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. - CreateApiKeyObject: + errors: type: object 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: + object: type: string - format: uuid - example: "c3d4e5f6-a7b8-6c7d-0e1f-2a3b4c5d6e7f" - rate_limits: + description: The object type, which is always `list`. + data: type: array items: type: object properties: - type: + code: type: string - example: "requests" - unit: + description: An error code identifying the error type. + message: type: string - example: "rpm" - value: + 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 - example: 100 - usage_limits: - $ref: "#/components/schemas/UsageLimits" - scopes: - type: array - items: - type: string - example: ["completions.write"] - defaults: + 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 - 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" - - UpdateApiKeyObject: + 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: - name: + code: type: string - example: "Development API Key" - description: + description: A machine-readable error code. + message: type: string - example: "API key for development environment" - rate_limits: - type: array - items: - type: object - properties: - 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: + 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 + + 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"] + unit: + type: string + enum: ["rpm"] + value: + type: integer + UsageLimits: + type: object + properties: + credit_limit: + type: integer + description: Credit Limit. Used for tracking usage + minimum: 1 + default: null + 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"] + example: + credit_limit: 10 + periodic_reset: monthly + alert_threshold: 8 + + 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 + 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 - properties: - metadata: - type: object - additionalProperties: true - example: - environment: "development" - team: "backend" - config_id: - type: string - example: config-abc - alert_emails: - type: array - items: + additionalProperties: type: string - format: email - example: "foo@bar.com" + example: + foo: bar + is_default: + type: integer + example: 0 + object: + type: string + enum: + - workspace + + WorkspaceList: + type: object + properties: + total: + type: integer + example: 2 + object: + type: string + enum: + - list + data: + type: array + items: + $ref: "#/components/schemas/Workspace" - PromptRenderResponse: + 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 - required: - - success - - data + nullable: true 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" + metadata: + type: object + additionalProperties: + type: string + example: + foo: bar + is_default: + type: integer + example: 0 + object: + type: string + enum: + - workspace + users: + type: array + items: + type: object + $ref: "#/components/schemas/WorkspaceMember" - BedrockBatchJob: + CustomLog: + type: object + properties: + request: type: object - required: - - model - - role_arn properties: - job_name: + url: 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: + method: 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: + headers: + type: object + additionalProperties: + type: string + body: + type: object + required: + - url + - body + response: type: object properties: - role_arn: - type: string - description: Role ARN for the bedrock batch job - CommonBatchParams: - type: object + status: + type: integer + headers: + type: object + additionalProperties: + type: string + body: + type: object + response_time: + type: integer required: - - model + - body + metadata: + type: object properties: - job_name: + trace_id: type: string - description: Job name for the batch job - output_data_config: + span_id: type: string - description: Batch job's output storage location, will be constructed based on `input_file_id` if not provided - model: + span_name: type: string - description: Model to start batch job with + 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 - OpenAIBatchJob: + 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 + + 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: + 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 - 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 + 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" + 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" - PortkeyBatchJob: + CreateApiKeyObject: + type: object + 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 + example: "c3d4e5f6-a7b8-6c7d-0e1f-2a3b4c5d6e7f" + rate_limits: + type: array + items: + type: object + properties: + 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 - 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: + metadata: + type: object + additionalProperties: true + example: + environment: "development" + team: "backend" + config_id: 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 + example: config-abc + alert_emails: + type: array + items: + type: string + format: email + example: "foo@bar.com" - PortkeyBatchOptions: + 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: + 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 - 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: + metadata: + type: object + additionalProperties: true + example: + environment: "development" + team: "backend" + config_id: 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: + example: config-abc + alert_emails: + type: array + items: + type: string + format: email + example: "foo@bar.com" + + 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" + + 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 + 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 + required: + - type + ResponseFormatJsonSchema: + type: object + title: JSON schema + description: | + JSON Schema response format. Used to generate structured JSON responses. + Learn more about [Structured Outputs](/integrations/llms/openai/structured-outputs). + properties: + type: + type: string + description: The type of response format being defined. Always `json_schema`. + enum: + - json_schema + json_schema: type: object - required: - - model + title: JSON schema + description: | + Structured Outputs configuration options, including a JSON Schema. properties: - job_name: - type: string - description: Job name for the batch job - output_data_config: + description: type: string - description: Batch job's output storage location, will be constructed based on `input_file_id` if not provided - model: + 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: 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 + 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`. + 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 + required: + - type + security: - - Portkey-Key: [] + - 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: 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 + 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 From 30cc0de266916ce45b5468d3c151e77f5dd3d9dc Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Thu, 20 Mar 2025 17:17:51 +0530 Subject: [PATCH 093/124] add URLs to a bunch of endpoints --- openapi.yaml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 8bae0843..8ae73273 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -75,6 +75,7 @@ paths: servers: - url: https://api.portkey.ai/v1 - url: http://localhost:8080/v1 + - url: PORTKEY_ENTERPRISE_AI_GATEWAY_URL/v1 tags: - Chat summary: Chat @@ -174,6 +175,10 @@ paths: /completions: post: operationId: createCompletion + servers: + - url: https://api.portkey.ai/v1 + - url: http://localhost:8080/v1 + - url: PORTKEY_ENTERPRISE_AI_GATEWAY_URL/v1 tags: - Completions summary: Completions @@ -258,6 +263,9 @@ paths: /prompts/{promptId}/completions: post: operationId: createPromptCompletion + servers: + - url: https://api.portkey.ai/v1 + - url: PORTKEY_ENTERPRISE_AI_GATEWAY_URL/v1 tags: - Prompts summary: Prompts Completions @@ -471,6 +479,10 @@ paths: /images/generations: post: operationId: createImage + servers: + - url: https://api.portkey.ai/v1 + - url: http://localhost:8080/v1 + - url: PORTKEY_ENTERPRISE_AI_GATEWAY_URL/v1 tags: - Images summary: Create Image @@ -547,6 +559,10 @@ paths: /images/edits: post: operationId: createImageEdit + servers: + - url: https://api.portkey.ai/v1 + - url: http://localhost:8080/v1 + - url: PORTKEY_ENTERPRISE_AI_GATEWAY_URL/v1 tags: - Images summary: Create Image Edit @@ -627,6 +643,10 @@ paths: /images/variations: post: operationId: createImageVariation + servers: + - url: https://api.portkey.ai/v1 + - url: http://localhost:8080/v1 + - url: PORTKEY_ENTERPRISE_AI_GATEWAY_URL/v1 tags: - Images summary: Creates Image Variation @@ -701,6 +721,10 @@ paths: /embeddings: post: operationId: createEmbedding + servers: + - url: https://api.portkey.ai/v1 + - url: http://localhost:8080/v1 + - url: PORTKEY_ENTERPRISE_AI_GATEWAY_URL/v1 tags: - Embeddings summary: Embeddings @@ -780,6 +804,10 @@ paths: /audio/speech: post: operationId: createSpeech + servers: + - url: https://api.portkey.ai/v1 + - url: http://localhost:8080/v1 + - url: PORTKEY_ENTERPRISE_AI_GATEWAY_URL/v1 tags: - Audio summary: Create Speech @@ -874,6 +902,10 @@ paths: /audio/transcriptions: post: operationId: createTranscription + servers: + - url: https://api.portkey.ai/v1 + - url: http://localhost:8080/v1 + - url: PORTKEY_ENTERPRISE_AI_GATEWAY_URL/v1 tags: - Audio summary: Create Transcription @@ -952,6 +984,10 @@ paths: /audio/translations: post: operationId: createTranslation + servers: + - url: https://api.portkey.ai/v1 + - url: http://localhost:8080/v1 + - url: PORTKEY_ENTERPRISE_AI_GATEWAY_URL/v1 tags: - Audio summary: Create Translation From 4518b519bb2c9eef3b5268a691a9a2bd24333de2 Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Fri, 21 Mar 2025 15:52:12 +0530 Subject: [PATCH 094/124] openapi update --- openapi.yaml | 595 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 582 insertions(+), 13 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 8ae73273..c13e3557 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -75,7 +75,7 @@ paths: servers: - url: https://api.portkey.ai/v1 - url: http://localhost:8080/v1 - - url: PORTKEY_ENTERPRISE_AI_GATEWAY_URL/v1 + - url: PORTKEY_ENTERPRISE_URL/v1 tags: - Chat summary: Chat @@ -115,7 +115,8 @@ paths: Custom-Host: [] x-code-samples: - - lang: curl + - lang: cURL + label: Default source: | curl https://api.portkey.ai/v1/chat/completions \ -H "Content-Type: application/json" \ @@ -134,12 +135,53 @@ paths: } ] }' + - lang: cURL + label: Self-Hosted + source: | + curl PORTKEY_ENTERPRISE_URL/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: 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 = "PORTKEY_ENTERPRISE_URL", virtual_key = "PROVIDER_VIRTUAL_KEY" ) @@ -153,6 +195,7 @@ paths: print(response.choices[0].message) - lang: javascript + label: Default source: | import Portkey from 'portkey-ai'; @@ -170,6 +213,27 @@ paths: 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: 'PORTKEY_ENTERPRISE_URL' + }); + + async function main() { + const response = await client.chat.completions.create({ + messages: [{ role: "system", content: "You are a helpful assistant." }], + model: "gpt-4o", + }); + + console.log(response.choices[0]); + } + main(); /completions: @@ -178,7 +242,7 @@ paths: servers: - url: https://api.portkey.ai/v1 - url: http://localhost:8080/v1 - - url: PORTKEY_ENTERPRISE_AI_GATEWAY_URL/v1 + - url: PORTKEY_ENTERPRISE_URL/v1 tags: - Completions summary: Completions @@ -210,6 +274,7 @@ paths: x-code-samples: - lang: curl + label: Default source: | curl https://api.portkey.ai/v1/completions \ -H "Content-Type: application/json" \ @@ -222,6 +287,7 @@ paths: "temperature": 0 }' - lang: python + label: Default source: | from portkey_ai import Portkey @@ -239,6 +305,7 @@ paths: print(response) - lang: javascript + label: Default source: | import Portkey from 'portkey-ai'; @@ -259,13 +326,68 @@ paths: } 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: 'PORTKEY_ENTERPRISE_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 = "PORTKEY_ENTERPRISE_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://PORTKEY_ENTERPRISE_URL/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 + }' /prompts/{promptId}/completions: post: operationId: createPromptCompletion servers: - url: https://api.portkey.ai/v1 - - url: PORTKEY_ENTERPRISE_AI_GATEWAY_URL/v1 + - url: PORTKEY_ENTERPRISE_URL/v1 tags: - Prompts summary: Prompts Completions @@ -328,7 +450,8 @@ paths: $ref: "#/components/schemas/CreateCompletionResponse" x-code-samples: - - lang: "cURL" + - lang: cURL + label: Default source: | curl -X POST "https://api.portkey.ai/v1/prompts/YOUR_PROMPT_ID/completions" \ -H "Content-Type: application/json" \ @@ -341,6 +464,7 @@ paths: "presence_penalty": 0.2 }' - lang: Python + label: Default source: | from portkey_ai import Portkey @@ -359,7 +483,8 @@ paths: print(completion) - - lang: "JavaScript" + - lang: JavaScript + label: Default source: | import Portkey from 'portkey-ai'; @@ -376,6 +501,59 @@ paths: presence_penalty: 0.2 }); + console.log(completion); + - lang: curl + label: Self-Hosted + source: | + curl -X POST "PORTKEY_ENTERPRISE_URL/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: Self-Hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key="PORTKEY_API_KEY", + base_url="PORTKEY_ENTERPRISE_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: 'PORTKEY_ENTERPRISE_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: @@ -482,7 +660,7 @@ paths: servers: - url: https://api.portkey.ai/v1 - url: http://localhost:8080/v1 - - url: PORTKEY_ENTERPRISE_AI_GATEWAY_URL/v1 + - url: PORTKEY_ENTERPRISE_URL/v1 tags: - Images summary: Create Image @@ -514,6 +692,7 @@ paths: x-code-samples: - lang: curl + label: Default source: | curl https://api.portkey.ai/v1/images/generations \ -H "Content-Type: application/json" \ @@ -526,6 +705,7 @@ paths: "size": "1024x1024" }' - lang: python + label: Default source: | from portkey_ai import Portkey @@ -541,6 +721,7 @@ paths: size="1024x1024" ) - lang: javascript + label: Default source: | import Portkey from 'portkey-ai'; @@ -555,6 +736,57 @@ paths: console.log(image.data); } main(); + - lang: curl + label: Self-Hosted + source: | + curl -X POST "PORTKEY_ENTERPRISE_URL/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: Self-Hosted + source: | + from portkey_ai import Portkey + + client = Portkey( + api_key="PORTKEY_API_KEY", + virtual_key="PROVIDER_VIRTUAL_KEY", + base_url="PORTKEY_ENTERPRISE_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: 'PORTKEY_ENTERPRISE_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: post: @@ -562,7 +794,7 @@ paths: servers: - url: https://api.portkey.ai/v1 - url: http://localhost:8080/v1 - - url: PORTKEY_ENTERPRISE_AI_GATEWAY_URL/v1 + - url: PORTKEY_ENTERPRISE_URL/v1 tags: - Images summary: Create Image Edit @@ -594,6 +826,7 @@ paths: x-code-samples: - lang: curl + label: Default source: | curl https://api.portkey.ai/v1/images/edits \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ @@ -604,6 +837,7 @@ paths: -F n=2 \ -F size="1024x1024" - lang: python + label: Default source: | from portkey_ai import Portkey @@ -620,6 +854,7 @@ paths: size="1024x1024" ) - lang: javascript + label: Default source: | import fs from "fs"; import Portkey from 'portkey-ai'; @@ -639,6 +874,62 @@ paths: console.log(image.data); } main(); + - lang: curl + label: Self-Hosted + source: | + curl -X POST "PORTKEY_ENTERPRISE_URL/v1/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="PORTKEY_ENTERPRISE_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: 'PORTKEY_ENTERPRISE_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: post: @@ -646,7 +937,7 @@ paths: servers: - url: https://api.portkey.ai/v1 - url: http://localhost:8080/v1 - - url: PORTKEY_ENTERPRISE_AI_GATEWAY_URL/v1 + - url: PORTKEY_ENTERPRISE_URL/v1 tags: - Images summary: Creates Image Variation @@ -678,6 +969,7 @@ paths: x-code-samples: - lang: curl + label: Default source: | curl https://api.portkey.ai/v1/images/variations \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ @@ -686,6 +978,7 @@ paths: -F n=2 \ -F size="1024x1024" - lang: python + label: Default source: | from portkey_ai import Portkey @@ -700,6 +993,7 @@ paths: size="1024x1024" ) - lang: javascript + label: Default source: | import fs from "fs"; import Portkey from 'portkey-ai'; @@ -717,6 +1011,56 @@ paths: console.log(image.data); } main(); + - lang: curl + label: Self-Hosted + source: | + curl -X POST "PORTKEY_ENTERPRISE_URL/v1/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="PORTKEY_ENTERPRISE_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: 'PORTKEY_ENTERPRISE_URL' + }); + + async function main() { + const image = await portkey.images.createVariation({ + image: fs.createReadStream("otter.png"), + }); + + console.log(image.data); + } + main(); /embeddings: post: @@ -724,7 +1068,7 @@ paths: servers: - url: https://api.portkey.ai/v1 - url: http://localhost:8080/v1 - - url: PORTKEY_ENTERPRISE_AI_GATEWAY_URL/v1 + - url: PORTKEY_ENTERPRISE_URL/v1 tags: - Embeddings summary: Embeddings @@ -756,6 +1100,7 @@ paths: x-code-samples: - lang: curl + label: Default source: | curl https://api.portkey.ai/v1/embeddings \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ @@ -767,6 +1112,7 @@ paths: "encoding_format": "float" }' - lang: python + label: Default source: | from portkey_ai import Portkey @@ -781,6 +1127,7 @@ paths: encoding_format="float" ) - lang: javascript + label: Default source: | import Portkey from 'portkey-ai'; @@ -799,6 +1146,59 @@ paths: console.log(embedding); } + main(); + - lang: curl + label: Self-Hosted + source: | + curl -X POST "PORTKEY_ENTERPRISE_URL/v1/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="PORTKEY_ENTERPRISE_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: 'PORTKEY_ENTERPRISE_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: @@ -807,7 +1207,7 @@ paths: servers: - url: https://api.portkey.ai/v1 - url: http://localhost:8080/v1 - - url: PORTKEY_ENTERPRISE_AI_GATEWAY_URL/v1 + - url: PORTKEY_ENTERPRISE_URL/v1 tags: - Audio summary: Create Speech @@ -846,6 +1246,7 @@ paths: x-code-samples: - lang: curl + label: Default source: | curl https://api.portkey.ai/v1/audio/speech \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ @@ -858,6 +1259,7 @@ paths: }' \ --output speech.mp3 - lang: python + label: Default source: | from pathlib import Path from portkey_ai import Portkey @@ -875,6 +1277,7 @@ paths: ) response.stream_to_file(speech_file_path) - lang: javascript + label: Default source: | import fs from "fs"; import path from "path"; @@ -887,6 +1290,64 @@ paths: 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 "PORTKEY_ENTERPRISE_URL/v1/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="PORTKEY_ENTERPRISE_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: 'PORTKEY_ENTERPRISE_URL' + }); + + const speechFile = path.resolve("./speech.mp3"); + async function main() { const mp3 = await client.audio.speech.create({ model: "tts-1", @@ -905,7 +1366,7 @@ paths: servers: - url: https://api.portkey.ai/v1 - url: http://localhost:8080/v1 - - url: PORTKEY_ENTERPRISE_AI_GATEWAY_URL/v1 + - url: PORTKEY_ENTERPRISE_URL/v1 tags: - Audio summary: Create Transcription @@ -940,6 +1401,7 @@ paths: x-code-samples: - lang: curl + label: Default source: | curl https://api.portkey.ai/v1/audio/transcriptions \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ @@ -948,6 +1410,7 @@ paths: -F file="@/path/to/file/audio.mp3" \ -F model="whisper-1" - lang: python + label: Default source: | from portkey_ai import Portkey @@ -962,6 +1425,7 @@ paths: file=audio_file ) - lang: javascript + label: Default source: | import fs from "fs"; import Portkey from 'portkey-ai'; @@ -980,6 +1444,57 @@ paths: console.log(transcription.text); } main(); + - lang: curl + label: Self-Hosted + source: | + curl -X POST "PORTKEY_ENTERPRISE_URL/v1/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="PORTKEY_ENTERPRISE_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: 'PORTKEY_ENTERPRISE_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: post: @@ -987,7 +1502,7 @@ paths: servers: - url: https://api.portkey.ai/v1 - url: http://localhost:8080/v1 - - url: PORTKEY_ENTERPRISE_AI_GATEWAY_URL/v1 + - url: PORTKEY_ENTERPRISE_URL/v1 tags: - Audio summary: Create Translation @@ -1022,6 +1537,7 @@ paths: x-code-samples: - lang: curl + label: Default source: | curl https://api.portkey.ai/v1/audio/translations \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ @@ -1030,6 +1546,7 @@ paths: -F file="@/path/to/file/german.m4a" \ -F model="whisper-1" - lang: python + label: Default source: | from portkey_ai import Portkey @@ -1044,6 +1561,7 @@ paths: file=audio_file ) - lang: javascript + label: Default source: | import fs from "fs"; import Portkey from 'portkey-ai'; @@ -1062,6 +1580,57 @@ paths: console.log(translation.text); } main(); + - lang: curl + label: Self-Hosted + source: | + curl -X POST "PORTKEY_ENTERPRISE_URL/v1/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="PORTKEY_ENTERPRISE_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: 'PORTKEY_ENTERPRISE_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: get: From 28fbcf7ec8974aef38460a66e925da1fa8e87061 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Mon, 24 Mar 2025 18:05:11 +0530 Subject: [PATCH 095/124] feat: sdk example for checkpoint list --- openapi.yaml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index c13e3557..5c1e08e4 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -2421,10 +2421,27 @@ paths: -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" - lang: python source: | - Reach out to us on portkey.wiki/community + 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 source: | - Reach out to us on portkey.wiki/community + 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) /models: get: From ff4a92d63b26798591a9e98b48d37d566af3c6a0 Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Tue, 25 Mar 2025 14:16:04 +0530 Subject: [PATCH 096/124] add self hosted examples and options --- openapi.yaml | 3640 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 3407 insertions(+), 233 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index c13e3557..835ffa7f 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -74,8 +74,7 @@ paths: operationId: createChatCompletion servers: - url: https://api.portkey.ai/v1 - - url: http://localhost:8080/v1 - - url: PORTKEY_ENTERPRISE_URL/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - Chat summary: Chat @@ -138,7 +137,7 @@ paths: - lang: cURL label: Self-Hosted source: | - curl PORTKEY_ENTERPRISE_URL/v1/chat/completions \ + curl SELF_HOSTED_GATEWAY_URL/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" \ @@ -181,7 +180,7 @@ paths: portkey = Portkey( api_key = "PORTKEY_API_KEY", - base_url = "PORTKEY_ENTERPRISE_URL", + base_url = "SELF_HOSTED_GATEWAY_URL", virtual_key = "PROVIDER_VIRTUAL_KEY" ) @@ -222,7 +221,7 @@ paths: const portkey = new Portkey({ apiKey: 'PORTKEY_API_KEY', virtualKey: 'PROVIDER_VIRTUAL_KEY', - baseUrl: 'PORTKEY_ENTERPRISE_URL' + baseUrl: 'SELF_HOSTED_GATEWAY_URL' }); async function main() { @@ -241,8 +240,7 @@ paths: operationId: createCompletion servers: - url: https://api.portkey.ai/v1 - - url: http://localhost:8080/v1 - - url: PORTKEY_ENTERPRISE_URL/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - Completions summary: Completions @@ -334,7 +332,7 @@ paths: const portkey = new Portkey({ apiKey: 'PORTKEY_API_KEY', virtualKey: 'PROVIDER_VIRTUAL_KEY', - baseUrl: 'PORTKEY_ENTERPRISE_URL' + baseUrl: 'SELF_HOSTED_GATEWAY_URL' }); async function main() { @@ -357,7 +355,7 @@ paths: portkey = Portkey( api_key = "PORTKEY_API_KEY", virtual_key = "PROVIDER_VIRTUAL_KEY", - base_url = "PORTKEY_ENTERPRISE_URL" + base_url = "SELF_HOSTED_GATEWAY_URL" ) response = portkey.completions.create( @@ -371,7 +369,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl https://PORTKEY_ENTERPRISE_URL/v1/completions \ + curl https://SELF_HOSTED_GATEWAY_URL/v1/completions \ -H "Content-Type: application/json" \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ @@ -387,7 +385,7 @@ paths: operationId: createPromptCompletion servers: - url: https://api.portkey.ai/v1 - - url: PORTKEY_ENTERPRISE_URL/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - Prompts summary: Prompts Completions @@ -505,7 +503,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST "PORTKEY_ENTERPRISE_URL/v1/prompts/YOUR_PROMPT_ID/completions" \ + curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/prompts/YOUR_PROMPT_ID/completions" \ -H "Content-Type: application/json" \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ -d '{ @@ -522,7 +520,7 @@ paths: client = Portkey( api_key="PORTKEY_API_KEY", - base_url="PORTKEY_ENTERPRISE_URL" + base_url="SELF_HOSTED_GATEWAY_URL" ) completion = client.prompts.completions.create( @@ -542,7 +540,7 @@ paths: const portkey = new Portkey({ apiKey: 'PORTKEY_API_KEY', - baseURL: 'PORTKEY_ENTERPRISE_URL' + baseURL: 'SELF_HOSTED_GATEWAY_URL' }); const completion = await portkey.prompts.completions.create({ @@ -659,8 +657,7 @@ paths: operationId: createImage servers: - url: https://api.portkey.ai/v1 - - url: http://localhost:8080/v1 - - url: PORTKEY_ENTERPRISE_URL/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - Images summary: Create Image @@ -739,7 +736,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST "PORTKEY_ENTERPRISE_URL/v1/images/generations" \ + curl -X POST "SELF_HOSTED_GATEWAY_URL/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" \ @@ -757,7 +754,7 @@ paths: client = Portkey( api_key="PORTKEY_API_KEY", virtual_key="PROVIDER_VIRTUAL_KEY", - base_url="PORTKEY_ENTERPRISE_URL" + base_url="SELF_HOSTED_GATEWAY_URL" ) image = client.images.generate( @@ -776,7 +773,7 @@ paths: const portkey = new Portkey({ apiKey: 'PORTKEY_API_KEY', virtualKey: 'PROVIDER_VIRTUAL_KEY', - baseURL: 'PORTKEY_ENTERPRISE_URL' + baseURL: 'SELF_HOSTED_GATEWAY_URL' }); const image = await portkey.images.generate({ @@ -793,8 +790,7 @@ paths: operationId: createImageEdit servers: - url: https://api.portkey.ai/v1 - - url: http://localhost:8080/v1 - - url: PORTKEY_ENTERPRISE_URL/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - Images summary: Create Image Edit @@ -877,7 +873,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST "PORTKEY_ENTERPRISE_URL/v1/images/edits" \ + curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/images/edits" \ -H "Content-Type: application/json" \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ @@ -896,7 +892,7 @@ paths: client = Portkey( api_key="PORTKEY_API_KEY", virtual_key="PROVIDER_VIRTUAL_KEY", - base_url="PORTKEY_ENTERPRISE_URL" + base_url="SELF_HOSTED_GATEWAY_URL" ) image = client.images.edit( @@ -917,7 +913,7 @@ paths: const portkey = new Portkey({ apiKey: 'PORTKEY_API_KEY', virtualKey: 'PROVIDER_VIRTUAL_KEY', - baseURL: 'PORTKEY_ENTERPRISE_URL' + baseURL: 'SELF_HOSTED_GATEWAY_URL' }); async function main() { @@ -936,8 +932,7 @@ paths: operationId: createImageVariation servers: - url: https://api.portkey.ai/v1 - - url: http://localhost:8080/v1 - - url: PORTKEY_ENTERPRISE_URL/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - Images summary: Creates Image Variation @@ -1014,7 +1009,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST "PORTKEY_ENTERPRISE_URL/v1/images/variations" \ + curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/images/variations" \ -H "Content-Type: application/json" \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ @@ -1031,7 +1026,7 @@ paths: client = Portkey( api_key="PORTKEY_API_KEY", virtual_key="PROVIDER_VIRTUAL_KEY", - base_url="PORTKEY_ENTERPRISE_URL" + base_url="SELF_HOSTED_GATEWAY_URL" ) image = client.images.create_variation( @@ -1050,7 +1045,7 @@ paths: const portkey = new Portkey({ apiKey: 'PORTKEY_API_KEY', virtualKey: 'PROVIDER_VIRTUAL_KEY', - baseURL: 'PORTKEY_ENTERPRISE_URL' + baseURL: 'SELF_HOSTED_GATEWAY_URL' }); async function main() { @@ -1067,8 +1062,7 @@ paths: operationId: createEmbedding servers: - url: https://api.portkey.ai/v1 - - url: http://localhost:8080/v1 - - url: PORTKEY_ENTERPRISE_URL/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - Embeddings summary: Embeddings @@ -1150,7 +1144,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST "PORTKEY_ENTERPRISE_URL/v1/embeddings" \ + curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/embeddings" \ -H "Content-Type: application/json" \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ @@ -1167,7 +1161,7 @@ paths: client = Portkey( api_key="PORTKEY_API_KEY", virtual_key="PROVIDER_VIRTUAL_KEY", - base_url="PORTKEY_ENTERPRISE_URL" + base_url="SELF_HOSTED_GATEWAY_URL" ) response = client.embeddings.create( @@ -1186,7 +1180,7 @@ paths: const portkey = new Portkey({ apiKey: 'PORTKEY_API_KEY', virtualKey: 'PROVIDER_VIRTUAL_KEY', - baseURL: 'PORTKEY_ENTERPRISE_URL' + baseURL: 'SELF_HOSTED_GATEWAY_URL' }); async function main() { @@ -1206,8 +1200,7 @@ paths: operationId: createSpeech servers: - url: https://api.portkey.ai/v1 - - url: http://localhost:8080/v1 - - url: PORTKEY_ENTERPRISE_URL/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - Audio summary: Create Speech @@ -1304,7 +1297,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST "PORTKEY_ENTERPRISE_URL/v1/audio/speech" \ + curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/audio/speech" \ -H "Content-Type: application/json" \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ @@ -1323,7 +1316,7 @@ paths: client = Portkey( api_key = "PORTKEY_API_KEY", virtual_key = "PROVIDER_VIRTUAL_KEY", - base_url="PORTKEY_ENTERPRISE_URL" + base_url="SELF_HOSTED_GATEWAY_URL" ) speech_file_path = Path(__file__).parent / "speech.mp3" @@ -1343,7 +1336,7 @@ paths: const client = new Portkey({ apiKey: 'PORTKEY_API_KEY', virtualKey: 'PROVIDER_VIRTUAL_KEY', - baseUrl: 'PORTKEY_ENTERPRISE_URL' + baseUrl: 'SELF_HOSTED_GATEWAY_URL' }); const speechFile = path.resolve("./speech.mp3"); @@ -1365,8 +1358,7 @@ paths: operationId: createTranscription servers: - url: https://api.portkey.ai/v1 - - url: http://localhost:8080/v1 - - url: PORTKEY_ENTERPRISE_URL/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - Audio summary: Create Transcription @@ -1447,7 +1439,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST "PORTKEY_ENTERPRISE_URL/v1/audio/transcriptions" \ + curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/audio/transcriptions" \ -H "Content-Type: application/json" \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ @@ -1464,7 +1456,7 @@ paths: client = Portkey( api_key = "PORTKEY_API_KEY", virtual_key = "PROVIDER_VIRTUAL_KEY", - base_url="PORTKEY_ENTERPRISE_URL" + base_url="SELF_HOSTED_GATEWAY_URL" ) audio_file = open("speech.mp3", "rb") @@ -1481,7 +1473,7 @@ paths: const client = new Portkey({ apiKey: 'PORTKEY_API_KEY', virtualKey: 'PROVIDER_VIRTUAL_KEY', - baseUrl: 'PORTKEY_ENTERPRISE_URL' + baseUrl: 'SELF_HOSTED_GATEWAY_URL' }); const audioFile = fs.createReadStream("speech.mp3"); @@ -1501,8 +1493,7 @@ paths: operationId: createTranslation servers: - url: https://api.portkey.ai/v1 - - url: http://localhost:8080/v1 - - url: PORTKEY_ENTERPRISE_URL/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - Audio summary: Create Translation @@ -1583,7 +1574,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST "PORTKEY_ENTERPRISE_URL/v1/audio/translations" \ + curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/audio/translations" \ -H "Content-Type: application/json" \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ @@ -1600,7 +1591,7 @@ paths: client = Portkey( api_key = "PORTKEY_API_KEY", virtual_key = "PROVIDER_VIRTUAL_KEY", - base_url="PORTKEY_ENTERPRISE_URL" + base_url="SELF_HOSTED_GATEWAY_URL" ) audio_file = open("speech.mp3", "rb") @@ -1617,7 +1608,7 @@ paths: const client = new Portkey({ apiKey: 'PORTKEY_API_KEY', virtualKey: 'PROVIDER_VIRTUAL_KEY', - baseUrl: 'PORTKEY_ENTERPRISE_URL' + baseUrl: 'SELF_HOSTED_GATEWAY_URL' }); const audioFile = fs.createReadStream("speech.mp3"); @@ -1979,6 +1970,9 @@ paths: /fine_tuning/jobs: post: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 operationId: createFineTuningJob summary: Create a Finetune Job description: Finetune a provider model @@ -2017,6 +2011,7 @@ paths: x-code-samples: - lang: curl + label: Default source: | curl https://api.portkey.ai/v1/fine_tuning/jobs \ -H "Content-Type: application/json" \ @@ -2027,11 +2022,57 @@ paths: "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/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: 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" ) @@ -2040,11 +2081,13 @@ paths: 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' }); @@ -2059,6 +2102,9 @@ paths: main(); get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 operationId: listPaginatedFineTuningJobs tags: - Fine-tuning @@ -2101,26 +2147,67 @@ paths: 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/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: 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' }); @@ -2136,6 +2223,9 @@ paths: /fine_tuning/jobs/{fine_tuning_job_id}: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 operationId: retrieveFineTuningJob tags: - Fine-tuning @@ -2175,26 +2265,65 @@ paths: 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/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: 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' }); @@ -2208,6 +2337,9 @@ paths: /fine_tuning/jobs/{fine_tuning_job_id}/events: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 operationId: listFineTuningEvents tags: - Fine-tuning @@ -2258,16 +2390,58 @@ paths: 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/v1/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" ) @@ -2276,11 +2450,13 @@ paths: 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' }); @@ -2296,6 +2472,9 @@ paths: /fine_tuning/jobs/{fine_tuning_job_id}/cancel: post: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 operationId: cancelFineTuningJob tags: - Fine-tuning @@ -2333,11 +2512,13 @@ paths: 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 @@ -2348,6 +2529,7 @@ paths: client.fine_tuning.jobs.cancel("ftjob-abc123") - lang: javascript + label: Default source: | import Portkey from 'portkey-ai'; @@ -2362,9 +2544,48 @@ paths: console.log(fineTune); } main(); + - lang: curl + label: Self-hosted + source: | + curl -X POST SELF_HOSTED_GATEWAY_URL/v1/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: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 operationId: listFineTuningJobCheckpoints tags: - Fine-tuning @@ -2415,17 +2636,35 @@ paths: 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: python + label: Default + source: | + Reach out to us on portkey.wiki/community + - lang: javascript + label: Default + source: | + Reach out to us on portkey.wiki/community + - lang: curl + label: Self-Hosted + source: | + curl SELF_HOSTED_GATEWAY_URL/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: python + label: Self-Hosted source: | Reach out to us on portkey.wiki/community - lang: javascript + label: Self-Hosted source: | Reach out to us on portkey.wiki/community + /models: get: operationId: listModels @@ -2625,6 +2864,9 @@ paths: /moderations: post: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 operationId: createModeration tags: - Moderations @@ -2659,6 +2901,7 @@ paths: x-code-samples: - lang: curl + label: Default source: | curl https://api.portkey.ai/v1/moderations \ -H "Content-Type: application/json" \ @@ -2668,6 +2911,7 @@ paths: "input": "I want to kill them." }' - lang: python + label: Default source: | from portkey_ai import Portkey @@ -2679,6 +2923,7 @@ paths: moderation = client.moderations.create(input="I want to kill them.") print(moderation) - lang: javascript + label: Default source: | import Portkey from 'portkey-ai'; @@ -2687,6 +2932,46 @@ paths: 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/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: 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." }); @@ -6723,6 +7008,9 @@ paths: /batches: post: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 summary: Creates and executes a batch from an uploaded file of requests operationId: createBatch tags: @@ -6760,6 +7048,7 @@ paths: x-code-samples: - lang: curl + label: Default source: | curl https://api.portkey.ai/v1/batches \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ @@ -6771,6 +7060,7 @@ paths: "completion_window": "24h" }' - lang: python + label: Default source: | from portkey_ai import Portkey @@ -6785,6 +7075,7 @@ paths: completion_window="24h" ) - lang: javascript + label: Default source: | import Portkey from 'portkey-ai'; @@ -6803,10 +7094,63 @@ paths: console.log(batch); } + main(); + - lang: curl + label: Self-Hosted + source: | + curl SELF_HOSTED_GATEWAY_URL/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: 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 + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL tags: - Batch summary: List your organization's batches. @@ -6847,27 +7191,69 @@ paths: 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/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: 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' }); @@ -6883,6 +7269,9 @@ paths: /batches/{batch_id}: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 operationId: retrieveBatch tags: - Batch @@ -6917,27 +7306,67 @@ paths: 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/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: 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' }); @@ -6952,6 +7381,9 @@ paths: /batches/{batch_id}/cancel: post: operationId: cancelBatch + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL 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. @@ -6985,6 +7417,7 @@ paths: 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" \ @@ -6992,21 +7425,61 @@ paths: -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/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: 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' }); @@ -7020,6 +7493,9 @@ paths: /configs: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 summary: List all configs tags: - Configs @@ -7092,6 +7568,7 @@ paths: } x-code-samples: - lang: python + label: Default source: | from portkey_ai import Portkey @@ -7107,6 +7584,7 @@ paths: print(config) - lang: javascript + label: Default source: | import { Portkey } from "portkey-ai"; @@ -7118,8 +7596,41 @@ paths: 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: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 summary: Create a config tags: - Configs @@ -7182,11 +7693,61 @@ paths: } 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 @@ -7205,11 +7766,13 @@ paths: 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({ @@ -7229,6 +7792,9 @@ paths: /configs/{slug}: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 summary: Get a config tags: - Configs @@ -7317,6 +7883,7 @@ paths: } x-code-samples: - lang: python + label: Default source: | from portkey_ai import Portkey @@ -7332,6 +7899,7 @@ paths: print(config) - lang: javascript + label: Default source: | import { Portkey } from "portkey-ai"; @@ -7344,8 +7912,43 @@ paths: }) 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: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 summary: Update a config tags: - Configs @@ -7408,9 +8011,59 @@ paths: } 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 @@ -7428,11 +8081,13 @@ paths: ) 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({ @@ -7453,6 +8108,9 @@ paths: /feedback: post: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 summary: Create new feedback description: This endpoint allows users to submit feedback for a particular interaction or response. operationId: createFeedback @@ -7464,17 +8122,6 @@ paths: application/json: schema: $ref: "#/components/schemas/FeedbackRequest" - examples: - thumbsUpExample: - summary: Thumbs Up Feedback - value: - trace_id: "REQUEST_TRACE_ID" - value: 1 - thumbsDownExample: - summary: Thumbs Down Feedback - value: - trace_id: "REQUEST_TRACE_ID" - value: 0 responses: "200": description: Feedback successfully saved @@ -7482,9 +8129,91 @@ paths: 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/v1/feedback \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"trace_id":"REQUEST_TRACE_ID","value":1}' /feedback/{id}: put: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 summary: Updates existing feedback description: This endpoint allows users to update existing feedback. operationId: updateFeedback @@ -7504,15 +8233,6 @@ paths: application/json: schema: $ref: "#/components/schemas/FeedbackUpdateRequest" - examples: - thumbsUpExample: - summary: Thumbs Up Feedback - value: - value: 1 - thumbsDownExample: - summary: Thumbs Down Feedback - value: - value: 0 responses: "200": description: Feedback successfully updated @@ -7520,9 +8240,91 @@ paths: 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/v1/feedback/{id} \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"value":1}' /virtual-keys: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 summary: List All Virtual Keys tags: - Virtual-keys @@ -7564,12 +8366,44 @@ paths: 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 @@ -7577,17 +8411,29 @@ paths: 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/v1/virtual-keys \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: PROVIDER_VIRTUAL_KEY" post: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 summary: Create a Virtual Key tags: - Virtual-keys @@ -7766,6 +8612,7 @@ paths: message: "Unauthorised Request" x-code-samples: - lang: python + label: Default source: | from portkey_ai import Portkey @@ -7783,6 +8630,7 @@ paths: print(new_virtual_key) - lang: javascript + label: Default source: | import { Portkey } from "portkey-ai"; @@ -7796,23 +8644,83 @@ paths: 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 - /virtual-keys/{slug}: - 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: + # 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/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" + }' + + /virtual-keys/{slug}: + get: + servers: + - url: "https://api.portkey.ai/v1" + - url: "SELF_HOSTED_CONTROL_PLANE_URL/v1" + 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": @@ -7835,12 +8743,53 @@ paths: 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/v1/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 @@ -7850,11 +8799,13 @@ paths: 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({ @@ -7864,6 +8815,9 @@ paths: put: summary: Update a Virtual Key + servers: + - url: "https://api.portkey.ai/v1" + - url: "SELF_HOSTED_CONTROL_PLANE_URL/v1" tags: - Virtual-keys parameters: @@ -7930,6 +8884,7 @@ paths: message: "Unauthorised Request" x-code-samples: - lang: python + label: Default source: | from portkey_ai import Portkey @@ -7948,6 +8903,7 @@ paths: print(updated_virtual_key) - lang: javascript + label: Default source: | import { Portkey } from "portkey-ai"; @@ -7962,9 +8918,83 @@ paths: 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/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: 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 + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Virtual-keys parameters: @@ -8001,12 +9031,51 @@ paths: 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/v1/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 @@ -8016,11 +9085,13 @@ paths: 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({ @@ -8030,6 +9101,9 @@ paths: /admin/users/invites: post: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 operationId: Invites_create summary: Invite User description: Send an invite to user for your organization @@ -8051,6 +9125,7 @@ paths: $ref: "#/components/schemas/CreateInvite" x-code-samples: - lang: python + label: Default source: | from portkey_ai import Portkey @@ -8081,6 +9156,7 @@ paths: print(user) - lang: javascript + label: Default source: | import { Portkey } from "portkey-ai"; @@ -8107,78 +9183,192 @@ paths: }) 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 + - lang: curl + label: Default source: | - from portkey_ai import Portkey + 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/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: 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: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + 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( @@ -8192,6 +9382,7 @@ paths: print(user_invites) - lang: javascript + label: Default source: | import { Portkey } from "portkey-ai"; @@ -8199,6 +9390,47 @@ paths: 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/v1/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" }); @@ -8206,6 +9438,9 @@ paths: /admin/users/invites/{inviteId}: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - User-invites summary: Get Invite @@ -8243,6 +9478,7 @@ paths: role: "" x-code-samples: - lang: python + label: Default source: | from portkey_ai import Portkey @@ -8258,6 +9494,7 @@ paths: print(user) - lang: javascript + label: Default source: | import { Portkey } from "portkey-ai"; @@ -8265,11 +9502,55 @@ paths: 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/v1/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: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - User-invites summary: Delete Invite By ID @@ -8294,6 +9575,7 @@ paths: example: {} x-code-samples: - lang: python + label: Default source: | from portkey_ai import Portkey @@ -8311,11 +9593,54 @@ paths: 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/v1/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({ @@ -8326,6 +9651,9 @@ paths: /admin/users/invites/{inviteId}/resend: post: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - User-invites summary: Resend Invite @@ -8356,16 +9684,58 @@ paths: 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/v1/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" @@ -8373,21 +9743,26 @@ paths: 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); + console.log(user); /admin/users: get: + servers: + - url: https://api.portkey.ai + - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - Users summary: Get users @@ -8448,12 +9823,50 @@ paths: 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/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 @@ -8461,11 +9874,13 @@ paths: 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({}) @@ -8474,6 +9889,9 @@ paths: /admin/users/{userId}: get: + servers: + - url: https://api.portkey.ai + - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - Users summary: Get user @@ -8507,6 +9925,7 @@ paths: workspace_ids: ["ws-shared-123"] x-code-sample: - lang: python + label: Default source: | from portkey_ai import Portkey @@ -8523,11 +9942,53 @@ paths: 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/v1/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', @@ -8536,6 +9997,9 @@ paths: console.log(user); delete: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Users summary: Remove a user @@ -8560,12 +10024,54 @@ paths: 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/v1/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 @@ -8575,11 +10081,13 @@ paths: 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({ @@ -8588,6 +10096,9 @@ paths: console.log(user); put: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Users summary: Update user @@ -8625,12 +10136,58 @@ paths: 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/v1/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 @@ -8641,11 +10198,13 @@ paths: 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({ @@ -8657,6 +10216,9 @@ paths: /admin/workspaces/{workspaceId}/users: post: + servers: + - url: https://api.portkey.ai + - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - Workspaces > Members summary: Add workspace member @@ -8703,6 +10265,7 @@ paths: example: {} x-code-samples: - lang: python + label: Default source: | from portkey_ai import Portkey @@ -8724,6 +10287,7 @@ paths: print(user) - lang: javascript + label: Default source: | import { Portkey } from "portkey-ai"; @@ -8739,8 +10303,65 @@ paths: }] }) 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/v1/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: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Workspaces > Members summary: Get workspace members @@ -8783,12 +10404,52 @@ paths: $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/v1/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 @@ -8798,11 +10459,13 @@ paths: 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({ @@ -8810,8 +10473,12 @@ paths: }) console.log(user); + /admin/workspaces/{workspaceId}/users/{userId}: put: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Workspaces > Members summary: Update workspace member @@ -8854,12 +10521,59 @@ paths: 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/v1/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 @@ -8871,11 +10585,13 @@ paths: 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({ @@ -8886,6 +10602,9 @@ paths: console.log(user); delete: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Workspaces > Members summary: Remove workspace member @@ -8915,12 +10634,57 @@ paths: 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/v1/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 @@ -8932,11 +10696,13 @@ paths: # 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({ @@ -8947,6 +10713,9 @@ paths: console.log(user) get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Workspaces > Members summary: Get member @@ -8987,12 +10756,55 @@ paths: 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/v1/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 @@ -9003,11 +10815,13 @@ paths: 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({ @@ -9018,6 +10832,9 @@ paths: /admin/workspaces: post: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Workspaces summary: Create Workspace @@ -9063,6 +10880,7 @@ paths: $ref: "#/components/schemas/Workspace" x-code-samples: - lang: python + label: Default source: | from portkey_ai import Portkey @@ -9085,6 +10903,7 @@ paths: print(workspace) - lang: javascript + label: Default source: | import { Portkey } from "portkey-ai"; @@ -9103,11 +10922,92 @@ paths: } }) 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/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: 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: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Workspaces - summary: Get All + summary: Get All Workspaces parameters: - name: page_size in: query @@ -9155,12 +11055,47 @@ paths: 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/v1/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 @@ -9168,11 +11103,13 @@ paths: 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({}) @@ -9180,6 +11117,9 @@ paths: /admin/workspaces/{workspaceId}: put: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Workspaces summary: Update Workspace @@ -9226,12 +11166,67 @@ paths: $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", + ) + + # 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/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: 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 @@ -9240,17 +11235,19 @@ paths: name='WORKSPACE 0909', description='This is a test description', defaults={ - "x": "y" + 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({ @@ -9264,6 +11261,9 @@ paths: console.log(workspace); get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Workspaces summary: Get workspace @@ -9287,12 +11287,53 @@ paths: $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/v1/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 @@ -9302,11 +11343,13 @@ paths: 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({ @@ -9315,6 +11358,9 @@ paths: console.log(workspace); delete: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Workspaces summary: Delete a workspace @@ -9329,6 +11375,7 @@ paths: description: OK x-code-samples: - lang: python + label: Default source: | from portkey_ai import Portkey @@ -9339,12 +11386,12 @@ paths: # Delete workspace result = portkey.admin.workspaces.delete( - name='WORKSPACE_NAME_0909', workspace_id='WORKSPACE_SLUG' ) print(result) - lang: javascript + label: Default source: | import { Portkey } from "portkey-ai"; @@ -9353,14 +11400,57 @@ paths: }) const workspace=await portkey.admin.workspaces.delete({ - name: 'WORKSPACE_NAME_0909', + 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/v1/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); /logs: post: - summary: Submit logs + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 + summary: Insert New logs tags: - Logs description: Submit one or more log entries @@ -9379,6 +11469,7 @@ paths: description: Successful response x-code-samples: - lang: python + label: Default source: | from portkey_ai import Portkey @@ -9408,6 +11499,7 @@ paths: print(result) - lang: javascript + label: Default source: | import Portkey from "portkey-ai"; @@ -9439,10 +11531,128 @@ paths: }); 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/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: 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/exports/{exportId}: get: + servers: + - url: "https://api.portkey.ai/v1" + - url: "SELF_HOSTED_CONTROL_PLANE_URL" tags: - Logs Export summary: Get a specific logs export @@ -9461,6 +11671,7 @@ paths: $ref: "#/components/schemas/ExportItem" x-code-samples: - lang: python + label: Default source: | from portkey_ai import Portkey @@ -9474,6 +11685,7 @@ paths: print(res) - lang: javascript + label: Default source: | import Portkey from "portkey-ai"; @@ -9490,7 +11702,54 @@ paths: } 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: + servers: + - url: "https://api.portkey.ai/v1" + - url: "SELF_HOSTED_CONTROL_PLANE_URL" tags: - Logs Export summary: Update a logs export @@ -9523,28 +11782,86 @@ paths: $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" + 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", + export_id='EXPORT_ID', + workspace_id='WORKSPACE_ID', filters={ - "time_of_generation_max": "2024-07-25" + '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" + apiKey:"PORTKEY_API_KEY", + baseUrl:"SELF_HOSTED_CONTROL_PLANE_URL" }) async function main() { @@ -9560,8 +11877,12 @@ paths: } main(); + /logs/exports: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - Logs Export summary: Get all logs exports @@ -9579,6 +11900,7 @@ paths: $ref: "#/components/schemas/ExportListResponse" x-code-samples: - lang: python + label: Default source: | from portkey_ai import Portkey @@ -9592,6 +11914,7 @@ paths: print(res) - lang: javascript + label: Default source: | import Portkey from "portkey-ai"; @@ -9607,8 +11930,55 @@ paths: 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: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - Logs Export summary: Create log export @@ -9636,6 +12006,7 @@ paths: $ref: "#/components/schemas/UpdateExportResponse" x-code-samples: - lang: python + label: Default source: | from portkey_ai import Portkey @@ -9676,6 +12047,7 @@ paths: print(res) - lang: javascript + label: Default source: | import Portkey from "portkey-ai"; @@ -9719,11 +12091,234 @@ paths: } main(); - /logs/exports/{exportId}/start: + - 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: + post: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL + 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: post: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - Logs Export - summary: Start log export + summary: Cancel log export parameters: - name: exportId in: path @@ -9739,6 +12334,7 @@ paths: $ref: "#/components/schemas/ExportTaskResponse" x-code-samples: - lang: python + label: Default source: | from portkey_ai import Portkey @@ -9746,21 +12342,22 @@ paths: api_key="PORTKEY_API_KEY" ) - res = portkey.logs.exports.start( + 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" + apiKey:"PORTKEY_API_KEY", }) async function main() { - const res = await portkey.logs.exports.start({ + const res = await portkey.logs.exports.cancel({ exportId:'EXPORT_ID' }); @@ -9768,31 +12365,20 @@ paths: } main(); - /logs/exports/{exportId}/cancel: - 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: 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" + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) res = portkey.logs.exports.cancel( @@ -9801,11 +12387,13 @@ paths: 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() { @@ -9817,8 +12405,12 @@ paths: } main(); + /logs/exports/{exportId}/download: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - Logs Export summary: Download log export @@ -9837,6 +12429,7 @@ paths: $ref: "#/components/schemas/DownloadLogsResponse" x-code-samples: - lang: python + label: Default source: | from portkey_ai import Portkey @@ -9850,6 +12443,7 @@ paths: print(res) - lang: javascript + label: Default source: | import Portkey from "portkey-ai"; @@ -9865,10 +12459,53 @@ paths: 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() /api-keys/{type}/{sub-type}: post: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - Api-Keys summary: Create Api Keys @@ -9916,6 +12553,7 @@ paths: example: "api-key" x-code-samples: - lang: python + label: Default source: | from portkey_ai import Portkey @@ -9950,6 +12588,7 @@ paths: print(api_key) - lang: javascript + label: Default source: | import { Portkey } from "portkey-ai"; @@ -9980,9 +12619,134 @@ paths: ] }) 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/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: 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) /api-keys: get: + servers: + - url: https://api.portkey.ai + - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - Api-Keys summary: Get All @@ -10016,12 +12780,13 @@ paths: $ref: "#/components/schemas/ApiKeyObjectList" x-code-samples: - lang: python + label: Default source: | from portkey_ai import Portkey # Initialize the Portkey client portkey = Portkey( - api_key="PORTKEY_API_KEY", + api_key="PORTKEY_API_KEY" ) # List API keys @@ -10029,8 +12794,106 @@ paths: workspace_id="WORKSPACE_SLUG" ) - print(api_keys) + 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" + + /api-keys/{id}: + put: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + tags: + - Api-Keys + summary: Update Api Keys + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateApiKeyObject" + 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"; @@ -10038,50 +12901,202 @@ paths: apiKey: "PORTKEY_API_KEY", }) - const apiKey=await portkey.apiKeys.list({ - workspace_id:"WORKSPACE_SLUG" - }) + 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); - - /api-keys/{id}: - put: - tags: - - Api-Keys - summary: Update Api Keys - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/UpdateApiKeyObject" - 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: curl + label: Default + source: | + curl -X GET "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 GET "SELF_HOSTED_CONTROL_PLANE_URL/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: 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 @@ -10118,11 +13133,13 @@ paths: 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({ @@ -10183,9 +13200,13 @@ paths: ], }) - console.log(apiKey); + console.log(apiKey); + get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Api-Keys summary: Get Api Keys @@ -10210,12 +13231,54 @@ paths: $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/v1/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 @@ -10225,11 +13288,13 @@ paths: 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({ @@ -10239,6 +13304,9 @@ paths: console.log(apiKey); delete: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Api-Keys summary: Remove a Api Key @@ -10264,12 +13332,53 @@ paths: 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/v1/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 @@ -10279,11 +13388,13 @@ paths: 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({ @@ -10293,6 +13404,9 @@ paths: /analytics/graphs/requests: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get requests graph @@ -10367,6 +13481,9 @@ paths: /analytics/graphs/cost: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get cost graph @@ -10449,6 +13566,9 @@ paths: /analytics/graphs/latency: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get latency graph @@ -10548,6 +13668,9 @@ paths: /analytics/graphs/tokens: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get tokens graph @@ -10630,6 +13753,9 @@ paths: /analytics/graphs/users: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get users graph. Returns unique user count across different time buckets @@ -10704,6 +13830,9 @@ paths: /analytics/graphs/users/requests: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get users requests graph. Returns average requests per user across different time buckets @@ -10786,6 +13915,9 @@ paths: /analytics/graphs/errors: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get errors graph @@ -10860,6 +13992,9 @@ paths: /analytics/graphs/errors/rate: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get percentage error rate graph @@ -10934,6 +14069,9 @@ paths: /analytics/graphs/errors/stacks: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get status code wise stacked error graph @@ -11016,6 +14154,9 @@ paths: /analytics/graphs/errors/status-codes: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get status code wise grouped error graph. @@ -11093,6 +14234,9 @@ paths: /analytics/graphs/requests/rescued: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get retry and fallback rescued requests graph @@ -11183,6 +14327,9 @@ paths: /analytics/graphs/cache/hit-rate: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get cache hit rate graph @@ -11277,6 +14424,9 @@ paths: /analytics/graphs/cache/latency: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get cache hit latency graph @@ -11345,6 +14495,9 @@ paths: /analytics/graphs/feedbacks: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get feedbacks graph @@ -11419,6 +14572,9 @@ paths: /analytics/graphs/feedbacks/scores: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get score-wise feedbacks distribution graph @@ -11492,6 +14648,9 @@ paths: /analytics/graphs/feedbacks/weighted: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get weighted feedbacks graph. Weighted feedback is (value * score) @@ -11566,6 +14725,9 @@ paths: /analytics/graphs/feedbacks/ai-models: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get feedbacks per ai_models graph @@ -11637,6 +14799,9 @@ paths: /analytics/summary/cache: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Summary summary: Get cache summary data for the selected time period @@ -11701,6 +14866,9 @@ paths: /analytics/groups/users: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Groups summary: Get metadata users grouped data. @@ -11773,6 +14941,9 @@ paths: /analytics/groups/ai-models: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Groups summary: Get ai model grouped data. @@ -11842,6 +15013,9 @@ paths: /analytics/groups/metadata/{metadataKey}: get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Groups summary: Get metadata key based grouped data. From 47a2eb0fbae329f9794d58bf623f224e0ce3bbbb Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Tue, 25 Mar 2025 14:38:31 +0530 Subject: [PATCH 097/124] add self-hosted code options for prompt render API --- openapi.yaml | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 835ffa7f..eaada378 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -556,6 +556,9 @@ paths: /prompts/{promptId}/render: post: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 operationId: createPromptRender tags: - Prompts @@ -603,6 +606,7 @@ paths: 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" \ @@ -615,6 +619,7 @@ paths: "presence_penalty": 0.2 }' - lang: Python + label: Default source: | from portkey_ai import Portkey @@ -634,6 +639,7 @@ paths: print(completion) - lang: "JavaScript" + label: Default source: | import Portkey from 'portkey-ai'; @@ -651,6 +657,63 @@ paths: }); console.log(completion); + - lang: "cURL" + label: Self-Hosted + source: | + curl -X POST "SELF_HOSTED_GATEWAY_URL/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: 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); + + + /images/generations: post: From 30454522a6144c1d6c9d98970d6dc75d4c18ab1e Mon Sep 17 00:00:00 2001 From: Narendranath Gogineni Date: Tue, 25 Mar 2025 16:49:58 +0530 Subject: [PATCH 098/124] update openapi spec for content blocks support --- openapi.yaml | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index eaada378..aa6a6c83 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -15897,6 +15897,36 @@ components: - 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" @@ -16259,6 +16289,14 @@ components: 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. @@ -16287,6 +16325,13 @@ components: 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 + $ref: "#/components/schemas/ChatCompletionMessageContentBlock" required: - role - content From 6dfd6943afc74d352d143e0579691209a176eb69 Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Tue, 25 Mar 2025 17:35:39 +0530 Subject: [PATCH 099/124] update finetuning checkpoints examples --- openapi.yaml | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 5c1e08e4..2bd0ff0e 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -2415,11 +2415,19 @@ paths: 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/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: python + label: Default source: | from portkey_ai import Portkey @@ -2431,6 +2439,7 @@ paths: 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'; @@ -2442,6 +2451,39 @@ paths: 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: get: From b6acf44fab81893cd35c125236da930eefd3ed05 Mon Sep 17 00:00:00 2001 From: siddharthsambharia-portkey Date: Tue, 25 Mar 2025 18:33:41 +0530 Subject: [PATCH 100/124] chore/developer-mode-support --- openapi.yaml | 92 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 7db9f0ef..96a1b22a 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -153,7 +153,7 @@ paths: "content": "Hello!" } ] - }' + }' - lang: python label: Default source: | @@ -712,9 +712,6 @@ paths: console.log(completion); - - - /images/generations: post: operationId: createImage @@ -2643,7 +2640,6 @@ paths: } main(); - /fine_tuning/jobs/{fine_tuning_job_id}/checkpoints: get: servers: @@ -2709,7 +2705,7 @@ paths: source: | curl SELF_HOSTED_GATEWAY_URL/v1/fine_tuning/jobs/ftjob-abc123/checkpoints \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" - lang: python label: Default source: | @@ -2767,7 +2763,7 @@ paths: console.log(checkpointsList) } - main(); + main(); /models: get: @@ -8422,7 +8418,7 @@ paths: curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/v1/feedback/{id} \ -H "x-portkey-api-key: PORTKEY_API_KEY" \ -H "Content-Type: application/json" \ - -d '{"value":1}' + -d '{"value":1}' /virtual-keys: get: @@ -8810,7 +8806,7 @@ paths: get: servers: - url: "https://api.portkey.ai/v1" - - url: "SELF_HOSTED_CONTROL_PLANE_URL/v1" + - url: "SELF_HOSTED_CONTROL_PLANE_URL/v1" summary: Get a Virtual Key tags: - Virtual-keys @@ -8921,7 +8917,7 @@ paths: summary: Update a Virtual Key servers: - url: "https://api.portkey.ai/v1" - - url: "SELF_HOSTED_CONTROL_PLANE_URL/v1" + - url: "SELF_HOSTED_CONTROL_PLANE_URL/v1" tags: - Virtual-keys parameters: @@ -9007,7 +9003,7 @@ paths: print(updated_virtual_key) - lang: javascript - label: Default + label: Default source: | import { Portkey } from "portkey-ai"; @@ -9818,13 +9814,13 @@ paths: inviteId:"INVITE_ID" }); - console.log(user); + 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 + - lang: curl label: Self-Hosted source: | curl -X POST "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users/invites/INVITE_ID/resend" @@ -9860,7 +9856,7 @@ paths: inviteId:"INVITE_ID" }); - console.log(user); + console.log(user); /admin/users: get: @@ -10059,7 +10055,7 @@ paths: console.log(user); - lang: curl - label: Default + label: Default source: | curl -X GET "https://api.portkey.ai/v1/admin/users/USER_ID" -H "x-portkey-api-key: PORTKEY_API_KEY" @@ -10577,7 +10573,6 @@ paths: }) console.log(user); - /admin/workspaces/{workspaceId}/users/{userId}: put: servers: @@ -11635,7 +11630,7 @@ paths: }); console.log(result); } - + main(); - lang: curl label: Default @@ -11749,8 +11744,8 @@ paths: }); console.log(result); } - - main(); + + main(); /logs/exports/{exportId}: get: @@ -13304,8 +13299,7 @@ paths: ], }) - console.log(apiKey); - + console.log(apiKey); get: servers: @@ -13774,7 +13768,7 @@ paths: get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get tokens graph @@ -13859,7 +13853,7 @@ paths: get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get users graph. Returns unique user count across different time buckets @@ -13936,7 +13930,7 @@ paths: get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get users requests graph. Returns average requests per user across different time buckets @@ -14021,7 +14015,7 @@ paths: get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get errors graph @@ -14098,7 +14092,7 @@ paths: get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get percentage error rate graph @@ -14175,7 +14169,7 @@ paths: get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get status code wise stacked error graph @@ -14260,7 +14254,7 @@ paths: get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get status code wise grouped error graph. @@ -14340,7 +14334,7 @@ paths: get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get retry and fallback rescued requests graph @@ -14433,7 +14427,7 @@ paths: get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get cache hit rate graph @@ -14530,7 +14524,7 @@ paths: get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get cache hit latency graph @@ -14601,7 +14595,7 @@ paths: get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get feedbacks graph @@ -14678,7 +14672,7 @@ paths: get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get score-wise feedbacks distribution graph @@ -14754,7 +14748,7 @@ paths: get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get weighted feedbacks graph. Weighted feedback is (value * score) @@ -14831,7 +14825,7 @@ paths: get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get feedbacks per ai_models graph @@ -14905,7 +14899,7 @@ paths: get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Summary summary: Get cache summary data for the selected time period @@ -14972,7 +14966,7 @@ paths: get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Groups summary: Get metadata users grouped data. @@ -15047,7 +15041,7 @@ paths: get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Groups summary: Get ai model grouped data. @@ -15119,7 +15113,7 @@ paths: get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Groups summary: Get metadata key based grouped data. @@ -15971,6 +15965,7 @@ components: ChatCompletionRequestMessage: oneOf: - $ref: "#/components/schemas/ChatCompletionRequestSystemMessage" + - $ref: "#/components/schemas/ChatCompletionRequestDeveloperMessage" - $ref: "#/components/schemas/ChatCompletionRequestUserMessage" - $ref: "#/components/schemas/ChatCompletionRequestAssistantMessage" - $ref: "#/components/schemas/ChatCompletionRequestToolMessage" @@ -15995,6 +15990,25 @@ components: - content - role + ChatCompletionRequestDeveloperMessage: + type: object + title: Developer message + description: This role is specific to a few OpenAI models. For other providers, we transform this to a system message. Only use this role for models that explicitly support it, otherwise use system message instead. + 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 From c2a4f5d5d365b2885a42b1ca56382839e61bf8ab Mon Sep 17 00:00:00 2001 From: Vrushank Vyas <134934501+vrushankportkey@users.noreply.github.com> Date: Tue, 25 Mar 2025 18:46:59 +0530 Subject: [PATCH 101/124] Update openapi.yaml --- openapi.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index 96a1b22a..6f7b6420 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -15993,7 +15993,7 @@ components: ChatCompletionRequestDeveloperMessage: type: object title: Developer message - description: This role is specific to a few OpenAI models. For other providers, we transform this to a system message. Only use this role for models that explicitly support it, otherwise use system message instead. + 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. From 817261368ce4b4bdeac60ad18f11fdc0bbcd7b37 Mon Sep 17 00:00:00 2001 From: Vrushank Vyas <134934501+vrushankportkey@users.noreply.github.com> Date: Fri, 28 Mar 2025 16:45:44 +0530 Subject: [PATCH 102/124] Update openapi.yaml --- openapi.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 6f7b6420..10047b87 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -204,7 +204,7 @@ paths: }); async function main() { - const response = await client.chat.completions.create({ + const response = await portkey.chat.completions.create({ messages: [{ role: "system", content: "You are a helpful assistant." }], model: "gpt-4o", }); @@ -225,7 +225,7 @@ paths: }); async function main() { - const response = await client.chat.completions.create({ + const response = await portkey.chat.completions.create({ messages: [{ role: "system", content: "You are a helpful assistant." }], model: "gpt-4o", }); From b3090f1f0de17b04847202d0829bb6dd93df9337 Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Mon, 7 Apr 2025 10:53:55 +0530 Subject: [PATCH 103/124] feat: prompts api ga --- openapi.yaml | 17337 +++++++++++++++++++++++++++---------------------- 1 file changed, 9441 insertions(+), 7896 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 10047b87..15b81cca 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -19,6 +19,14 @@ tags: 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: Collections + description: Create, List, Retrieve, Update, and Delete collections of prompts. + - name: Labels + description: Create, List, Retrieve, Update, and Delete labels. + - name: PromptCollections + 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: Completions @@ -380,703 +388,1304 @@ paths: "temperature": 0 }' - /prompts/{promptId}/completions: + /collections: post: - operationId: createPromptCompletion - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 + summary: Create a new collection + description: Creates a new collection in the specified workspace 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 + - Collections + security: + - Portkey-Key: [] 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. - + 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: Successful completion response + '200': + description: Collection created successfully content: application/json: schema: type: object properties: - status: + id: 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/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: 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: - post: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 - operationId: createPromptRender + 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: - - Prompts - summary: Prompts Render - description: | - Renders a prompt template with its variable values filled in + - Collections + security: + - Portkey-Key: [] parameters: - - in: path - name: promptId + - name: workspace_id + in: query required: true schema: type: string - description: The unique identifier of the prompt template to render + 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 + items: + $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}: + 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: - 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. - + type: object + properties: + name: + type: string + description: New name for the collection + required: + - name responses: - "200": - description: Successful rendered prompt + '200': + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json 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/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: 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); - - /images/generations: + 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: post: - operationId: createImage - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 + summary: Create a new label + description: Creates a new label in the system + operationId: createLabel + security: + - Portkey-Key: [] tags: - - Images - summary: Create Image + - Labels requestBody: required: true content: application/json: schema: - $ref: "#/components/schemas/CreateImageRequest" + $ref: '#/components/schemas/CreateLabelRequest' responses: - "200": - description: OK + '200': + description: Label created successfully content: application/json: schema: - $ref: "#/components/schemas/ImagesResponse" + $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: [] - Virtual-Key: [] - - Portkey-Key: [] - Provider-Auth: [] - Provider-Name: [] + 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}: + get: + summary: Get a label by ID + description: Returns a specific label by its ID + operationId: getLabel + security: - Portkey-Key: [] - Config: [] + 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: [] - Provider-Auth: [] - Provider-Name: [] - Custom-Host: [] + 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 - 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/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: 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: + delete: + summary: Delete a label + description: Deletes a label (marks it as archived) + 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: post: - operationId: createImageEdit - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 + summary: Create a new prompt + operationId: createPrompt tags: - - Images - summary: Create Image Edit + - PromptCollections + security: + - Portkey-Key: [] requestBody: required: true content: - multipart/form-data: + application/json: schema: - $ref: "#/components/schemas/CreateImageEditRequest" + type: object + required: + - name + - collection_id + - string + - parameters + properties: + name: + 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 + tools: + type: array + description: Tools for the prompt + 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: OK + '200': + description: Prompt created successfully content: application/json: schema: - $ref: "#/components/schemas/ImagesResponse" + 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: + - PromptCollections security: - Portkey-Key: [] - Virtual-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 + items: + $ref: '#/components/schemas/PromptSummary' + total: + type: integer + '400': + description: Bad request + '401': + description: Unauthorized + '403': + description: Forbidden + '500': + description: Server error + + /prompts/{promptId}: + get: + summary: Get a prompt by ID or slug + operationId: getPrompt + tags: + - PromptCollections + security: - Portkey-Key: [] - Provider-Auth: [] - Provider-Name: [] + 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 + operationId: updatePrompt + tags: + - PromptCollections + security: - Portkey-Key: [] - Config: [] + parameters: + - name: promptId + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + name: + type: string + collection_id: + type: string + string: + type: string + parameters: + type: object + model: + type: string + virtual_key: + type: string + version_description: + type: string + functions: + type: array + items: + type: object + tools: + type: array + items: + type: object + tool_choice: + type: object + is_raw_template: + type: integer + enum: [0, 1] + prompt_metadata: + type: object + 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: + - PromptCollections + security: - 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/v1/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: - post: - operationId: createImageVariation - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 + 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: + get: + summary: Get all versions of a prompt + operationId: getPromptVersions tags: - - Images - summary: Creates Image Variation + - PromptCollections + 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}: + get: + summary: Get a specific version of a prompt + operationId: getPromptByVersion + tags: + - PromptCollections + 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 + operationId: updatePromptVersion + tags: + - PromptCollections + 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: - multipart/form-data: + application/json: schema: - $ref: "#/components/schemas/CreateImageVariationRequest" + type: object + properties: + label_id: + type: string + format: uuid responses: - "200": - description: OK + '200': + description: Prompt version updated successfully content: application/json: schema: - $ref: "#/components/schemas/ImagesResponse" + 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}/default: + put: + summary: Set a version as the default for a prompt + operationId: updatePromptDefault + tags: + - PromptCollections security: - Portkey-Key: [] - Virtual-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: + post: + summary: Create a new prompt partial + operationId: createPromptPartial + tags: + - PromptPartials + security: - Portkey-Key: [] - Provider-Auth: [] - Provider-Name: [] + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - name + - string + properties: + workspace_id: + type: string + description: Required for Admin keys + name: + 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: [] - Config: [] + 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}: + get: + summary: Get a prompt partial by ID or slug + operationId: getPromptPartial + tags: + - PromptPartials + security: - 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 + 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: + 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: + 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}/default: + 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: + post: + operationId: createPromptCompletion + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 + 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", - virtual_key = "PROVIDER_VIRTUAL_KEY" + api_key="PORTKEY_API_KEY" ) - response = client.images.create_variation( - image=open("image_edit_original.png", "rb"), - n=2, - size="1024x1024" + completion = client.prompts.completions.create( + prompt_id="YOUR_PROMPT_ID", + variables={ + "user_input": "Hello world" + }, + max_tokens=250, + presence_penalty=0.2 ) - - lang: javascript + + print(completion) + + - 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' + const portkey = new Portkey({ + apiKey: 'PORTKEY_API_KEY' }); - async function main() { - const image = await client.images.createVariation({ - image: fs.createReadStream("otter.png"), - }); + 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(image.data); - } - main(); + console.log(completion); - lang: curl label: Self-Hosted source: | - curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/images/variations" \ + curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/prompts/YOUR_PROMPT_ID/completions" \ -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" + "variables": { + "user_input": "Hello world" + }, + "max_tokens": 250, + "presence_penalty": 0.2 }' - lang: python label: Self-Hosted @@ -1085,205 +1694,220 @@ paths: 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" + completion = client.prompts.completions.create( + prompt_id="YOUR_PROMPT_ID", + variables={ + "user_input": "Hello world" + }, + max_tokens=250, + presence_penalty=0.2 ) - print(image.data) + print(completion) - 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: + 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: post: - operationId: createEmbedding servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_GATEWAY_URL/v1 + operationId: createPromptRender tags: - - Embeddings - summary: Embeddings + - 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: - $ref: "#/components/schemas/CreateEmbeddingRequest" + 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: OK + description: Successful rendered prompt 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: [] + $ref: "#/components/schemas/PromptRenderResponse" x-code-samples: - - lang: curl + - 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" \ + 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 '{ - "input": "The food was delicious and the waiter...", - "model": "text-embedding-ada-002", - "encoding_format": "float" + "variables": { + "user_input": "Hello world" + }, + "max_tokens": 250, + "presence_penalty": 0.2 }' - - lang: python + - lang: Python label: Default source: | from portkey_ai import Portkey client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" + api_key="PORTKEY_API_KEY" ) - client.embeddings.create( - model="text-embedding-ada-002", - input="The food was delicious and the waiter...", - encoding_format="float" + completion = client.prompts.render( + prompt_id="YOUR_PROMPT_ID", + variables={ + "user_input": "Hello world" + }, + max_tokens=250, + presence_penalty=0.2 ) - - lang: javascript + + print(completion) + + - lang: "JavaScript" label: Default source: | import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' + const portkey = new Portkey({ + apiKey: 'PORTKEY_API_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); - } + const completion = await portkey.prompts.render({ + promptId: "YOUR_PROMPT_ID", + variables: { + user_input: "Hello world" + }, + max_tokens: 250, + presence_penalty: 0.2 + }); - main(); - - lang: curl + console.log(completion); + - lang: "cURL" label: Self-Hosted source: | - curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/embeddings" \ + curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/prompts/YOUR_PROMPT_ID/render" \ -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" + "variables": { + "user_input": "Hello world" + }, + "max_tokens": 250, + "presence_penalty": 0.2 }' - - lang: python + - 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" + completion = client.prompts.render( + prompt_id="YOUR_PROMPT_ID", + variables={ + "user_input": "Hello world" + }, + max_tokens=250, + presence_penalty=0.2 ) - print(response.data) - - lang: javascript + print(completion) + + - 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' + 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); - } + const completion = await portkey.prompts.render({ + promptId: "YOUR_PROMPT_ID", + variables: { + user_input: "Hello world" + }, + max_tokens: 250, + presence_penalty: 0.2 + }); - main(); + console.log(completion); - /audio/speech: + /images/generations: post: - operationId: createSpeech + operationId: createImage servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - - Audio - summary: Create Speech + - Images + summary: Create Image requestBody: required: true content: application/json: schema: - $ref: "#/components/schemas/CreateSpeechRequest" + $ref: "#/components/schemas/CreateImageRequest" responses: "200": description: OK - headers: - Transfer-Encoding: - schema: - type: string - description: chunked content: - application/octet-stream: + application/json: schema: - type: string - format: binary - + $ref: "#/components/schemas/ImagesResponse" security: - Portkey-Key: [] Virtual-Key: [] @@ -1301,20 +1925,19 @@ paths: - lang: curl label: Default source: | - curl https://api.portkey.ai/v1/audio/speech \ + 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" \ - -H "Content-Type: application/json" \ -d '{ - "model": "tts-1", - "input": "The quick brown fox jumped over the lazy dog.", - "voice": "alloy" - }' \ - --output speech.mp3 + "model": "dall-e-3", + "prompt": "A cute baby sea otter", + "n": 1, + "size": "1024x1024" + }' - lang: python label: Default source: | - from pathlib import Path from portkey_ai import Portkey client = Portkey( @@ -1322,18 +1945,15 @@ paths: 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." + client.images.generate( + model="dall-e-3", + prompt="A cute baby sea otter", + n=1, + size="1024x1024" ) - 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({ @@ -1341,103 +1961,86 @@ paths: 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); + 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/v1/audio/speech" \ + curl -X POST "SELF_HOSTED_GATEWAY_URL/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": "tts-1", - "input": "The quick brown fox jumped over the lazy dog.", - "voice": "alloy" - }' \ - --output speech.mp3 + "model": "dall-e-3", + "prompt": "A cute baby sea otter", + "n": 1, + "size": "1024x1024" + }' - 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" + 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." + image = client.images.generate( + model="dall-e-3", + prompt="A cute baby sea otter", + n=1, + size="1024x1024" ) - response.stream_to_file(speech_file_path) + + print(image.data) - lang: javascript label: Self-Hosted source: | - import fs from "fs"; - import path from "path"; import Portkey from 'portkey-ai'; - const client = new Portkey({ + const portkey = new Portkey({ apiKey: 'PORTKEY_API_KEY', virtualKey: 'PROVIDER_VIRTUAL_KEY', - baseUrl: 'SELF_HOSTED_GATEWAY_URL' + baseURL: 'SELF_HOSTED_GATEWAY_URL' }); - const speechFile = path.resolve("./speech.mp3"); + const image = await portkey.images.generate({ + model: "dall-e-3", + prompt: "A cute baby sea otter", + n: 1, + size: "1024x1024" + }); - 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(); + console.log(image.data); - /audio/transcriptions: + /images/edits: post: - operationId: createTranscription + operationId: createImageEdit servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - - Audio - summary: Create Transcription + - Images + summary: Create Image Edit requestBody: required: true content: multipart/form-data: schema: - $ref: "#/components/schemas/CreateTranscriptionRequest" + $ref: "#/components/schemas/CreateImageEditRequest" responses: "200": description: OK content: application/json: schema: - oneOf: - - $ref: "#/components/schemas/CreateTranscriptionResponseJson" - - $ref: "#/components/schemas/CreateTranscriptionResponseVerboseJson" - + $ref: "#/components/schemas/ImagesResponse" security: - Portkey-Key: [] Virtual-Key: [] @@ -1455,12 +2058,14 @@ paths: - lang: curl label: Default source: | - curl https://api.portkey.ai/v1/audio/transcriptions \ + 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" \ - -H "Content-Type: multipart/form-data" \ - -F file="@/path/to/file/audio.mp3" \ - -F model="whisper-1" + -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: | @@ -1471,10 +2076,12 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - audio_file = open("speech.mp3", "rb") - transcript = client.audio.transcriptions.create( - model="whisper-1", - file=audio_file + 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 @@ -1488,91 +2095,94 @@ paths: }); async function main() { - const transcription = await client.audio.transcriptions.create({ - file: fs.createReadStream("audio.mp3"), - model: "whisper-1", + 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(transcription.text); + console.log(image.data); } main(); - lang: curl label: Self-Hosted source: | - curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/audio/transcriptions" \ + curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/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 '{ - "model": "whisper-1", - "file": "@/path/to/file/audio.mp3" - }' \ - --output transcription.json + "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" + 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 + 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 client = new Portkey({ + const portkey = new Portkey({ apiKey: 'PORTKEY_API_KEY', virtualKey: 'PROVIDER_VIRTUAL_KEY', - baseUrl: 'SELF_HOSTED_GATEWAY_URL' + 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", + 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(transcription.text); + console.log(image.data); } main(); - /audio/translations: + /images/variations: post: - operationId: createTranslation + operationId: createImageVariation servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - - Audio - summary: Create Translation + - Images + summary: Creates Image Variation requestBody: required: true content: multipart/form-data: schema: - $ref: "#/components/schemas/CreateTranslationRequest" + $ref: "#/components/schemas/CreateImageVariationRequest" responses: "200": description: OK content: application/json: schema: - oneOf: - - $ref: "#/components/schemas/CreateTranslationResponseJson" - - $ref: "#/components/schemas/CreateTranslationResponseVerboseJson" - + $ref: "#/components/schemas/ImagesResponse" security: - Portkey-Key: [] Virtual-Key: [] @@ -1590,12 +2200,12 @@ paths: - lang: curl label: Default source: | - curl https://api.portkey.ai/v1/audio/translations \ + 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" \ - -H "Content-Type: multipart/form-data" \ - -F file="@/path/to/file/german.m4a" \ - -F model="whisper-1" + -F image="@otter.png" \ + -F n=2 \ + -F size="1024x1024" - lang: python label: Default source: | @@ -1606,10 +2216,10 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - audio_file = open("speech.mp3", "rb") - transcript = client.audio.translations.create( - model="whisper-1", - file=audio_file + response = client.images.create_variation( + image=open("image_edit_original.png", "rb"), + n=2, + size="1024x1024" ) - lang: javascript label: Default @@ -1623,87 +2233,86 @@ paths: }); async function main() { - const translation = await client.audio.translations.create({ - file: fs.createReadStream("speech.mp3"), - model: "whisper-1", - }); + const image = await client.images.createVariation({ + image: fs.createReadStream("otter.png"), + }); - console.log(translation.text); + console.log(image.data); } main(); - lang: curl label: Self-Hosted source: | - curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/audio/translations" \ + curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/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 '{ - "model": "whisper-1", - "file": "@/path/to/file/german.m4a" - }' \ - --output translation.json + "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" + 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 + 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 client = new Portkey({ + const portkey = new Portkey({ apiKey: 'PORTKEY_API_KEY', virtualKey: 'PROVIDER_VIRTUAL_KEY', - baseUrl: 'SELF_HOSTED_GATEWAY_URL' + 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", + const image = await portkey.images.createVariation({ + image: fs.createReadStream("otter.png"), }); - console.log(translation.text); + console.log(image.data); } main(); - /files: - get: - operationId: listFiles + /embeddings: + post: + operationId: createEmbedding + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - - Files - summary: List Files - parameters: - - in: query - name: purpose - required: false - schema: - type: string - description: Only return files with the given purpose. + - 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/ListFilesResponse" - + $ref: "#/components/schemas/CreateEmbeddingResponse" security: - Portkey-Key: [] Virtual-Key: [] @@ -1719,11 +2328,19 @@ paths: x-code-samples: - lang: curl + label: Default source: | - curl https://api.portkey.ai/v1/files \ + 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 @@ -1732,8 +2349,13 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - client.files.list() + 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'; @@ -1743,34 +2365,98 @@ paths: }); async function main() { - const list = await client.files.list(); + const embedding = await client.embeddings.create({ + model: "text-embedding-ada-002", + input: "The quick brown fox jumped over the lazy dog", + encoding_format: "float", + }); - for await (const file of list) { - console.log(file); - } + console.log(embedding); + } + + main(); + - lang: curl + label: Self-Hosted + source: | + curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/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: post: - operationId: createFile + operationId: createSpeech + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 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. + - Audio + summary: Create Speech requestBody: required: true content: - multipart/form-data: + application/json: schema: - $ref: "#/components/schemas/CreateFileRequest" + $ref: "#/components/schemas/CreateSpeechRequest" responses: "200": description: OK + headers: + Transfer-Encoding: + schema: + type: string + description: chunked content: - application/json: + application/octet-stream: schema: - $ref: "#/components/schemas/OpenAIFile" + type: string + format: binary security: - Portkey-Key: [] @@ -1787,14 +2473,22 @@ paths: x-code-samples: - lang: curl + label: Default source: | - curl https://api.portkey.ai/v1/files \ + 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" \ - -F purpose="fine-tune" \ - -F file="@mydata.jsonl" + -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( @@ -1802,13 +2496,18 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - client.files.create( - file=open("mydata.jsonl", "rb"), - purpose="fine-tune" + 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({ @@ -1816,104 +2515,102 @@ paths: virtualKey: 'PROVIDER_VIRTUAL_KEY' }); + const speechFile = path.resolve("./speech.mp3"); + async function main() { - const file = await client.files.create({ - file: fs.createReadStream("mydata.jsonl"), - purpose: "fine-tune", + 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(file); + console.log(speechFile); + const buffer = Buffer.from(await mp3.arrayBuffer()); + await fs.promises.writeFile(speechFile, buffer); } - main(); - - /files/{file_id}: - 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 + label: Self-Hosted source: | - curl https://api.portkey.ai/v1/files/file-abc123 \ - -X DELETE \ + curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/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" + virtual_key = "PROVIDER_VIRTUAL_KEY", + base_url="SELF_HOSTED_GATEWAY_URL" ) - client.files.delete("file-abc123") + 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' + virtualKey: 'PROVIDER_VIRTUAL_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL' }); - async function main() { - const file = await client.files.del("file-abc123"); + const speechFile = path.resolve("./speech.mp3"); - console.log(file); + 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(); - get: - operationId: retrieveFile + /audio/transcriptions: + post: + operationId: createTranscription + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 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. + - Audio + summary: Create Transcription + requestBody: + required: true + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/CreateTranscriptionRequest" responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/OpenAIFile" + oneOf: + - $ref: "#/components/schemas/CreateTranscriptionResponseJson" + - $ref: "#/components/schemas/CreateTranscriptionResponseVerboseJson" security: - Portkey-Key: [] @@ -1930,11 +2627,16 @@ paths: x-code-samples: - lang: curl + label: Default source: | - curl https://api.portkey.ai/v1/files/file-abc123 \ + 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 "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 @@ -1943,9 +2645,15 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - client.files.retrieve("file-abc123") + 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({ @@ -1954,107 +2662,90 @@ paths: }); async function main() { - const file = await client.files.retrieve("file-abc123"); - - console.log(file); - } + const transcription = await client.audio.transcriptions.create({ + file: fs.createReadStream("audio.mp3"), + model: "whisper-1", + }); + console.log(transcription.text); + } main(); - - /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 - - 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: Self-Hosted 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 + curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/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" + virtual_key = "PROVIDER_VIRTUAL_KEY", + base_url="SELF_HOSTED_GATEWAY_URL" ) - content = client.files.content("file-abc123") + 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' + virtualKey: 'PROVIDER_VIRTUAL_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL' }); + const audioFile = fs.createReadStream("speech.mp3"); + async function main() { - const file = await client.files.content("file-abc123"); + const transcription = await client.audio.transcriptions.create({ + file: audioFile, + model: "whisper-1", + }); - console.log(file); + console.log(transcription.text); } - main(); - /fine_tuning/jobs: + /audio/translations: post: + operationId: createTranslation servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_GATEWAY_URL/v1 - 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 + - Audio + summary: Create Translation requestBody: required: true content: - application/json: + multipart/form-data: schema: - anyOf: - - $ref: "#/components/schemas/OpenAIFinetuneJob" - - $ref: "#/components/schemas/BedrockFinetuneJob" - - $ref: "#/components/schemas/PortkeyFinetuneJob" + $ref: "#/components/schemas/CreateTranslationRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + oneOf: + - $ref: "#/components/schemas/CreateTranslationResponseJson" + - $ref: "#/components/schemas/CreateTranslationResponseVerboseJson" security: - Portkey-Key: [] @@ -2073,14 +2764,12 @@ paths: - lang: curl label: Default source: | - curl https://api.portkey.ai/v1/fine_tuning/jobs \ - -H "Content-Type: application/json" \ + 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" \ - -d '{ - "training_file": "file-BK7bzQj3FfZFXr7DbL6xJwfo", - "model": "gpt-3.5-turbo" - }' + -H "Content-Type: multipart/form-data" \ + -F file="@/path/to/file/german.m4a" \ + -F model="whisper-1" - lang: python label: Default source: | @@ -2091,13 +2780,15 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - client.fine_tuning.jobs.create( - training_file="file-abc123", - model="gpt-3.5-turbo" + 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({ @@ -2106,91 +2797,86 @@ paths: }); async function main() { - const fineTune = await client.fineTuning.jobs.create({ - training_file: "file-abc123" - }); + const translation = await client.audio.translations.create({ + file: fs.createReadStream("speech.mp3"), + model: "whisper-1", + }); - console.log(fineTune); + console.log(translation.text); } - main(); - lang: curl - label: Self-hosted + label: Self-Hosted source: | - curl https://SELF_HOSTED_GATEWAY_URL/v1/fine_tuning/jobs \ + curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/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 '{ - "training_file": "file-BK7bzQj3FfZFXr7DbL6xJwfo", - "model": "gpt-3.5-turbo" - }' + "model": "whisper-1", + "file": "@/path/to/file/german.m4a" + }' \ + --output translation.json - lang: python - label: Self-hosted + 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" + virtual_key = "PROVIDER_VIRTUAL_KEY", + base_url="SELF_HOSTED_GATEWAY_URL" ) - client.fine_tuning.jobs.create( - training_file="file-abc123", - model="gpt-3.5-turbo" + audio_file = open("speech.mp3", "rb") + transcript = client.audio.translations.create( + model="whisper-1", + file=audio_file ) - lang: javascript - label: Self-hosted + label: Self-Hosted source: | + import fs from "fs"; import Portkey from 'portkey-ai'; const client = new Portkey({ apiKey: 'PORTKEY_API_KEY', - baseUrl: 'SELF_HOSTED_GATEWAY_URL', - virtualKey: 'PROVIDER_VIRTUAL_KEY' + virtualKey: 'PROVIDER_VIRTUAL_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL' }); + const audioFile = fs.createReadStream("speech.mp3"); + async function main() { - const fineTune = await client.fineTuning.jobs.create({ - training_file: "file-abc123" + const translation = await client.audio.translations.create({ + file: audioFile, + model: "whisper-1", }); - console.log(fineTune); + console.log(translation.text); } - main(); + /files: get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 - operationId: listPaginatedFineTuningJobs + operationId: listFiles tags: - - Fine-tuning - summary: | - List your organization's fine-tuning jobs + - Files + summary: List Files parameters: - - name: after - in: query - description: Identifier for the last job from the previous pagination request. + - in: query + name: purpose required: false schema: type: string - - name: limit - in: query - description: Number of fine-tuning jobs to retrieve. - required: false - schema: - type: integer - default: 20 + description: Only return files with the given purpose. responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/ListPaginatedFineTuningJobsResponse" + $ref: "#/components/schemas/ListFilesResponse" security: - Portkey-Key: [] @@ -2207,13 +2893,11 @@ paths: x-code-samples: - lang: curl - label: Default source: | - curl https://api.portkey.ai/v1/fine_tuning/jobs?limit=2 \ + curl https://api.portkey.ai/v1/files \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - lang: python - label: Default source: | from portkey_ai import Portkey @@ -2222,9 +2906,8 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - client.fine_tuning.jobs.list() + client.files.list() - lang: javascript - label: Default source: | import Portkey from 'portkey-ai'; @@ -2234,81 +2917,34 @@ paths: }); async function main() { - const list = await client.fineTuning.jobs.list(); + const list = await client.files.list(); - for await (const fineTune of list) { - console.log(fineTune); + for await (const file of list) { + console.log(file); } } main(); - - lang: curl - label: Self-hosted - source: | - curl https://SELF_HOSTED_GATEWAY_URL/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: 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}: - get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 - operationId: retrieveFineTuningJob + post: + operationId: createFile tags: - - Fine-tuning + - Files 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. + 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/FineTuningJob" + $ref: "#/components/schemas/OpenAIFile" security: - Portkey-Key: [] @@ -2325,13 +2961,13 @@ paths: x-code-samples: - lang: curl - label: Default source: | - curl https://api.portkey.ai/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F \ + curl https://api.portkey.ai/v1/files \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ + -F purpose="fine-tune" \ + -F file="@mydata.jsonl" - lang: python - label: Default source: | from portkey_ai import Portkey @@ -2340,10 +2976,13 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - client.fine_tuning.jobs.retrieve("ftjob-abc123") + client.files.create( + file=open("mydata.jsonl", "rb"), + purpose="fine-tune" + ) - lang: javascript - label: Default source: | + import fs from "fs"; import Portkey from 'portkey-ai'; const client = new Portkey({ @@ -2352,88 +2991,103 @@ paths: }); async function main() { - const fineTune = await client.fineTuning.jobs.retrieve("ftjob-abc123"); + const file = await client.files.create({ + file: fs.createReadStream("mydata.jsonl"), + purpose: "fine-tune", + }); - console.log(fineTune); + console.log(file); } main(); + + /files/{file_id}: + 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 - label: Self-hosted source: | - curl SELF_HOSTED_GATEWAY_URL/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F \ + 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" + -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") + client.files.delete("file-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"); + const file = await client.files.del("file-abc123"); - console.log(fineTune); + console.log(file); } main(); - /fine_tuning/jobs/{fine_tuning_job_id}/events: get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 - operationId: listFineTuningEvents + operationId: retrieveFile tags: - - Fine-tuning - summary: | - Get status updates for a fine-tuning job. + - Files + summary: Returns information about a specific file. parameters: - in: path - name: fine_tuning_job_id + name: file_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 + description: The ID of the file to use for this request. responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/ListFineTuningJobEventsResponse" + $ref: "#/components/schemas/OpenAIFile" security: - Portkey-Key: [] @@ -2450,13 +3104,11 @@ paths: x-code-samples: - lang: curl - label: Default source: | - curl https://api.portkey.ai/v1/fine_tuning/jobs/ftjob-abc123/events \ + 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 - label: Default source: | from portkey_ai import Portkey @@ -2465,12 +3117,8 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - client.fine_tuning.jobs.list_events( - fine_tuning_job_id="ftjob-abc123", - limit=2 - ) + client.files.retrieve("file-abc123") - lang: javascript - label: Default source: | import Portkey from 'portkey-ai'; @@ -2480,82 +3128,107 @@ paths: }); async function main() { - const list = await client.fineTuning.list_events(id="ftjob-abc123", limit=2); + const file = await client.files.retrieve("file-abc123"); - for await (const fineTune of list) { - console.log(fineTune); - } + console.log(file); } main(); + + /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 + + 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: Self-hosted source: | - curl SELF_HOSTED_GATEWAY_URL/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F/events \ - -H "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" + 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 - 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 - ) + content = client.files.content("file-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 list = await client.fineTuning.list_events(id="ftjob-abc123", limit=2); + const file = await client.files.content("file-abc123"); - for await (const fineTune of list) { - console.log(fineTune); - } + console.log(file); } main(); - /fine_tuning/jobs/{fine_tuning_job_id}/cancel: + /fine_tuning/jobs: post: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_GATEWAY_URL/v1 - 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. + operationId: createFineTuningJob + summary: Create a Finetune Job + description: Finetune a provider model + parameters: [] responses: "200": - description: OK + 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: [] @@ -2574,11 +3247,16 @@ paths: - lang: curl label: Default source: | - curl -X POST https://api.portkey.ai/v1/fine_tuning/jobs/ftjob-abc123/cancel \ + 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" - - lang: python - label: Default + -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 @@ -2587,7 +3265,10 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - client.fine_tuning.jobs.cancel("ftjob-abc123") + client.fine_tuning.jobs.create( + training_file="file-abc123", + model="gpt-3.5-turbo" + ) - lang: javascript label: Default source: | @@ -2599,17 +3280,25 @@ paths: }); async function main() { - const fineTune = await client.fineTuning.jobs.cancel("ftjob-abc123"); + const fineTune = await client.fineTuning.jobs.create({ + training_file: "file-abc123" + }); console.log(fineTune); } + main(); - lang: curl label: Self-hosted source: | - curl -X POST SELF_HOSTED_GATEWAY_URL/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F/cancel \ + curl https://SELF_HOSTED_GATEWAY_URL/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" + -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: | @@ -2621,7 +3310,10 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - client.fine_tuning.jobs.cancel("ft-AF1WoRqd3aJAHsqc9NY7iL8F") + client.fine_tuning.jobs.create( + training_file="file-abc123", + model="gpt-3.5-turbo" + ) - lang: javascript label: Self-hosted source: | @@ -2634,51 +3326,45 @@ paths: }); async function main() { - const fineTune = await client.fineTuning.jobs.cancel("ft-AF1WoRqd3aJAHsqc9NY7iL8F"); + const fineTune = await client.fineTuning.jobs.create({ + training_file: "file-abc123" + }); console.log(fineTune); } + main(); - /fine_tuning/jobs/{fine_tuning_job_id}/checkpoints: get: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_GATEWAY_URL/v1 - operationId: listFineTuningJobCheckpoints + operationId: listPaginatedFineTuningJobs tags: - Fine-tuning summary: | - List checkpoints for a fine-tuning job. + List your organization's fine-tuning jobs 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. + description: Identifier for the last job from the previous pagination request. required: false schema: type: string - name: limit in: query - description: Number of checkpoints to retrieve. + description: Number of fine-tuning jobs to retrieve. required: false schema: type: integer - default: 10 + default: 20 responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/ListFineTuningJobCheckpointsResponse" + $ref: "#/components/schemas/ListPaginatedFineTuningJobsResponse" security: - Portkey-Key: [] @@ -2697,13 +3383,7 @@ paths: - 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/v1/fine_tuning/jobs/ftjob-abc123/checkpoints \ + 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 @@ -2716,8 +3396,7 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - checkpoints_list = client.fine_tuning.jobs.checkpoints.list(fine_tuning_job_id="") - print(checkpoints_list) + client.fine_tuning.jobs.list() - lang: javascript label: Default source: | @@ -2729,55 +3408,81 @@ paths: }); async function main() { - const checkpointsList = await client.fineTuning.jobs.checkpoints.list("") - console.log(checkpointsList) + 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/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: Self-Hosted + 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" + base_url = "SELF_HOSTED_GATEWAY_URL", + virtual_key = "PROVIDER_VIRTUAL_KEY" ) - checkpoints_list = client.fine_tuning.jobs.checkpoints.list(fine_tuning_job_id="") - print(checkpoints_list) + client.fine_tuning.jobs.list() - lang: javascript - label: Self-Hosted + 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' + baseUrl: 'SELF_HOSTED_GATEWAY_URL', + virtualKey: 'PROVIDER_VIRTUAL_KEY' }); async function main() { - const checkpointsList = await client.fineTuning.jobs.checkpoints.list("") - console.log(checkpointsList) + const list = await client.fineTuning.jobs.list(); + + for await (const fineTune of list) { + console.log(fineTune); + } } main(); - /models: + /fine_tuning/jobs/{fine_tuning_job_id}: get: - operationId: listModels + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 + operationId: retrieveFineTuningJob tags: - - Models - summary: Lists the currently available models, and provides basic information about each one such as the owner and availability. + - 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/ListModelsResponse" + $ref: "#/components/schemas/FineTuningJob" security: - Portkey-Key: [] @@ -2794,11 +3499,13 @@ paths: x-code-samples: - lang: curl + label: Default source: | - curl https://api.portkey.ai/v1/models \ + 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 @@ -2807,8 +3514,9 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - client.models.list() + client.fine_tuning.jobs.retrieve("ftjob-abc123") - lang: javascript + label: Default source: | import Portkey from 'portkey-ai'; @@ -2818,103 +3526,88 @@ paths: }); async function main() { - const list = await client.models.list(); + const fineTune = await client.fineTuning.jobs.retrieve("ftjob-abc123"); - for await (const model of list) { - console.log(model); - } + console.log(fineTune); } - 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: + main(); - lang: curl + label: Self-hosted source: | - curl https://api.portkey.ai/v1/models/VAR_model_id \ + curl SELF_HOSTED_GATEWAY_URL/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_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.models.retrieve("VAR_model_id") + 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 model = await client.models.retrieve("VAR_model_id"); + const fineTune = await client.fineTuning.jobs.retrieve("ftjob-abc123"); - console.log(model); + console.log(fineTune); } main(); - delete: - operationId: deleteModel + /fine_tuning/jobs/{fine_tuning_job_id}/events: + get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 + operationId: listFineTuningEvents tags: - - Models - summary: Delete a fine-tuned model. You must have the Owner role in your organization to delete a model. + - Fine-tuning + summary: | + Get status updates for a fine-tuning job. parameters: - in: path - name: model + name: fine_tuning_job_id required: true schema: type: string - example: ft:gpt-3.5-turbo:acemeco:suffix:abc123 - description: The model to delete + 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/DeleteModelResponse" + $ref: "#/components/schemas/ListFineTuningJobEventsResponse" security: - Portkey-Key: [] @@ -2931,12 +3624,13 @@ paths: x-code-samples: - lang: curl + label: Default source: | - curl https://api.portkey.ai/v1/models/ft:gpt-3.5-turbo:acemeco:suffix:abc123 \ - -X DELETE \ + 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 @@ -2945,8 +3639,12 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - client.models.delete("ft:gpt-3.5-turbo:acemeco:suffix:abc123") + client.fine_tuning.jobs.list_events( + fine_tuning_job_id="ftjob-abc123", + limit=2 + ) - lang: javascript + label: Default source: | import Portkey from 'portkey-ai'; @@ -2956,35 +3654,82 @@ paths: }); async function main() { - const model = await client.models.del("ft:gpt-3.5-turbo:acemeco:suffix:abc123"); + const list = await client.fineTuning.list_events(id="ftjob-abc123", limit=2); - console.log(model); + for await (const fineTune of list) { + console.log(fineTune); + } } - main(); - /moderations: - post: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 - operationId: createModeration - tags: - - Moderations + main(); + - lang: curl + label: Self-hosted + source: | + curl SELF_HOSTED_GATEWAY_URL/v1/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: + post: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 + operationId: cancelFineTuningJob + tags: + - Fine-tuning 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" + 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/CreateModerationResponse" + $ref: "#/components/schemas/FineTuningJob" security: - Portkey-Key: [] @@ -3003,13 +3748,9 @@ paths: - lang: curl label: Default source: | - curl https://api.portkey.ai/v1/moderations \ - -H "Content-Type: application/json" \ + 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" \ - -d '{ - "input": "I want to kill them." - }' + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" - lang: python label: Default source: | @@ -3020,8 +3761,7 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - moderation = client.moderations.create(input="I want to kill them.") - print(moderation) + client.fine_tuning.jobs.cancel("ftjob-abc123") - lang: javascript label: Default source: | @@ -3033,94 +3773,86 @@ paths: }); async function main() { - const moderation = await client.moderations.create({ input: "I want to kill them." }); + const fineTune = await client.fineTuning.jobs.cancel("ftjob-abc123"); - console.log(moderation); + console.log(fineTune); } main(); - lang: curl - label: Self-Hosted + label: Self-hosted source: | - curl https://SELF_HOSTED_GATEWAY_URL/v1/moderations \ - -H "Content-Type: application/json" \ + curl -X POST SELF_HOSTED_GATEWAY_URL/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F/cancel \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ - -d '{ - "input": "I want to kill them." - }' + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" - lang: python - label: Self-Hosted + label: Self-hosted source: | from portkey_ai import Portkey client = Portkey( api_key = "PORTKEY_API_KEY", - base_url="SELF_HOSTED_GATEWAY_URL", + base_url = "SELF_HOSTED_GATEWAY_URL", virtual_key = "PROVIDER_VIRTUAL_KEY" ) - moderation = client.moderations.create(input="I want to kill them.") - print(moderation) + client.fine_tuning.jobs.cancel("ft-AF1WoRqd3aJAHsqc9NY7iL8F") - lang: javascript - label: Self-Hosted + 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' + baseUrl: 'SELF_HOSTED_GATEWAY_URL', + virtualKey: 'PROVIDER_VIRTUAL_KEY' }); async function main() { - const moderation = await client.moderations.create({ input: "I want to kill them." }); + const fineTune = await client.fineTuning.jobs.cancel("ft-AF1WoRqd3aJAHsqc9NY7iL8F"); - console.log(moderation); + console.log(fineTune); } main(); - /assistants: + /fine_tuning/jobs/{fine_tuning_job_id}/checkpoints: get: - operationId: listAssistants + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 + operationId: listFineTuningJobCheckpoints tags: - - Assistants - summary: Returns a list of assistants. + - Fine-tuning + summary: | + List checkpoints for a fine-tuning job. 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. + - in: path + name: fine_tuning_job_id + required: true schema: type: string - default: desc - enum: ["asc", "desc"] + example: ft-AF1WoRqd3aJAHsqc9NY7iL8F + description: | + The ID of the fine-tuning job to get checkpoints for. - 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. + description: Identifier for the last checkpoint ID from the previous pagination request. + required: false schema: type: string - - name: before + - name: limit 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. + description: Number of checkpoints to retrieve. + required: false schema: - type: string + type: integer + default: 10 responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/ListAssistantsResponse" + $ref: "#/components/schemas/ListFineTuningJobCheckpointsResponse" security: - Portkey-Key: [] @@ -3137,13 +3869,19 @@ paths: 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 "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" + curl SELF_HOSTED_GATEWAY_URL/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: python + label: Default source: | from portkey_ai import Portkey @@ -3152,12 +3890,10 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - my_assistants = client.beta.assistants.list( - order="desc", - limit="20", - ) - print(my_assistants.data) + 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'; @@ -3167,88 +3903,55 @@ paths: }); async function main() { - const myAssistants = await client.beta.assistants.list({ - order: "desc", - limit: "20", - }); - - console.log(myAssistants.data); + const checkpointsList = await client.fineTuning.jobs.checkpoints.list("") + console.log(checkpointsList) } 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 - } + - lang: python + label: Self-Hosted + source: | + from portkey_ai import Portkey - 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" + 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: + 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/AssistantObject" + $ref: "#/components/schemas/ListModelsResponse" security: - Portkey-Key: [] @@ -3266,17 +3969,9 @@ paths: x-code-samples: - lang: curl source: | - curl "https://api.portkey.ai/v1/assistants" \ - -H "Content-Type: application/json" \ + curl https://api.portkey.ai/v1/models \ -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" - }' + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" - lang: python source: | from portkey_ai import Portkey @@ -3286,13 +3981,7 @@ paths: 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) + client.models.list() - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -3303,57 +3992,36 @@ paths: }); async function main() { - const myAssistant = await 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", - }); + const list = await client.models.list(); - console.log(myAssistant); + for await (const model of list) { + console.log(model); + } } - 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}: + + /models/{model}: get: - operationId: getAssistant + operationId: retrieveModel tags: - - Assistants - summary: Retrieves an assistant. + - Models + summary: Retrieves a model instance, providing basic information about the model such as the owner and permissioning. parameters: - in: path - name: assistant_id + name: model required: true schema: type: string - description: The ID of the assistant to retrieve. + # 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/AssistantObject" + $ref: "#/components/schemas/Model" security: - Portkey-Key: [] @@ -3371,11 +4039,9 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/assistants/asst_abc123 \ - -H "Content-Type: application/json" \ + 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" \ - -H "OpenAI-Beta: assistants=v2" - lang: python source: | from portkey_ai import Portkey @@ -3385,8 +4051,7 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - my_assistant = client.beta.assistants.retrieve("asst_abc123") - print(my_assistant) + client.models.retrieve("VAR_model_id") - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -3397,58 +4062,33 @@ paths: }); async function main() { - const myAssistant = await client.beta.assistants.retrieve( - "asst_abc123" - ); + const model = await client.models.retrieve("VAR_model_id"); - console.log(myAssistant); + console.log(model); } 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 + + delete: + operationId: deleteModel tags: - - Assistants - summary: Modifies an assistant. + - Models + summary: Delete a fine-tuned model. You must have the Owner role in your organization to delete a model. parameters: - in: path - name: assistant_id + name: model required: true schema: type: string - description: The ID of the assistant to modify. - requestBody: - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/ModifyAssistantRequest" + 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/AssistantObject" + $ref: "#/components/schemas/DeleteModelResponse" security: - Portkey-Key: [] @@ -3466,16 +4106,10 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/assistants/asst_abc123 \ - -H "Content-Type: application/json" \ + 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" \ - -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" - }' + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" - lang: python source: | from portkey_ai import Portkey @@ -3485,15 +4119,7 @@ paths: 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) + client.models.delete("ft:gpt-3.5-turbo:acemeco:suffix:abc123") - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -3504,64 +4130,35 @@ paths: }); 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" - } - ); + const model = await client.models.del("ft:gpt-3.5-turbo:acemeco:suffix:abc123"); - console.log(myUpdatedAssistant); + console.log(model); } - 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 + + /moderations: + post: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_GATEWAY_URL/v1 + operationId: createModeration 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. + - 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/DeleteAssistantResponse" + $ref: "#/components/schemas/CreateModerationResponse" security: - Portkey-Key: [] @@ -3578,14 +4175,17 @@ paths: x-code-samples: - lang: curl + label: Default source: | - curl https://api.portkey.ai/v1/assistants/asst_abc123 \ + 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" \ - -H "OpenAI-Beta: assistants=v2" \ - -X DELETE - - lang: python + -d '{ + "input": "I want to kill them." + }' + - lang: python + label: Default source: | from portkey_ai import Portkey @@ -3594,9 +4194,10 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - response = client.beta.assistants.delete("asst_abc123") - print(response) + moderation = client.moderations.create(input="I want to kill them.") + print(moderation) - lang: javascript + label: Default source: | import Portkey from 'portkey-ai'; @@ -3606,146 +4207,94 @@ paths: }); async function main() { - const response = await client.beta.assistants.del("asst_abc123"); + const moderation = await client.moderations.create({ input: "I want to kill them." }); - console.log(response); + console.log(moderation); } 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" - - 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: Self-Hosted source: | - curl https://api.portkey.ai/v1/threads \ + curl https://SELF_HOSTED_GATEWAY_URL/v1/moderations \ -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." - }] - }' + "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" ) - 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) + 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' + virtualKey: 'PROVIDER_VIRTUAL_KEY', + baseURL: 'SELF_HOSTED_GATEWAY_URL' }); 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.", - }, - ], - }); + const moderation = await client.moderations.create({ input: "I want to kill them." }); - console.log(messageThread); + console.log(moderation); } - main(); - response: | - { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699014083, - "metadata": {}, - "tool_resources": {} - } - /threads/{thread_id}: + /assistants: get: - operationId: getThread + operationId: listAssistants tags: - Assistants - summary: Retrieves a thread. + summary: Returns a list of assistants. parameters: - - in: path - name: thread_id - required: true + - 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 - description: The ID of the thread to retrieve. responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/ThreadObject" + $ref: "#/components/schemas/ListAssistantsResponse" security: - Portkey-Key: [] @@ -3763,11 +4312,11 @@ paths: 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" + 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 @@ -3777,8 +4326,11 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - my_thread = client.beta.threads.retrieve("thread_abc123") - print(my_thread) + my_assistants = client.beta.assistants.list( + order="desc", + limit="20", + ) + print(my_assistants.data) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -3789,51 +4341,88 @@ paths: }); async function main() { - const myThread = await client.beta.threads.retrieve( - "thread_abc123" - ); + const myAssistants = await client.beta.assistants.list({ + order: "desc", + limit: "20", + }); - console.log(myThread); + console.log(myAssistants.data); } main(); - response: | + response: &list_assistants_example | { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699014083, - "metadata": {}, - "tool_resources": { - "code_interpreter": { - "file_ids": [] + "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: modifyThread + operationId: createAssistant 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. + summary: Create an assistant with a model and instructions. requestBody: required: true content: application/json: schema: - $ref: "#/components/schemas/ModifyThreadRequest" + $ref: "#/components/schemas/CreateAssistantRequest" responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/ThreadObject" + $ref: "#/components/schemas/AssistantObject" security: - Portkey-Key: [] @@ -3851,17 +4440,17 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_abc123 \ + 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 '{ - "metadata": { - "modified": "true", - "user": "abc123" - } - }' + "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 @@ -3871,14 +4460,13 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - my_updated_thread = client.beta.threads.update( - "thread_abc123", - metadata={ - "modified": "true", - "user": "abc123" - } + 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_updated_thread) + print(my_assistant) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -3889,47 +4477,57 @@ paths: }); async function main() { - const updatedThread = await client.beta.threads.update( - "thread_abc123", - { - metadata: { modified: "true", user: "abc123" }, - } - ); + const myAssistant = await 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", + }); - console.log(updatedThread); + console.log(myAssistant); } main(); - response: | + response: &create_assistants_example | { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699014083, - "metadata": { - "modified": "true", - "user": "abc123" - }, - "tool_resources": {} + "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" } - delete: - operationId: deleteThread + /assistants/{assistant_id}: + get: + operationId: getAssistant tags: - Assistants - summary: Delete a thread. + summary: Retrieves an assistant. parameters: - in: path - name: thread_id + name: assistant_id required: true schema: type: string - description: The ID of the thread to delete. + description: The ID of the assistant to retrieve. responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/DeleteThreadResponse" + $ref: "#/components/schemas/AssistantObject" security: - Portkey-Key: [] @@ -3947,12 +4545,11 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_abc123 \ + 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 + -H "OpenAI-Beta: assistants=v2" - lang: python source: | from portkey_ai import Portkey @@ -3962,8 +4559,8 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - response = client.beta.threads.delete("thread_abc123") - print(response) + my_assistant = client.beta.assistants.retrieve("asst_abc123") + print(my_assistant) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -3974,68 +4571,58 @@ paths: }); async function main() { - const response = await client.beta.threads.del("thread_abc123"); + const myAssistant = await client.beta.assistants.retrieve( + "asst_abc123" + ); - console.log(response); + console.log(myAssistant); } + main(); response: | { - "id": "thread_abc123", - "object": "thread.deleted", - "deleted": true + "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" } - - /threads/{thread_id}/messages: - get: - operationId: listMessages + post: + operationId: modifyAssistant tags: - Assistants - summary: Returns a list of messages for a given thread. + summary: Modifies an assistant. parameters: - in: path - name: thread_id + name: assistant_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 + 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/ListMessagesResponse" + $ref: "#/components/schemas/AssistantObject" security: - Portkey-Key: [] @@ -4053,11 +4640,16 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_abc123/messages \ + 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" + -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 @@ -4067,8 +4659,15 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - thread_messages = client.beta.threads.messages.list("thread_abc123") - print(thread_messages.data) + 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'; @@ -4079,88 +4678,138 @@ paths: }); async function main() { - const threadMessages = await client.beta.threads.messages.list( - "thread_abc123" + 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(threadMessages.data); + console.log(myUpdatedAssistant); } 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": "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": [ { - "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": {} + "type": "file_search" } ], - "first_id": "msg_abc123", - "last_id": "msg_abc456", - "has_more": false + "tool_resources": { + "file_search": { + "vector_store_ids": [] + } + }, + "metadata": {}, + "top_p": 1.0, + "temperature": 1.0, + "response_format": "auto" } - post: - operationId: createMessage + delete: + operationId: deleteAssistant tags: - Assistants - summary: Create a message. + summary: Delete an assistant. parameters: - in: path - name: thread_id + name: assistant_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. + 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 + } + + /threads: + post: + operationId: createThread + tags: + - Assistants + summary: Create a thread. requestBody: - required: true content: application/json: schema: - $ref: "#/components/schemas/CreateMessageRequest" + $ref: "#/components/schemas/CreateThreadRequest" responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/MessageObject" + $ref: "#/components/schemas/ThreadObject" security: - Portkey-Key: [] @@ -4178,14 +4827,19 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_abc123/messages \ + 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 '{ - "role": "user", - "content": "How does AI work? Explain it in simple terms." + "messages": [{ + "role": "user", + "content": "Hello, what is AI?" + }, { + "role": "user", + "content": "How does AI work? Explain it in simple terms." + }] }' - lang: python source: | @@ -4196,12 +4850,20 @@ paths: 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.", + 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(thread_message) + + print(message_thread) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -4212,63 +4874,52 @@ paths: }); 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." } - ); + 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(threadMessages); + console.log(messageThread); } 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": {} + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, + "metadata": {}, + "tool_resources": {} } - /threads/{thread_id}/messages/{message_id}: + /threads/{thread_id}: get: - operationId: getMessage + operationId: getThread tags: - Assistants - summary: Retrieve a message. + summary: Retrieves a 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) to which this message belongs. - - in: path - name: message_id - required: true - schema: - type: string - description: The ID of the message to retrieve. + description: The ID of the thread to retrieve. responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/MessageObject" + $ref: "#/components/schemas/ThreadObject" security: - Portkey-Key: [] @@ -4286,7 +4937,7 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_abc123/messages/msg_abc123 \ + 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" \ @@ -4300,11 +4951,8 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - message = client.beta.threads.messages.retrieve( - message_id="msg_abc123", - thread_id="thread_abc123", - ) - print(message) + my_thread = client.beta.threads.retrieve("thread_abc123") + print(my_thread) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -4315,67 +4963,51 @@ paths: }); async function main() { - const message = await client.beta.threads.messages.retrieve( - "thread_abc123", - "msg_abc123" + const myThread = await client.beta.threads.retrieve( + "thread_abc123" ); - console.log(message); + console.log(myThread); } 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": [] - } + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, + "metadata": {}, + "tool_resources": { + "code_interpreter": { + "file_ids": [] } - ], - "attachments": [], - "metadata": {} + } } post: - operationId: modifyMessage + operationId: modifyThread tags: - Assistants - summary: Modifies a message. + summary: Modifies a thread. 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. + description: The ID of the thread to modify. Only the `metadata` can be modified. requestBody: required: true content: application/json: schema: - $ref: "#/components/schemas/ModifyMessageRequest" + $ref: "#/components/schemas/ModifyThreadRequest" responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/MessageObject" + $ref: "#/components/schemas/ThreadObject" security: - Portkey-Key: [] @@ -4393,7 +5025,7 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_abc123/messages/msg_abc123 \ + 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" \ @@ -4413,15 +5045,14 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - message = client.beta.threads.messages.update( - message_id="msg_abc12", - thread_id="thread_abc123", + my_updated_thread = client.beta.threads.update( + "thread_abc123", metadata={ "modified": "true", - "user": "abc123", - }, + "user": "abc123" + } ) - print(message) + print(my_updated_thread) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -4432,65 +5063,47 @@ paths: }); async function main() { - const message = await client.beta.threads.messages.update( + const updatedThread = await client.beta.threads.update( "thread_abc123", - "msg_abc123", { - metadata: { - modified: "true", - user: "abc123", - }, + metadata: { modified: "true", user: "abc123" }, } - }' + ); + + console.log(updatedThread); + } + + 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": [] - } - } - ], - "file_ids": [], + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, "metadata": { "modified": "true", "user": "abc123" - } + }, + "tool_resources": {} } delete: - operationId: deleteMessage + operationId: deleteThread tags: - Assistants - summary: Deletes a message. + summary: Delete a thread. 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. + description: The ID of the thread to delete. responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/DeleteMessageResponse" + $ref: "#/components/schemas/DeleteThreadResponse" security: - Portkey-Key: [] @@ -4508,11 +5121,12 @@ paths: x-code-samples: - lang: curl source: | - curl -X DELETE https://api.portkey.ai/v1/threads/thread_abc123/messages/msg_abc123 \ + 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" + -H "OpenAI-Beta: assistants=v2" \ + -X DELETE - lang: python source: | from portkey_ai import Portkey @@ -4522,103 +5136,8 @@ paths: 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: - 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) + response = client.beta.threads.delete("thread_abc123") + print(response) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -4629,67 +5148,31 @@ paths: }); 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." }, - ], - }, - }); + const response = await client.beta.threads.del("thread_abc123"); - console.log(run); + console.log(response); } - 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 + "id": "thread_abc123", + "object": "thread.deleted", + "deleted": true } - /threads/{thread_id}/runs: + /threads/{thread_id}/messages: get: - operationId: listRuns + operationId: listMessages tags: - Assistants - summary: Returns a list of runs belonging to a thread. + summary: Returns a list of messages for a given thread. parameters: - - name: thread_id - in: path + - in: path + name: thread_id required: true schema: type: string - description: The ID of the thread the run belongs to. + 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 @@ -4714,13 +5197,19 @@ paths: 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/ListRunsResponse" + $ref: "#/components/schemas/ListMessagesResponse" security: - Portkey-Key: [] @@ -4738,10 +5227,10 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_abc123/runs \ + 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 "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" - lang: python source: | @@ -4752,11 +5241,8 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - runs = client.beta.threads.runs.list( - "thread_abc123" - ) - - print(runs) + thread_messages = client.beta.threads.messages.list("thread_abc123") + print(thread_messages.data) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -4767,11 +5253,11 @@ paths: }); async function main() { - const runs = await client.beta.threads.runs.list( + const threadMessages = await client.beta.threads.messages.list( "thread_abc123" ); - console.log(runs); + console.log(threadMessages.data); } main(); @@ -4780,122 +5266,75 @@ paths: "object": "list", "data": [ { - "id": "run_abc123", - "object": "thread.run", - "created_at": 1699075072, - "assistant_id": "asst_abc123", + "id": "msg_abc123", + "object": "thread.message", + "created_at": 1699016383, + "assistant_id": null, "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": [ + "run_id": null, + "role": "user", + "content": [ { - "type": "code_interpreter" + "type": "text", + "text": { + "value": "How does AI work? Explain it in simple terms.", + "annotations": [] + } } ], - "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 + "attachments": [], + "metadata": {} }, { - "id": "run_abc456", - "object": "thread.run", - "created_at": 1699063290, - "assistant_id": "asst_abc123", + "id": "msg_abc456", + "object": "thread.message", + "created_at": 1699016383, + "assistant_id": null, "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": [ + "run_id": null, + "role": "user", + "content": [ { - "type": "code_interpreter" + "type": "text", + "text": { + "value": "Hello, what is AI?", + "annotations": [] + } } ], - "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 + "attachments": [], + "metadata": {} } ], - "first_id": "run_abc123", - "last_id": "run_abc456", + "first_id": "msg_abc123", + "last_id": "msg_abc456", "has_more": false } post: - operationId: createRun + operationId: createMessage tags: - Assistants - summary: Create a run. + summary: Create a message. parameters: - in: path name: thread_id required: true schema: type: string - description: The ID of the thread to run. + 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/CreateRunRequest" + $ref: "#/components/schemas/CreateMessageRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/MessageObject" security: - Portkey-Key: [] @@ -4910,24 +5349,18 @@ paths: 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 \ + 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 "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" \ -d '{ - "assistant_id": "asst_abc123" - }' + "role": "user", + "content": "How does AI work? Explain it in simple terms." + }' - lang: python source: | from portkey_ai import Portkey @@ -4937,12 +5370,12 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - run = client.beta.threads.runs.create( - thread_id="thread_abc123", - assistant_id="asst_abc123" + thread_message = client.beta.threads.messages.create( + "thread_abc123", + role="user", + content="How does AI work? Explain it in simple terms.", ) - - print(run) + print(thread_message) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -4953,78 +5386,63 @@ paths: }); async function main() { - const run = await client.beta.threads.runs.create( + const threadMessages = await client.beta.threads.messages.create( "thread_abc123", - { assistant_id: "asst_abc123" } + { role: "user", content: "How does AI work? Explain it in simple terms." } ); - console.log(run); + console.log(threadMessages); } main(); - response: &run_object_example | + response: | { - "id": "run_abc123", - "object": "thread.run", - "created_at": 1699063290, - "assistant_id": "asst_abc123", + "id": "msg_abc123", + "object": "thread.message", + "created_at": 1713226573, + "assistant_id": null, "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": [ + "run_id": null, + "role": "user", + "content": [ { - "type": "code_interpreter" + "type": "text", + "text": { + "value": "How does AI work? Explain it in simple terms.", + "annotations": [] + } } ], - "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 + "attachments": [], + "metadata": {} } - /threads/{thread_id}/runs/{run_id}: + /threads/{thread_id}/messages/{message_id}: get: - operationId: getRun + operationId: getMessage tags: - Assistants - summary: Retrieves a run. + 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) that was run. + description: The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) to which this message belongs. - in: path - name: run_id + name: message_id required: true schema: type: string - description: The ID of the run to retrieve. + description: The ID of the message to retrieve. responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/RunObject" + $ref: "#/components/schemas/MessageObject" security: - Portkey-Key: [] @@ -5042,7 +5460,8 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_abc123/runs/run_abc123 \ + 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" @@ -5055,12 +5474,11 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - run = client.beta.threads.runs.retrieve( + message = client.beta.threads.messages.retrieve( + message_id="msg_abc123", thread_id="thread_abc123", - run_id="run_abc123" ) - - print(run) + print(message) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -5071,86 +5489,67 @@ paths: }); async function main() { - const run = await client.beta.threads.runs.retrieve( + const message = await client.beta.threads.messages.retrieve( "thread_abc123", - "run_abc123" + "msg_abc123" ); - console.log(run); + console.log(message); } main(); response: | { - "id": "run_abc123", - "object": "thread.run", - "created_at": 1699075072, - "assistant_id": "asst_abc123", + "id": "msg_abc123", + "object": "thread.message", + "created_at": 1699017614, + "assistant_id": null, "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": [ + "run_id": null, + "role": "user", + "content": [ { - "type": "code_interpreter" + "type": "text", + "text": { + "value": "How does AI work? Explain it in simple terms.", + "annotations": [] + } } ], - "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 + "attachments": [], + "metadata": {} } post: - operationId: modifyRun + operationId: modifyMessage tags: - Assistants - summary: Modifies a run. + summary: Modifies 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) that was run. + description: The ID of the thread to which this message belongs. - in: path - name: run_id + name: message_id required: true schema: type: string - description: The ID of the run to modify. + description: The ID of the message to modify. requestBody: required: true content: application/json: schema: - $ref: "#/components/schemas/ModifyRunRequest" + $ref: "#/components/schemas/ModifyMessageRequest" responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/RunObject" + $ref: "#/components/schemas/MessageObject" security: - Portkey-Key: [] @@ -5168,16 +5567,17 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_abc123/runs/run_abc123 \ + 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 "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" \ -d '{ - "metadata": { - "user_id": "user_abc123" - } - }' + "metadata": { + "modified": "true", + "user": "abc123" + } + }' - lang: python source: | from portkey_ai import Portkey @@ -5187,13 +5587,15 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - run = client.beta.threads.runs.update( + message = client.beta.threads.messages.update( + message_id="msg_abc12", thread_id="thread_abc123", - run_id="run_abc123", - metadata={"user_id": "user_abc123"}, + metadata={ + "modified": "true", + "user": "abc123", + }, ) - - print(run) + print(message) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -5204,97 +5606,137 @@ paths: }); async function main() { - const run = await client.beta.threads.runs.update( + const message = await client.beta.threads.messages.update( "thread_abc123", - "run_abc123", + "msg_abc123", { metadata: { - user_id: "user_abc123", + modified: "true", + user: "abc123", }, } - ); - - console.log(run); - } - - main(); + }' response: | { - "id": "run_abc123", - "object": "thread.run", - "created_at": 1699075072, - "assistant_id": "asst_abc123", + "id": "msg_abc123", + "object": "thread.message", + "created_at": 1699017614, + "assistant_id": null, "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": [ + "run_id": null, + "role": "user", + "content": [ { - "type": "code_interpreter" + "type": "text", + "text": { + "value": "How does AI work? Explain it in simple terms.", + "annotations": [] + } } ], - "tool_resources": { - "code_interpreter": { - "file_ids": [ - "file-abc123", - "file-abc456" - ] - } - }, + "file_ids": [], "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 + "modified": "true", + "user": "abc123" + } } - - /threads/{thread_id}/runs/{run_id}/submit_tool_outputs: - post: - operationId: submitToolOuputsToRun + delete: + operationId: deleteMessage 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. + summary: Deletes 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 run belongs. + description: The ID of the thread to which this message belongs. - in: path - name: run_id + name: message_id required: true schema: type: string - description: The ID of the run that requires the tool output submission. + 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: + 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/SubmitToolOutputsRunRequest" + $ref: "#/components/schemas/CreateThreadAndRunRequest" responses: "200": description: OK @@ -5319,19 +5761,19 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_123/runs/run_123/submit_tool_outputs \ + 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 '{ - "tool_outputs": [ - { - "tool_call_id": "call_001", - "output": "70 degrees and sunny." + "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 @@ -5341,15 +5783,13 @@ paths: 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." - } - ] + 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) @@ -5363,18 +5803,14 @@ paths: }); 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.", - }, + 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); } @@ -5382,194 +5818,52 @@ paths: main(); response: | { - "id": "run_123", + "id": "run_abc123", "object": "thread.run", - "created_at": 1699075592, - "assistant_id": "asst_123", - "thread_id": "thread_123", + "created_at": 1699076792, + "assistant_id": "asst_abc123", + "thread_id": "thread_abc123", "status": "queued", - "started_at": 1699075592, - "expires_at": 1699076192, + "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": 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"] - } - } - } - ], + "instructions": "You are a helpful assistant.", + "tools": [], + "tool_resources": {}, "metadata": {}, - "usage": null, "temperature": 1.0, "top_p": 1.0, - "max_prompt_tokens": 1000, - "max_completion_tokens": 1000, + "max_completion_tokens": null, + "max_prompt_tokens": null, "truncation_strategy": { "type": "auto", "last_messages": null }, - "response_format": "auto", - "tool_choice": "auto", - "parallel_tool_calls": true - } - - /threads/{thread_id}/runs/{run_id}/cancel: - post: - operationId: cancelRun - tags: - - Assistants - summary: Cancels a run that is `in_progress`. - parameters: - - in: path - name: thread_id - required: true - schema: - type: string - description: The ID of the thread to which this run belongs. - - in: path - name: run_id - required: true - schema: - type: string - description: The ID of the run to cancel. - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/RunObject" - - 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": {}, + "incomplete_details": null, "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: + /threads/{thread_id}/runs: get: - operationId: listRunSteps + operationId: listRuns tags: - Assistants - summary: Returns a list of run steps belonging to a run. + 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 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. + description: The ID of the thread the run belongs to. - name: limit in: query description: *pagination_limit_param_description @@ -5600,7 +5894,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/ListRunStepsResponse" + $ref: "#/components/schemas/ListRunsResponse" security: - Portkey-Key: [] @@ -5618,7 +5912,7 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_abc123/runs/run_abc123/steps \ + 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" \ @@ -5632,12 +5926,11 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - run_steps = client.beta.threads.runs.steps.list( - thread_id="thread_abc123", - run_id="run_abc123" + runs = client.beta.threads.runs.list( + "thread_abc123" ) - print(run_steps) + print(runs) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -5648,11 +5941,11 @@ paths: }); async function main() { - const runStep = await client.beta.threads.runs.steps.list( - "thread_abc123", - "run_abc123" + const runs = await client.beta.threads.runs.list( + "thread_abc123" ); - console.log(runStep); + + console.log(runs); } main(); @@ -5661,73 +5954,126 @@ paths: "object": "list", "data": [ { - "id": "step_abc123", - "object": "thread.run.step", - "created_at": 1699063291, - "run_id": "run_abc123", + "id": "run_abc123", + "object": "thread.run", + "created_at": 1699075072, "assistant_id": "asst_abc123", "thread_id": "thread_abc123", - "type": "message_creation", "status": "completed", + "started_at": 1699075072, + "expires_at": null, "cancelled_at": null, - "completed_at": 1699063291, - "expired_at": null, "failed_at": null, + "completed_at": 1699075073, "last_error": null, - "step_details": { - "type": "message_creation", - "message_creation": { - "message_id": "msg_abc123" + "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 - } - } - ], - "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" - - security: - - Portkey-Key: [] - Virtual-Key: [] + }, + "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: [] @@ -5738,14 +6084,24 @@ paths: 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/run_abc123/steps/step_abc123 \ + 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" + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "assistant_id": "asst_abc123" + }' - lang: python source: | from portkey_ai import Portkey @@ -5755,13 +6111,12 @@ paths: 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" + run = client.beta.threads.runs.create( + thread_id="thread_abc123", + assistant_id="asst_abc123" ) - print(run_step) + print(run) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -5772,81 +6127,78 @@ paths: }); async function main() { - const runStep = await client.beta.threads.runs.steps.retrieve( + const run = await client.beta.threads.runs.create( "thread_abc123", - "run_abc123", - "step_abc123" + { assistant_id: "asst_abc123" } ); - console.log(runStep); + + console.log(run); } main(); - response: &run_step_object_example | + response: &run_object_example | { - "id": "step_abc123", - "object": "thread.run.step", - "created_at": 1699063291, - "run_id": "run_abc123", + "id": "run_abc123", + "object": "thread.run", + "created_at": 1699063290, "assistant_id": "asst_abc123", "thread_id": "thread_abc123", - "type": "message_creation", - "status": "completed", + "status": "queued", + "started_at": 1699063290, + "expires_at": null, "cancelled_at": null, - "completed_at": 1699063291, - "expired_at": null, "failed_at": null, + "completed_at": 1699063291, "last_error": null, - "step_details": { - "type": "message_creation", - "message_creation": { - "message_id": "msg_abc123" + "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 }, - "usage": { - "prompt_tokens": 123, - "completion_tokens": 456, - "total_tokens": 579 - } + "response_format": "auto", + "tool_choice": "auto", + "parallel_tool_calls": true } - /vector_stores: + /threads/{thread_id}/runs/{run_id}: get: - operationId: listVectorStores + operationId: getRun tags: - - Vector Stores - summary: Returns a list of vector stores. + - Assistants + summary: Retrieves a run. 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 + - in: path + name: thread_id + required: true schema: type: string - - name: before - in: query - description: *pagination_before_param_description + 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/ListVectorStoresResponse" + $ref: "#/components/schemas/RunObject" security: - Portkey-Key: [] @@ -5864,10 +6216,9 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores \ + 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" - lang: python source: | @@ -5878,8 +6229,12 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - vector_stores = client.beta.vector_stores.list() - print(vector_stores) + run = client.beta.threads.runs.retrieve( + thread_id="thread_abc123", + run_id="run_abc123" + ) + + print(run) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -5890,66 +6245,86 @@ paths: }); async function main() { - const vectorStores = await client.beta.vectorStores.list(); - console.log(vectorStores); + const run = await client.beta.threads.runs.retrieve( + "thread_abc123", + "run_abc123" + ); + + console.log(run); } 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": "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": [ { - "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 - } + "type": "code_interpreter" } ], - "first_id": "vs_abc123", - "last_id": "vs_abc456", - "has_more": false + "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: createVectorStore + operationId: modifyRun tags: - - Vector Stores - summary: Create a vector store. + - 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/CreateVectorStoreRequest" + $ref: "#/components/schemas/ModifyRunRequest" responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/VectorStoreObject" + $ref: "#/components/schemas/RunObject" security: - Portkey-Key: [] @@ -5967,14 +6342,16 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores \ + 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" + -H "OpenAI-Beta: assistants=v2" \ -d '{ - "name": "Support FAQ" - }' + "metadata": { + "user_id": "user_abc123" + } + }' - lang: python source: | from portkey_ai import Portkey @@ -5984,10 +6361,13 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - vector_store = client.beta.vector_stores.create( - name="Support FAQ" + run = client.beta.threads.runs.update( + thread_id="thread_abc123", + run_id="run_abc123", + metadata={"user_id": "user_abc123"}, ) - print(vector_store) + + print(run) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -5998,49 +6378,104 @@ paths: }); async function main() { - const vectorStore = await client.beta.vectorStores.create({ - name: "Support FAQ" - }); - console.log(vectorStore); + const run = await client.beta.threads.runs.update( + "thread_abc123", + "run_abc123", + { + metadata: { + user_id: "user_abc123", + }, + } + ); + + console.log(run); } 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 - } + "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 } - /vector_stores/{vector_store_id}: - get: - operationId: getVectorStore + /threads/{thread_id}/runs/{run_id}/submit_tool_outputs: + post: + operationId: submitToolOuputsToRun tags: - - Vector Stores - summary: Retrieves a vector store. + - 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: vector_store_id + name: thread_id required: true schema: type: string - description: The ID of the vector store to retrieve. + 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/VectorStoreObject" + $ref: "#/components/schemas/RunObject" security: - Portkey-Key: [] @@ -6058,24 +6493,40 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores/vs_abc123 \ + 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" + -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" - ) + 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) + 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'; @@ -6086,138 +6537,103 @@ paths: }); async function main() { - const vectorStore = await client.beta.vectorStores.retrieve( - "vs_abc123" + 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(vectorStore); + + console.log(run); } 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", + "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": [ { - name: "Support FAQ" + "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"] + } + } } - ); - 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 - } + ], + "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 } - delete: - operationId: deleteVectorStore + /threads/{thread_id}/runs/{run_id}/cancel: + post: + operationId: cancelRun tags: - - Vector Stores - summary: Delete a vector store. + - Assistants + summary: Cancels a run that is `in_progress`. parameters: - in: path - name: vector_store_id + name: thread_id required: true schema: type: string - description: The ID of the vector store to delete. + 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/DeleteVectorStoreResponse" + $ref: "#/components/schemas/RunObject" security: - Portkey-Key: [] @@ -6235,12 +6651,11 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores/vs_abc123 \ + 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 "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" \ - -X DELETE + -X POST - lang: python source: | from portkey_ai import Portkey @@ -6250,10 +6665,12 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - deleted_vector_store = client.beta.vector_stores.delete( - vector_store_id="vs_abc123" + run = client.beta.threads.runs.cancel( + thread_id="thread_abc123", + run_id="run_abc123" ) - print(deleted_vector_store) + + print(run) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -6264,33 +6681,69 @@ paths: }); async function main() { - const deletedVectorStore = await client.beta.vectorStores.del( - "vs_abc123" + const run = await client.beta.threads.runs.cancel( + "thread_abc123", + "run_abc123" ); - console.log(deletedVectorStore); + + console.log(run); } main(); response: | { - "id": "vs_abc123", - "object": "vector_store.deleted", - "deleted": true + "id": "run_abc123", + "object": "thread.run", + "created_at": 1699076126, + "assistant_id": "asst_abc123", + "thread_id": "thread_abc123", + "status": "cancelling", + "started_at": 1699076126, + "expires_at": 1699076726, + "cancelled_at": null, + "failed_at": null, + "completed_at": null, + "last_error": null, + "model": "gpt-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 } - /vector_stores/{vector_store_id}/files: + /threads/{thread_id}/runs/{run_id}/steps: get: - operationId: listVectorStoreFiles + operationId: listRunSteps tags: - - Vector Stores - summary: Returns a list of vector store files. + - Assistants + summary: Returns a list of run steps belonging to a run. parameters: - - name: vector_store_id + - 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 - description: The ID of the vector store that the files belong to. 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 @@ -6315,19 +6768,13 @@ paths: 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" + $ref: "#/components/schemas/ListRunStepsResponse" security: - Portkey-Key: [] @@ -6345,7 +6792,7 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files \ + 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" \ @@ -6359,10 +6806,12 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - vector_store_files = client.beta.vector_stores.files.list( - vector_store_id="vs_abc123" + run_steps = client.beta.threads.runs.steps.list( + thread_id="thread_abc123", + run_id="run_abc123" ) - print(vector_store_files) + + print(run_steps) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -6373,10 +6822,11 @@ paths: }); async function main() { - const vectorStoreFiles = await client.beta.vectorStores.files.list( - "vs_abc123" + const runStep = await client.beta.threads.runs.steps.list( + "thread_abc123", + "run_abc123" ); - console.log(vectorStoreFiles); + console.log(runStep); } main(); @@ -6385,49 +6835,69 @@ paths: "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). + "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: vector_store_id + name: thread_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" + 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/VectorStoreFileObject" + $ref: "#/components/schemas/RunStepObject" security: - Portkey-Key: [] @@ -6445,14 +6915,11 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files \ + 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" \ - -d '{ - "file_id": "file-abc123" - }' + -H "OpenAI-Beta: assistants=v2" - lang: python source: | from portkey_ai import Portkey @@ -6462,11 +6929,13 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - vector_store_file = client.beta.vector_stores.files.create( - vector_store_id="vs_abc123", - file_id="file-abc123" + run_step = client.beta.threads.runs.steps.retrieve( + thread_id="thread_abc123", + run_id="run_abc123", + step_id="step_abc123" ) - print(vector_store_file) + + print(run_step) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -6477,55 +6946,81 @@ paths: }); async function main() { - const myVectorStoreFile = await client.beta.vectorStores.files.create( - "vs_abc123", - { - file_id: "file-abc123" - } + const runStep = await client.beta.threads.runs.steps.retrieve( + "thread_abc123", + "run_abc123", + "step_abc123" ); - console.log(myVectorStoreFile); + console.log(runStep); } main(); - response: | + response: &run_step_object_example | { - "id": "file-abc123", - "object": "vector_store.file", - "created_at": 1699061776, - "usage_bytes": 1234, - "vector_store_id": "vs_abcd", + "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", - "last_error": null + "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/{vector_store_id}/files/{file_id}: + /vector_stores: get: - operationId: getVectorStoreFile + operationId: listVectorStores tags: - Vector Stores - summary: Retrieves a vector store file. + summary: Returns a list of vector stores. parameters: - - in: path - name: vector_store_id - required: true + - 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 - example: vs_abc123 - description: The ID of the vector store that the file belongs to. - - in: path - name: file_id - required: true + 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 - example: file-abc123 - description: The ID of the file being retrieved. responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/VectorStoreFileObject" + $ref: "#/components/schemas/ListVectorStoresResponse" security: - Portkey-Key: [] @@ -6543,7 +7038,7 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files/file-abc123 \ + 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" \ @@ -6557,11 +7052,8 @@ paths: 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) + vector_stores = client.beta.vector_stores.list() + print(vector_stores) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -6572,48 +7064,66 @@ paths: }); async function main() { - const vectorStoreFile = await client.beta.vectorStores.files.retrieve( - "vs_abc123", - "file-abc123" - ); - console.log(vectorStoreFile); + const vectorStores = await client.beta.vectorStores.list(); + console.log(vectorStores); } main(); response: | { - "id": "file-abc123", - "object": "vector_store.file", - "created_at": 1699061776, - "vector_store_id": "vs_abcd", - "status": "completed", - "last_error": null + "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 } - delete: - operationId: deleteVectorStoreFile + post: + operationId: createVectorStore 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. + 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/DeleteVectorStoreFileResponse" + $ref: "#/components/schemas/VectorStoreObject" security: - Portkey-Key: [] @@ -6631,12 +7141,14 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files/file-abc123 \ + 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" \ - -X DELETE + -H "OpenAI-Beta: assistants=v2" + -d '{ + "name": "Support FAQ" + }' - lang: python source: | from portkey_ai import Portkey @@ -6646,11 +7158,10 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - deleted_vector_store_file = client.beta.vector_stores.files.delete( - vector_store_id="vs_abc123", - file_id="file-abc123" + vector_store = client.beta.vector_stores.create( + name="Support FAQ" ) - print(deleted_vector_store_file) + print(vector_store) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -6661,49 +7172,49 @@ paths: }); async function main() { - const deletedVectorStoreFile = await client.beta.vectorStores.files.del( - "vs_abc123", - "file-abc123" - ); - console.log(deletedVectorStoreFile); + const vectorStore = await client.beta.vectorStores.create({ + name: "Support FAQ" + }); + console.log(vectorStore); } main(); response: | { - "id": "file-abc123", - "object": "vector_store.file.deleted", - "deleted": true + "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}/file_batches: - post: - operationId: createVectorStoreFileBatch + /vector_stores/{vector_store_id}: + get: + operationId: getVectorStore tags: - Vector Stores - summary: Create a vector store file batch. + summary: Retrieves a vector store. 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" + description: The ID of the vector store to retrieve. responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/VectorStoreFileBatchObject" + $ref: "#/components/schemas/VectorStoreObject" security: - Portkey-Key: [] @@ -6721,14 +7232,11 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores/vs_abc123/file_batches \ + 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 '{ - "file_ids": ["file-abc123", "file-abc456"] - }' + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" - lang: python source: | from portkey_ai import Portkey @@ -6738,11 +7246,10 @@ paths: 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"] + vector_store = client.beta.vector_stores.retrieve( + vector_store_id="vs_abc123" ) - print(vector_store_file_batch) + print(vector_store) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -6753,60 +7260,44 @@ paths: }); async function main() { - const myVectorStoreFileBatch = await client.beta.vectorStores.fileBatches.create( - "vs_abc123", - { - file_ids: ["file-abc123", "file-abc456"] - } + const vectorStore = await client.beta.vectorStores.retrieve( + "vs_abc123" ); - console.log(myVectorStoreFileBatch); + console.log(vectorStore); } 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, - } + "id": "vs_abc123", + "object": "vector_store", + "created_at": 1699061776 } - - /vector_stores/{vector_store_id}/file_batches/{batch_id}: - get: - operationId: getVectorStoreFileBatch + post: + operationId: modifyVectorStore tags: - Vector Stores - summary: Retrieves a vector store file batch. + summary: Modifies a vector store. 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. + 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/VectorStoreFileBatchObject" + $ref: "#/components/schemas/VectorStoreObject" security: - Portkey-Key: [] @@ -6824,11 +7315,14 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123 \ + 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 @@ -6838,11 +7332,11 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - vector_store_file_batch = client.beta.vector_stores.file_batches.retrieve( + vector_store = client.beta.vector_stores.update( vector_store_id="vs_abc123", - batch_id="vsfb_abc123" + name="Support FAQ" ) - print(vector_store_file_batch) + print(vector_store) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -6853,56 +7347,51 @@ paths: }); async function main() { - const vectorStoreFileBatch = await client.beta.vectorStores.fileBatches.retrieve( + const vectorStore = await client.beta.vectorStores.update( "vs_abc123", - "vsfb_abc123" + { + name: "Support FAQ" + } ); - console.log(vectorStoreFileBatch); + console.log(vectorStore); } main(); response: | { - "id": "vsfb_abc123", - "object": "vector_store.file_batch", + "id": "vs_abc123", + "object": "vector_store", "created_at": 1699061776, - "vector_store_id": "vs_abc123", - "status": "in_progress", + "name": "Support FAQ", + "bytes": 139920, "file_counts": { - "in_progress": 1, - "completed": 1, + "in_progress": 0, + "completed": 3, "failed": 0, "cancelled": 0, - "total": 0, + "total": 3 } } - /vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel: - post: - operationId: cancelVectorStoreFileBatch + delete: + operationId: deleteVectorStore 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. + summary: Delete a vector store. 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. + description: The ID of the vector store to delete. responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/VectorStoreFileBatchObject" + $ref: "#/components/schemas/DeleteVectorStoreResponse" security: - Portkey-Key: [] @@ -6920,12 +7409,12 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/cancel \ + 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 POST + -X DELETE - lang: python source: | from portkey_ai import Portkey @@ -6935,11 +7424,10 @@ paths: 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" + deleted_vector_store = client.beta.vector_stores.delete( + vector_store_id="vs_abc123" ) - print(deleted_vector_store_file_batch) + print(deleted_vector_store) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -6950,36 +7438,26 @@ paths: }); async function main() { - const deletedVectorStoreFileBatch = await client.vector_stores.fileBatches.cancel( - "vs_abc123", - "vsfb_abc123" + const deletedVectorStore = await client.beta.vectorStores.del( + "vs_abc123" ); - console.log(deletedVectorStoreFileBatch); + console.log(deletedVectorStore); } 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, - } + "id": "vs_abc123", + "object": "vector_store.deleted", + "deleted": true } - /vector_stores/{vector_store_id}/file_batches/{batch_id}/files: + /vector_stores/{vector_store_id}/files: get: - operationId: listFilesInVectorStoreBatch + operationId: listVectorStoreFiles tags: - Vector Stores - summary: Returns a list of vector store files in a batch. + summary: Returns a list of vector store files. parameters: - name: vector_store_id in: path @@ -6987,12 +7465,6 @@ paths: 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 @@ -7047,7 +7519,7 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/files \ + 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" \ @@ -7061,9 +7533,8 @@ paths: 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" + vector_store_files = client.beta.vector_stores.files.list( + vector_store_id="vs_abc123" ) print(vector_store_files) - lang: javascript @@ -7076,9 +7547,8 @@ paths: }); async function main() { - const vectorStoreFiles = await client.beta.vectorStores.fileBatches.listFiles( - "vs_abc123", - "vsfb_abc123" + const vectorStoreFiles = await client.beta.vectorStores.files.list( + "vs_abc123" ); console.log(vectorStoreFiles); } @@ -7105,33 +7575,33 @@ paths: "last_id": "file-abc456", "has_more": false } - - /batches: post: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 - summary: Creates and executes a batch from an uploaded file of requests - operationId: createBatch + operationId: createVectorStoreFile tags: - - Batch + - 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: - anyOf: - - $ref: "#/components/schemas/OpenAIBatchJob" - - $ref: "#/components/schemas/BedrockBatchJob" - - $ref: "#/components/schemas/VertexBatchJob" - - $ref: "#/components/schemas/PortkeyBatchJob" + $ref: "#/components/schemas/CreateVectorStoreFileRequest" responses: "200": - description: Batch created successfully. + description: OK content: application/json: schema: - $ref: "#/components/schemas/Batch" + $ref: "#/components/schemas/VectorStoreFileObject" security: - Portkey-Key: [] @@ -7148,19 +7618,16 @@ paths: x-code-samples: - lang: curl - label: Default source: | - curl https://api.portkey.ai/v1/batches \ + 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 '{ - "input_file_id": "file-abc123", - "endpoint": "/v1/chat/completions", - "completion_window": "24h" + "file_id": "file-abc123" }' - lang: python - label: Default source: | from portkey_ai import Portkey @@ -7169,13 +7636,12 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - client.batches.create( - input_file_id="file-abc123", - endpoint="/v1/chat/completions", - completion_window="24h" + vector_store_file = client.beta.vector_stores.files.create( + vector_store_id="vs_abc123", + file_id="file-abc123" ) + print(vector_store_file) - lang: javascript - label: Default source: | import Portkey from 'portkey-ai'; @@ -7185,96 +7651,55 @@ paths: }); async function main() { - const batch = await client.batches.create({ - input_file_id: "file-abc123", - endpoint: "/v1/chat/completions", - completion_window: "24h" - }); - - console.log(batch); + const myVectorStoreFile = await client.beta.vectorStores.files.create( + "vs_abc123", + { + file_id: "file-abc123" + } + ); + console.log(myVectorStoreFile); } main(); - - lang: curl - label: Self-Hosted - source: | - curl SELF_HOSTED_GATEWAY_URL/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: 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); + response: | + { + "id": "file-abc123", + "object": "vector_store.file", + "created_at": 1699061776, + "usage_bytes": 1234, + "vector_store_id": "vs_abcd", + "status": "completed", + "last_error": null } - main(); - + /vector_stores/{vector_store_id}/files/{file_id}: get: - operationId: listBatches - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL + operationId: getVectorStoreFile tags: - - Batch - summary: List your organization's batches. + - Vector Stores + summary: Retrieves a vector store file. parameters: - - in: query - name: after - required: false + - in: path + name: vector_store_id + required: true schema: type: string - description: *pagination_after_param_description - - name: limit - in: query - description: *pagination_limit_param_description - required: false + example: vs_abc123 + description: The ID of the vector store that the file belongs to. + - in: path + name: file_id + required: true schema: - type: integer - default: 20 + type: string + example: file-abc123 + description: The ID of the file being retrieved. responses: "200": - description: Batch listed successfully. + description: OK content: application/json: schema: - $ref: "#/components/schemas/ListBatchesResponse" + $ref: "#/components/schemas/VectorStoreFileObject" security: - Portkey-Key: [] @@ -7291,14 +7716,13 @@ paths: x-code-samples: - lang: curl - label: Default source: | - curl https://api.portkey.ai/v1/batches?limit=2 \ + 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 "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" - lang: python - label: Default source: | from portkey_ai import Portkey @@ -7307,89 +7731,63 @@ paths: 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/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: 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" + vector_store_file = client.beta.vector_stores.files.retrieve( + vector_store_id="vs_abc123", + file_id="file-abc123" ) - - client.batches.list() + print(vector_store_file) - 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); - } + const vectorStoreFile = await client.beta.vectorStores.files.retrieve( + "vs_abc123", + "file-abc123" + ); + console.log(vectorStoreFile); } main(); - - /batches/{batch_id}: - get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 - operationId: retrieveBatch + 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: - - Batch - summary: Retrieves a batch. + - 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: batch_id + name: vector_store_id required: true schema: type: string - description: The ID of the batch to retrieve. + 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: Batch retrieved successfully. + description: OK content: application/json: schema: - $ref: "#/components/schemas/Batch" + $ref: "#/components/schemas/DeleteVectorStoreFileResponse" security: - Portkey-Key: [] @@ -7406,14 +7804,14 @@ paths: x-code-samples: - lang: curl - label: Default source: | - curl https://api.portkey.ai/v1/batches/batch_abc123 \ + 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 - label: Default source: | from portkey_ai import Portkey @@ -7422,9 +7820,12 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - client.batches.retrieve("batch_abc123") + 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 - label: Default source: | import Portkey from 'portkey-ai'; @@ -7434,73 +7835,152 @@ paths: }); async function main() { - const batch = await client.batches.retrieve("batch_abc123"); - - console.log(batch); + const deletedVectorStoreFile = await client.beta.vectorStores.files.del( + "vs_abc123", + "file-abc123" + ); + console.log(deletedVectorStoreFile); } main(); - - lang: curl - label: Self-Hosted - source: | - curl SELF_HOSTED_GATEWAY_URL/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: Self-Hosted - source: | - from portkey_ai import Portkey + response: | + { + "id": "file-abc123", + "object": "vector_store.file.deleted", + "deleted": true + } - client = Portkey( + /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", - base_url = "SELF_HOSTED_GATEWAY_URL", virtual_key = "PROVIDER_VIRTUAL_KEY" ) - client.batches.retrieve("batch_abc123") + 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 - 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); + 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, + } + } - /batches/{batch_id}/cancel: - post: - operationId: cancelBatch - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL + /vector_stores/{vector_store_id}/file_batches/{batch_id}: + get: + operationId: getVectorStoreFileBatch 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. + - 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 - description: The ID of the batch to cancel. + example: vsfb_abc123 + description: The ID of the file batch being retrieved. responses: "200": - description: Batch is cancelling. Returns the cancelling batch's details. + description: OK content: application/json: schema: - $ref: "#/components/schemas/Batch" + $ref: "#/components/schemas/VectorStoreFileBatchObject" security: - Portkey-Key: [] @@ -7517,15 +7997,13 @@ paths: x-code-samples: - lang: curl - label: Default source: | - curl https://api.portkey.ai/v1/batches/batch_abc123/cancel \ + 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" \ - -X POST + -H "OpenAI-Beta: assistants=v2" - lang: python - label: Default source: | from portkey_ai import Portkey @@ -7534,9 +8012,12 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - client.batches.cancel("batch_abc123") + 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 - label: Default source: | import Portkey from 'portkey-ai'; @@ -7546,908 +8027,756 @@ paths: }); async function main() { - const batch = await client.batches.cancel("batch_abc123"); - - console.log(batch); + 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 - label: Self-Hosted source: | - curl SELF_HOSTED_GATEWAY_URL/v1/batches/batch_abc123/cancel \ + 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 - 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") + 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 - 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); + 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, + } + } - /configs: + /vector_stores/{vector_store_id}/file_batches/{batch_id}/files: get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - summary: List all configs + operationId: listFilesInVectorStoreBatch tags: - - Configs - operationId: listConfigs - responses: - "200": - description: A list of configs - content: - application/json: - schema: - type: object - properties: - success: - type: boolean - data: - type: array - items: - 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", - ) + - 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" - # Retrieve the configuration - config = portkey.configs.list( - workspace_id="WORKSPACE_ID" - ) + security: + - Portkey-Key: [] + Virtual-Key: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + - Portkey-Key: [] + Config: [] + - Portkey-Key: [] + Provider-Auth: [] + Provider-Name: [] + Custom-Host: [] - print(config) - - lang: javascript - label: Default + x-code-samples: + - lang: curl 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); + 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 - 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" + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" ) - # Retrieve the configuration - config = portkey.configs.list( - workspace_id="WORKSPACE_ID" + vector_store_files = client.beta.vector_stores.file_batches.list_files( + vector_store_id="vs_abc123", + batch_id="vsfb_abc123" ) - - print(config) + print(vector_store_files) - lang: javascript - label: Self-Hosted source: | - import { Portkey } from "portkey-ai"; + import Portkey from 'portkey-ai'; - const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", - baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" - }) + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - const config=await portkey.configs.list({ - workspace_id:"WORKSPACE_ID" - }) - console.log(config); + 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: post: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - summary: Create a config + - url: SELF_HOSTED_GATEWAY_URL/v1 + summary: Creates and executes a batch from an uploaded file of requests + operationId: createBatch tags: - - Configs - operationId: createConfig + - Batch 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, - } + anyOf: + - $ref: "#/components/schemas/OpenAIBatchJob" + - $ref: "#/components/schemas/BedrockBatchJob" + - $ref: "#/components/schemas/VertexBatchJob" + - $ref: "#/components/schemas/PortkeyBatchJob" responses: "200": - description: Config created successfully + description: Batch 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", - }, - } + $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 - portkey = Portkey( - api_key="PORTKEY_API_KEY", + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" ) - # Create a new configuration - config = portkey.configs.create( - name="ConfigName_0909", - config={ - "retry": { - "attempts": 3 - }, - "cache": { - "mode": "simple" - } - }, - workspace_id="WORKSPACE_ID", + client.batches.create( + input_file_id="file-abc123", + endpoint="/v1/chat/completions", + completion_window="24h" ) - - print(config) - lang: javascript label: Default source: | - import { Portkey } from "portkey-ai"; + import Portkey from 'portkey-ai'; - const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", - }) + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - const config=await portkey.configs.create({ - name:"ConfigName_0909", - config:{ - "retry": { - "attempts": 3 - }, - "cache": { - "mode": "simple" - } - }, - workspace_id:"WORKSPACE_ID" - }) + async function main() { + const batch = await client.batches.create({ + input_file_id: "file-abc123", + endpoint: "/v1/chat/completions", + completion_window: "24h" + }); - console.log(config); + console.log(batch); + } + + main(); + - lang: curl + label: Self-Hosted + source: | + curl SELF_HOSTED_GATEWAY_URL/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: 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" + client = Portkey( + api_key = "PORTKEY_API_KEY", + base_url = "SELF_HOSTED_GATEWAY_URL", + virtual_key = "PROVIDER_VIRTUAL_KEY" ) - # Create a new configuration - config = portkey.configs.create( - name="ConfigName_0909", - config={ - "retry": { - "attempts": 3 - }, - "cache": { - "mode": "simple" - } - }, - workspace_id="WORKSPACE_ID", + client.batches.create( + input_file_id="file-abc123", + endpoint="/v1/chat/completions", + completion_window="24h" ) - - print(config) - lang: javascript label: Self-Hosted source: | - import { Portkey } from "portkey-ai"; + import Portkey from 'portkey-ai'; - const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", - baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" - }) + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - const config=await portkey.configs.create({ - name:"ConfigName_0909", - config:{ - "retry": { - "attempts": 3 - }, - "cache": { - "mode": "simple" - } - }, - workspace_id:"WORKSPACE_ID" - }) + async function main() { + const batch = await client.batches.create({ + input_file_id: "file-abc123", + endpoint: "/v1/chat/completions", + completion_window: "24h" + }); - console.log(config); + console.log(batch); + } + + main(); - /configs/{slug}: get: + operationId: listBatches servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - summary: Get a config + - url: SELF_HOSTED_GATEWAY_URL tags: - - Configs - operationId: getConfig + - Batch + summary: List your organization's batches. parameters: - - name: slug - in: path - required: true + - 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: Config details + description: Batch listed successfully. content: application/json: schema: - type: object - properties: - success: - type: boolean - data: - type: object - properties: - config: - type: object - properties: - retry: - type: object - properties: - attempts: - type: integer - on_status_codes: - type: array - items: - type: integer - cache: - type: object - properties: - 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", - }, - ], - }, - }, - } + $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 - # Initialize the Portkey client - portkey = Portkey( - api_key="PORTKEY_API_KEY", - ) - - # Retrieve the configuration - config = portkey.configs.retrieve( - slug='CONFIG_SLUG' + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" ) - print(config) + client.batches.list() - lang: javascript label: Default source: | - import { Portkey } from "portkey-ai"; + import Portkey from 'portkey-ai'; - const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", - }) + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - const config=await portkey.configs.retrieve({ - slug:'CONFIG_SLUG' - }) + async function main() { + const list = await client.batches.list(); - console.log(config); + for await (const batch of list) { + console.log(batch); + } + } + + main(); + - lang: curl + label: Self-Hosted + source: | + curl SELF_HOSTED_GATEWAY_URL/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: 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' + client = Portkey( + api_key = "PORTKEY_API_KEY", + base_url = "SELF_HOSTED_GATEWAY_URL", + virtual_key = "PROVIDER_VIRTUAL_KEY" ) - print(config) + client.batches.list() - lang: javascript label: Self-Hosted source: | - import { Portkey } from "portkey-ai"; + import Portkey from 'portkey-ai'; - const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", - baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" - }) + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - const config=await portkey.configs.retrieve({ - slug:'CONFIG_SLUG' - }) + async function main() { + const list = await client.batches.list(); - console.log(config); + for await (const batch of list) { + console.log(batch); + } + } - put: + main(); + + /batches/{batch_id}: + get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - summary: Update a config + - url: SELF_HOSTED_GATEWAY_URL/v1 + operationId: retrieveBatch tags: - - Configs - operationId: updateConfig + - Batch + summary: Retrieves a batch. parameters: - - name: slug - in: path + - in: path + name: batch_id 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", - } + description: The ID of the batch to retrieve. responses: "200": - description: Config updated successfully + description: Batch retrieved successfully. content: application/json: schema: - type: object - properties: - success: - type: boolean - data: - type: object - properties: - version_id: - type: string - format: uuid - examples: - example-1: - value: - { - "success": true, - "data": - { - "version_id": "abe447e2-f6aa-4229-93b7-8ee3183b6667", - }, - } + $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: | - portkey = Portkey( - api_key="PORTKEY_API_KEY", - ) + from portkey_ai import Portkey - # Update the configuration - updated_config = portkey.configs.update( - slug="CONFIG_SLUG", - name="Updated Config", - config={ - "retry": { - "attempts": 3 - }, - "cache": { - "mode": "semantic" - } - } + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" ) - print(updated_config) + + client.batches.retrieve("batch_abc123") - lang: javascript label: Default source: | - import { Portkey } from "portkey-ai"; + import Portkey from 'portkey-ai'; - const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", - }) + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - const config=await portkey.configs.update({ - slug:"CONFIG_SLUG", - name:"Updated Config", - config:{ - "retry": { - "attempts": 3 - }, - "cache": { - "mode": "semantic" - } - }, + async function main() { + const batch = await client.batches.retrieve("batch_abc123"); - }) + console.log(batch); + } - console.log(config); + main(); + - lang: curl + label: Self-Hosted + source: | + curl SELF_HOSTED_GATEWAY_URL/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: 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" + client = Portkey( + api_key = "PORTKEY_API_KEY", + base_url = "SELF_HOSTED_GATEWAY_URL", + virtual_key = "PROVIDER_VIRTUAL_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) + client.batches.retrieve("batch_abc123") - lang: javascript label: Self-Hosted source: | - import { Portkey } from "portkey-ai"; + import Portkey from 'portkey-ai'; - const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", - baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" - }) + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - const config=await portkey.configs.update({ - slug:"CONFIG_SLUG", - name:"Updated Config", - config:{ - "retry": { - "attempts": 3 - }, - "cache": { - "mode": "semantic" - } - }, + async function main() { + const batch = await client.batches.retrieve("batch_abc123"); - }) + console.log(batch); + } - console.log(config); + main(); - /feedback: + /batches/{batch_id}/cancel: post: + operationId: cancelBatch servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - summary: Create new feedback - description: This endpoint allows users to submit feedback for a particular interaction or response. - operationId: createFeedback + - url: SELF_HOSTED_GATEWAY_URL tags: - - Feedback - requestBody: - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/FeedbackRequest" + - 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: Feedback successfully saved + description: Batch is cancelling. Returns the cancelling batch's details. content: application/json: schema: - $ref: "#/components/schemas/FeedbackResponse" + $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 - portkey = Portkey(api_key="PORTKEY_API_KEY") - - feedback = portkey.feedback.create( - trace_id="REQUEST_TRACE_ID", - value=1 + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" ) - print(feedback) + client.batches.cancel("batch_abc123") - lang: javascript label: Default source: | - import { Portkey } from "portkey-ai"; + import Portkey from 'portkey-ai'; - const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY" + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' }); - const feedback = await portkey.feedback.create({ - trace_id: "REQUEST_TRACE_ID", - value: 1 - }); + async function main() { + const batch = await client.batches.cancel("batch_abc123"); - console.log(feedback); + console.log(batch); + } + + main(); - lang: curl - label: Default + label: Self-Hosted 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}' + curl SELF_HOSTED_GATEWAY_URL/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: 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 + client = Portkey( + api_key = "PORTKEY_API_KEY", + base_url = "SELF_HOSTED_GATEWAY_URL", + virtual_key = "PROVIDER_VIRTUAL_KEY" ) - print(feedback) + client.batches.cancel("batch_abc123") - lang: javascript label: Self-Hosted source: | - import { Portkey } from "portkey-ai"; + import Portkey from 'portkey-ai'; - const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", - virtualKey: "PROVIDER_VIRTUAL_KEY", - baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL', + virtualKey: 'PROVIDER_VIRTUAL_KEY' }); async function main() { - const feedback = await portkey.feedback.create({ - trace_id: "REQUEST_TRACE_ID", - value: 1 - }); - console.log(feedback); + const batch = await client.batches.cancel("batch_abc123"); + + console.log(batch); } main(); - - lang: curl - label: Self-Hosted - source: | - curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/v1/feedback \ - -H "x-portkey-api-key: PORTKEY_API_KEY" \ - -H "Content-Type: application/json" \ - -d '{"trace_id":"REQUEST_TRACE_ID","value":1}' - /feedback/{id}: - put: + /configs: + get: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - 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 + summary: List all configs tags: - - Feedback - requestBody: - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/FeedbackUpdateRequest" + - Configs + operationId: listConfigs 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/v1/feedback/{id} \ - -H "x-portkey-api-key: PORTKEY_API_KEY" \ - -H "Content-Type: application/json" \ - -d '{"value":1}' - - /virtual-keys: - get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - summary: List All Virtual Keys - tags: - - Virtual-keys - responses: - "200": - description: Successful response - content: - application/json: - schema: - type: object - properties: - object: - type: string - enum: [list] - total: - type: integer - description: Total number of virtual keys - data: - type: array - items: - $ref: "#/components/schemas/VirtualKeys" - "401": - description: Unauthorized response + description: A list of configs content: application/json: schema: @@ -8456,14 +8785,61 @@ paths: success: type: boolean data: - type: object - properties: - message: - type: string - example: - success: false - data: - message: "Unauthorised Request" + type: array + items: + 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 @@ -8475,26 +8851,25 @@ paths: api_key="PORTKEY_API_KEY", ) - # List virtual keys - virtual_keys = portkey.virtual_keys.list() + # Retrieve the configuration + config = portkey.configs.list( + workspace_id="WORKSPACE_ID" + ) - print(virtual_keys) + print(config) - lang: javascript label: Default source: | import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", + 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" + const config=await portkey.configs.list({ + workspace_id:"WORKSPACE_ID" + }) + console.log(config); - lang: python label: Self-Hosted source: | @@ -8506,37 +8881,34 @@ paths: base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - # List virtual keys - virtual_keys = portkey.virtual_keys.list() + # Retrieve the configuration + config = portkey.configs.list( + workspace_id="WORKSPACE_ID" + ) - print(virtual_keys) + print(config) - lang: javascript label: Self-Hosted source: | import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", - virtualKey: "PROVIDER_VIRTUAL_KEY", + apiKey:"PORTKEY_API_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/v1/virtual-keys \ - -H "x-portkey-api-key: PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: PROVIDER_VIRTUAL_KEY" - + const config=await portkey.configs.list({ + workspace_id:"WORKSPACE_ID" + }) + console.log(config); post: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - summary: Create a Virtual Key + summary: Create a config tags: - - Virtual-keys + - Configs + operationId: createConfig requestBody: required: true content: @@ -8546,215 +8918,101 @@ paths: 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 + config: + type: object + isDefault: + type: integer workspace_id: type: string format: uuid - description: optional, needed when using organisation admin API keys - deploymentConfig: - type: array - items: + 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: - apiVersion: + id: type: string - alias: + format: uuid + version_id: type: string - is_default: - type: boolean - deploymentName: - type: string - required: ["apiVersion", "deploymentName"] - usage_limits: - $ref: "#/components/schemas/UsageLimits" - rate_limits: - $ref: "#/components/schemas/RateLimits" - examples: - generic: - value: - name: "My first virtual key" - provider: "openai" - key: "sk-jhkfkjs8d9f7jksfghkjhfg" - note: "Virtual key description" - usage_limits: + format: uuid + examples: + example-1: + value: { - "credit_limit": 10, - "periodic_reset": "monthly", - "alert_threshold": 9, + "success": true, + "data": + { + "id": "f3d8d070-f29d-43a3-bf97-3159c60f4ce0", + "version_id": "0db4065b-ead2-4daa-bf5e-7e9106585133", + }, } - 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, - }, - { - "apiVersion": "a", - "alias": "b", - "deploymentName": "c", - is_default: false, - }, - ] - 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 - properties: - slug: - type: string - "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", ) - # Add a new virtual key - new_virtual_key = portkey.virtual_keys.create( - name="openaiVKey", - provider="openai", - key="PROVIDER_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(new_virtual_key) + print(config) - lang: javascript label: Default source: | import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", + apiKey:"PORTKEY_API_KEY", }) - const newVkey=await portkey.virtualKeys.create({ - name:"openaiVKey", - provider:"openai", - key:"PROVIDER_API_KEY", + const config=await portkey.configs.create({ + name:"ConfigName_0909", + config:{ + "retry": { + "attempts": 3 + }, + "cache": { + "mode": "simple" + } + }, + workspace_id:"WORKSPACE_ID" }) - 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" - }' + + console.log(config); - lang: python label: Self-Hosted source: | @@ -8766,65 +9024,64 @@ paths: 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" + # Create a new configuration + config = portkey.configs.create( + name="ConfigName_0909", + config={ + "retry": { + "attempts": 3 + }, + "cache": { + "mode": "simple" + } + }, + workspace_id="WORKSPACE_ID", ) - print(new_virtual_key) + print(config) - lang: javascript label: Self-Hosted source: | import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", + apiKey:"PORTKEY_API_KEY", baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) - const newVkey=await portkey.virtualKeys.create({ - name:"openaiVKey", - provider:"openai", - key:"PROVIDER_API_KEY", + const config=await portkey.configs.create({ + name:"ConfigName_0909", + config:{ + "retry": { + "attempts": 3 + }, + "cache": { + "mode": "simple" + } + }, + workspace_id:"WORKSPACE_ID" }) - console.log(newVkey); - - lang: curl - label: Self-Hosted - source: | - curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/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" - }' - /virtual-keys/{slug}: + console.log(config); + + /configs/{slug}: get: servers: - - url: "https://api.portkey.ai/v1" - - url: "SELF_HOSTED_CONTROL_PLANE_URL/v1" - summary: Get a Virtual Key + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + summary: Get a config tags: - - Virtual-keys + - Configs + operationId: getConfig parameters: - - in: path - name: slug + - name: slug + in: path required: true schema: type: string responses: "200": - description: Successful response - content: - application/json: - schema: - $ref: "#/components/schemas/VirtualKeys" - "401": - description: Unauthorized response + description: Config details content: application/json: schema: @@ -8835,52 +9092,100 @@ paths: 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", - ) - - # Get a specific virtual key - virtual_key = portkey.virtual_keys.retrieve( - slug='VIRTUAL_KEY_SLUG' - ) - - print(virtual_key) + config: + type: object + properties: + retry: + type: object + properties: + attempts: + type: integer + on_status_codes: + type: array + items: + type: integer + cache: + type: object + properties: + 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", + apiKey:"PORTKEY_API_KEY", }) - const vKey=await portkey.virtualKeys.retrieve({ - slug:'VIRTUAL_KEY_SLUG' + const config=await portkey.configs.retrieve({ + slug:'CONFIG_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/v1/virtual-keys/VIRTUAL_KEY_SLUG \ - -H "x-portkey-api-key: PORTKEY_API_KEY" + + console.log(config); - lang: python label: Self-Hosted source: | @@ -8892,37 +9197,39 @@ paths: base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - # Get a specific virtual key - virtual_key = portkey.virtual_keys.retrieve( - slug='VIRTUAL_KEY_SLUG' + # Retrieve the configuration + config = portkey.configs.retrieve( + slug='CONFIG_SLUG' ) - print(virtual_key) + print(config) - lang: javascript label: Self-Hosted source: | import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", + apiKey:"PORTKEY_API_KEY", baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) - const vKey=await portkey.virtualKeys.retrieve({ - slug:'VIRTUAL_KEY_SLUG' + const config=await portkey.configs.retrieve({ + slug:'CONFIG_SLUG' }) - console.log(vKey); + + console.log(config); put: - summary: Update a Virtual Key servers: - - url: "https://api.portkey.ai/v1" - - url: "SELF_HOSTED_CONTROL_PLANE_URL/v1" + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + summary: Update a config tags: - - Virtual-keys + - Configs + operationId: updateConfig parameters: - - in: path - name: slug + - name: slug + in: path required: true schema: type: string @@ -8935,37 +9242,24 @@ paths: properties: name: type: string - key: - type: string - note: + config: + type: object + properties: + virtual_key: + type: string + status: 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" + examples: + example-1: + value: + { + "name": "testConf", + "config": { "virtual_key": "copy-of-anthrop-b20259" }, + "status": "active", + } responses: "200": - description: Successful response - content: - application/json: - schema: - type: object - - "401": - description: Unauthorized response + description: Config updated successfully content: application/json: schema: @@ -8976,83 +9270,66 @@ paths: data: type: object properties: - message: + version_id: type: string - example: - success: false - data: - message: "Unauthorised Request" + format: uuid + examples: + example-1: + value: + { + "success": true, + "data": + { + "version_id": "abe447e2-f6aa-4229-93b7-8ee3183b6667", + }, + } 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}] + # Update the configuration + updated_config = portkey.configs.update( + slug="CONFIG_SLUG", + name="Updated Config", + config={ + "retry": { + "attempts": 3 + }, + "cache": { + "mode": "semantic" + } + } ) - - print(updated_virtual_key) + print(updated_config) - lang: javascript label: Default source: | import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", + 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 + const config=await portkey.configs.update({ + slug:"CONFIG_SLUG", + name:"Updated Config", + config:{ + "retry": { + "attempts": 3 + }, + "cache": { + "mode": "semantic" } - ] - }' - - lang: curl - label: Self-Hosted - source: | - curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/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: python + }, + + }) + + console.log(config); + - lang: python label: Self-Hosted source: | from portkey_ai import Portkey @@ -9063,127 +9340,121 @@ paths: 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}] + # Update the configuration + updated_config = portkey.configs.update( + slug="CONFIG_SLUG", + name="Updated Config", + config={ + "retry": { + "attempts": 3 + }, + "cache": { + "mode": "semantic" + } + } ) - - print(updated_virtual_key) + print(updated_config) - lang: javascript label: Self-Hosted source: | import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", + 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}] + const config=await portkey.configs.update({ + slug:"CONFIG_SLUG", + name:"Updated Config", + config:{ + "retry": { + "attempts": 3 + }, + "cache": { + "mode": "semantic" + } + }, + }) - console.log(updatedVkey); - delete: - summary: Delete a Virtual Key + console.log(config); + + /feedback: + post: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + summary: Create new feedback + description: This endpoint allows users to submit feedback for a particular interaction or response. + operationId: createFeedback tags: - - Virtual-keys - parameters: - - in: path - name: slug - required: true - schema: - type: string + - Feedback + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/FeedbackRequest" responses: "200": - description: Successful response - content: - application/json: - schema: - type: object - - "401": - description: Unauthorized response + description: Feedback successfully saved content: application/json: schema: - type: object - properties: - success: - type: boolean - data: - type: object - properties: - message: - type: string - example: - success: false - data: - message: "Unauthorised Request" + $ref: "#/components/schemas/FeedbackResponse" x-code-samples: - lang: python label: Default source: | from portkey_ai import Portkey - # Initialize the Portkey client - portkey = Portkey( - api_key="PORTKEY_API_KEY", - ) + portkey = Portkey(api_key="PORTKEY_API_KEY") - # Delete a specific virtual key - result = portkey.virtual_keys.delete( - slug='VIRTUAL_KEY_SLUG' + feedback = portkey.feedback.create( + trace_id="REQUEST_TRACE_ID", + value=1 ) - print(result) + print(feedback) - lang: javascript label: Default source: | import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", - }) + apiKey: "PORTKEY_API_KEY" + }); - const result=await portkey.virtualKeys.delete({ - slug:'VIRTUAL_KEY_SLUG', - }) - console.log(result); + const feedback = await portkey.feedback.create({ + trace_id: "REQUEST_TRACE_ID", + value: 1 + }); + + console.log(feedback); - 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/v1/virtual_keys/VIRTUAL_KEY_SLUG + 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 - # Initialize the Portkey client portkey = Portkey( - api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + 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' + feedback = portkey.feedback.create( + trace_id="REQUEST_TRACE_ID", + value=1 ) - print(result) + print(feedback) - lang: javascript label: Self-Hosted source: | @@ -9191,178 +9462,110 @@ paths: const portkey = new Portkey({ apiKey: "PORTKEY_API_KEY", + virtualKey: "PROVIDER_VIRTUAL_KEY", baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" - }) + }); - const result=await portkey.virtualKeys.delete({ - slug:'VIRTUAL_KEY_SLUG', - }) - console.log(result); + async function main() { + const feedback = await portkey.feedback.create({ + trace_id: "REQUEST_TRACE_ID", + value: 1 + }); + console.log(feedback); + } - /admin/users/invites: - post: + main(); + - lang: curl + label: Self-Hosted + source: | + curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/v1/feedback \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"trace_id":"REQUEST_TRACE_ID","value":1}' + + /feedback/{id}: + put: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - 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" + 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: - - User-invites + - Feedback requestBody: required: true content: application/json: schema: - $ref: "#/components/schemas/CreateInvite" + $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 - # Initialize the Portkey client - portkey = Portkey( - api_key="PORTKEY_API_KEY", - ) + 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", - ] - } + feedback = portkey.feedback.update( + feedback_id="FEEDBACK_ID", + value=1 ) - print(user) + print(feedback) - lang: javascript label: Default source: | import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", - }) + 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", - ] - } - }) + const feedback = await portkey.feedback.update({ + feedbackId: "FEEDBACK_ID", + value: 1 + }); - console.log(user); + console.log(feedback); - 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/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" - ] - } - }' + 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 - # Initialize the Portkey client portkey = Portkey( - api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + 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", - ] - } + feedback = portkey.feedback.update( + feedback_id="FEEDBACK_ID", + value=1 ) - print(user) + print(feedback) - lang: javascript label: Self-Hosted source: | @@ -9370,100 +9573,71 @@ paths: const portkey = new Portkey({ apiKey: "PORTKEY_API_KEY", + virtualKey: "PROVIDER_VIRTUAL_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", - ] - } - }) + async function main() { + const feedback = await portkey.feedback.update({ + feedbackId: "FEEDBACK_ID", + value: 1 + }); + console.log(feedback); + } - console.log(user); + main(); + - lang: curl + label: Self-Hosted + source: | + curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/v1/feedback/{id} \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"value":1}' + /virtual-keys: get: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + summary: List All Virtual Keys 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" + - Virtual-keys responses: "200": - description: OK - headers: - Content-Type: + description: Successful response + content: + application/json: schema: - type: string - example: application/json + type: object + properties: + object: + type: string + enum: [list] + total: + type: integer + description: Total number of virtual keys + data: + type: array + items: + $ref: "#/components/schemas/VirtualKeys" + "401": + description: Unauthorized response content: application/json: schema: - $ref: "#/components/schemas/InviteList" + type: object + properties: + success: + type: boolean + data: + type: object + properties: + message: + type: string example: - object: list - total: 2 + success: false 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: "" + message: "Unauthorised Request" x-code-samples: - lang: python label: Default @@ -9475,12 +9649,10 @@ paths: api_key="PORTKEY_API_KEY", ) - # List user invites - user_invites = portkey.admin.users.invites.list( - email="user@example.com" - ) + # List virtual keys + virtual_keys = portkey.virtual_keys.list() - print(user_invites) + print(virtual_keys) - lang: javascript label: Default source: | @@ -9490,20 +9662,13 @@ paths: apiKey: "PORTKEY_API_KEY", }) - const user=await portkey.admin.users.invites.list({ - email:"user@example.com" - }); - console.log(user); + const virtualKeys=await portkey.virtualKeys.list({}) + console.log(virtualKeys); - 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/v1/admin/users/invites?email=user@example.com" - -H "x-portkey-api-key: PORTKEY_API_KEY" + curl -X GET https://api.portkey.ai/v1/virtual-keys \ + -H "x-portkey-api-key: PORTKEY_API_KEY" - lang: python label: Self-Hosted source: | @@ -9515,12 +9680,10 @@ paths: base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - # List user invites - user_invites = portkey.admin.users.invites.list( - email="user@example.com" - ) + # List virtual keys + virtual_keys = portkey.virtual_keys.list() - print(user_invites) + print(virtual_keys) - lang: javascript label: Self-Hosted source: | @@ -9528,54 +9691,199 @@ paths: const portkey = new Portkey({ apiKey: "PORTKEY_API_KEY", + virtualKey: "PROVIDER_VIRTUAL_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}: - get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - tags: - - User-invites - summary: Get Invite - parameters: - - name: inviteId - in: path - schema: - type: string - required: true - description: string + const virtualKeys=await portkey.virtualKeys.list({}) + console.log(virtualKeys); + - lang: curl + label: Self-Hosted + source: | + curl -X GET SELF_HOSTED_CONTROL_PLANE_URL/v1/virtual-keys \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: PROVIDER_VIRTUAL_KEY" + + post: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + 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" + examples: + generic: + value: + name: "My first virtual key" + provider: "openai" + key: "sk-jhkfkjs8d9f7jksfghkjhfg" + note: "Virtual key description" + usage_limits: + { + "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, + }, + { + "apiVersion": "a", + "alias": "b", + "deploymentName": "c", + is_default: false, + }, + ] + 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: OK - headers: - Content-Type: + description: Successful response + content: + application/json: schema: - type: string - example: application/json + type: object + properties: + success: + type: boolean + data: + type: object + properties: + slug: + type: string + "401": + description: Unauthorized response content: application/json: schema: - $ref: "#/components/schemas/Invite" + type: object + properties: + success: + type: boolean + data: + type: object + properties: + message: + type: string 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: "" + success: false + data: + message: "Unauthorised Request" x-code-samples: - lang: python label: Default @@ -9587,12 +9895,14 @@ paths: api_key="PORTKEY_API_KEY", ) - # Get a user invite - user = portkey.admin.users.invites.retrieve( - invite_id='INVITE_ID' + # Add a new virtual key + new_virtual_key = portkey.virtual_keys.create( + name="openaiVKey", + provider="openai", + key="PROVIDER_API_KEY" ) - print(user) + print(new_virtual_key) - lang: javascript label: Default source: | @@ -9602,20 +9912,23 @@ paths: apiKey: "PORTKEY_API_KEY", }) - const user=await portkey.admin.users.invites.retrieve({ - inviteId: 'INVITE_ID', - }); - console.log(user); + const newVkey=await portkey.virtualKeys.create({ + name:"openaiVKey", + provider:"openai", + key:"PROVIDER_API_KEY", + }) + console.log(newVkey); - 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/v1/admin/users/invites/INVITE_ID" - -H "x-portkey-api-key: PORTKEY_API_KEY" + 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: | @@ -9627,12 +9940,14 @@ paths: base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - # Get a user invite - user = portkey.admin.users.invites.retrieve( - invite_id='INVITE_ID' + # Add a new virtual key + new_virtual_key = portkey.virtual_keys.create( + name="openaiVKey", + provider="openai", + key="PROVIDER_API_KEY" ) - print(user) + print(new_virtual_key) - lang: javascript label: Self-Hosted source: | @@ -9643,36 +9958,63 @@ paths: baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) - const user=await portkey.admin.users.invites.retrieve({ - inviteId: 'INVITE_ID', - }); - console.log(user); - delete: + 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/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" + }' + + /virtual-keys/{slug}: + get: servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: "https://api.portkey.ai/v1" + - url: "SELF_HOSTED_CONTROL_PLANE_URL/v1" + summary: Get a Virtual Key tags: - - User-invites - summary: Delete Invite By ID + - Virtual-keys parameters: - - name: inviteId - in: path + - in: path + name: slug + required: true schema: type: string - required: true responses: "200": - description: OK - headers: - Content-Type: + description: Successful response + content: + application/json: schema: - type: string - example: application/json + $ref: "#/components/schemas/VirtualKeys" + "401": + description: Unauthorized response content: application/json: schema: type: object - example: {} + 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 @@ -9684,14 +10026,12 @@ paths: api_key="PORTKEY_API_KEY", ) - - - # Delete a user invite - user = portkey.admin.users.invites.delete( - invite_id="INVITE_ID" + # Get a specific virtual key + virtual_key = portkey.virtual_keys.retrieve( + slug='VIRTUAL_KEY_SLUG' ) - print(user) + print(virtual_key) - lang: javascript label: Default source: | @@ -9701,21 +10041,20 @@ paths: apiKey: "PORTKEY_API_KEY", }) - const user=await portkey.admin.users.invites.delete({ - inviteId:"INVITE_ID" + const vKey=await portkey.virtualKeys.retrieve({ + slug:'VIRTUAL_KEY_SLUG' }) - - console.log(user); + console.log(vKey); - 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" + 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 DELETE "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users/invites/INVITE_ID" - -H "x-portkey-api-key: PORTKEY_API_KEY" + curl -X GET SELF_HOSTED_CONTROL_PLANE_URL/v1/virtual-keys/VIRTUAL_KEY_SLUG \ + -H "x-portkey-api-key: PORTKEY_API_KEY" - lang: python label: Self-Hosted source: | @@ -9727,12 +10066,12 @@ paths: base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - # Delete a user invite - user = portkey.admin.users.invites.delete( - invite_id="INVITE_ID" + # Get a specific virtual key + virtual_key = portkey.virtual_keys.retrieve( + slug='VIRTUAL_KEY_SLUG' ) - print(user) + print(virtual_key) - lang: javascript label: Self-Hosted source: | @@ -9743,45 +10082,80 @@ paths: baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) - const user=await portkey.admin.users.invites.delete({ - inviteId:"INVITE_ID" + const vKey=await portkey.virtualKeys.retrieve({ + slug:'VIRTUAL_KEY_SLUG' }) + console.log(vKey); - console.log(user); - - /admin/users/invites/{inviteId}/resend: - post: + put: + summary: Update a Virtual Key servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: "https://api.portkey.ai/v1" + - url: "SELF_HOSTED_CONTROL_PLANE_URL/v1" tags: - - User-invites - summary: Resend Invite - description: Resend an invite to user for your organization + - Virtual-keys parameters: - - name: inviteId - in: path + - in: path + name: slug + required: true schema: type: string - required: true + 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" responses: "200": - description: OK - headers: - Content-Type: + description: Successful response + content: + application/json: schema: - type: string - example: application/json + type: object + + "401": + description: Unauthorized response content: application/json: schema: type: object properties: - inviteLink: - type: string - format: uri + success: + type: boolean + data: + type: object + properties: + message: + type: string example: - inviteLink: https://app.portkey.ai/invite/some-invite-link + success: false + data: + message: "Unauthorised Request" x-code-samples: - lang: python label: Default @@ -9793,14 +10167,15 @@ paths: api_key="PORTKEY_API_KEY", ) - - - # Delete a user invite - user = portkey.admin.users.invites.resend( - invite_id="INVITE_ID" + # 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(user) + print(updated_virtual_key) - lang: javascript label: Default source: | @@ -9810,21 +10185,47 @@ paths: apiKey: "PORTKEY_API_KEY", }) - const user=await portkey.admin.users.invites.resend({ - inviteId:"INVITE_ID" - }); - - console.log(user); + 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 POST "https://api.portkey.ai/v1/admin/users/invites/INVITE_ID/resend" - -H "x-portkey-api-key: PORTKEY_API_KEY" + 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 POST "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users/invites/INVITE_ID/resend" - -H "x-portkey-api-key: PORTKEY_API_KEY" + curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/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: python label: Self-Hosted source: | @@ -9836,12 +10237,15 @@ paths: base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - # Delete a user invite - user = portkey.admin.users.invites.resend( - invite_id="INVITE_ID" + # 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(user) + print(updated_virtual_key) - lang: javascript label: Self-Hosted source: | @@ -9852,75 +10256,53 @@ paths: baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) - const user=await portkey.admin.users.invites.resend({ - inviteId:"INVITE_ID" - }); - - console.log(user); + 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); - /admin/users: - get: + delete: + summary: Delete a Virtual Key servers: - - url: https://api.portkey.ai - - url: SELF_HOSTED_CONTROL_PLANE_URL + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - - Users - summary: Get users + - Virtual-keys 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 + - in: path + name: slug + required: true schema: type: string - format: email - example: "foo@bar.com" responses: "200": - description: OK - headers: - Content-Type: + description: Successful response + content: + application/json: schema: - type: string - example: application/json + type: object + + "401": + description: Unauthorized response content: application/json: schema: - $ref: "#/components/schemas/UserList" + type: object + properties: + success: + type: boolean + data: + type: object + properties: + message: + type: string example: - total: 2 - object: list + success: false 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" + message: "Unauthorised Request" x-code-samples: - lang: python label: Default @@ -9932,10 +10314,12 @@ paths: api_key="PORTKEY_API_KEY", ) - # List users - users = portkey.admin.users.list() + # Delete a specific virtual key + result = portkey.virtual_keys.delete( + slug='VIRTUAL_KEY_SLUG' + ) - print(users) + print(result) - lang: javascript label: Default source: | @@ -9945,19 +10329,18 @@ paths: apiKey: "PORTKEY_API_KEY", }) - const users=await portkey.admin.users.list({}) - - console.log(users); + const result=await portkey.virtualKeys.delete({ + slug:'VIRTUAL_KEY_SLUG', + }) + console.log(result); - lang: curl label: Default source: | - curl -X GET "https://api.portkey.ai/admin/users" - -H "x-portkey-api-key: PORTKEY_API_KEY" + curl -X DELETE https://api.portkey.ai/v1/virtual_keys/VIRTUAL_KEY_SLUG - lang: curl label: Self-Hosted source: | - curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/admin/users" - -H "x-portkey-api-key: PORTKEY_API_KEY" + curl -X DELETE https://SELF_HOSTED_CONTROL_PLANE_URL/v1/virtual_keys/VIRTUAL_KEY_SLUG - lang: python label: Self-Hosted source: | @@ -9969,10 +10352,12 @@ paths: base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - # List users - users = portkey.admin.users.list() + # Delete a specific virtual key + result = portkey.virtual_keys.delete( + slug='VIRTUAL_KEY_SLUG' + ) - print(users) + print(result) - lang: javascript label: Self-Hosted source: | @@ -9983,47 +10368,36 @@ paths: baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) - const users=await portkey.admin.users.list({}) - - console.log(users); + const result=await portkey.virtualKeys.delete({ + slug:'VIRTUAL_KEY_SLUG', + }) + console.log(result); - /admin/users/{userId}: - get: + /admin/users/invites: + post: servers: - - url: https://api.portkey.ai - - url: SELF_HOSTED_CONTROL_PLANE_URL - tags: - - Users - summary: Get user - parameters: - - name: userId - in: path - schema: - type: string - required: true + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + operationId: Invites_create + summary: Invite User + description: Send an invite to user for your organization + parameters: [] 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: + $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: | @@ -10034,13 +10408,27 @@ paths: api_key="PORTKEY_API_KEY", ) - # Get a specific user - user = portkey.admin.users.retrieve( - user_id='USER_ID' + # 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: | @@ -10049,21 +10437,74 @@ paths: const portkey = new Portkey({ apiKey: "PORTKEY_API_KEY", }) - const user = await portkey.admin.users.retrieve({ - userId: 'USER_ID', - }); + + 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 GET "https://api.portkey.ai/v1/admin/users/USER_ID" - -H "x-portkey-api-key: PORTKEY_API_KEY" + 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 GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users/USER_ID" - -H "x-portkey-api-key: PORTKEY_API_KEY" + curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/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: python label: Self-Hosted source: | @@ -10075,14 +10516,29 @@ paths: 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 + # 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"; @@ -10090,25 +10546,70 @@ paths: apiKey: "PORTKEY_API_KEY", baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) - const user = await portkey.admin.users.retrieve({ - userId: 'USER_ID', - }); + + 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); - delete: + get: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - - Users - summary: Remove a user + - User-invites + summary: Get All Invites parameters: - - name: userId - in: path + - 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 - required: true + 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 @@ -10120,8 +10621,23 @@ paths: content: application/json: schema: - type: object - example: {} + $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 @@ -10133,12 +10649,12 @@ paths: api_key="PORTKEY_API_KEY", ) - # Delete a user - user = portkey.admin.users.delete( - user_id='USER_ID' + # List user invites + user_invites = portkey.admin.users.invites.list( + email="user@example.com" ) - print(user) + print(user_invites) - lang: javascript label: Default source: | @@ -10148,20 +10664,19 @@ paths: apiKey: "PORTKEY_API_KEY", }) - const user=await portkey.admin.users.delete({ - userId: 'USER_ID', - }) - + const user=await portkey.admin.users.invites.list({ + email:"user@example.com" + }); console.log(user); - lang: curl label: Default source: | - curl -X DELETE "https://api.portkey.ai/v1/admin/users/USER_ID" + 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 DELETE "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users/USER_ID" + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users/invites?email=user@example.com" -H "x-portkey-api-key: PORTKEY_API_KEY" - lang: python label: Self-Hosted @@ -10174,12 +10689,12 @@ paths: base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - # Delete a user - user = portkey.admin.users.delete( - user_id='USER_ID' + # List user invites + user_invites = portkey.admin.users.invites.list( + email="user@example.com" ) - print(user) + print(user_invites) - lang: javascript label: Self-Hosted source: | @@ -10190,37 +10705,26 @@ paths: baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) - const user=await portkey.admin.users.delete({ - userId: 'USER_ID', - }) - + const user=await portkey.admin.users.invites.list({ + email:"user@example.com" + }); console.log(user); - put: + + /admin/users/invites/{inviteId}: + get: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - - Users - summary: Update user - requestBody: - content: - application/json: - schema: - type: object - properties: - role: - type: string - enum: - - admin - - member - example: - role: admin + - User-invites + summary: Get Invite parameters: - - name: userId + - name: inviteId in: path schema: type: string required: true + description: string responses: "200": description: OK @@ -10232,8 +10736,20 @@ paths: content: application/json: schema: - type: object - example: {} + $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 @@ -10245,10 +10761,9 @@ paths: api_key="PORTKEY_API_KEY", ) - # Update a user - user = portkey.admin.users.update( - user_id='USER_ID', - role="member" + # Get a user invite + user = portkey.admin.users.invites.retrieve( + invite_id='INVITE_ID' ) print(user) @@ -10261,24 +10776,20 @@ paths: apiKey: "PORTKEY_API_KEY", }) - const user = await portkey.admin.users.update({ - userId: 'USER_ID', - role: "member" - }) - + const user=await portkey.admin.users.invites.retrieve({ + inviteId: 'INVITE_ID', + }); console.log(user); - lang: curl label: Default source: | - curl -X PUT "https://api.portkey.ai/v1/admin/users/USER_ID" + curl -X GET "https://api.portkey.ai/v1/admin/users/invites/INVITE_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/v1/admin/users/USER_ID" + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users/invites/INVITE_ID" -H "x-portkey-api-key: PORTKEY_API_KEY" - -d '{"role":"member"}' - lang: python label: Self-Hosted source: | @@ -10290,10 +10801,9 @@ paths: base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - # Update a user - user = portkey.admin.users.update( - user_id='USER_ID', - role="member" + # Get a user invite + user = portkey.admin.users.invites.retrieve( + invite_id='INVITE_ID' ) print(user) @@ -10307,50 +10817,19 @@ paths: baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) - const user = await portkey.admin.users.update({ - userId: 'USER_ID', - role: "member" - }) - + const user=await portkey.admin.users.invites.retrieve({ + inviteId: 'INVITE_ID', + }); console.log(user); - - /admin/workspaces/{workspaceId}/users: - post: + delete: servers: - - url: https://api.portkey.ai - - url: SELF_HOSTED_CONTROL_PLANE_URL + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 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 - example: - users: - - id: 419641fb-1458-47d6-94d0-e308159b3ec2 - role: member - - id: 419641fb-1458-47d6-94d0-e308159b3ec3 - role: member + - User-invites + summary: Delete Invite By ID parameters: - - name: workspaceId + - name: inviteId in: path schema: type: string @@ -10358,6 +10837,11 @@ paths: responses: "200": description: OK + headers: + Content-Type: + schema: + type: string + example: application/json content: application/json: schema: @@ -10374,15 +10858,11 @@ paths: 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" - } - ] + + + # Delete a user invite + user = portkey.admin.users.invites.delete( + invite_id="INVITE_ID" ) print(user) @@ -10395,26 +10875,21 @@ paths: apiKey: "PORTKEY_API_KEY", }) - const user=await portkey.admin.workspaces.users.create({ - workspaceId: "WORKSPACE_SLUG", - users:[{ - id:"USER_ID", - role:'member' - }] + const user=await portkey.admin.users.invites.delete({ + inviteId:"INVITE_ID" }) + console.log(user); - lang: curl label: Default source: | - curl -X POST "https://api.portkey.ai/v1/admin/workspaces/{workspaceId}/users" + curl -X DELETE "https://api.portkey.ai/v1/admin/users/invites/INVITE_ID" -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/v1/admin/workspaces/{workspaceId}/users" + curl -X DELETE "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users/invites/INVITE_ID" -H "x-portkey-api-key: PORTKEY_API_KEY" - -d '{"users":[{"id":"USER_ID","role":"member"}]}' - lang: python label: Self-Hosted source: | @@ -10426,15 +10901,9 @@ paths: 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" - } - ] + # Delete a user invite + user = portkey.admin.users.invites.delete( + invite_id="INVITE_ID" ) print(user) @@ -10448,60 +10917,45 @@ paths: baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) - const user = await portkey.admin.workspaces.users.create({ - workspaceId: "WORKSPACE_SLUG", - users: [{ - id: "USER_ID", - role: 'member' - }] + const user=await portkey.admin.users.invites.delete({ + inviteId:"INVITE_ID" }) console.log(user); - get: + /admin/users/invites/{inviteId}/resend: + post: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - - Workspaces > Members - summary: Get workspace members + - User-invites + summary: Resend Invite + description: Resend an invite to user for your organization parameters: - - name: workspaceId + - name: inviteId 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 + headers: + Content-Type: + schema: + type: string + example: application/json content: application/json: schema: - $ref: "#/components/schemas/WorkspaceMemberList" + 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 @@ -10513,12 +10967,14 @@ paths: api_key="PORTKEY_API_KEY", ) - # Get user from workspace - users = portkey.admin.workspaces.users.list( - workspace_id="WORKSPACE_SLUG", + + + # Delete a user invite + user = portkey.admin.users.invites.resend( + invite_id="INVITE_ID" ) - print(users) + print(user) - lang: javascript label: Default source: | @@ -10528,18 +10984,20 @@ paths: apiKey: "PORTKEY_API_KEY", }) - const user=await portkey.admin.workspaces.users.list({ - workspaceId: 'WORKSPACE_SLUG', - }) + const user=await portkey.admin.users.invites.resend({ + inviteId:"INVITE_ID" + }); + console.log(user); - lang: curl label: Default source: | - curl -X GET "https://api.portkey.ai/v1/admin/workspaces/{workspaceId}/users" + 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 GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/workspaces/{workspaceId}/users" + curl -X POST "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users/invites/INVITE_ID/resend" -H "x-portkey-api-key: PORTKEY_API_KEY" - lang: python label: Self-Hosted @@ -10552,12 +11010,12 @@ paths: base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - # Get user from workspace - users = portkey.admin.workspaces.users.list( - workspace_id="WORKSPACE_SLUG", + # Delete a user invite + user = portkey.admin.users.invites.resend( + invite_id="INVITE_ID" ) - print(users) + print(user) - lang: javascript label: Self-Hosted source: | @@ -10568,43 +11026,51 @@ paths: baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) - const user=await portkey.admin.workspaces.users.list({ - workspaceId: 'WORKSPACE_SLUG', - }) + const user=await portkey.admin.users.invites.resend({ + inviteId:"INVITE_ID" + }); + console.log(user); - /admin/workspaces/{workspaceId}/users/{userId}: - put: + /admin/users: + get: servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: https://api.portkey.ai + - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - - Workspaces > Members - summary: Update workspace member - requestBody: - content: - application/json: - schema: - type: object - properties: - role: - type: string - enum: - - admin - - member - example: - role: member + - Users + summary: Get users parameters: - - name: workspaceId - in: path + - name: x-portkey-api-key + in: header schema: type: string - required: true - - name: userId - in: path + 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 - required: true + enum: + - admin + - member + - owner + example: "admin" + - name: email + in: query + schema: + type: string + format: email + example: "foo@bar.com" responses: "200": description: OK @@ -10616,8 +11082,19 @@ paths: content: application/json: schema: - type: object - example: {} + $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 @@ -10629,14 +11106,10 @@ paths: 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' - ) + # List users + users = portkey.admin.users.list() - print(updated_user) + print(users) - lang: javascript label: Default source: | @@ -10646,24 +11119,19 @@ paths: apiKey: "PORTKEY_API_KEY", }) - const user=await portkey.admin.workspaces.users.update({ - workspaceId: 'WORKSPACE_SLUG', - userId:"USER_ID", - role:'member' - }) - console.log(user); + const users=await portkey.admin.users.list({}) + + console.log(users); - lang: curl label: Default source: | - curl -X PUT "https://api.portkey.ai/v1/admin/workspaces/{workspaceId}/users/{userId}" + curl -X GET "https://api.portkey.ai/admin/users" -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/v1/admin/workspaces/{workspaceId}/users/{userId}" + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/admin/users" -H "x-portkey-api-key: PORTKEY_API_KEY" - -d '{"role":"member"}' - lang: python label: Self-Hosted source: | @@ -10675,14 +11143,10 @@ paths: 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' - ) + # List users + users = portkey.admin.users.list() - print(updated_user) + print(users) - lang: javascript label: Self-Hosted source: | @@ -10693,26 +11157,19 @@ paths: 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); + const users=await portkey.admin.users.list({}) - delete: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + console.log(users); + + /admin/users/{userId}: + get: + servers: + - url: https://api.portkey.ai + - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - - Workspaces > Members - summary: Remove workspace member + - Users + summary: Get user parameters: - - name: workspaceId - in: path - schema: - type: string - required: true - name: userId in: path schema: @@ -10729,9 +11186,18 @@ paths: content: application/json: schema: - type: object - example: {} - x-code-samples: + $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: | @@ -10742,14 +11208,13 @@ paths: api_key="PORTKEY_API_KEY", ) - # Delete user from workspace - result = portkey.admin.workspaces.users.delete( - workspace_id='WORKSPACE_SLUG', + # Get a specific user + user = portkey.admin.users.retrieve( user_id='USER_ID' ) - # Print the result (if any) - print(result) + print(user) + - lang: javascript label: Default source: | @@ -10758,22 +11223,20 @@ paths: const portkey = new Portkey({ apiKey: "PORTKEY_API_KEY", }) + const user = await portkey.admin.users.retrieve({ + userId: 'USER_ID', + }); - user = await portkey.admin.workspaces.users.delete({ - workspaceId: 'WORKSPACE_SLUG', - userId:'USER_ID' - }) - - console.log(user) + console.log(user); - lang: curl label: Default source: | - curl -X DELETE "https://api.portkey.ai/v1/admin/workspaces/{workspaceId}/users/{userId}" + 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 DELETE "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/workspaces/{workspaceId}/users/{userId}" + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users/USER_ID" -H "x-portkey-api-key: PORTKEY_API_KEY" - lang: python label: Self-Hosted @@ -10786,14 +11249,12 @@ paths: base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - # Delete user from workspace - result = portkey.admin.workspaces.users.delete( - workspace_id='WORKSPACE_SLUG', + # Get a specific user + user = portkey.admin.users.retrieve( user_id='USER_ID' ) - # Print the result (if any) - print(result) + print(user) - lang: javascript label: Self-Hosted source: | @@ -10803,27 +11264,20 @@ paths: apiKey: "PORTKEY_API_KEY", baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) + const user = await portkey.admin.users.retrieve({ + userId: 'USER_ID', + }); - user = await portkey.admin.workspaces.users.delete({ - workspaceId: 'WORKSPACE_SLUG', - userId:'USER_ID' - }) - - console.log(user) + console.log(user); - get: + delete: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - - Workspaces > Members - summary: Get member + - Users + summary: Remove a user parameters: - - name: workspaceId - in: path - schema: - type: string - required: true - name: userId in: path schema: @@ -10840,19 +11294,8 @@ paths: 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" + type: object + example: {} x-code-samples: - lang: python label: Default @@ -10864,10 +11307,9 @@ paths: api_key="PORTKEY_API_KEY", ) - # Get user from workspace - user = portkey.admin.workspaces.users.retrieve( - workspace_id="WORKSPACE_SLUG", - user_id="USER_ID" + # Delete a user + user = portkey.admin.users.delete( + user_id='USER_ID' ) print(user) @@ -10880,20 +11322,20 @@ paths: apiKey: "PORTKEY_API_KEY", }) - const user=await portkey.admin.workspaces.users.retrieve({ - workspaceId: 'WORKSPACE_SLUG', - userId:'USER_ID', + const user=await portkey.admin.users.delete({ + userId: 'USER_ID', }) + console.log(user); - lang: curl label: Default source: | - curl -X GET "https://api.portkey.ai/v1/admin/workspaces/{workspaceId}/users/{userId}" + 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 GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/workspaces/{workspaceId}/users/{userId}" + curl -X DELETE "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users/USER_ID" -H "x-portkey-api-key: PORTKEY_API_KEY" - lang: python label: Self-Hosted @@ -10906,10 +11348,9 @@ paths: 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" + # Delete a user + user = portkey.admin.users.delete( + user_id='USER_ID' ) print(user) @@ -10923,48 +11364,37 @@ paths: baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) - const user=await portkey.admin.workspaces.users.retrieve({ - workspaceId: 'WORKSPACE_SLUG', - userId:'USER_ID', + const user=await portkey.admin.users.delete({ + userId: 'USER_ID', }) - console.log(user); - /admin/workspaces: - post: + console.log(user); + put: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - - Workspaces - summary: Create Workspace + - Users + summary: Update user requestBody: content: application/json: schema: type: object properties: - name: - type: string - description: + role: type: string - defaults: - type: object - properties: - metadata: - type: object - additionalProperties: - type: string - users: - type: array - items: - type: string + enum: + - admin + - member example: - name: My Workspace - description: My Description - defaults: - metadata: - environment: production - foo: bar + role: admin + parameters: + - name: userId + in: path + schema: + type: string + required: true responses: "200": description: OK @@ -10976,7 +11406,8 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Workspace" + type: object + example: {} x-code-samples: - lang: python label: Default @@ -10988,19 +11419,13 @@ paths: 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" - } - } + # Update a user + user = portkey.admin.users.update( + user_id='USER_ID', + role="member" ) - print(workspace) + print(user) - lang: javascript label: Default source: | @@ -11010,49 +11435,24 @@ paths: apiKey: "PORTKEY_API_KEY", }) - const workspace=await portkey.admin.workspaces.create({ - name: 'WORKSPACE_NAME_0909', - description: "WORKSPACE_DESCRIPTION", - defaults: { - metadata: { - environment: "production", - foo: "bar" - } - } + const user = await portkey.admin.users.update({ + userId: 'USER_ID', + role: "member" }) - console.log(workspace); + + console.log(user); - 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" - } - } - }' + 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 POST SELF_HOSTED_CONTROL_PLANE_URL/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" - } - } - }' + curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users/USER_ID" + -H "x-portkey-api-key: PORTKEY_API_KEY" + -d '{"role":"member"}' - lang: python label: Self-Hosted source: | @@ -11064,19 +11464,13 @@ paths: 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" - } - } + # Update a user + user = portkey.admin.users.update( + user_id='USER_ID', + role="member" ) - print(workspace) + print(user) - lang: javascript label: Self-Hosted source: | @@ -11087,71 +11481,62 @@ paths: 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" - } - } + const user = await portkey.admin.users.update({ + userId: 'USER_ID', + role: "member" }) - console.log(workspace) + console.log(user); - get: + /admin/workspaces/{workspaceId}/users: + post: servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: https://api.portkey.ai + - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - - Workspaces - summary: Get All Workspaces + - 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 + example: + users: + - id: 419641fb-1458-47d6-94d0-e308159b3ec2 + role: member + - id: 419641fb-1458-47d6-94d0-e308159b3ec3 + role: member parameters: - - name: page_size - in: query - schema: - type: integer - example: "1" - - name: current_page - in: query + - name: workspaceId + in: path schema: - type: integer - example: "0" + type: string + required: true 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" - defaults: - metadata: - foo: bar - 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" - defaults: - metadata: - foo: bar - object: workspace + type: object + example: {} x-code-samples: - lang: python label: Default @@ -11163,10 +11548,18 @@ paths: api_key="PORTKEY_API_KEY", ) - # List workspaces - workspaces = portkey.admin.workspaces.list() + # Add user to workspace + user = portkey.admin.workspaces.users.create( + workspace_id="WORKSPACE_SLUG", + users=[ + { + "id": "USER_ID", + "role": "member" + } + ] + ) - print(workspaces) + print(user) - lang: javascript label: Default source: | @@ -11176,16 +11569,26 @@ paths: apiKey: "PORTKEY_API_KEY", }) - const workspaces=await portkey.admin.workspaces.list({}) - console.log(workspaces); + 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 GET https://api.portkey.ai/v1/admin/workspaces + 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 GET SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/workspaces + curl -X POST "SELF_HOSTED_CONTROL_PLANE_URL/v1/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: | @@ -11197,10 +11600,18 @@ paths: base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - # List workspaces - workspaces = portkey.admin.workspaces.list() + # Add user to workspace + user = portkey.admin.workspaces.users.create( + workspace_id="WORKSPACE_SLUG", + users=[ + { + "id": "USER_ID", + "role": "member" + } + ] + ) - print(workspaces) + print(user) - lang: javascript label: Self-Hosted source: | @@ -11211,58 +11622,60 @@ paths: baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) - const workspaces=await portkey.admin.workspaces.list({}) - console.log(workspaces); + const user = await portkey.admin.workspaces.users.create({ + workspaceId: "WORKSPACE_SLUG", + users: [{ + id: "USER_ID", + role: 'member' + }] + }) - /admin/workspaces/{workspaceId}: - put: + console.log(user); + + get: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 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 - example: - name: My Workspace - description: My Description - defaults: - metadata: - foo: bar + - 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 - headers: - Content-Type: - schema: - type: string - example: application/json content: application/json: schema: - $ref: "#/components/schemas/Workspace" + $ref: "#/components/schemas/WorkspaceMemberList" x-code-samples: - lang: python label: Default @@ -11274,17 +11687,12 @@ paths: 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" - } + # Get user from workspace + users = portkey.admin.workspaces.users.list( + workspace_id="WORKSPACE_SLUG", ) - print(workspace) + print(users) - lang: javascript label: Default source: | @@ -11294,29 +11702,19 @@ paths: 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" - } + const user=await portkey.admin.workspaces.users.list({ + workspaceId: 'WORKSPACE_SLUG', }) - console.log(workspace); + console.log(user); - 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"}}' + curl -X GET "https://api.portkey.ai/v1/admin/workspaces/{workspaceId}/users" - lang: curl label: Self-Hosted source: | - curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/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"}}' + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/workspaces/{workspaceId}/users" + -H "x-portkey-api-key: PORTKEY_API_KEY" - lang: python label: Self-Hosted source: | @@ -11328,17 +11726,12 @@ paths: 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" - } + # Get user from workspace + users = portkey.admin.workspaces.users.list( + workspace_id="WORKSPACE_SLUG", ) - print(workspace) + print(users) - lang: javascript label: Self-Hosted source: | @@ -11349,29 +11742,43 @@ paths: 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" - } + const user=await portkey.admin.workspaces.users.list({ + workspaceId: 'WORKSPACE_SLUG', }) - console.log(workspace); + console.log(user); - get: + /admin/workspaces/{workspaceId}/users/{userId}: + put: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - - Workspaces - summary: Get workspace + - Workspaces > Members + summary: Update workspace member + requestBody: + content: + application/json: + schema: + type: object + properties: + role: + type: string + enum: + - admin + - member + 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 @@ -11383,7 +11790,8 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/WorkspaceWithUsers" + type: object + example: {} x-code-samples: - lang: python label: Default @@ -11395,12 +11803,14 @@ paths: api_key="PORTKEY_API_KEY", ) - # Get workspace details - workspace = portkey.admin.workspaces.retrieve( - workspace_id='WORKSPACE_SLUG' + # Update user in workspace + updated_user = portkey.admin.workspaces.users.update( + workspace_id='WORKSPACE_SLUG', + user_id="USER_ID", + role='member' ) - print(workspace) + print(updated_user) - lang: javascript label: Default source: | @@ -11410,20 +11820,24 @@ paths: apiKey: "PORTKEY_API_KEY", }) - const workspace=await portkey.admin.workspaces.retrieve({ + const user=await portkey.admin.workspaces.users.update({ workspaceId: 'WORKSPACE_SLUG', + userId:"USER_ID", + role:'member' }) - console.log(workspace); + console.log(user); - lang: curl label: Default source: | - curl -X GET "https://api.portkey.ai/v1/admin/workspaces/{workspaceId}" \ - -H "x-portkey-api-key: PORTKEY_API_KEY" + 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 GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/workspaces/{workspaceId}" \ - -H "x-portkey-api-key: PORTKEY_API_KEY" + curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/workspaces/{workspaceId}/users/{userId}" + -H "x-portkey-api-key: PORTKEY_API_KEY" + -d '{"role":"member"}' - lang: python label: Self-Hosted source: | @@ -11432,15 +11846,17 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - baseUrl="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - # Get workspace details - workspace = portkey.admin.workspaces.retrieve( - workspace_id='WORKSPACE_SLUG' + # Update user in workspace + updated_user = portkey.admin.workspaces.users.update( + workspace_id='WORKSPACE_SLUG', + user_id="USER_ID", + role='member' ) - print(workspace) + print(updated_user) - lang: javascript label: Self-Hosted source: | @@ -11451,27 +11867,44 @@ paths: baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) - const workspace=await portkey.admin.workspaces.retrieve({ + const user=await portkey.admin.workspaces.users.update({ workspaceId: 'WORKSPACE_SLUG', + userId:"USER_ID", + role:'member' }) - console.log(workspace); + console.log(user); delete: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - - Workspaces - summary: Delete a workspace + - 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 @@ -11483,11 +11916,13 @@ paths: api_key="PORTKEY_API_KEY", ) - # Delete workspace - result = portkey.admin.workspaces.delete( - workspace_id='WORKSPACE_SLUG' + # 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 @@ -11498,20 +11933,22 @@ paths: apiKey: "PORTKEY_API_KEY", }) - const workspace=await portkey.admin.workspaces.delete({ + user = await portkey.admin.workspaces.users.delete({ workspaceId: 'WORKSPACE_SLUG', + userId:'USER_ID' }) - console.log(workspace); + + console.log(user) - lang: curl label: Default source: | - curl -X DELETE "https://api.portkey.ai/v1/admin/workspaces/{workspaceId}" \ - -H "x-portkey-api-key: PORTKEY_API_KEY" + 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/v1/admin/workspaces/{workspaceId}" \ - -H "x-portkey-api-key: PORTKEY_API_KEY" + curl -X DELETE "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/workspaces/{workspaceId}/users/{userId}" + -H "x-portkey-api-key: PORTKEY_API_KEY" - lang: python label: Self-Hosted source: | @@ -11523,11 +11960,13 @@ paths: base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - # Delete workspace - result = portkey.admin.workspaces.delete( - workspace_id='WORKSPACE_SLUG' + # 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 @@ -11539,898 +11978,768 @@ paths: baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) - const workspace=await portkey.admin.workspaces.delete({ + user = await portkey.admin.workspaces.users.delete({ workspaceId: 'WORKSPACE_SLUG', + userId:'USER_ID' }) - console.log(workspace); - /logs: - post: + console.log(user) + + get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 - summary: Insert New logs + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 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" + - 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: Successful response + 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", + 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) + # 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"; + import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY" + 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(); + const user=await portkey.admin.workspaces.users.retrieve({ + workspaceId: 'WORKSPACE_SLUG', + userId:'USER_ID', + }) + console.log(user); - 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" - } - }' + 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 POST "SELF_HOSTED_GATEWAY_URL/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" - } - }' + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/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_GATEWAY_URL" + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_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) + # Get user from workspace + user = portkey.admin.workspaces.users.retrieve( + workspace_id="WORKSPACE_SLUG", + user_id="USER_ID" + ) - print(result) + print(user) - lang: javascript label: Self-Hosted source: | - import Portkey from "portkey-ai"; + import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", - baseUrl: "SELF_HOSTED_GATEWAY_URL" + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_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(); + const user=await portkey.admin.workspaces.users.retrieve({ + workspaceId: 'WORKSPACE_SLUG', + userId:'USER_ID', + }) + console.log(user); - /logs/exports/{exportId}: - get: + /admin/workspaces: + post: servers: - - url: "https://api.portkey.ai/v1" - - url: "SELF_HOSTED_CONTROL_PLANE_URL" + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - - Logs Export - summary: Get a specific logs export - parameters: - - name: exportId - in: path - required: true - schema: - type: string + - 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 + example: + name: My Workspace + description: My Description + defaults: + metadata: + environment: production + foo: bar responses: "200": - description: Successful response + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json content: application/json: schema: - $ref: "#/components/schemas/ExportItem" + $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" + api_key="PORTKEY_API_KEY", ) - res = portkey.logs.exports.retrieve( - export_id="EXPORT_ID" + # Add a workspace + workspace = portkey.admin.workspaces.create( + name='WORKSPACE_NAME_0909', + description="WORKSPACE_DESCRIPTION", + defaults={ + "metadata": { + "environment": "production", + "foo": "bar" + } + } ) - print(res) + print(workspace) - lang: javascript label: Default source: | - import Portkey from "portkey-ai"; + import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY" + apiKey: "PORTKEY_API_KEY", }) - async function main() { - const res= await portkey.logs.exports.retrieve({ - exportId:"EXPORT_ID" - }); - - console.log(res); - } - - main(); + 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 GET "https://api.portkey.ai/v1/logs/exports/EXPORT_ID" \ - -H "x-portkey-api-key: PORTKEY_API_KEY" + 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 GET "SELF_HOSTED_CONTROL_PLANE_URL/logs/exports/EXPORT_ID" \ - -H "x-portkey-api-key: PORTKEY_API_KEY" + curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/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: 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" + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - res = portkey.logs.exports.retrieve( - export_id='EXPORT_ID' + # Add a workspace + workspace = portkey.admin.workspaces.create( + name='WORKSPACE_NAME_0909', + description="WORKSPACE_DESCRIPTION", + defaults={ + "metadata": { + "environment": "production", + "foo": "bar" + } + } ) - print(res) + print(workspace) - lang: javascript label: Self-Hosted source: | - import Portkey from "portkey-ai"; + import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", - baseUrl:"SELF_HOSTED_CONTROL_PLANE_URL" + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) - async function main() { - const res= await portkey.logs.exports.retrieve({ - exportId:'EXPORT_ID' - });; + const workspace = await portkey.admin.workspaces.create({ + name: 'WORKSPACE_NAME_0909', + description: "WORKSPACE_DESCRIPTION", + defaults: { + metadata: { + environment: "production", + foo: "bar" + } + } + }) - console.log(res); - } + console.log(workspace) - main() - put: + get: servers: - - url: "https://api.portkey.ai/v1" - - url: "SELF_HOSTED_CONTROL_PLANE_URL" + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - - Logs Export - summary: Update a logs export + - Workspaces + summary: Get All Workspaces parameters: - - name: exportId - in: path - required: true + - name: page_size + in: query 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 + type: integer + example: "1" + - name: current_page + in: query + schema: + type: integer + example: "0" responses: "200": - description: Successful response + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json content: application/json: schema: - $ref: "#/components/schemas/UpdateExportResponse" + $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" + defaults: + metadata: + foo: bar + 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" + defaults: + metadata: + foo: bar + 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" + 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" - } - ) + # List workspaces + workspaces = portkey.admin.workspaces.list() - print(res) + print(workspaces) - lang: javascript label: Default source: | - import Portkey from "portkey-ai"; + import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY" + 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(); + const workspaces=await portkey.admin.workspaces.list({}) + console.log(workspaces); - 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"}}' + curl -X GET https://api.portkey.ai/v1/admin/workspaces - 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"}}' + curl -X GET SELF_HOSTED_CONTROL_PLANE_URL/v1/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" + 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' - } - ) + # List workspaces + workspaces = portkey.admin.workspaces.list() - print(res) + print(workspaces) - lang: javascript label: Self-Hosted source: | - import Portkey from "portkey-ai"; + import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", - baseUrl:"SELF_HOSTED_CONTROL_PLANE_URL" + 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(); + const workspaces=await portkey.admin.workspaces.list({}) + console.log(workspaces); - /logs/exports: - get: + /admin/workspaces/{workspaceId}: + put: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - - Logs Export - summary: Get all logs exports + - 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 + example: + name: My Workspace + description: My Description + defaults: + metadata: + foo: bar parameters: - - name: workspace_id - in: query + - name: workspaceId + in: path schema: type: string + required: true responses: "200": - description: Successful response + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json content: application/json: schema: - $ref: "#/components/schemas/ExportListResponse" + $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" + api_key="PORTKEY_API_KEY", ) - res = portkey.logs.exports.list( - workspace_id="WORKSPACE_ID" + # Update workspace + workspace = portkey.admin.workspaces.update( + workspace_id='WORKSPACE_ID', + name='WORKSPACE 0909', + description='This is a test description', + defaults={ + "x": "y" + } ) - print(res) + print(workspace) - 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" - }); + import { Portkey } from "portkey-ai"; - console.log(res); - } + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + }) - 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" + 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 GET "SELF_HOSTED_CONTROL_PLANE_URL/logs/exports?workspace_id=WORKSPACE_ID" \ - -H "x-portkey-api-key: PORTKEY_API_KEY" + curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/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: 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" + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - res = portkey.logs.exports.list( - workspace_id="WORKSPACE_ID" + # Update workspace + workspace = portkey.admin.workspaces.update( + workspace_id='WORKSPACE_ID', + name='WORKSPACE 0909', + description='This is a test description', + defaults={ + x: "y" + } ) - print(res) + print(workspace) - 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" - }) + import { Portkey } from "portkey-ai"; - const res = await portkey.logs.exports.list({ - workspaceId:"WORKSPACE_ID" - }); + const portkey = new Portkey({ + apiKey: "PORTKEY_API_KEY", + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + }) - console.log(res); - } + 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); - main(); - post: + get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 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 + - Workspaces + summary: Get workspace + parameters: + - name: workspaceId + in: path + schema: + type: string + required: true responses: "200": - description: Successful response + description: OK + headers: + Content-Type: + schema: + type: string + example: application/json content: application/json: schema: - $ref: "#/components/schemas/UpdateExportResponse" + $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" + 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" - ] + # Get workspace details + workspace = portkey.admin.workspaces.retrieve( + workspace_id='WORKSPACE_SLUG' ) - print(res) + print(workspace) - lang: javascript label: Default source: | - import Portkey from "portkey-ai"; + import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY" + 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(); + const workspace=await portkey.admin.workspaces.retrieve({ + workspaceId: 'WORKSPACE_SLUG', + }) + console.log(workspace); - 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" - ] - }' + 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/v1/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" + api_key="PORTKEY_API_KEY", + baseUrl="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" - ] + # Get workspace details + workspace = portkey.admin.workspaces.retrieve( + workspace_id='WORKSPACE_SLUG' ) - print(res) + print(workspace) - lang: javascript label: Self-Hosted source: | - import Portkey from "portkey-ai"; + import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", - baseUrl:"SELF_HOSTED_CONTROL_PLANE_URL" + 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(); + const workspace=await portkey.admin.workspaces.retrieve({ + workspaceId: 'WORKSPACE_SLUG', + }) + console.log(workspace); - /logs/exports/{exportId}/start: - post: + delete: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - - Logs Export - summary: Start log export + - Workspaces + summary: Delete a workspace parameters: - - name: exportId + - name: workspaceId in: path - required: true schema: type: string + required: true responses: "200": - description: Successful response - content: - application/json: - schema: - $ref: "#/components/schemas/ExportTaskResponse" + 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" + api_key="PORTKEY_API_KEY", ) - res = portkey.logs.exports.start( - export_id='EXPORT_ID' + # Delete workspace + result = portkey.admin.workspaces.delete( + workspace_id='WORKSPACE_SLUG' ) - print(res) + print(result) - lang: javascript label: Default source: | - import Portkey from "portkey-ai"; + import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY" + apiKey: "PORTKEY_API_KEY", }) - async function main() { - const res = await portkey.logs.exports.start({ - exportId:'EXPORT_ID' - }); - - console.log(res); - } - - main(); + const workspace=await portkey.admin.workspaces.delete({ + workspaceId: 'WORKSPACE_SLUG', + }) + console.log(workspace); - 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" + 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/v1/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" + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - res = portkey.logs.exports.start( - export_id='EXPORT_ID' + # Delete workspace + result = portkey.admin.workspaces.delete( + workspace_id='WORKSPACE_SLUG' ) - print(res) + print(result) - lang: javascript label: Self-Hosted source: | - import Portkey from "portkey-ai"; + import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", - baseUrl:"SELF_HOSTED_CONTROL_PLANE_URL" + 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(); + const workspace=await portkey.admin.workspaces.delete({ + workspaceId: 'WORKSPACE_SLUG', + }) + console.log(workspace); - /logs/exports/{exportId}/cancel: + /logs: post: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL + - url: SELF_HOSTED_GATEWAY_URL/v1 + summary: Insert New logs tags: - - Logs Export - summary: Cancel log export - parameters: - - name: exportId - in: path - required: true - schema: - type: string + - 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 - content: - application/json: - schema: - $ref: "#/components/schemas/ExportTaskResponse" x-code-samples: - lang: python label: Default @@ -12438,53 +12747,143 @@ paths: from portkey_ai import Portkey portkey = Portkey( - api_key="PORTKEY_API_KEY" + api_key="PORTKEY_API_KEY", ) - res = portkey.logs.exports.cancel( - export_id='EXPORT_ID' - ) + 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) - print(res) - lang: javascript label: Default source: | import Portkey from "portkey-ai"; const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", + apiKey:"PORTKEY_API_KEY" }) async function main() { - const res = await portkey.logs.exports.cancel({ - exportId:'EXPORT_ID' + 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(res); + console.log(result); } 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 + 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: | - 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' + curl -X POST "SELF_HOSTED_GATEWAY_URL/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: python + label: Self-Hosted + source: | + from portkey_ai import Portkey + + portkey = Portkey( + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_GATEWAY_URL" ) - print(res) + 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: | @@ -12492,27 +12891,44 @@ paths: const portkey = new Portkey({ apiKey:"PORTKEY_API_KEY", - baseUrl:"SELF_HOSTED_CONTROL_PLANE_URL" + baseUrl: "SELF_HOSTED_GATEWAY_URL" }) async function main() { - const res = await portkey.logs.exports.cancel({ - exportId:'EXPORT_ID' + 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(res); + console.log(result); } main(); - /logs/exports/{exportId}/download: + /logs/exports/{exportId}: get: servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL + - url: "https://api.portkey.ai/v1" + - url: "SELF_HOSTED_CONTROL_PLANE_URL" tags: - Logs Export - summary: Download log export + summary: Get a specific logs export parameters: - name: exportId in: path @@ -12525,7 +12941,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/DownloadLogsResponse" + $ref: "#/components/schemas/ExportItem" x-code-samples: - lang: python label: Default @@ -12536,8 +12952,8 @@ paths: api_key="PORTKEY_API_KEY" ) - res = portkey.logs.exports.download( - export_id='EXPORT_ID' + res = portkey.logs.exports.retrieve( + export_id="EXPORT_ID" ) print(res) @@ -12551,20 +12967,24 @@ paths: }) async function main() { - const config=await portkey.logs.exports.download({ - exportId:'EXPORT_ID' - });; + const res= await portkey.logs.exports.retrieve({ + exportId:"EXPORT_ID" + }); - console.log(config); + console.log(res); } - main() + 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" + 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: | @@ -12575,7 +12995,7 @@ paths: base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - res = portkey.logs.exports.download( + res = portkey.logs.exports.retrieve( export_id='EXPORT_ID' ) @@ -12591,1108 +13011,795 @@ paths: }) async function main() { - const config=await portkey.logs.exports.download({ + const res= await portkey.logs.exports.retrieve({ exportId:'EXPORT_ID' });; - console.log(config); + console.log(res); } main() - - /api-keys/{type}/{sub-type}: - post: + put: servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL + - url: "https://api.portkey.ai/v1" + - url: "SELF_HOSTED_CONTROL_PLANE_URL" tags: - - Api-Keys - summary: Create Api Keys + - Logs Export + summary: Update a logs export parameters: - - name: type + - name: exportId 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" + type: object + properties: + workspace_id: + type: string + filters: + $ref: "#/components/schemas/GenerationsFilterSchema" + requested_data: + $ref: "#/components/schemas/LogExportsRequestedData" + required: + - filters responses: "200": - description: OK - headers: - Content-Type: - schema: - type: string - example: application/json + description: Successful response 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" + $ref: "#/components/schemas/UpdateExportResponse" x-code-samples: - lang: python label: Default source: | from portkey_ai import Portkey - # Initialize the Portkey client portkey = Portkey( - api_key="PORTKEY_API_KEY", + 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" - ] + res = portkey.logs.exports.update( + export_id="EXPORT_ID", + workspace_id="WORKSPACE_ID", + filters={ + "time_of_generation_max": "2024-07-25" + } ) - print(api_key) + print(res) - lang: javascript label: Default source: | - import { Portkey } from "portkey-ai"; + import Portkey from "portkey-ai"; const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", + 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); + 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 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" - ] - }' + 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 POST SELF_HOSTED_CONTROL_PLANE_URL/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" - ] - }' + 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"; + import Portkey from "portkey-ai"; const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", - baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + 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 + 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" + } + }); - portkey = Portkey( - api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" - ) + console.log(res); + } - 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) + main(); - /api-keys: + /logs/exports: get: servers: - - url: https://api.portkey.ai + - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - - Api-Keys - summary: Get All + - Logs Export + summary: Get all logs exports 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 + description: Successful response content: application/json: schema: - $ref: "#/components/schemas/ApiKeyObjectList" + $ref: "#/components/schemas/ExportListResponse" x-code-samples: - lang: python label: Default source: | from portkey_ai import Portkey - # Initialize the Portkey client portkey = Portkey( - api_key="PORTKEY_API_KEY" + api_key="PORTKEY_API_KEY" ) - # List API keys - api_keys = portkey.api_keys.list( - workspace_id="WORKSPACE_SLUG" + res = portkey.logs.exports.list( + workspace_id="WORKSPACE_ID" ) - print(api_keys) + print(res) - lang: javascript label: Default source: | - import { Portkey } from "portkey-ai"; + import Portkey from "portkey-ai"; - const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY" - }) + async function main() { + const portkey = new Portkey({ + apiKey:"PORTKEY_API_KEY" + }) - const apiKey=await portkey.apiKeys.list({ - workspaceId:"WORKSPACE_SLUG" - }) + const res = await portkey.logs.exports.list({ + workspaceId:"WORKSPACE_ID" + }); - console.log(apiKey); + console.log(res); + } + + main(); - 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" + 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 - /api-keys/{id}: - put: + 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: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - - Api-Keys - summary: Update Api Keys + - Logs Export + summary: Create log export requestBody: content: application/json: schema: - $ref: "#/components/schemas/UpdateApiKeyObject" - 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 + 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: - type: object - example: {} + $ref: "#/components/schemas/UpdateExportResponse" x-code-samples: - lang: python label: Default source: | from portkey_ai import Portkey - # Initialize the Portkey client portkey = Portkey( - api_key="PORTKEY_API_KEY", + 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" - ] + 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(updated_api_key) + print(res) - lang: javascript label: Default source: | - import { Portkey } from "portkey-ai"; + import Portkey from "portkey-ai"; const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", + 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" - ], + 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(apiKey); + console.log(res); + } + + main(); - lang: curl label: Default source: | - curl -X GET "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 GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/api-keys/{id}" \ + curl -X POST "https://api.portkey.ai/v1/logs/exports" \ -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" - ] + "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 - # Initialize the Portkey client portkey = Portkey( - api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + 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" - ] + 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(updated_api_key) + print(res) - lang: javascript label: Self-Hosted source: | - import { Portkey } from "portkey-ai"; + import Portkey from "portkey-ai"; const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", - baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + 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" - ], + 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(apiKey); + console.log(res); + } - get: + main(); + + /logs/exports/{exportId}/start: + post: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - - Api-Keys - summary: Get Api Keys + - Logs Export + summary: Start log export parameters: - - name: id + - name: exportId in: path + required: true schema: type: string - format: uuid - required: true responses: "200": - description: OK - headers: - Content-Type: - schema: - type: string - example: application/json + description: Successful response content: application/json: schema: - $ref: "#/components/schemas/ApiKeyObject" + $ref: "#/components/schemas/ExportTaskResponse" x-code-samples: - lang: python label: Default source: | from portkey_ai import Portkey - # Initialize the Portkey client portkey = Portkey( - api_key="PORTKEY_API_KEY", + api_key="PORTKEY_API_KEY" ) - # Get API keys - api_keys = portkey.api_keys.retrieve( - id="API_KEY_ID" + res = portkey.logs.exports.start( + export_id='EXPORT_ID' ) - print(api_keys) + print(res) - lang: javascript label: Default source: | - import { Portkey } from "portkey-ai"; + import Portkey from "portkey-ai"; const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", + apiKey:"PORTKEY_API_KEY" }) - const apiKey=await portkey.apiKeys.retrieve({ - id:"API_KEY_ID" - }) + async function main() { + const res = await portkey.logs.exports.start({ + exportId:'EXPORT_ID' + }); - console.log(apiKey); + console.log(res); + } + + main(); - 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/v1/api_keys/{id}" \ - -H "x-portkey-api-key: PORTKEY_API_KEY" + 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 - # Initialize the Portkey client portkey = Portkey( - api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + 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" + res = portkey.logs.exports.start( + export_id='EXPORT_ID' ) - print(api_keys) + print(res) - lang: javascript label: Self-Hosted source: | - import { Portkey } from "portkey-ai"; + import Portkey from "portkey-ai"; const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", - baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + apiKey:"PORTKEY_API_KEY", + baseUrl:"SELF_HOSTED_CONTROL_PLANE_URL" }) - const apiKey=await portkey.apiKeys.retrieve({ - id:"API_KEY_ID" - }) + async function main() { + const res = await portkey.logs.exports.start({ + exportId:'EXPORT_ID' + }); - console.log(apiKey); + console.log(res); + } - delete: + main(); + + /logs/exports/{exportId}/cancel: + post: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - - Api-Keys - summary: Remove a Api Key + - Logs Export + summary: Cancel log export parameters: - - name: id + - name: exportId in: path + required: true schema: type: string - format: uuid - required: true responses: "200": - description: OK - headers: - Content-Type: - schema: - type: string - example: application/json + description: Successful response content: application/json: schema: - type: object - example: {} + $ref: "#/components/schemas/ExportTaskResponse" x-code-samples: - lang: python label: Default source: | from portkey_ai import Portkey - # Initialize the Portkey client portkey = Portkey( - api_key="PORTKEY_API_KEY", + api_key="PORTKEY_API_KEY" ) - # Delete the API key - result = portkey.api_keys.delete( - id="API_KEY_ID" + res = portkey.logs.exports.cancel( + export_id='EXPORT_ID' ) - print(result) + print(res) - lang: javascript label: Default source: | - import { Portkey } from "portkey-ai"; + import Portkey from "portkey-ai"; const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", + apiKey:"PORTKEY_API_KEY", }) - const apiKey=await portkey.apiKeys.delete({ - id:"API_KEY_ID" - }) - console.log(apiKey); + async function main() { + const res = await portkey.logs.exports.cancel({ + exportId:'EXPORT_ID' + }); + + console.log(res); + } + + main(); - 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/v1/api_keys/{id}" \ - -H "x-portkey-api-key: PORTKEY_API_KEY" + 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 - # Initialize the Portkey client portkey = Portkey( - api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + 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" + res = portkey.logs.exports.cancel( + export_id='EXPORT_ID' ) - print(result) + print(res) - lang: javascript label: Self-Hosted source: | - import { Portkey } from "portkey-ai"; + import Portkey from "portkey-ai"; const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", - baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + apiKey:"PORTKEY_API_KEY", + baseUrl:"SELF_HOSTED_CONTROL_PLANE_URL" }) - const apiKey=await portkey.apiKeys.delete({ - id:"API_KEY_ID" - }) - console.log(apiKey); + async function main() { + const res = await portkey.logs.exports.cancel({ + exportId:'EXPORT_ID' + }); - /analytics/graphs/requests: + console.log(res); + } + + main(); + + /logs/exports/{exportId}/download: get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - - Analytics > Graphs - summary: Get requests graph + - Logs Export + summary: Download log export 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" + - name: exportId + in: path + required: true + schema: + type: string responses: "200": - description: OK - headers: - Content-Type: - schema: - type: string - example: application/json + description: Successful response content: application/json: schema: - type: object - properties: - summary: - type: object - properties: - total: - type: integer - description: Total requests 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 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 + $ref: "#/components/schemas/DownloadLogsResponse" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey - /analytics/graphs/cost: - get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - tags: - - Analytics > Graphs - summary: Get cost 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: - 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: - 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 + portkey = Portkey( + api_key="PORTKEY_API_KEY" + ) - /analytics/graphs/latency: - get: + 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() + + /api-keys/{type}/{sub-type}: + post: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - - Analytics > Graphs - summary: Get latency graph + - Api-Keys + summary: Create Api Keys 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" + - 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 @@ -13706,95 +13813,232 @@ paths: schema: type: object properties: - summary: - type: object - properties: - 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 - - required: - - avg - - p50 - - p90 - - p99 - 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 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 + id: + type: string + format: uuid + example: "183f497a-2a7f-4f47-992e-26213fa863we" + key: + type: string + example: "abssofjosfjs" object: type: string - description: The type of object being returned - enum: [analytics-graph] - required: - - summary - - data_points - - object + enum: ["api-key"] + example: "api-key" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey - /analytics/graphs/tokens: + # 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/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: 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) + + /api-keys: get: servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + - url: https://api.portkey.ai + - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - - Analytics > Graphs - summary: Get tokens graph + - Api-Keys + summary: Get All 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" + - 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 @@ -13806,157 +14050,64 @@ paths: content: application/json: schema: - type: object - properties: - summary: - type: object - properties: - total: - type: integer - description: Total tokens across all data points - avg: - type: integer - description: Average tokens per request across all data points - required: - - total - - avg - 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 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 + $ref: "#/components/schemas/ApiKeyObjectList" + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey - /analytics/graphs/users: - get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - tags: - - Analytics > Graphs - summary: Get users graph. Returns unique user count across different time buckets - 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: - total: - type: integer - description: Total unique users 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 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 + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY" + ) - /analytics/graphs/users/requests: - get: + # List API keys + 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" + + /api-keys/{id}: + put: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - - Analytics > Graphs - summary: Get users requests graph. Returns average requests per user across different time buckets + - Api-Keys + summary: Update Api Keys + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateApiKeyObject" 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" + - name: id + in: path + schema: + type: string + format: uuid + required: true responses: "200": description: OK @@ -13969,79 +14120,1102 @@ paths: application/json: schema: type: object - properties: - summary: - type: object - properties: - 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 + example: {} + x-code-samples: + - lang: python + label: Default + source: | + from portkey_ai import Portkey - /analytics/graphs/errors: - get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - tags: - - Analytics > Graphs - summary: Get errors 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" + # 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 GET "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 GET "SELF_HOSTED_CONTROL_PLANE_URL/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: 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: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + 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/v1/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: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + tags: + - Api-Keys + summary: Remove a 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/v1/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); + + /analytics/graphs/requests: + get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + tags: + - Analytics > Graphs + summary: Get requests 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: + total: + type: integer + description: Total requests 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 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: + get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + tags: + - Analytics > Graphs + summary: Get cost 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: + 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: + 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: + get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + tags: + - Analytics > Graphs + summary: Get latency 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: + 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 + + required: + - avg + - p50 + - p90 + - p99 + 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 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: + get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + tags: + - Analytics > Graphs + summary: Get tokens 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: + total: + type: integer + description: Total tokens across all data points + avg: + type: integer + description: Average tokens per request across all data points + required: + - total + - avg + 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 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: + get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + tags: + - Analytics > Graphs + summary: Get users graph. Returns unique user count across different time buckets + 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: + total: + type: integer + description: Total unique users 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 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: + get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + tags: + - Analytics > Graphs + summary: Get users requests graph. Returns average requests per user across different time buckets + 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: + 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: + get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + tags: + - Analytics > Graphs + summary: Get errors 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 @@ -21635,657 +22809,1028 @@ components: dataDescription: "`data` is a [message delta](https://platform.openai.com/docs/api-reference/assistants-streaming/message-delta-object)" - type: object properties: - event: + 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)" + + 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 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 - 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: + description: A machine-readable error code. + message: 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)" + 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} - ErrorEvent: + ListBatchesResponse: type: object properties: - event: + 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 + + 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"] + unit: + type: string + enum: ["rpm"] + value: + type: integer + UsageLimits: + type: object + properties: + credit_limit: + type: integer + description: Credit Limit. Used for tracking usage + minimum: 1 + default: null + 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"] + example: + credit_limit: 10 + periodic_reset: monthly + alert_threshold: 8 + + 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 + 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 - 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)" + format: email + created_at: + type: string + format: date-time + last_updated_at: + type: string + format: date-time + workspace_ids: + type: array - DoneEvent: + items: + type: string + UserList: type: object properties: - event: + total: + type: integer + example: 2 + object: type: string - enum: ["done"] + enum: + - list data: - type: string - enum: ["[DONE]"] - required: - - event - - data - description: Occurs when a stream ends. - x-code-samples: - dataDescription: "`data` is `[DONE]`" + type: array + items: + $ref: "#/components/schemas/User" - Batch: + WorkspaceMember: type: object properties: + object: + type: string + example: workspace-user + enum: + - workspace-user id: type: string - object: + format: uuid + example: 25afb7bd-f98a-11ee-85fe-0e27d7367987 + first_name: type: string - enum: [batch] - description: The object type, which is always `batch`. - endpoint: + example: John + last_name: 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: + example: Doe + org_role: type: string - description: The ID of the input file for the batch. - completion_window: + example: member + enum: + - admin + - member + - owner + role: type: string - description: The time frame within which the batch should be processed. + 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 - description: The current status of the batch. + example: active enum: - - validating - - failed - - in_progress - - finalizing - - completed - - expired - - cancelling - - cancelled - output_file_id: + - active + WorkspaceMemberList: + type: object + properties: + total: + type: integer + example: 2 + object: type: string - description: The ID of the file containing the outputs of successfully executed requests. - error_file_id: + example: list + enum: + - list + data: + type: array + items: + $ref: "#/components/schemas/WorkspaceMember" + + Workspace: + type: object + properties: + id: type: string - description: The ID of the file containing the outputs of requests with errors. + 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: 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: 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: - total: - type: integer - description: Total number of requests in the batch. - completed: - type: integer - description: Number of requests that have been completed successfully. - failed: + metadata: + type: object + additionalProperties: + type: string + example: + foo: bar + is_default: 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 + example: 0 + object: + type: string + enum: + - workspace - BatchRequestInput: + WorkspaceList: 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: + total: + type: integer + example: 2 + object: 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?"}]}} + enum: + - list + data: + type: array + items: + $ref: "#/components/schemas/Workspace" - BatchRequestOutput: + WorkspaceWithUsers: type: object - description: The per-line object of the batch output and error files properties: id: type: string - custom_id: + example: ws-test-a-174eb1 + slug: + type: string + example: ws-test-a-174eb1 + name: + type: string + example: New Workspace + description: 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: + 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 - 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: + metadata: + type: object + additionalProperties: + type: string + example: + foo: bar + is_default: + type: integer + example: 0 + object: 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} + enum: + - workspace + users: + type: array + items: + type: object + $ref: "#/components/schemas/WorkspaceMember" - ListBatchesResponse: + Collection: type: object properties: - data: - type: array - items: - $ref: "#/components/schemas/Batch" - first_id: + id: type: string - example: "batch_abc123" - last_id: + format: uuid + name: type: string - example: "batch_abc456" - has_more: + workspace_id: + type: string + format: uuid + slug: + type: string + parent_collection_id: + type: string + format: uuid + nullable: true + is_default: type: boolean - object: + status: type: string - enum: [list] - required: - - object - - data - - has_more - - FeedbackRequest: + enum: [active, archived] + created_at: + type: string + format: date-time + last_updated_at: + type: string + format: date-time + + CollectionDetails: type: object - required: - - trace_id - - value properties: - trace_id: - type: string - description: Unique identifier for the request trace. - value: + child_collections_count: 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. + 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' - FeedbackResponse: + Label: type: object properties: - status: + id: type: string - description: success or failure - message: + format: uuid + description: Unique identifier for the label + name: 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 + 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 - FeedbackUpdateRequest: + CreateLabelRequest: type: object required: - - value + - name 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. + 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 - RateLimits: + UpdateLabelRequest: type: object properties: - type: + name: type: string - enum: ["requests"] - unit: + description: Name of the label + pattern: ^(?!latest$)(?!default$)(?!\d+$)[a-zA-Z0-9_-]*[^@\s]?[a-zA-Z0-9_-]*$ + description: type: string - enum: ["rpm"] - value: - type: integer - UsageLimits: + description: Description of the label + color_code: + type: string + description: Color code for the label + + CreateLabelResponse: type: object properties: - credit_limit: - type: integer - description: Credit Limit. Used for tracking usage - minimum: 1 - default: null - alert_threshold: - type: integer - description: Alert Threshold. Used for alerting when usage reaches more than this - minimum: 1 - default: null - periodic_reset: + id: type: string - description: Reset the usage periodically. - enum: ["monthly"] - example: - credit_limit: 10 - periodic_reset: monthly - alert_threshold: 8 + format: uuid + description: ID of the created label - VirtualKeys: + ListLabelsResponse: + type: object + properties: + total: + type: integer + description: Total number of labels + data: + type: array + items: + $ref: '#/components/schemas/Label' + + schemas: + PromptSummary: type: object properties: + id: + type: string + format: uuid + slug: + type: string name: type: string - example: "Open AI Workspace" - note: + collection_id: type: string - nullable: true - example: "randomness" + format: uuid + model: + type: string + format: string 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: + last_updated_at: type: string - model_config: - type: object - rate_limits: - type: array - items: - $ref: "#/components/schemas/RateLimits" - nullable: true + format: date-time object: type: string - enum: [virtual-key] - - Invite: + enum: ["prompt"] + + Prompt: type: object properties: - object: - type: string - example: invite id: type: string format: uuid - email: + slug: type: string - format: email - role: + name: type: string - enum: - - admin - - member - created_at: + collection_id: type: string - format: date-time - expires_at: + format: uuid + string: type: string - format: date-time - accepted_at: + parameters: + type: object + prompt_version: + type: number + prompt_version_id: type: string - format: date-time - status: + format: uuid + prompt_version_status: type: string - enum: - - pending - - cancelled - - accepted - - expired - invited_by: + enum: ["active", "archived"] + prompt_version_description: + type: string + prompt_version_label_id: type: string format: uuid - InviteList: - type: object - properties: - object: + virtual_key: type: string - enum: - - list - total: - type: integer - data: + model: + type: string + functions: type: array items: - $ref: "#/components/schemas/Invite" - - User: + type: object + tools: + type: array + items: + type: object + 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: - object: - type: string - enum: - - user id: type: string format: uuid - first_name: - type: string - last_name: + prompt_id: type: string - role: + format: uuid + prompt_template: + type: object + prompt_version: + type: number + prompt_description: type: string - enum: - - admin - - member - - owner - email: + label_id: type: string - format: email + format: uuid created_at: type: string format: date-time - last_updated_at: + status: type: string - format: date-time - workspace_ids: - type: array - - items: - type: string - UserList: - type: object - properties: - total: - type: integer - example: 2 + enum: ["active", "archived"] object: type: string - enum: - - list - data: - type: array - items: - $ref: "#/components/schemas/User" - - WorkspaceMember: + enum: ["prompt"] + + PromptPartialSummary: 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: + slug: type: string - example: Doe - org_role: + name: type: string - example: member - enum: - - admin - - member - - owner - role: + collection_id: type: string - example: member - enum: - - admin - - member - - manager + format: uuid 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 + enum: ["active", "archived"] object: type: string - example: list - enum: - - list - data: - type: array - items: - $ref: "#/components/schemas/WorkspaceMember" - - Workspace: + enum: ["partial"] + + PromptPartial: type: object properties: id: type: string - example: ws-test-a-174eb1 + format: uuid slug: type: string - example: ws-test-a-174eb1 name: type: string - example: New Workspace - description: + collection_id: type: string - nullable: true - example: null + 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 - 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 - - WorkspaceList: - type: object - properties: - total: - type: integer - example: 2 - object: + status: type: string - enum: - - list - data: - type: array - items: - $ref: "#/components/schemas/Workspace" - - WorkspaceWithUsers: + enum: ["active"] + + PromptPartialVersion: type: object properties: - id: + prompt_partial_id: type: string - example: ws-test-a-174eb1 + format: uuid + prompt_partial_version_id: + type: string + format: uuid slug: type: string - example: ws-test-a-174eb1 - name: + version: + type: string + string: 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: + prompt_version_status: 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 - users: - type: array - items: - type: object - $ref: "#/components/schemas/WorkspaceMember" + enum: ["active", "archived"] + object: + type: string + enum: ["partial"] CustomLog: type: object From 4e10b08698d3771b71c3b44c8bd07d73a5b5e330 Mon Sep 17 00:00:00 2001 From: siddharthsambharia-portkey Date: Mon, 7 Apr 2025 19:01:52 +0530 Subject: [PATCH 104/124] chore/thinking-update --- openapi.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 10047b87..1306122a 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -16557,6 +16557,27 @@ components: 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 From c8113aa83df996dffabb01f8b468298f82693db6 Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Mon, 7 Apr 2025 23:06:14 +0530 Subject: [PATCH 105/124] fix: publis prompt and prompt partial route --- openapi.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 15b81cca..5f4db0e6 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -23,7 +23,7 @@ tags: description: Create, List, Retrieve, Update, and Delete collections of prompts. - name: Labels description: Create, List, Retrieve, Update, and Delete labels. - - name: PromptCollections + - name: Prompts description: Create, List, Retrieve, Update, and Delete prompt collections. - name: PromptPartials description: Create, List, Retrieve, Update, and Delete prompt partials. @@ -845,7 +845,7 @@ paths: summary: Create a new prompt operationId: createPrompt tags: - - PromptCollections + - Prompts security: - Portkey-Key: [] requestBody: @@ -924,7 +924,7 @@ paths: summary: List prompts operationId: listPrompts tags: - - PromptCollections + - Prompts security: - Portkey-Key: [] parameters: @@ -976,7 +976,7 @@ paths: summary: Get a prompt by ID or slug operationId: getPrompt tags: - - PromptCollections + - Prompts security: - Portkey-Key: [] parameters: @@ -1007,7 +1007,7 @@ paths: summary: Update a prompt operationId: updatePrompt tags: - - PromptCollections + - Prompts security: - Portkey-Key: [] parameters: @@ -1083,7 +1083,7 @@ paths: summary: Delete a prompt operationId: deletePrompt tags: - - PromptCollections + - Prompts security: - Portkey-Key: [] parameters: @@ -1116,7 +1116,7 @@ paths: summary: Get all versions of a prompt operationId: getPromptVersions tags: - - PromptCollections + - Prompts security: - Portkey-Key: [] parameters: @@ -1150,7 +1150,7 @@ paths: summary: Get a specific version of a prompt operationId: getPromptByVersion tags: - - PromptCollections + - Prompts security: - Portkey-Key: [] parameters: @@ -1187,7 +1187,7 @@ paths: summary: Update a specific version of a prompt operationId: updatePromptVersion tags: - - PromptCollections + - Prompts security: - Portkey-Key: [] parameters: @@ -1231,12 +1231,12 @@ paths: '500': description: Server error - /prompts/{promptId}/default: + /prompts/{promptId}/makedefault: put: summary: Set a version as the default for a prompt operationId: updatePromptDefault tags: - - PromptCollections + - Prompts security: - Portkey-Key: [] parameters: @@ -1509,7 +1509,7 @@ paths: '500': description: Server error - /prompts/partials/{promptPartialId}/default: + /prompts/partials/{promptPartialId}/makedefault: put: summary: Set a version as the default for a prompt partial operationId: updatePromptPartialDefault From 34b29c710060f71904be0df09ef8f47550187efe Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Tue, 8 Apr 2025 00:17:56 +0530 Subject: [PATCH 106/124] fix the openapi error --- openapi.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 5f4db0e6..fe7bc5c3 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1,3 +1,4 @@ + openapi: 3.0.0 info: title: Portkey API @@ -23633,7 +23634,6 @@ components: items: $ref: '#/components/schemas/Label' - schemas: PromptSummary: type: object properties: @@ -25017,4 +25017,4 @@ x-code-samples: path: create - type: object key: CreateCompletionResponse - path: object + path: object \ No newline at end of file From c98f49c193d12774fe325e078ab12e47346120b9 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Sat, 12 Apr 2025 15:10:41 +0530 Subject: [PATCH 107/124] fix: type makeDefault --- openapi.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index fb038eb1..6153940f 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1232,7 +1232,7 @@ paths: '500': description: Server error - /prompts/{promptId}/makedefault: + /prompts/{promptId}/makeDefault: put: summary: Set a version as the default for a prompt operationId: updatePromptDefault @@ -1510,7 +1510,7 @@ paths: '500': description: Server error - /prompts/partials/{promptPartialId}/makedefault: + /prompts/partials/{promptPartialId}/makeDefault: put: summary: Set a version as the default for a prompt partial operationId: updatePromptPartialDefault From 4f35dae6424ab61d84e08f64623761275e4d58aa Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Thu, 17 Apr 2025 18:07:22 +0530 Subject: [PATCH 108/124] feat: audit logs openapi spec --- openapi.yaml | 190 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 189 insertions(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index 6153940f..e18d0955 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -65,7 +65,9 @@ tags: - name: Api-Keys description: Create, List, Retrieve, Update, and Delete your Portkey Api keys. - name: Logs Export - description: Exports logs service . + 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 @@ -13774,6 +13776,124 @@ paths: } main() + + /audit-logs: + get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL + 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}: post: @@ -24080,6 +24200,74 @@ components: - prompt_slug - metadata + AuditLogObjectList: + type: object + properties: + records: + type: array + items: + type: object + properties: + 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: From 3df3bd1688ace9caea3850c8a15b397caa3fbe23 Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Thu, 17 Apr 2025 18:23:32 +0530 Subject: [PATCH 109/124] Delete Config API & Prompt API Fixes --- openapi.yaml | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index 6153940f..d1bf9a85 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -24,7 +24,7 @@ tags: description: Create, List, Retrieve, Update, and Delete collections of prompts. - name: Labels description: Create, List, Retrieve, Update, and Delete labels. - - name: Prompts + - name: Prompt Collections description: Create, List, Retrieve, Update, and Delete prompt collections. - name: PromptPartials description: Create, List, Retrieve, Update, and Delete prompt partials. @@ -875,9 +875,13 @@ paths: functions: type: array description: Functions for the prompt + items: + type: object tools: type: array description: Tools for the prompt + items: + type: object tool_choice: type: object description: Tool Choice for the prompt @@ -9066,6 +9070,80 @@ paths: console.log(config); /configs/{slug}: + delete: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + 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: - url: https://api.portkey.ai/v1 From 2ee2d593210546c3e654513dc613b3a3d8c4f190 Mon Sep 17 00:00:00 2001 From: Narendranath Gogineni Date: Tue, 22 Apr 2025 12:20:53 +0530 Subject: [PATCH 110/124] responses api --- openapi.yaml | 12572 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 8949 insertions(+), 3623 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index dd57018c..467175a8 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -4798,425 +4798,1261 @@ paths: "object": "assistant.deleted", "deleted": true } - - /threads: + /responses: post: - operationId: createThread + operationId: createResponse tags: - - Assistants - summary: Create a thread. + - Responses + summary: > + Creates a model response. Provide [text](/docs/guides/text) or + + [image](/docs/guides/images) inputs to generate + [text](/docs/guides/text) + + or [JSON](/docs/guides/structured-outputs) outputs. Have the model call + + your own [custom code](/docs/guides/function-calling) or use built-in + + [tools](/docs/guides/tools) like [web + search](/docs/guides/tools-web-search) + + or [file search](/docs/guides/tools-file-search) to use your own data + + as input for the model's response. requestBody: + required: true content: application/json: schema: - $ref: "#/components/schemas/CreateThreadRequest" + $ref: "#/components/schemas/CreateResponse" responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/ThreadObject" + $ref: "#/components/schemas/Response" + text/event-stream: + schema: + $ref: "#/components/schemas/ResponseStreamEvent" + x-oaiMeta: + name: Create a model response + group: responses + returns: | + Returns a [Response](/docs/api-reference/responses/object) object. + path: create + examples: + - title: Text input + request: + curl: > + curl https://api.openai.com/v1/responses \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "model": "gpt-4o", + "input": "Tell me a three sentence bedtime story about a unicorn." + }' + javascript: > + import OpenAI from "openai"; + + + const openai = new OpenAI(); + + + const response = await openai.responses.create({ + model: "gpt-4o", + input: "Tell me a three sentence bedtime story about a unicorn." + }); - 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 + console.log(response); + python: > + from openai import OpenAI - 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." - }, - ] - ) + client = OpenAI() - print(message_thread) - - lang: javascript - source: | - import Portkey from 'portkey-ai'; - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: 'PROVIDER_VIRTUAL_KEY' - }); + response = client.responses.create( + model="gpt-4o", + input="Tell me a three sentence bedtime story about a unicorn." + ) - async function main() { - const messageThread = await client.beta.threads.create({ - messages: [ + + print(response) + response: > + { + "id": "resp_67ccd2bed1ec8190b14f964abc0542670bb6a6b452d3795b", + "object": "response", + "created_at": 1741476542, + "status": "completed", + "error": null, + "incomplete_details": null, + "instructions": null, + "max_output_tokens": null, + "model": "gpt-4o-2024-08-06", + "output": [ { - role: "user", - content: "Hello, what is AI?" + "type": "message", + "id": "msg_67ccd2bf17f0819081ff3bb2cf6508e60bb6a6b452d3795b", + "status": "completed", + "role": "assistant", + "content": [ + { + "type": "output_text", + "text": "In a peaceful grove beneath a silver moon, a unicorn named Lumina discovered a hidden pool that reflected the stars. As she dipped her horn into the water, the pool began to shimmer, revealing a pathway to a magical realm of endless night skies. Filled with wonder, Lumina whispered a wish for all who dream to find their own hidden magic, and as she glanced back, her hoofprints sparkled like stardust.", + "annotations": [] + } + ] + } + ], + "parallel_tool_calls": true, + "previous_response_id": null, + "reasoning": { + "effort": null, + "generate_summary": null + }, + "store": true, + "temperature": 1.0, + "text": { + "format": { + "type": "text" + } + }, + "tool_choice": "auto", + "tools": [], + "top_p": 1.0, + "truncation": "disabled", + "usage": { + "input_tokens": 36, + "input_tokens_details": { + "cached_tokens": 0 }, - { - role: "user", - content: "How does AI work? Explain it in simple terms.", + "output_tokens": 87, + "output_tokens_details": { + "reasoning_tokens": 0 }, - ], - }); + "total_tokens": 123 + }, + "user": null, + "metadata": {} + } + - title: Image input + request: + curl: > + curl https://api.openai.com/v1/responses \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "model": "gpt-4o", + "input": [ + { + "role": "user", + "content": [ + {"type": "input_text", "text": "what is in this image?"}, + { + "type": "input_image", + "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" + } + ] + } + ] + }' + javascript: > + import OpenAI from "openai"; - console.log(messageThread); - } - main(); - response: | - { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699014083, - "metadata": {}, - "tool_resources": {} - } + const openai = new OpenAI(); - /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" - security: - - Portkey-Key: [] - Virtual-Key: [] - - Portkey-Key: [] - Provider-Auth: [] - Provider-Name: [] - - Portkey-Key: [] - Config: [] - - Portkey-Key: [] - Provider-Auth: [] - Provider-Name: [] - Custom-Host: [] + const response = await openai.responses.create({ + model: "gpt-4o", + input: [ + { + role: "user", + content: [ + { type: "input_text", text: "what is in this image?" }, + { + type: "input_image", + 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", + }, + ], + }, + ], + }); - 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" - ) + console.log(response); + python: > + from openai import OpenAI - 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' - }); + client = OpenAI() - async function main() { - const myThread = await client.beta.threads.retrieve( - "thread_abc123" - ); - console.log(myThread); - } + response = client.responses.create( + model="gpt-4o", + input=[ + { + "role": "user", + "content": [ + { "type": "input_text", "text": "what is in this image?" }, + { + "type": "input_image", + "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" + } + ] + } + ] + ) - main(); - response: | - { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699014083, - "metadata": {}, - "tool_resources": { - "code_interpreter": { - "file_ids": [] - } + + print(response) + response: > + { + "id": "resp_67ccd3a9da748190baa7f1570fe91ac604becb25c45c1d41", + "object": "response", + "created_at": 1741476777, + "status": "completed", + "error": null, + "incomplete_details": null, + "instructions": null, + "max_output_tokens": null, + "model": "gpt-4o-2024-08-06", + "output": [ + { + "type": "message", + "id": "msg_67ccd3acc8d48190a77525dc6de64b4104becb25c45c1d41", + "status": "completed", + "role": "assistant", + "content": [ + { + "type": "output_text", + "text": "The image depicts a scenic landscape with a wooden boardwalk or pathway leading through lush, green grass under a blue sky with some clouds. The setting suggests a peaceful natural area, possibly a park or nature reserve. There are trees and shrubs in the background.", + "annotations": [] + } + ] + } + ], + "parallel_tool_calls": true, + "previous_response_id": null, + "reasoning": { + "effort": null, + "generate_summary": null + }, + "store": true, + "temperature": 1.0, + "text": { + "format": { + "type": "text" + } + }, + "tool_choice": "auto", + "tools": [], + "top_p": 1.0, + "truncation": "disabled", + "usage": { + "input_tokens": 328, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 52, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 380 + }, + "user": null, + "metadata": {} } - } - 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" + - title: Web search + request: + curl: | + curl https://api.openai.com/v1/responses \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "model": "gpt-4o", + "tools": [{ "type": "web_search_preview" }], + "input": "What was a positive news story from today?" + }' + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + const response = await openai.responses.create({ + model: "gpt-4o", + tools: [{ type: "web_search_preview" }], + input: "What was a positive news story from today?", + }); - security: - - Portkey-Key: [] - Virtual-Key: [] - - Portkey-Key: [] - Provider-Auth: [] - Provider-Name: [] - - Portkey-Key: [] - Config: [] - - Portkey-Key: [] - Provider-Auth: [] - Provider-Name: [] - Custom-Host: [] + console.log(response); + python: | + from openai import OpenAI - 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 = OpenAI() - client = Portkey( - api_key = "PORTKEY_API_KEY", - virtual_key = "PROVIDER_VIRTUAL_KEY" - ) + response = client.responses.create( + model="gpt-4o", + tools=[{ "type": "web_search_preview" }], + input="What was a positive news story from today?", + ) - my_updated_thread = client.beta.threads.update( - "thread_abc123", - metadata={ - "modified": "true", - "user": "abc123" + print(response) + response: > + { + "id": "resp_67ccf18ef5fc8190b16dbee19bc54e5f087bb177ab789d5c", + "object": "response", + "created_at": 1741484430, + "status": "completed", + "error": null, + "incomplete_details": null, + "instructions": null, + "max_output_tokens": null, + "model": "gpt-4o-2024-08-06", + "output": [ + { + "type": "web_search_call", + "id": "ws_67ccf18f64008190a39b619f4c8455ef087bb177ab789d5c", + "status": "completed" + }, + { + "type": "message", + "id": "msg_67ccf190ca3881909d433c50b1f6357e087bb177ab789d5c", + "status": "completed", + "role": "assistant", + "content": [ + { + "type": "output_text", + "text": "As of today, March 9, 2025, one notable positive news story...", + "annotations": [ + { + "type": "url_citation", + "start_index": 442, + "end_index": 557, + "url": "https://.../?utm_source=chatgpt.com", + "title": "..." + }, + { + "type": "url_citation", + "start_index": 962, + "end_index": 1077, + "url": "https://.../?utm_source=chatgpt.com", + "title": "..." + }, + { + "type": "url_citation", + "start_index": 1336, + "end_index": 1451, + "url": "https://.../?utm_source=chatgpt.com", + "title": "..." + } + ] + } + ] + } + ], + "parallel_tool_calls": true, + "previous_response_id": null, + "reasoning": { + "effort": null, + "generate_summary": null + }, + "store": true, + "temperature": 1.0, + "text": { + "format": { + "type": "text" + } + }, + "tool_choice": "auto", + "tools": [ + { + "type": "web_search_preview", + "domains": [], + "search_context_size": "medium", + "user_location": { + "type": "approximate", + "city": null, + "country": "US", + "region": null, + "timezone": null + } + } + ], + "top_p": 1.0, + "truncation": "disabled", + "usage": { + "input_tokens": 328, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 356, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 684 + }, + "user": null, + "metadata": {} } - ) - print(my_updated_thread) - - lang: javascript - source: | - import Portkey from 'portkey-ai'; + - title: File search + request: + curl: > + curl https://api.openai.com/v1/responses \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "model": "gpt-4o", + "tools": [{ + "type": "file_search", + "vector_store_ids": ["vs_1234567890"], + "max_num_results": 20 + }], + "input": "What are the attributes of an ancient brown dragon?" + }' + javascript: > + import OpenAI from "openai"; + + + const openai = new OpenAI(); + + + const response = await openai.responses.create({ + model: "gpt-4o", + tools: [{ + type: "file_search", + vector_store_ids: ["vs_1234567890"], + max_num_results: 20 + }], + input: "What are the attributes of an ancient brown dragon?", + }); - 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(response); + python: | + from openai import OpenAI + + client = OpenAI() + + response = client.responses.create( + model="gpt-4o", + tools=[{ + "type": "file_search", + "vector_store_ids": ["vs_1234567890"], + "max_num_results": 20 + }], + input="What are the attributes of an ancient brown dragon?", + ) + + print(response) + response: > + { + "id": "resp_67ccf4c55fc48190b71bd0463ad3306d09504fb6872380d7", + "object": "response", + "created_at": 1741485253, + "status": "completed", + "error": null, + "incomplete_details": null, + "instructions": null, + "max_output_tokens": null, + "model": "gpt-4o-2024-08-06", + "output": [ + { + "type": "file_search_call", + "id": "fs_67ccf4c63cd08190887ef6464ba5681609504fb6872380d7", + "status": "completed", + "queries": [ + "attributes of an ancient brown dragon" + ], + "results": null + }, + { + "type": "message", + "id": "msg_67ccf4c93e5c81909d595b369351a9d309504fb6872380d7", + "status": "completed", + "role": "assistant", + "content": [ + { + "type": "output_text", + "text": "The attributes of an ancient brown dragon include...", + "annotations": [ + { + "type": "file_citation", + "index": 320, + "file_id": "file-4wDz5b167pAf72nx1h9eiN", + "filename": "dragons.pdf" + }, + { + "type": "file_citation", + "index": 576, + "file_id": "file-4wDz5b167pAf72nx1h9eiN", + "filename": "dragons.pdf" + }, + { + "type": "file_citation", + "index": 815, + "file_id": "file-4wDz5b167pAf72nx1h9eiN", + "filename": "dragons.pdf" + }, + { + "type": "file_citation", + "index": 815, + "file_id": "file-4wDz5b167pAf72nx1h9eiN", + "filename": "dragons.pdf" + }, + { + "type": "file_citation", + "index": 1030, + "file_id": "file-4wDz5b167pAf72nx1h9eiN", + "filename": "dragons.pdf" + }, + { + "type": "file_citation", + "index": 1030, + "file_id": "file-4wDz5b167pAf72nx1h9eiN", + "filename": "dragons.pdf" + }, + { + "type": "file_citation", + "index": 1156, + "file_id": "file-4wDz5b167pAf72nx1h9eiN", + "filename": "dragons.pdf" + }, + { + "type": "file_citation", + "index": 1225, + "file_id": "file-4wDz5b167pAf72nx1h9eiN", + "filename": "dragons.pdf" + } + ] + } + ] + } + ], + "parallel_tool_calls": true, + "previous_response_id": null, + "reasoning": { + "effort": null, + "generate_summary": null + }, + "store": true, + "temperature": 1.0, + "text": { + "format": { + "type": "text" + } + }, + "tool_choice": "auto", + "tools": [ + { + "type": "file_search", + "filters": null, + "max_num_results": 20, + "ranking_options": { + "ranker": "auto", + "score_threshold": 0.0 + }, + "vector_store_ids": [ + "vs_1234567890" + ] + } + ], + "top_p": 1.0, + "truncation": "disabled", + "usage": { + "input_tokens": 18307, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 348, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 18655 + }, + "user": null, + "metadata": {} + } + - title: Streaming + request: + curl: | + curl https://api.openai.com/v1/responses \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "model": "gpt-4o", + "instructions": "You are a helpful assistant.", + "input": "Hello!", + "stream": true + }' + python: | + from openai import OpenAI + + client = OpenAI() + + response = client.responses.create( + model="gpt-4o", + instructions="You are a helpful assistant.", + input="Hello!", + stream=True + ) + + for event in response: + print(event) + javascript: | + import OpenAI from "openai"; + + const openai = new OpenAI(); + + const response = await openai.responses.create({ + model: "gpt-4o", + instructions: "You are a helpful assistant.", + input: "Hello!", + stream: true, + }); + + for await (const event of response) { + console.log(event); } - ); + response: > + event: response.created - console.log(updatedThread); - } + data: + {"type":"response.created","response":{"id":"resp_67c9fdcecf488190bdd9a0409de3a1ec07b8b0ad4e5eb654","object":"response","created_at":1741290958,"status":"in_progress","error":null,"incomplete_details":null,"instructions":"You + are a helpful + assistant.","max_output_tokens":null,"model":"gpt-4o-2024-08-06","output":[],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":null,"generate_summary":null},"store":true,"temperature":1.0,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":1.0,"truncation":"disabled","usage":null,"user":null,"metadata":{}}} - main(); - response: | - { - "id": "thread_abc123", - "object": "thread", - "created_at": 1699014083, - "metadata": { - "modified": "true", - "user": "abc123" - }, - "tool_resources": {} - } - delete: - operationId: deleteThread + + event: response.in_progress + + data: + {"type":"response.in_progress","response":{"id":"resp_67c9fdcecf488190bdd9a0409de3a1ec07b8b0ad4e5eb654","object":"response","created_at":1741290958,"status":"in_progress","error":null,"incomplete_details":null,"instructions":"You + are a helpful + assistant.","max_output_tokens":null,"model":"gpt-4o-2024-08-06","output":[],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":null,"generate_summary":null},"store":true,"temperature":1.0,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":1.0,"truncation":"disabled","usage":null,"user":null,"metadata":{}}} + + + event: response.output_item.added + + data: + {"type":"response.output_item.added","output_index":0,"item":{"id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","type":"message","status":"in_progress","role":"assistant","content":[]}} + + + event: response.content_part.added + + data: + {"type":"response.content_part.added","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"part":{"type":"output_text","text":"","annotations":[]}} + + + event: response.output_text.delta + + data: + {"type":"response.output_text.delta","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"delta":"Hi"} + + + ... + + + event: response.output_text.done + + data: + {"type":"response.output_text.done","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"text":"Hi + there! How can I assist you today?"} + + + event: response.content_part.done + + data: + {"type":"response.content_part.done","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"part":{"type":"output_text","text":"Hi + there! How can I assist you today?","annotations":[]}} + + + event: response.output_item.done + + data: + {"type":"response.output_item.done","output_index":0,"item":{"id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","type":"message","status":"completed","role":"assistant","content":[{"type":"output_text","text":"Hi + there! How can I assist you today?","annotations":[]}]}} + + + event: response.completed + + data: + {"type":"response.completed","response":{"id":"resp_67c9fdcecf488190bdd9a0409de3a1ec07b8b0ad4e5eb654","object":"response","created_at":1741290958,"status":"completed","error":null,"incomplete_details":null,"instructions":"You + are a helpful + assistant.","max_output_tokens":null,"model":"gpt-4o-2024-08-06","output":[{"id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","type":"message","status":"completed","role":"assistant","content":[{"type":"output_text","text":"Hi + there! How can I assist you + today?","annotations":[]}]}],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":null,"generate_summary":null},"store":true,"temperature":1.0,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":1.0,"truncation":"disabled","usage":{"input_tokens":37,"output_tokens":11,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":48},"user":null,"metadata":{}}} + - title: Functions + request: + curl: > + curl https://api.openai.com/v1/responses \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "model": "gpt-4o", + "input": "What is the weather like in Boston today?", + "tools": [ + { + "type": "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", "unit"] + } + } + ], + "tool_choice": "auto" + }' + python: > + from openai import OpenAI + + + client = OpenAI() + + + tools = [ + { + "type": "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", "unit"], + } + } + ] + + + response = client.responses.create( + model="gpt-4o", + tools=tools, + input="What is the weather like in Boston today?", + tool_choice="auto" + ) + + + print(response) + javascript: > + import OpenAI from "openai"; + + + const openai = new OpenAI(); + + + const tools = [ + { + type: "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", "unit"], + }, + }, + ]; + + + const response = await openai.responses.create({ + model: "gpt-4o", + tools: tools, + input: "What is the weather like in Boston today?", + tool_choice: "auto", + }); + + + console.log(response); + response: > + { + "id": "resp_67ca09c5efe0819096d0511c92b8c890096610f474011cc0", + "object": "response", + "created_at": 1741294021, + "status": "completed", + "error": null, + "incomplete_details": null, + "instructions": null, + "max_output_tokens": null, + "model": "gpt-4o-2024-08-06", + "output": [ + { + "type": "function_call", + "id": "fc_67ca09c6bedc8190a7abfec07b1a1332096610f474011cc0", + "call_id": "call_unLAR8MvFNptuiZK6K6HCy5k", + "name": "get_current_weather", + "arguments": "{\"location\":\"Boston, MA\",\"unit\":\"celsius\"}", + "status": "completed" + } + ], + "parallel_tool_calls": true, + "previous_response_id": null, + "reasoning": { + "effort": null, + "generate_summary": null + }, + "store": true, + "temperature": 1.0, + "text": { + "format": { + "type": "text" + } + }, + "tool_choice": "auto", + "tools": [ + { + "type": "function", + "description": "Get the current weather in a given location", + "name": "get_current_weather", + "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", + "unit" + ] + }, + "strict": true + } + ], + "top_p": 1.0, + "truncation": "disabled", + "usage": { + "input_tokens": 291, + "output_tokens": 23, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 314 + }, + "user": null, + "metadata": {} + } + - title: Reasoning + request: + curl: | + curl https://api.openai.com/v1/responses \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "model": "o3-mini", + "input": "How much wood would a woodchuck chuck?", + "reasoning": { + "effort": "high" + } + }' + javascript: | + import OpenAI from "openai"; + const openai = new OpenAI(); + + const response = await openai.responses.create({ + model: "o3-mini", + input: "How much wood would a woodchuck chuck?", + reasoning: { + effort: "high" + } + }); + + console.log(response); + python: | + from openai import OpenAI + client = OpenAI() + + response = client.responses.create( + model="o3-mini", + input="How much wood would a woodchuck chuck?", + reasoning={ + "effort": "high" + } + ) + + print(response) + response: > + { + "id": "resp_67ccd7eca01881908ff0b5146584e408072912b2993db808", + "object": "response", + "created_at": 1741477868, + "status": "completed", + "error": null, + "incomplete_details": null, + "instructions": null, + "max_output_tokens": null, + "model": "o1-2024-12-17", + "output": [ + { + "type": "message", + "id": "msg_67ccd7f7b5848190a6f3e95d809f6b44072912b2993db808", + "status": "completed", + "role": "assistant", + "content": [ + { + "type": "output_text", + "text": "The classic tongue twister...", + "annotations": [] + } + ] + } + ], + "parallel_tool_calls": true, + "previous_response_id": null, + "reasoning": { + "effort": "high", + "generate_summary": null + }, + "store": true, + "temperature": 1.0, + "text": { + "format": { + "type": "text" + } + }, + "tool_choice": "auto", + "tools": [], + "top_p": 1.0, + "truncation": "disabled", + "usage": { + "input_tokens": 81, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 1035, + "output_tokens_details": { + "reasoning_tokens": 832 + }, + "total_tokens": 1116 + }, + "user": null, + "metadata": {} + } + /responses/{response_id}: + get: + operationId: getResponse tags: - - Assistants - summary: Delete a thread. + - Responses + summary: | + Retrieves a model response with the given ID. parameters: - in: path - name: thread_id + name: response_id required: true schema: type: string - description: The ID of the thread to delete. + 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/DeleteThreadResponse" - - security: - - Portkey-Key: [] - Virtual-Key: [] - - Portkey-Key: [] - Provider-Auth: [] - Provider-Name: [] - - Portkey-Key: [] - Config: [] - - Portkey-Key: [] - Provider-Auth: [] - Provider-Name: [] - Custom-Host: [] + $ref: "#/components/schemas/Response" + x-oaiMeta: + name: Get a model response + group: responses + returns: > + The [Response](/docs/api-reference/responses/object) object matching + the + + specified ID. + examples: + request: + curl: | + curl https://api.openai.com/v1/responses/resp_123 \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" + javascript: | + import OpenAI from "openai"; + const client = new OpenAI(); + + const response = await client.responses.retrieve("resp_123"); + console.log(response); + python: | + from openai import OpenAI + client = OpenAI() - 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); + response = client.responses.retrieve("resp_123") + print(response) + response: > + { + "id": "resp_67cb71b351908190a308f3859487620d06981a8637e6bc44", + "object": "response", + "created_at": 1741386163, + "status": "completed", + "error": null, + "incomplete_details": null, + "instructions": null, + "max_output_tokens": null, + "model": "gpt-4o-2024-08-06", + "output": [ + { + "type": "message", + "id": "msg_67cb71b3c2b0819084d481baaaf148f206981a8637e6bc44", + "status": "completed", + "role": "assistant", + "content": [ + { + "type": "output_text", + "text": "Silent circuits hum, \nThoughts emerge in data streams— \nDigital dawn breaks.", + "annotations": [] + } + ] + } + ], + "parallel_tool_calls": true, + "previous_response_id": null, + "reasoning": { + "effort": null, + "generate_summary": null + }, + "store": true, + "temperature": 1.0, + "text": { + "format": { + "type": "text" + } + }, + "tool_choice": "auto", + "tools": [], + "top_p": 1.0, + "truncation": "disabled", + "usage": { + "input_tokens": 32, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 18, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 50 + }, + "user": null, + "metadata": {} } - main(); + 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" + x-oaiMeta: + name: Delete a model response + group: responses + returns: | + A success message. + examples: + request: + curl: | + curl -X DELETE https://api.openai.com/v1/responses/resp_123 \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" + javascript: | + import OpenAI from "openai"; + const client = new OpenAI(); + + const response = await client.responses.del("resp_123"); + console.log(response); + python: | + from openai import OpenAI + client = OpenAI() + + response = client.responses.del("resp_123") + print(response) response: | { - "id": "thread_abc123", - "object": "thread.deleted", + "id": "resp_6786a1bec27481909a17d673315b29f6", + "object": "response", "deleted": true } - - /threads/{thread_id}/messages: + /responses/{response_id}/input_items: get: - operationId: listMessages + operationId: listInputItems tags: - - Assistants - summary: Returns a list of messages for a given thread. + - Responses + summary: Returns a list of input items for a given response. parameters: - in: path - name: thread_id + name: response_id required: true schema: type: string - description: The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) the messages belong to. + description: The ID of the response to retrieve input items for. - name: limit in: query - description: *pagination_limit_param_description + 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 - schema: - type: string - default: desc - enum: ["asc", "desc"] - - name: after - in: query - description: *pagination_after_param_description + - in: query + name: order schema: type: string - - name: before - in: query - description: *pagination_before_param_description + 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 - - name: run_id - in: query description: | - Filter messages by the run ID that generated them. + 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/ListMessagesResponse" + $ref: "#/components/schemas/ResponseItemList" + x-oaiMeta: + name: List input items + group: responses + returns: A list of input item objects. + examples: + request: + curl: | + curl https://api.openai.com/v1/responses/resp_abc123/input_items \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" + javascript: > + import OpenAI from "openai"; + + const client = new OpenAI(); + + + const response = await + client.responses.inputItems.list("resp_123"); + + console.log(response.data); + python: | + from openai import OpenAI + client = OpenAI() + + response = client.responses.input_items.list("resp_123") + print(response.data) + response: > + { + "object": "list", + "data": [ + { + "id": "msg_abc123", + "type": "message", + "role": "user", + "content": [ + { + "type": "input_text", + "text": "Tell me a three sentence bedtime story about a unicorn." + } + ] + } + ], + "first_id": "msg_abc123", + "last_id": "msg_abc123", + "has_more": false + } + /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" security: - Portkey-Key: [] @@ -5234,11 +6070,20 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_abc123/messages \ + 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" + -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 @@ -5248,8 +6093,20 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - thread_messages = client.beta.threads.messages.list("thread_abc123") - print(thread_messages.data) + 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'; @@ -5260,88 +6117,52 @@ paths: }); async function main() { - const threadMessages = await client.beta.threads.messages.list( - "thread_abc123" - ); + 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(threadMessages.data); + console.log(messageThread); } 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 + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, + "metadata": {}, + "tool_resources": {} } - post: - operationId: createMessage + + /threads/{thread_id}: + get: + operationId: getThread tags: - Assistants - summary: Create a message. + summary: Retrieves a 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) to create a message for. - requestBody: - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/CreateMessageRequest" + description: The ID of the thread to retrieve. responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/MessageObject" + $ref: "#/components/schemas/ThreadObject" security: - Portkey-Key: [] @@ -5359,15 +6180,11 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_abc123/messages \ + 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 '{ - "role": "user", - "content": "How does AI work? Explain it in simple terms." - }' + -H "OpenAI-Beta: assistants=v2" - lang: python source: | from portkey_ai import Portkey @@ -5377,12 +6194,8 @@ paths: 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) + my_thread = client.beta.threads.retrieve("thread_abc123") + print(my_thread) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -5393,63 +6206,51 @@ paths: }); 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." } + const myThread = await client.beta.threads.retrieve( + "thread_abc123" ); - console.log(threadMessages); + console.log(myThread); } 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": [] - } + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, + "metadata": {}, + "tool_resources": { + "code_interpreter": { + "file_ids": [] } - ], - "attachments": [], - "metadata": {} + } } - - /threads/{thread_id}/messages/{message_id}: - get: - operationId: getMessage + post: + operationId: modifyThread tags: - Assistants - summary: Retrieve a message. + summary: Modifies a 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) to which this message belongs. - - in: path - name: message_id - required: true - schema: - type: string - description: The ID of the message to retrieve. + 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/MessageObject" + $ref: "#/components/schemas/ThreadObject" security: - Portkey-Key: [] @@ -5467,11 +6268,17 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_abc123/messages/msg_abc123 \ + 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" + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "metadata": { + "modified": "true", + "user": "abc123" + } + }' - lang: python source: | from portkey_ai import Portkey @@ -5481,11 +6288,14 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - message = client.beta.threads.messages.retrieve( - message_id="msg_abc123", - thread_id="thread_abc123", + my_updated_thread = client.beta.threads.update( + "thread_abc123", + metadata={ + "modified": "true", + "user": "abc123" + } ) - print(message) + print(my_updated_thread) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -5496,67 +6306,47 @@ paths: }); async function main() { - const message = await client.beta.threads.messages.retrieve( + const updatedThread = await client.beta.threads.update( "thread_abc123", - "msg_abc123" + { + metadata: { modified: "true", user: "abc123" }, + } ); - console.log(message); + console.log(updatedThread); } 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": {} + "id": "thread_abc123", + "object": "thread", + "created_at": 1699014083, + "metadata": { + "modified": "true", + "user": "abc123" + }, + "tool_resources": {} } - post: - operationId: modifyMessage + delete: + operationId: deleteThread tags: - Assistants - summary: Modifies a message. + summary: Delete a thread. 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" + description: The ID of the thread to delete. responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/MessageObject" + $ref: "#/components/schemas/DeleteThreadResponse" security: - Portkey-Key: [] @@ -5574,17 +6364,12 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_abc123/messages/msg_abc123 \ + 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" - } - }' + -X DELETE - lang: python source: | from portkey_ai import Portkey @@ -5594,15 +6379,8 @@ paths: 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) + response = client.beta.threads.delete("thread_abc123") + print(response) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -5613,65 +6391,68 @@ paths: }); async function main() { - const message = await client.beta.threads.messages.update( - "thread_abc123", - "msg_abc123", - { - metadata: { - modified: "true", - user: "abc123", - }, - } - }' + const response = await client.beta.threads.del("thread_abc123"); + + console.log(response); + } + 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": [] - } - } - ], - "file_ids": [], - "metadata": { - "modified": "true", - "user": "abc123" - } + "id": "thread_abc123", + "object": "thread.deleted", + "deleted": true } - delete: - operationId: deleteMessage + + /threads/{thread_id}/messages: + get: + operationId: listMessages tags: - Assistants - summary: Deletes a message. + 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 to which this message belongs. - - in: path - name: message_id - required: true + 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 - description: The ID of the message to delete. responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/DeleteMessageResponse" + $ref: "#/components/schemas/ListMessagesResponse" security: - Portkey-Key: [] @@ -5689,7 +6470,7 @@ paths: x-code-samples: - lang: curl source: | - curl -X DELETE https://api.portkey.ai/v1/threads/thread_abc123/messages/msg_abc123 \ + 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" \ @@ -5703,11 +6484,8 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - deleted_message = client.beta.threads.messages.delete( - message_id="msg_abc12", - thread_id="thread_abc123", - ) - print(deleted_message) + thread_messages = client.beta.threads.messages.list("thread_abc123") + print(thread_messages.data) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -5718,39 +6496,88 @@ paths: }); async function main() { - const deletedMessage = await client.beta.threads.messages.del( - "thread_abc123", - "msg_abc123" + const threadMessages = await client.beta.threads.messages.list( + "thread_abc123" ); - console.log(deletedMessage); + console.log(threadMessages.data); } + + main(); response: | { - "id": "msg_abc123", - "object": "thread.message.deleted", - "deleted": true + "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 } - - /threads/runs: post: - operationId: createThreadAndRun + operationId: createMessage tags: - Assistants - summary: Create a thread and run it in one request. + 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/CreateThreadAndRunRequest" + $ref: "#/components/schemas/CreateMessageRequest" responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/RunObject" + $ref: "#/components/schemas/MessageObject" security: - Portkey-Key: [] @@ -5768,38 +6595,30 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/runs \ + 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 "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."} - ] - } + "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" - ) - - run = client.beta.threads.create_and_run( - assistant_id="asst_abc123", - thread={ - "messages": [ - {"role": "user", "content": "Explain deep learning to a 5 year old."} - ] - } - ) + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - print(run) + 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'; @@ -5810,98 +6629,63 @@ paths: }); 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." }, - ], - }, - }); + const threadMessages = await client.beta.threads.messages.create( + "thread_abc123", + { role: "user", content: "How does AI work? Explain it in simple terms." } + ); - console.log(run); + console.log(threadMessages); } main(); response: | { - "id": "run_abc123", - "object": "thread.run", - "created_at": 1699076792, - "assistant_id": "asst_abc123", + "id": "msg_abc123", + "object": "thread.message", + "created_at": 1713226573, + "assistant_id": null, "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 + "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}/runs: + /threads/{thread_id}/messages/{message_id}: get: - operationId: listRuns + operationId: getMessage tags: - Assistants - summary: Returns a list of runs belonging to a thread. + summary: Retrieve a message. parameters: - - name: thread_id - in: path + - in: path + name: thread_id 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 + 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/ListRunsResponse" + $ref: "#/components/schemas/MessageObject" security: - Portkey-Key: [] @@ -5919,10 +6703,10 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_abc123/runs \ + 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 "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" - lang: python source: | @@ -5933,11 +6717,11 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - runs = client.beta.threads.runs.list( - "thread_abc123" + message = client.beta.threads.messages.retrieve( + message_id="msg_abc123", + thread_id="thread_abc123", ) - - print(runs) + print(message) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -5948,135 +6732,67 @@ paths: }); async function main() { - const runs = await client.beta.threads.runs.list( - "thread_abc123" + const message = await client.beta.threads.messages.retrieve( + "thread_abc123", + "msg_abc123" ); - console.log(runs); + console.log(message); } main(); response: | { - "object": "list", - "data": [ + "id": "msg_abc123", + "object": "thread.message", + "created_at": 1699017614, + "assistant_id": null, + "thread_id": "thread_abc123", + "run_id": null, + "role": "user", + "content": [ { - "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 + "type": "text", + "text": { + "value": "How does AI work? Explain it in simple terms.", + "annotations": [] + } } ], - "first_id": "run_abc123", - "last_id": "run_abc456", - "has_more": false + "attachments": [], + "metadata": {} } post: - operationId: createRun + operationId: modifyMessage tags: - Assistants - summary: Create a run. + summary: Modifies a message. parameters: - in: path name: thread_id required: true schema: type: string - description: The ID of the thread to run. + 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/CreateRunRequest" + $ref: "#/components/schemas/ModifyMessageRequest" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/MessageObject" security: - Portkey-Key: [] @@ -6091,24 +6807,20 @@ paths: 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 \ + 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 "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" \ -d '{ - "assistant_id": "asst_abc123" - }' + "metadata": { + "modified": "true", + "user": "abc123" + } + }' - lang: python source: | from portkey_ai import Portkey @@ -6118,12 +6830,15 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - run = client.beta.threads.runs.create( + message = client.beta.threads.messages.update( + message_id="msg_abc12", thread_id="thread_abc123", - assistant_id="asst_abc123" + metadata={ + "modified": "true", + "user": "abc123", + }, ) - - print(run) + print(message) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -6134,78 +6849,65 @@ paths: }); async function main() { - const run = await client.beta.threads.runs.create( + const message = await client.beta.threads.messages.update( "thread_abc123", - { assistant_id: "asst_abc123" } - ); - - console.log(run); - } - - main(); - response: &run_object_example | + "msg_abc123", + { + metadata: { + modified: "true", + user: "abc123", + }, + } + }' + response: | { - "id": "run_abc123", - "object": "thread.run", - "created_at": 1699063290, - "assistant_id": "asst_abc123", + "id": "msg_abc123", + "object": "thread.message", + "created_at": 1699017614, + "assistant_id": null, "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": [ + "run_id": null, + "role": "user", + "content": [ { - "type": "code_interpreter" + "type": "text", + "text": { + "value": "How does AI work? Explain it in simple terms.", + "annotations": [] + } } ], - "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 + "file_ids": [], + "metadata": { + "modified": "true", + "user": "abc123" + } } - - /threads/{thread_id}/runs/{run_id}: - get: - operationId: getRun + delete: + operationId: deleteMessage tags: - Assistants - summary: Retrieves a run. + summary: Deletes 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) that was run. + description: The ID of the thread to which this message belongs. - in: path - name: run_id + name: message_id required: true schema: type: string - description: The ID of the run to retrieve. + description: The ID of the message to delete. responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/RunObject" + $ref: "#/components/schemas/DeleteMessageResponse" security: - Portkey-Key: [] @@ -6223,7 +6925,8 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_abc123/runs/run_abc123 \ + 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" @@ -6236,12 +6939,11 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - run = client.beta.threads.runs.retrieve( + deleted_message = client.beta.threads.messages.delete( + message_id="msg_abc12", thread_id="thread_abc123", - run_id="run_abc123" ) - - print(run) + print(deleted_message) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -6252,79 +6954,32 @@ paths: }); async function main() { - const run = await client.beta.threads.runs.retrieve( + const deletedMessage = await client.beta.threads.messages.del( "thread_abc123", - "run_abc123" + "msg_abc123" ); - console.log(run); + console.log(deletedMessage); } - - 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 + "id": "msg_abc123", + "object": "thread.message.deleted", + "deleted": true } + + /threads/runs: post: - operationId: modifyRun + operationId: createThreadAndRun 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. + summary: Create a thread and run it in one request. requestBody: required: true content: application/json: schema: - $ref: "#/components/schemas/ModifyRunRequest" + $ref: "#/components/schemas/CreateThreadAndRunRequest" responses: "200": description: OK @@ -6349,32 +7004,38 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_abc123/runs/run_abc123 \ + 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 '{ - "metadata": { - "user_id": "user_abc123" - } - }' + "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" - ) + 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"}, - ) + 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) + print(run) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -6385,15 +7046,14 @@ paths: }); async function main() { - const run = await client.beta.threads.runs.update( - "thread_abc123", - "run_abc123", - { - metadata: { - user_id: "user_abc123", - }, - } - ); + 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); } @@ -6403,86 +7063,81 @@ paths: { "id": "run_abc123", "object": "thread.run", - "created_at": 1699075072, + "created_at": 1699076792, "assistant_id": "asst_abc123", "thread_id": "thread_abc123", - "status": "completed", - "started_at": 1699075072, - "expires_at": null, + "status": "queued", + "started_at": null, + "expires_at": 1699077392, "cancelled_at": null, "failed_at": null, - "completed_at": 1699075073, + "completed_at": null, + "required_action": null, "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 - }, + "instructions": "You are a helpful assistant.", + "tools": [], + "tool_resources": {}, + "metadata": {}, "temperature": 1.0, "top_p": 1.0, - "max_prompt_tokens": 1000, - "max_completion_tokens": 1000, + "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/{run_id}/submit_tool_outputs: - post: - operationId: submitToolOuputsToRun + /threads/{thread_id}/runs: + get: + operationId: listRuns 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. + summary: Returns a list of runs belonging to a thread. parameters: - - in: path - name: thread_id + - name: thread_id + in: path required: true schema: type: string - description: The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) to which this run belongs. - - in: path - name: run_id - required: true + 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 - 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" + $ref: "#/components/schemas/ListRunsResponse" security: - Portkey-Key: [] @@ -6500,40 +7155,25 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_123/runs/run_123/submit_tool_outputs \ + 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 '{ - "tool_outputs": [ - { - "tool_call_id": "call_001", - "output": "70 degrees and sunny." - } - ] - }' + -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" - ) + 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." - } - ] - ) + runs = client.beta.threads.runs.list( + "thread_abc123" + ) - print(run) + print(runs) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -6544,103 +7184,135 @@ paths: }); 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.", - }, - ], - } + const runs = await client.beta.threads.runs.list( + "thread_abc123" ); - console.log(run); + console.log(runs); } 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": [ + "object": "list", + "data": [ { - "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"] + "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 } ], - "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 + "first_id": "run_abc123", + "last_id": "run_abc456", + "has_more": false } - - /threads/{thread_id}/runs/{run_id}/cancel: post: - operationId: cancelRun + operationId: createRun tags: - Assistants - summary: Cancels a run that is `in_progress`. + summary: Create a run. 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" + description: The ID of the thread to run. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CreateRunRequest" security: - Portkey-Key: [] @@ -6655,14 +7327,24 @@ paths: 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/run_abc123/cancel \ + 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" \ - -X POST + -d '{ + "assistant_id": "asst_abc123" + }' - lang: python source: | from portkey_ai import Portkey @@ -6672,9 +7354,9 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - run = client.beta.threads.runs.cancel( + run = client.beta.threads.runs.create( thread_id="thread_abc123", - run_id="run_abc123" + assistant_id="asst_abc123" ) print(run) @@ -6688,100 +7370,78 @@ paths: }); async function main() { - const run = await client.beta.threads.runs.cancel( + const run = await client.beta.threads.runs.create( "thread_abc123", - "run_abc123" + { assistant_id: "asst_abc123" } ); console.log(run); } main(); - response: | + response: &run_object_example | { "id": "run_abc123", "object": "thread.run", - "created_at": 1699076126, + "created_at": 1699063290, "assistant_id": "asst_abc123", "thread_id": "thread_abc123", - "status": "cancelling", - "started_at": 1699076126, - "expires_at": 1699076726, + "status": "queued", + "started_at": 1699063290, + "expires_at": null, "cancelled_at": null, "failed_at": null, - "completed_at": null, + "completed_at": 1699063291, "last_error": null, "model": "gpt-4-turbo", - "instructions": "You summarize books.", + "instructions": null, + "incomplete_details": null, "tools": [ { - "type": "file_search" + "type": "code_interpreter" } ], - "tool_resources": { - "file_search": { - "vector_store_ids": ["vs_123"] - } - }, "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}/steps: + /threads/{thread_id}/runs/{run_id}: get: - operationId: listRunSteps + operationId: getRun tags: - Assistants - summary: Returns a list of run steps belonging to a run. + summary: Retrieves a run. parameters: - - name: thread_id - in: path + - in: path + name: thread_id required: true schema: type: string - description: The ID of the thread the run and run steps belong to. - - name: run_id - in: path + 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 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 + description: The ID of the run to retrieve. responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/ListRunStepsResponse" + $ref: "#/components/schemas/RunObject" security: - Portkey-Key: [] @@ -6799,10 +7459,9 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_abc123/runs/run_abc123/steps \ + 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" - lang: python source: | @@ -6813,12 +7472,12 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - run_steps = client.beta.threads.runs.steps.list( - thread_id="thread_abc123", - run_id="run_abc123" - ) + run = client.beta.threads.runs.retrieve( + thread_id="thread_abc123", + run_id="run_abc123" + ) - print(run_steps) + print(run) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -6829,82 +7488,86 @@ paths: }); async function main() { - const runStep = await client.beta.threads.runs.steps.list( + const run = await client.beta.threads.runs.retrieve( "thread_abc123", "run_abc123" ); - console.log(runStep); + + console.log(run); } 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": [ { - "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 - } + "type": "code_interpreter" } ], - "first_id": "step_abc123", - "last_id": "step_abc456", - "has_more": false + "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 } - - /threads/{thread_id}/runs/{run_id}/steps/{step_id}: - get: - operationId: getRunStep + post: + operationId: modifyRun tags: - Assistants - summary: Retrieves a run step. + summary: Modifies a run. 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. + 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 which the run step belongs. - - in: path - name: step_id - required: true - schema: - type: string - description: The ID of the run step to retrieve. + 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/RunStepObject" + $ref: "#/components/schemas/RunObject" security: - Portkey-Key: [] @@ -6922,11 +7585,16 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/threads/thread_abc123/runs/run_abc123/steps/step_abc123 \ + 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" + -H "OpenAI-Beta: assistants=v2" \ + -d '{ + "metadata": { + "user_id": "user_abc123" + } + }' - lang: python source: | from portkey_ai import Portkey @@ -6936,13 +7604,13 @@ paths: 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" + run = client.beta.threads.runs.update( + thread_id="thread_abc123", + run_id="run_abc123", + metadata={"user_id": "user_abc123"}, ) - print(run_step) + print(run) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -6953,81 +7621,104 @@ paths: }); async function main() { - const runStep = await client.beta.threads.runs.steps.retrieve( + const run = await client.beta.threads.runs.update( "thread_abc123", "run_abc123", - "step_abc123" + { + metadata: { + user_id: "user_abc123", + }, + } ); - console.log(runStep); + + console.log(run); } main(); - response: &run_step_object_example | + response: | { - "id": "step_abc123", - "object": "thread.run.step", - "created_at": 1699063291, - "run_id": "run_abc123", + "id": "run_abc123", + "object": "thread.run", + "created_at": 1699075072, "assistant_id": "asst_abc123", "thread_id": "thread_abc123", - "type": "message_creation", "status": "completed", + "started_at": 1699075072, + "expires_at": null, "cancelled_at": null, - "completed_at": 1699063291, - "expired_at": null, "failed_at": null, + "completed_at": 1699075073, "last_error": null, - "step_details": { - "type": "message_creation", - "message_creation": { - "message_id": "msg_abc123" + "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 } - /vector_stores: - get: - operationId: listVectorStores + /threads/{thread_id}/runs/{run_id}/submit_tool_outputs: + post: + operationId: submitToolOuputsToRun tags: - - Vector Stores - summary: Returns a list of vector stores. + - 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: - - 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 + - in: path + name: thread_id + required: true schema: type: string - - name: before - in: query - description: *pagination_before_param_description + 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/ListVectorStoresResponse" + $ref: "#/components/schemas/RunObject" security: - Portkey-Key: [] @@ -7045,92 +7736,147 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores \ + 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" + -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" - ) - - vector_stores = client.beta.vector_stores.list() - print(vector_stores) - - lang: javascript - source: | - import Portkey from 'portkey-ai'; + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" + ) - const client = new Portkey({ - apiKey: 'PORTKEY_API_KEY', - virtualKey: '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 vectorStores = await client.beta.vectorStores.list(); - console.log(vectorStores); + 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: | { - "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": "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": [ { - "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 + "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"] + } } } ], - "first_id": "vs_abc123", - "last_id": "vs_abc456", - "has_more": false + "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: post: - operationId: createVectorStore + operationId: cancelRun tags: - - Vector Stores - summary: Create a vector store. - requestBody: - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/CreateVectorStoreRequest" + - 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/VectorStoreObject" + $ref: "#/components/schemas/RunObject" security: - Portkey-Key: [] @@ -7148,14 +7894,11 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores \ + 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 "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v2" - -d '{ - "name": "Support FAQ" - }' + -H "OpenAI-Beta: assistants=v2" \ + -X POST - lang: python source: | from portkey_ai import Portkey @@ -7165,10 +7908,12 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - vector_store = client.beta.vector_stores.create( - name="Support FAQ" + run = client.beta.threads.runs.cancel( + thread_id="thread_abc123", + run_id="run_abc123" ) - print(vector_store) + + print(run) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -7179,49 +7924,100 @@ paths: }); async function main() { - const vectorStore = await client.beta.vectorStores.create({ - name: "Support FAQ" - }); - console.log(vectorStore); + const run = await client.beta.threads.runs.cancel( + "thread_abc123", + "run_abc123" + ); + + console.log(run); } 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 - } + "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 } - /vector_stores/{vector_store_id}: + /threads/{thread_id}/runs/{run_id}/steps: get: - operationId: getVectorStore + operationId: listRunSteps tags: - - Vector Stores - summary: Retrieves a vector store. + - Assistants + summary: Returns a list of run steps belonging to a run. parameters: - - in: path - name: vector_store_id + - name: thread_id + in: path required: true schema: type: string - description: The ID of the vector store to retrieve. + 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/VectorStoreObject" + $ref: "#/components/schemas/ListRunStepsResponse" security: - Portkey-Key: [] @@ -7239,7 +8035,7 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores/vs_abc123 \ + 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" \ @@ -7253,10 +8049,12 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - vector_store = client.beta.vector_stores.retrieve( - vector_store_id="vs_abc123" + run_steps = client.beta.threads.runs.steps.list( + thread_id="thread_abc123", + run_id="run_abc123" ) - print(vector_store) + + print(run_steps) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -7267,138 +8065,82 @@ paths: }); async function main() { - const vectorStore = await client.beta.vectorStores.retrieve( - "vs_abc123" + const runStep = await client.beta.threads.runs.steps.list( + "thread_abc123", + "run_abc123" ); - console.log(vectorStore); + console.log(runStep); } main(); response: | { - "id": "vs_abc123", - "object": "vector_store", - "created_at": 1699061776 + "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 } - post: - operationId: modifyVectorStore + + /threads/{thread_id}/runs/{run_id}/steps/{step_id}: + get: + operationId: getRunStep tags: - - Vector Stores - summary: Modifies a vector store. + - Assistants + summary: Retrieves a run step. parameters: - in: path - name: vector_store_id + name: thread_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: + description: The ID of the thread to which the run and run step belongs. - in: path - name: vector_store_id + name: run_id required: true schema: type: string - description: The ID of the vector store to delete. + 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/DeleteVectorStoreResponse" + $ref: "#/components/schemas/RunStepObject" security: - Portkey-Key: [] @@ -7416,12 +8158,11 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores/vs_abc123 \ + 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" \ - -X DELETE + -H "OpenAI-Beta: assistants=v2" - lang: python source: | from portkey_ai import Portkey @@ -7431,10 +8172,13 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - deleted_vector_store = client.beta.vector_stores.delete( - vector_store_id="vs_abc123" + run_step = client.beta.threads.runs.steps.retrieve( + thread_id="thread_abc123", + run_id="run_abc123", + step_id="step_abc123" ) - print(deleted_vector_store) + + print(run_step) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -7445,33 +8189,50 @@ paths: }); async function main() { - const deletedVectorStore = await client.beta.vectorStores.del( - "vs_abc123" + const runStep = await client.beta.threads.runs.steps.retrieve( + "thread_abc123", + "run_abc123", + "step_abc123" ); - console.log(deletedVectorStore); + console.log(runStep); } main(); - response: | + response: &run_step_object_example | { - "id": "vs_abc123", - "object": "vector_store.deleted", - "deleted": true + "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/{vector_store_id}/files: + /vector_stores: get: - operationId: listVectorStoreFiles + operationId: listVectorStores tags: - Vector Stores - summary: Returns a list of vector store files. + summary: Returns a list of vector stores. 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 @@ -7496,19 +8257,13 @@ paths: 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" + $ref: "#/components/schemas/ListVectorStoresResponse" security: - Portkey-Key: [] @@ -7526,7 +8281,7 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files \ + 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" \ @@ -7540,10 +8295,8 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - vector_store_files = client.beta.vector_stores.files.list( - vector_store_id="vs_abc123" - ) - print(vector_store_files) + vector_stores = client.beta.vector_stores.list() + print(vector_stores) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -7554,10 +8307,8 @@ paths: }); async function main() { - const vectorStoreFiles = await client.beta.vectorStores.files.list( - "vs_abc123" - ); - console.log(vectorStoreFiles); + const vectorStores = await client.beta.vectorStores.list(); + console.log(vectorStores); } main(); @@ -7566,49 +8317,56 @@ paths: "object": "list", "data": [ { - "id": "file-abc123", - "object": "vector_store.file", + "id": "vs_abc123", + "object": "vector_store", "created_at": 1699061776, - "vector_store_id": "vs_abc123" + "name": "Support FAQ", + "bytes": 139920, + "file_counts": { + "in_progress": 0, + "completed": 3, + "failed": 0, + "cancelled": 0, + "total": 3 + } }, { - "id": "file-abc456", - "object": "vector_store.file", + "id": "vs_abc456", + "object": "vector_store", "created_at": 1699061776, - "vector_store_id": "vs_abc123" + "name": "Support FAQ v2", + "bytes": 139920, + "file_counts": { + "in_progress": 0, + "completed": 3, + "failed": 0, + "cancelled": 0, + "total": 3 + } } ], - "first_id": "file-abc123", - "last_id": "file-abc456", + "first_id": "vs_abc123", + "last_id": "vs_abc456", "has_more": false } post: - operationId: createVectorStoreFile + operationId: createVectorStore 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. + summary: Create a vector store. requestBody: required: true content: application/json: schema: - $ref: "#/components/schemas/CreateVectorStoreFileRequest" + $ref: "#/components/schemas/CreateVectorStoreRequest" responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/VectorStoreFileObject" + $ref: "#/components/schemas/VectorStoreObject" security: - Portkey-Key: [] @@ -7626,14 +8384,14 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files \ + 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" \ + -H "OpenAI-Beta: assistants=v2" -d '{ - "file_id": "file-abc123" - }' + "name": "Support FAQ" + }' - lang: python source: | from portkey_ai import Portkey @@ -7643,11 +8401,10 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - vector_store_file = client.beta.vector_stores.files.create( - vector_store_id="vs_abc123", - file_id="file-abc123" + vector_store = client.beta.vector_stores.create( + name="Support FAQ" ) - print(vector_store_file) + print(vector_store) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -7658,55 +8415,49 @@ paths: }); async function main() { - const myVectorStoreFile = await client.beta.vectorStores.files.create( - "vs_abc123", - { - file_id: "file-abc123" - } - ); - console.log(myVectorStoreFile); + const vectorStore = await client.beta.vectorStores.create({ + name: "Support FAQ" + }); + console.log(vectorStore); } main(); response: | { - "id": "file-abc123", - "object": "vector_store.file", + "id": "vs_abc123", + "object": "vector_store", "created_at": 1699061776, - "usage_bytes": 1234, - "vector_store_id": "vs_abcd", - "status": "completed", - "last_error": null + "name": "Support FAQ", + "bytes": 139920, + "file_counts": { + "in_progress": 0, + "completed": 3, + "failed": 0, + "cancelled": 0, + "total": 3 + } } - /vector_stores/{vector_store_id}/files/{file_id}: + /vector_stores/{vector_store_id}: get: - operationId: getVectorStoreFile + operationId: getVectorStore tags: - Vector Stores - summary: Retrieves a vector store file. + summary: Retrieves a vector store. 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. + description: The ID of the vector store to retrieve. responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/VectorStoreFileObject" + $ref: "#/components/schemas/VectorStoreObject" security: - Portkey-Key: [] @@ -7724,7 +8475,7 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files/file-abc123 \ + 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" \ @@ -7738,11 +8489,10 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - vector_store_file = client.beta.vector_stores.files.retrieve( - vector_store_id="vs_abc123", - file_id="file-abc123" + vector_store = client.beta.vector_stores.retrieve( + vector_store_id="vs_abc123" ) - print(vector_store_file) + print(vector_store) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -7753,48 +8503,44 @@ paths: }); async function main() { - const vectorStoreFile = await client.beta.vectorStores.files.retrieve( - "vs_abc123", - "file-abc123" + const vectorStore = await client.beta.vectorStores.retrieve( + "vs_abc123" ); - console.log(vectorStoreFile); + console.log(vectorStore); } main(); response: | { - "id": "file-abc123", - "object": "vector_store.file", - "created_at": 1699061776, - "vector_store_id": "vs_abcd", - "status": "completed", - "last_error": null + "id": "vs_abc123", + "object": "vector_store", + "created_at": 1699061776 } - delete: - operationId: deleteVectorStoreFile + post: + operationId: modifyVectorStore 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. + summary: Modifies a vector store. 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. + 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/DeleteVectorStoreFileResponse" + $ref: "#/components/schemas/VectorStoreObject" security: - Portkey-Key: [] @@ -7812,12 +8558,14 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files/file-abc123 \ + 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 + -H "OpenAI-Beta: assistants=v2" + -d '{ + "name": "Support FAQ" + }' - lang: python source: | from portkey_ai import Portkey @@ -7827,11 +8575,11 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - deleted_vector_store_file = client.beta.vector_stores.files.delete( - vector_store_id="vs_abc123", - file_id="file-abc123" + vector_store = client.beta.vector_stores.update( + vector_store_id="vs_abc123", + name="Support FAQ" ) - print(deleted_vector_store_file) + print(vector_store) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -7842,49 +8590,51 @@ paths: }); async function main() { - const deletedVectorStoreFile = await client.beta.vectorStores.files.del( + const vectorStore = await client.beta.vectorStores.update( "vs_abc123", - "file-abc123" + { + name: "Support FAQ" + } ); - console.log(deletedVectorStoreFile); + console.log(vectorStore); } main(); response: | { - "id": "file-abc123", - "object": "vector_store.file.deleted", - "deleted": true + "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}/file_batches: - post: - operationId: createVectorStoreFileBatch + delete: + operationId: deleteVectorStore tags: - Vector Stores - summary: Create a vector store file batch. + summary: Delete a vector store. 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" + description: The ID of the vector store to delete. responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/VectorStoreFileBatchObject" + $ref: "#/components/schemas/DeleteVectorStoreResponse" security: - Portkey-Key: [] @@ -7902,14 +8652,12 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores/vs_abc123/file_batches \ + 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 "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" \ - -d '{ - "file_ids": ["file-abc123", "file-abc456"] - }' + -X DELETE - lang: python source: | from portkey_ai import Portkey @@ -7919,11 +8667,10 @@ paths: 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"] + deleted_vector_store = client.beta.vector_stores.delete( + vector_store_id="vs_abc123" ) - print(vector_store_file_batch) + print(deleted_vector_store) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -7934,60 +8681,70 @@ paths: }); async function main() { - const myVectorStoreFileBatch = await client.beta.vectorStores.fileBatches.create( - "vs_abc123", - { - file_ids: ["file-abc123", "file-abc456"] - } + const deletedVectorStore = await client.beta.vectorStores.del( + "vs_abc123" ); - console.log(myVectorStoreFileBatch); + console.log(deletedVectorStore); } 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, - } + "id": "vs_abc123", + "object": "vector_store.deleted", + "deleted": true } - /vector_stores/{vector_store_id}/file_batches/{batch_id}: + /vector_stores/{vector_store_id}/files: get: - operationId: getVectorStoreFileBatch + operationId: listVectorStoreFiles tags: - Vector Stores - summary: Retrieves a vector store file batch. + summary: Returns a list of vector store files. parameters: - - in: path - name: vector_store_id + - name: vector_store_id + in: path + description: The ID of the vector store that the files belong to. 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 + - 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 - example: vsfb_abc123 - description: The ID of the file batch being retrieved. + 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/VectorStoreFileBatchObject" + $ref: "#/components/schemas/ListVectorStoreFilesResponse" security: - Portkey-Key: [] @@ -8005,7 +8762,7 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123 \ + 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" \ @@ -8019,11 +8776,10 @@ paths: 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" + vector_store_files = client.beta.vector_stores.files.list( + vector_store_id="vs_abc123" ) - print(vector_store_file_batch) + print(vector_store_files) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -8034,56 +8790,61 @@ paths: }); async function main() { - const vectorStoreFileBatch = await client.beta.vectorStores.fileBatches.retrieve( - "vs_abc123", - "vsfb_abc123" + const vectorStoreFiles = await client.beta.vectorStores.files.list( + "vs_abc123" ); - console.log(vectorStoreFileBatch); + console.log(vectorStoreFiles); } 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, - } + "object": "list", + "data": [ + { + "id": "file-abc123", + "object": "vector_store.file", + "created_at": 1699061776, + "vector_store_id": "vs_abc123" + }, + { + "id": "file-abc456", + "object": "vector_store.file", + "created_at": 1699061776, + "vector_store_id": "vs_abc123" + } + ], + "first_id": "file-abc123", + "last_id": "file-abc456", + "has_more": false } - - /vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel: post: - operationId: cancelVectorStoreFileBatch + operationId: createVectorStoreFile 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. + 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 - 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. + 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/VectorStoreFileBatchObject" + $ref: "#/components/schemas/VectorStoreFileObject" security: - Portkey-Key: [] @@ -8101,12 +8862,14 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/cancel \ + 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" \ - -X POST + -d '{ + "file_id": "file-abc123" + }' - lang: python source: | from portkey_ai import Portkey @@ -8116,11 +8879,11 @@ paths: 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" + vector_store_file = client.beta.vector_stores.files.create( + vector_store_id="vs_abc123", + file_id="file-abc123" ) - print(deleted_vector_store_file_batch) + print(vector_store_file) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -8131,86 +8894,55 @@ paths: }); async function main() { - const deletedVectorStoreFileBatch = await client.vector_stores.fileBatches.cancel( + const myVectorStoreFile = await client.beta.vectorStores.files.create( "vs_abc123", - "vsfb_abc123" + { + file_id: "file-abc123" + } ); - console.log(deletedVectorStoreFileBatch); + console.log(myVectorStoreFile); } main(); response: | { - "id": "vsfb_abc123", - "object": "vector_store.file_batch", + "id": "file-abc123", + "object": "vector_store.file", "created_at": 1699061776, - "vector_store_id": "vs_abc123", - "status": "cancelling", - "file_counts": { - "in_progress": 12, - "completed": 3, - "failed": 0, - "cancelled": 0, - "total": 15, - } + "usage_bytes": 1234, + "vector_store_id": "vs_abcd", + "status": "completed", + "last_error": null } - /vector_stores/{vector_store_id}/file_batches/{batch_id}/files: + /vector_stores/{vector_store_id}/files/{file_id}: get: - operationId: listFilesInVectorStoreBatch + operationId: getVectorStoreFile tags: - Vector Stores - summary: Returns a list of vector store files in a batch. + summary: Retrieves a vector store file. parameters: - - name: vector_store_id - in: path - description: The ID of the vector store that the files belong to. + - in: path + name: vector_store_id required: true schema: type: string - - name: batch_id - in: path - description: The ID of the file batch that the files belong to. + 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 - - 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"] + example: file-abc123 + description: The ID of the file being retrieved. responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/ListVectorStoreFilesResponse" + $ref: "#/components/schemas/VectorStoreFileObject" security: - Portkey-Key: [] @@ -8228,7 +8960,7 @@ paths: x-code-samples: - lang: curl source: | - curl https://api.portkey.ai/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/files \ + 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" \ @@ -8242,11 +8974,11 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - vector_store_files = client.beta.vector_stores.file_batches.list_files( + vector_store_file = client.beta.vector_stores.files.retrieve( vector_store_id="vs_abc123", - batch_id="vsfb_abc123" + file_id="file-abc123" ) - print(vector_store_files) + print(vector_store_file) - lang: javascript source: | import Portkey from 'portkey-ai'; @@ -8257,62 +8989,48 @@ paths: }); async function main() { - const vectorStoreFiles = await client.beta.vectorStores.fileBatches.listFiles( + const vectorStoreFile = await client.beta.vectorStores.files.retrieve( "vs_abc123", - "vsfb_abc123" + "file-abc123" ); - console.log(vectorStoreFiles); + console.log(vectorStoreFile); } 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 + "id": "file-abc123", + "object": "vector_store.file", + "created_at": 1699061776, + "vector_store_id": "vs_abcd", + "status": "completed", + "last_error": null } - - /batches: - post: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 - 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" + 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: Batch created successfully. + description: OK content: application/json: schema: - $ref: "#/components/schemas/Batch" + $ref: "#/components/schemas/DeleteVectorStoreFileResponse" security: - Portkey-Key: [] @@ -8329,19 +9047,14 @@ paths: x-code-samples: - lang: curl - label: Default source: | - curl https://api.portkey.ai/v1/batches \ + 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" \ - -d '{ - "input_file_id": "file-abc123", - "endpoint": "/v1/chat/completions", - "completion_window": "24h" - }' + -H "OpenAI-Beta: assistants=v2" \ + -X DELETE - lang: python - label: Default source: | from portkey_ai import Portkey @@ -8350,13 +9063,12 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - client.batches.create( - input_file_id="file-abc123", - endpoint="/v1/chat/completions", - completion_window="24h" + 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 - label: Default source: | import Portkey from 'portkey-ai'; @@ -8366,96 +9078,152 @@ paths: }); async function main() { - const batch = await client.batches.create({ - input_file_id: "file-abc123", - endpoint: "/v1/chat/completions", - completion_window: "24h" - }); - - console.log(batch); + 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 - label: Self-Hosted source: | - curl SELF_HOSTED_GATEWAY_URL/v1/batches \ + 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 "Content-Type: application/json \ + -H "OpenAI-Beta: assistants=v2" \ -d '{ - "input_file_id": "file-abc123", - "endpoint": "/v1/chat/completions", - "completion_window": "24h" + "file_ids": ["file-abc123", "file-abc456"] }' - 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" + 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 - 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); + 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: listBatches - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL + operationId: getVectorStoreFileBatch tags: - - Batch - summary: List your organization's batches. + - Vector Stores + summary: Retrieves a vector store file batch. parameters: - - in: query - name: after - required: false + - in: path + name: vector_store_id + required: true schema: type: string - description: *pagination_after_param_description - - name: limit - in: query - description: *pagination_limit_param_description - required: false + 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: integer - default: 20 + type: string + example: vsfb_abc123 + description: The ID of the file batch being retrieved. responses: "200": - description: Batch listed successfully. + description: OK content: application/json: schema: - $ref: "#/components/schemas/ListBatchesResponse" + $ref: "#/components/schemas/VectorStoreFileBatchObject" security: - Portkey-Key: [] @@ -8472,14 +9240,13 @@ paths: x-code-samples: - lang: curl - label: Default source: | - curl https://api.portkey.ai/v1/batches?limit=2 \ + 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 "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v2" - lang: python - label: Default source: | from portkey_ai import Portkey @@ -8488,9 +9255,12 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - client.batches.list() + 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 - label: Default source: | import Portkey from 'portkey-ai'; @@ -8500,77 +9270,56 @@ paths: }); async function main() { - const list = await client.batches.list(); - - for await (const batch of list) { - console.log(batch); - } + const vectorStoreFileBatch = await client.beta.vectorStores.fileBatches.retrieve( + "vs_abc123", + "vsfb_abc123" + ); + console.log(vectorStoreFileBatch); } main(); - - lang: curl - label: Self-Hosted - source: | - curl SELF_HOSTED_GATEWAY_URL/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: Self-Hosted - source: | - from portkey_ai import Portkey + 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, + } + } - 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}: - get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 - operationId: retrieveBatch + /vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel: + post: + operationId: cancelVectorStoreFileBatch tags: - - Batch - summary: Retrieves a batch. + - 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 batch to retrieve. + description: The ID of the file batch to cancel. responses: "200": - description: Batch retrieved successfully. + description: OK content: application/json: schema: - $ref: "#/components/schemas/Batch" + $ref: "#/components/schemas/VectorStoreFileBatchObject" security: - Portkey-Key: [] @@ -8587,14 +9336,14 @@ paths: x-code-samples: - lang: curl - label: Default source: | - curl https://api.portkey.ai/v1/batches/batch_abc123 \ + 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 - label: Default source: | from portkey_ai import Portkey @@ -8603,9 +9352,12 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - client.batches.retrieve("batch_abc123") + 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 - label: Default source: | import Portkey from 'portkey-ai'; @@ -8615,69 +9367,184 @@ paths: }); async function main() { - const batch = await client.batches.retrieve("batch_abc123"); - - console.log(batch); + 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 - label: Self-Hosted source: | - curl SELF_HOSTED_GATEWAY_URL/v1/batches/batch_abc123 \ + 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 - 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") + 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 - 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); + 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/{batch_id}/cancel: + /batches: post: - operationId: cancelBatch servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL + - url: SELF_HOSTED_GATEWAY_URL/v1 + summary: Creates and executes a batch from an uploaded file of requests + operationId: createBatch 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. + 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 is cancelling. Returns the cancelling batch's details. + description: Batch created successfully. content: application/json: schema: @@ -8700,11 +9567,15 @@ paths: - lang: curl label: Default source: | - curl https://api.portkey.ai/v1/batches/batch_abc123/cancel \ + 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" \ - -X POST + -d '{ + "input_file_id": "file-abc123", + "endpoint": "/v1/chat/completions", + "completion_window": "24h" + }' - lang: python label: Default source: | @@ -8715,7 +9586,11 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - client.batches.cancel("batch_abc123") + client.batches.create( + input_file_id="file-abc123", + endpoint="/v1/chat/completions", + completion_window="24h" + ) - lang: javascript label: Default source: | @@ -8727,7 +9602,11 @@ paths: }); async function main() { - const batch = await client.batches.cancel("batch_abc123"); + const batch = await client.batches.create({ + input_file_id: "file-abc123", + endpoint: "/v1/chat/completions", + completion_window: "24h" + }); console.log(batch); } @@ -8736,11 +9615,15 @@ paths: - lang: curl label: Self-Hosted source: | - curl SELF_HOSTED_GATEWAY_URL/v1/batches/batch_abc123/cancel \ + curl SELF_HOSTED_GATEWAY_URL/v1/batches \ -H "x-portkey-api-key: $PORTKEY_API_KEY" \ -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ -H "Content-Type: application/json" \ - -X POST + -d '{ + "input_file_id": "file-abc123", + "endpoint": "/v1/chat/completions", + "completion_window": "24h" + }' - lang: python label: Self-Hosted source: | @@ -8752,8 +9635,12 @@ paths: virtual_key = "PROVIDER_VIRTUAL_KEY" ) - client.batches.cancel("batch_abc123") - - lang: javascript + 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'; @@ -8765,404 +9652,374 @@ paths: }); async function main() { - const batch = await client.batches.cancel("batch_abc123"); + const batch = await client.batches.create({ + input_file_id: "file-abc123", + endpoint: "/v1/chat/completions", + completion_window: "24h" + }); console.log(batch); } main(); - /configs: get: + operationId: listBatches servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - summary: List all configs + - url: SELF_HOSTED_GATEWAY_URL tags: - - Configs - operationId: listConfigs + - 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: A list of configs + description: Batch listed successfully. content: application/json: schema: - type: object - properties: - success: - type: boolean - data: - type: array - items: - 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", - }, - ], - } + $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 - # Initialize the Portkey client - portkey = Portkey( - api_key="PORTKEY_API_KEY", - ) - - # Retrieve the configuration - config = portkey.configs.list( - workspace_id="WORKSPACE_ID" + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" ) - print(config) + client.batches.list() - lang: javascript label: Default source: | - import { Portkey } from "portkey-ai"; + import Portkey from 'portkey-ai'; - const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", - }) + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - const config=await portkey.configs.list({ - workspace_id:"WORKSPACE_ID" - }) - console.log(config); + 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/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: 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" + client = Portkey( + api_key = "PORTKEY_API_KEY", + base_url = "SELF_HOSTED_GATEWAY_URL", + virtual_key = "PROVIDER_VIRTUAL_KEY" ) - print(config) + client.batches.list() - lang: javascript label: Self-Hosted source: | - import { Portkey } from "portkey-ai"; + import Portkey from 'portkey-ai'; - const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", - baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" - }) + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - const config=await portkey.configs.list({ - workspace_id:"WORKSPACE_ID" - }) - console.log(config); - post: + async function main() { + const list = await client.batches.list(); + + for await (const batch of list) { + console.log(batch); + } + } + + main(); + + /batches/{batch_id}: + get: servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - summary: Create a config + - url: SELF_HOSTED_GATEWAY_URL/v1 + operationId: retrieveBatch 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, - } + - 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: Config created successfully + description: Batch retrieved 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", - }, - } + $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 - 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", + client = Portkey( + api_key = "PORTKEY_API_KEY", + virtual_key = "PROVIDER_VIRTUAL_KEY" ) - print(config) + client.batches.retrieve("batch_abc123") - lang: javascript label: Default source: | - import { Portkey } from "portkey-ai"; + import Portkey from 'portkey-ai'; - const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", - }) + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - const config=await portkey.configs.create({ - name:"ConfigName_0909", - config:{ - "retry": { - "attempts": 3 - }, - "cache": { - "mode": "simple" - } - }, - workspace_id:"WORKSPACE_ID" - }) + async function main() { + const batch = await client.batches.retrieve("batch_abc123"); - console.log(config); + console.log(batch); + } + + main(); + - lang: curl + label: Self-Hosted + source: | + curl SELF_HOSTED_GATEWAY_URL/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: 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", + client = Portkey( + api_key = "PORTKEY_API_KEY", + base_url = "SELF_HOSTED_GATEWAY_URL", + virtual_key = "PROVIDER_VIRTUAL_KEY" ) - print(config) + client.batches.retrieve("batch_abc123") - lang: javascript label: Self-Hosted source: | - import { Portkey } from "portkey-ai"; + import Portkey from 'portkey-ai'; - const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", - baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" - }) + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - const config=await portkey.configs.create({ - name:"ConfigName_0909", - config:{ - "retry": { - "attempts": 3 - }, - "cache": { - "mode": "simple" - } - }, - workspace_id:"WORKSPACE_ID" - }) + async function main() { + const batch = await client.batches.retrieve("batch_abc123"); - console.log(config); + console.log(batch); + } - /configs/{slug}: - delete: + main(); + + /batches/{batch_id}/cancel: + post: + operationId: cancelBatch servers: - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - summary: Delete a config + - url: SELF_HOSTED_GATEWAY_URL tags: - - Configs - operationId: deleteConfig + - 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: - - name: slug - in: path + - in: path + name: batch_id required: true schema: type: string + description: The ID of the batch to cancel. responses: "200": - description: Config deleted successfully + description: Batch is cancelling. Returns the cancelling batch's details. content: application/json: schema: - type: object - examples: - example-1: - value: - {} + $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: | - portkey = Portkey( - api_key="PORTKEY_API_KEY", - ) + from portkey_ai import Portkey - portkey.configs.delete( - id="CONFIG_SLUG" + 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"; + import Portkey from 'portkey-ai'; - const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", - }) + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - await portkey.configs.delete({ - id:"CONFIG_SLUG" - }) + 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/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: Self-Hosted source: | from portkey_ai import Portkey - portkey = Portkey( - api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + client = Portkey( + api_key = "PORTKEY_API_KEY", + base_url = "SELF_HOSTED_GATEWAY_URL", + virtual_key = "PROVIDER_VIRTUAL_KEY" ) - portkey.configs.delete( - id="CONFIG_SLUG" - ) + client.batches.cancel("batch_abc123") - lang: javascript label: Self-Hosted source: | - import { Portkey } from "portkey-ai"; + import Portkey from 'portkey-ai'; - const portkey = new Portkey({ - apiKey:"PORTKEY_API_KEY", - baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" - }) + const client = new Portkey({ + apiKey: 'PORTKEY_API_KEY', + baseUrl: 'SELF_HOSTED_GATEWAY_URL', + virtualKey: 'PROVIDER_VIRTUAL_KEY' + }); - await portkey.configs.delete({ - id:"CONFIG_SLUG" - }) + async function main() { + const batch = await client.batches.cancel("batch_abc123"); + + console.log(batch); + } + + main(); + + /configs: get: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - summary: Get a config + summary: List all configs tags: - Configs - operationId: getConfig - parameters: - - name: slug - in: path - required: true - schema: - type: string + operationId: listConfigs responses: "200": - description: Config details + description: A list of configs content: application/json: schema: @@ -9171,70 +10028,60 @@ paths: success: type: boolean data: - type: object - properties: - config: - type: object - properties: - retry: - type: object - properties: - attempts: - type: integer - on_status_codes: - type: array - items: - type: integer - cache: - type: object - properties: - 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 + type: array + items: + 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": - { - "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", - }, - ], - }, - }, + [ + { + "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 @@ -9248,8 +10095,8 @@ paths: ) # Retrieve the configuration - config = portkey.configs.retrieve( - slug='CONFIG_SLUG' + config = portkey.configs.list( + workspace_id="WORKSPACE_ID" ) print(config) @@ -9262,10 +10109,9 @@ paths: apiKey:"PORTKEY_API_KEY", }) - const config=await portkey.configs.retrieve({ - slug:'CONFIG_SLUG' + const config=await portkey.configs.list({ + workspace_id:"WORKSPACE_ID" }) - console.log(config); - lang: python label: Self-Hosted @@ -9279,8 +10125,8 @@ paths: ) # Retrieve the configuration - config = portkey.configs.retrieve( - slug='CONFIG_SLUG' + config = portkey.configs.list( + workspace_id="WORKSPACE_ID" ) print(config) @@ -9294,26 +10140,18 @@ paths: baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) - const config=await portkey.configs.retrieve({ - slug:'CONFIG_SLUG' + const config=await portkey.configs.list({ + workspace_id:"WORKSPACE_ID" }) - console.log(config); - - put: + post: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - summary: Update a config + summary: Create a config tags: - Configs - operationId: updateConfig - parameters: - - name: slug - in: path - required: true - schema: - type: string + operationId: createConfig requestBody: required: true content: @@ -9325,22 +10163,24 @@ paths: type: string config: type: object - properties: - virtual_key: - type: string - status: + isDefault: + type: integer + workspace_id: type: string + format: uuid + description: optional, when using organisation admin API keys examples: example-1: value: { - "name": "testConf", - "config": { "virtual_key": "copy-of-anthrop-b20259" }, - "status": "active", + "name": "New config", + "config": { "retry": { "attempts": 3 } }, + "workspace_id": "", + "isDefault": 1, } responses: "200": - description: Config updated successfully + description: Config created successfully content: application/json: schema: @@ -9351,6 +10191,9 @@ paths: data: type: object properties: + id: + type: string + format: uuid version_id: type: string format: uuid @@ -9361,31 +10204,35 @@ paths: "success": true, "data": { - "version_id": "abe447e2-f6aa-4229-93b7-8ee3183b6667", + "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", ) - # Update the configuration - updated_config = portkey.configs.update( - slug="CONFIG_SLUG", - name="Updated Config", + # Create a new configuration + config = portkey.configs.create( + name="ConfigName_0909", config={ "retry": { "attempts": 3 }, "cache": { - "mode": "semantic" + "mode": "simple" } - } + }, + workspace_id="WORKSPACE_ID", ) - print(updated_config) + + print(config) - lang: javascript label: Default source: | @@ -9395,18 +10242,17 @@ paths: apiKey:"PORTKEY_API_KEY", }) - const config=await portkey.configs.update({ - slug:"CONFIG_SLUG", - name:"Updated Config", + const config=await portkey.configs.create({ + name:"ConfigName_0909", config:{ "retry": { "attempts": 3 }, "cache": { - "mode": "semantic" + "mode": "simple" } }, - + workspace_id:"WORKSPACE_ID" }) console.log(config); @@ -9421,20 +10267,21 @@ paths: base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - # Update the configuration - updated_config = portkey.configs.update( - slug="CONFIG_SLUG", - name="Updated Config", + # Create a new configuration + config = portkey.configs.create( + name="ConfigName_0909", config={ "retry": { "attempts": 3 }, "cache": { - "mode": "semantic" + "mode": "simple" } - } + }, + workspace_id="WORKSPACE_ID", ) - print(updated_config) + + print(config) - lang: javascript label: Self-Hosted source: | @@ -9445,264 +10292,291 @@ paths: baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) - const config=await portkey.configs.update({ - slug:"CONFIG_SLUG", - name:"Updated Config", + const config=await portkey.configs.create({ + name:"ConfigName_0909", config:{ "retry": { "attempts": 3 }, "cache": { - "mode": "semantic" + "mode": "simple" } }, - + workspace_id:"WORKSPACE_ID" }) console.log(config); - /feedback: - post: + /configs/{slug}: + delete: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - summary: Create new feedback - description: This endpoint allows users to submit feedback for a particular interaction or response. - operationId: createFeedback + summary: Delete a config tags: - - Feedback - requestBody: - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/FeedbackRequest" + - Configs + operationId: deleteConfig + parameters: + - name: slug + in: path + required: true + schema: + type: string responses: "200": - description: Feedback successfully saved + description: Config deleted successfully content: application/json: schema: - $ref: "#/components/schemas/FeedbackResponse" + type: object + examples: + example-1: + value: + {} 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 + portkey = Portkey( + api_key="PORTKEY_API_KEY", ) - print(feedback) + portkey.configs.delete( + id="CONFIG_SLUG" + ) - 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 - }); + apiKey:"PORTKEY_API_KEY", + }) - 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}' + 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" + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - feedback = portkey.feedback.create( - trace_id="REQUEST_TRACE_ID", - value=1 + portkey.configs.delete( + id="CONFIG_SLUG" ) - - 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", + apiKey:"PORTKEY_API_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/v1/feedback \ - -H "x-portkey-api-key: PORTKEY_API_KEY" \ - -H "Content-Type: application/json" \ - -d '{"trace_id":"REQUEST_TRACE_ID","value":1}' + }) - /feedback/{id}: - put: + await portkey.configs.delete({ + id:"CONFIG_SLUG" + }) + get: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - summary: Updates existing feedback - description: This endpoint allows users to update existing feedback. - operationId: updateFeedback + summary: Get a config + tags: + - Configs + operationId: getConfig parameters: - - name: id + - name: slug 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 + description: Config details content: application/json: schema: - $ref: "#/components/schemas/FeedbackResponse" + type: object + properties: + success: + type: boolean + data: + type: object + properties: + config: + type: object + properties: + retry: + type: object + properties: + attempts: + type: integer + on_status_codes: + type: array + items: + type: integer + cache: + type: object + properties: + 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 - portkey = Portkey(api_key="PORTKEY_API_KEY") + # Initialize the Portkey client + portkey = Portkey( + api_key="PORTKEY_API_KEY", + ) - feedback = portkey.feedback.update( - feedback_id="FEEDBACK_ID", - value=1 + # Retrieve the configuration + config = portkey.configs.retrieve( + slug='CONFIG_SLUG' ) - print(feedback) + print(config) - lang: javascript label: Default source: | import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY" - }); + apiKey:"PORTKEY_API_KEY", + }) - const feedback = await portkey.feedback.update({ - feedbackId: "FEEDBACK_ID", - value: 1 - }); + const config=await portkey.configs.retrieve({ + slug:'CONFIG_SLUG' + }) - 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}' + 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" + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - feedback = portkey.feedback.update( - feedback_id="FEEDBACK_ID", - value=1 + # Retrieve the configuration + config = portkey.configs.retrieve( + slug='CONFIG_SLUG' ) - print(feedback) + print(config) - lang: javascript label: Self-Hosted source: | import { Portkey } from "portkey-ai"; const portkey = new Portkey({ - apiKey: "PORTKEY_API_KEY", - virtualKey: "PROVIDER_VIRTUAL_KEY", + apiKey:"PORTKEY_API_KEY", baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" - }); + }) - async function main() { - const feedback = await portkey.feedback.update({ - feedbackId: "FEEDBACK_ID", - value: 1 - }); - console.log(feedback); - } + const config=await portkey.configs.retrieve({ + slug:'CONFIG_SLUG' + }) - main(); - - lang: curl - label: Self-Hosted - source: | - curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/v1/feedback/{id} \ - -H "x-portkey-api-key: PORTKEY_API_KEY" \ - -H "Content-Type: application/json" \ - -d '{"value":1}' + console.log(config); - /virtual-keys: - get: + put: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - summary: List All Virtual Keys + summary: Update a config tags: - - Virtual-keys - responses: - "200": - description: Successful response - content: - application/json: - schema: - type: object - properties: - object: - type: string - enum: [list] - total: - type: integer - description: Total number of virtual keys - data: - type: array - items: - $ref: "#/components/schemas/VirtualKeys" - "401": - description: Unauthorized response + - 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: @@ -9713,58 +10587,191 @@ paths: data: type: object properties: - message: + version_id: type: string - example: - success: false - data: - message: "Unauthorised Request" + 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" ) - # List virtual keys - virtual_keys = portkey.virtual_keys.list() + # 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"; - print(virtual_keys) + 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); + + /feedback: + post: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + 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", - }) + apiKey: "PORTKEY_API_KEY" + }); - const virtualKeys=await portkey.virtualKeys.list({}) - console.log(virtualKeys); + const feedback = await portkey.feedback.create({ + trace_id: "REQUEST_TRACE_ID", + value: 1 + }); + + console.log(feedback); - lang: curl label: Default source: | - curl -X GET https://api.portkey.ai/v1/virtual-keys \ - -H "x-portkey-api-key: PORTKEY_API_KEY" + 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 - # Initialize the Portkey client portkey = Portkey( - api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + api_key="PORTKEY_API_KEY", + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) - # List virtual keys - virtual_keys = portkey.virtual_keys.list() + feedback = portkey.feedback.create( + trace_id="REQUEST_TRACE_ID", + value=1 + ) - print(virtual_keys) + print(feedback) - lang: javascript label: Self-Hosted source: | @@ -9774,30 +10781,259 @@ paths: apiKey: "PORTKEY_API_KEY", virtualKey: "PROVIDER_VIRTUAL_KEY", baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" - }) + }); - const virtualKeys=await portkey.virtualKeys.list({}) - console.log(virtualKeys); + 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 GET SELF_HOSTED_CONTROL_PLANE_URL/v1/virtual-keys \ + curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/v1/feedback \ -H "x-portkey-api-key: PORTKEY_API_KEY" \ - -H "x-portkey-virtual-key: PROVIDER_VIRTUAL_KEY" + -H "Content-Type: application/json" \ + -d '{"trace_id":"REQUEST_TRACE_ID","value":1}' - post: + /feedback/{id}: + put: servers: - url: https://api.portkey.ai/v1 - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - summary: Create a Virtual Key + 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: - - Virtual-keys + - Feedback requestBody: required: true content: application/json: schema: - type: object + $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/v1/feedback/{id} \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"value":1}' + + /virtual-keys: + get: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + summary: List All Virtual Keys + tags: + - Virtual-keys + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + properties: + object: + type: string + enum: [list] + total: + type: integer + description: Total number of virtual keys + data: + type: array + items: + $ref: "#/components/schemas/VirtualKeys" + "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", + ) + + # 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/v1/virtual-keys \ + -H "x-portkey-api-key: PORTKEY_API_KEY" \ + -H "x-portkey-virtual-key: PROVIDER_VIRTUAL_KEY" + + post: + servers: + - url: https://api.portkey.ai/v1 + - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + summary: Create a Virtual Key + tags: + - Virtual-keys + requestBody: + required: true + content: + application/json: + schema: + type: object properties: name: type: string @@ -17446,45 +18682,174 @@ components: - name required: - role - - # TODO(apeng): This is only because we don't support tools yet. Use allOf once we do. - FineTuneChatCompletionRequestAssistantMessage: + FileSearchTool: type: object - title: Assistant message + 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: - content: - nullable: true + type: type: string + enum: + - file_search 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: + 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 - description: The name and arguments of a function that should be called, as generated by the model. - nullable: true + additionalProperties: false 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: + ranker: 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 - + 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 + properties: + file_id: + type: string + description: | + The unique ID of the file. + text: + type: string + description: | + The text that was retrieved from the file. + filename: + type: string + description: | + The name of the file. + attributes: + $ref: "#/components/schemas/VectorStoreFileAttributes" + score: + type: number + format: float + description: | + The relevance score of the file - a value between 0 and 1. + 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 @@ -17577,20 +18942,6 @@ components: - 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. @@ -17629,7 +18980,123 @@ components: 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 @@ -18344,75 +19811,475 @@ components: required: - created - data + Includable: + type: string + description: > + Specify additional output data to include in the model response. + Currently - Image: + 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 - 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: + description: type: string - description: The URL of the generated image, if `response_format` is `url` (default). - revised_prompt: + 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 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": "..." - } - - CreateImageEditRequest: + 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: - 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: 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`. + enum: + - function + description: | + The type of the function tool. Always `function`. + x-stainless-const: true + name: 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 + description: | + The name of the function to call. + description: 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 + description: > + A description of the function. Used by the model to determine + whether - CreateImageVariationRequest: + 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: @@ -18435,7 +20302,9 @@ components: user: *end_user_param_configuration required: - image - + CreateModelResponseProperties: + allOf: + - $ref: "#/components/schemas/ModelResponseProperties" CreateModerationRequest: type: object properties: @@ -18591,1075 +20460,3849 @@ components: - 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. - ListFilesResponse: + + Learn more: + + - [Text inputs and outputs](/docs/guides/text) + + - [Image inputs](/docs/guides/images) + + - [File inputs](/docs/guides/pdf-files) + + - [Conversation state](/docs/guides/conversation-state) + + - [Function calling](/docs/guides/function-calling) + x-oaiExpandable: true + oneOf: + - type: string + title: Text input + description: > + A text input to the model, equivalent to a text input with + the + + `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. 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 + + 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. 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 + 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 + properties: + mime_type: + type: string + description: | + The MIME type of the file. + file_id: + type: string + description: | + The ID of the file. + required: + - 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 + x-oaiMeta: + name: ComparisonFilter + 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 + x-oaiMeta: + name: CompoundFilter + 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 + x-oaiMeta: + name: Costs object + example: | + { + "object": "organization.costs.result", + "amount": { + "value": 0.06, + "currency": "usd" + }, + "line_item": "Image models", + "project_id": "proj_abc" + } + 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 + properties: + 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: + - 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 + x-oaiMeta: + name: The response object + group: responses + example: > + { + "id": "resp_67ccd3a9da748190baa7f1570fe91ac604becb25c45c1d41", + "object": "response", + "created_at": 1741476777, + "status": "completed", + "error": null, + "incomplete_details": null, + "instructions": null, + "max_output_tokens": null, + "model": "gpt-4o-2024-08-06", + "output": [ + { + "type": "message", + "id": "msg_67ccd3acc8d48190a77525dc6de64b4104becb25c45c1d41", + "status": "completed", + "role": "assistant", + "content": [ + { + "type": "output_text", + "text": "The image depicts a scenic landscape with a wooden boardwalk or pathway leading through lush, green grass under a blue sky with some clouds. The setting suggests a peaceful natural area, possibly a park or nature reserve. There are trees and shrubs in the background.", + "annotations": [] + } + ] + } + ], + "parallel_tool_calls": true, + "previous_response_id": null, + "reasoning": { + "effort": null, + "generate_summary": null + }, + "store": true, + "temperature": 1.0, + "text": { + "format": { + "type": "text" + } + }, + "tool_choice": "auto", + "tools": [], + "top_p": 1.0, + "truncation": "disabled", + "usage": { + "input_tokens": 328, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 52, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 380 + }, + "user": null, + "metadata": {} + } + 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 + x-oaiMeta: + name: response.audio.delta + group: responses + example: | + { + "type": "response.audio.delta", + "response_id": "resp_123", + "delta": "base64encoded..." + } + 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 + x-oaiMeta: + name: response.audio.done + group: responses + example: | + { + "type": "response.audio.done", + "response_id": "resp-123" + } + 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 + x-oaiMeta: + name: response.audio.transcript.delta + group: responses + example: | + { + "type": "response.audio.transcript.delta", + "response_id": "resp_123", + "delta": " ... partial transcript ... " + } + 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 + x-oaiMeta: + name: response.audio.transcript.done + group: responses + example: | + { + "type": "response.audio.transcript.done", + "response_id": "resp_123" + } + 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 + x-oaiMeta: + name: response.code_interpreter_call.code.delta + group: responses + example: | + { + "type": "response.code_interpreter_call.code.delta", + "response_id": "resp-123", + "output_index": 0, + "delta": "partial code" + } + 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 + x-oaiMeta: + name: response.code_interpreter_call.code.done + group: responses + example: | + { + "type": "response.code_interpreter_call.code.done", + "response_id": "resp-123", + "output_index": 3, + "code": "console.log('done');" + } + ResponseCodeInterpreterCallCompletedEvent: type: object + description: Emitted when the code interpreter call is completed. properties: - data: - type: array - items: - $ref: "#/components/schemas/OpenAIFile" - object: + type: type: string - enum: [list] + 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: - - object - - data - - CreateFileRequest: + - type + - response_id + - output_index + - code_interpreter_call + x-oaiMeta: + name: response.code_interpreter_call.completed + group: responses + example: | + { + "type": "response.code_interpreter_call.completed", + "response_id": "resp-123", + "output_index": 5, + "code_interpreter_call": {} + } + ResponseCodeInterpreterCallInProgressEvent: type: object - additionalProperties: false + description: Emitted when a code interpreter call is in progress. 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: type: string - enum: ["assistants", "batch", "fine-tune", "vision"] + 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: - - file - - purpose - - DeleteFileResponse: + - type + - response_id + - output_index + - code_interpreter_call + x-oaiMeta: + name: response.code_interpreter_call.in_progress + group: responses + example: | + { + "type": "response.code_interpreter_call.in.progress", + "response_id": "resp-123", + "output_index": 0, + "code_interpreter_call": {} + } + ResponseCodeInterpreterCallInterpretingEvent: type: object + description: + Emitted when the code interpreter is actively interpreting the code + snippet. properties: - id: - type: string - object: + type: type: string - enum: [file] - deleted: - type: boolean + 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: - - id - - object - - deleted - - BedrockFinetuneJob: + - type + - response_id + - output_index + - code_interpreter_call + x-oaiMeta: + name: response.code_interpreter_call.interpreting + group: responses + example: | + { + "type": "response.code_interpreter_call.interpreting", + "response_id": "resp-123", + "output_index": 4, + "code_interpreter_call": {} + } + ResponseCompletedEvent: type: object - description: Gateway supported body params for bedrock fine-tuning. - title: Bedrock Params + description: Emitted when the model response is complete. 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: 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 + 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: - - model - - training_file - - suffix - - method + - type + - response + x-oaiMeta: + name: response.completed + group: responses + example: > + { + "type": "response.completed", + "response": { + "id": "resp_123", + "object": "response", + "created_at": 1740855869, + "status": "completed", + "error": null, + "incomplete_details": null, + "input": [], + "instructions": null, + "max_output_tokens": null, + "model": "gpt-4o-mini-2024-07-18", + "output": [ + { + "id": "msg_123", + "type": "message", + "role": "assistant", + "content": [ + { + "type": "output_text", + "text": "In a shimmering forest under a sky full of stars, a lonely unicorn named Lila discovered a hidden pond that glowed with moonlight. Every night, she would leave sparkling, magical flowers by the water's edge, hoping to share her beauty with others. One enchanting evening, she woke to find a group of friendly animals gathered around, eager to be friends and share in her magic.", + "annotations": [] + } + ] + } + ], + "previous_response_id": null, + "reasoning_effort": null, + "store": false, + "temperature": 1, + "text": { + "format": { + "type": "text" + } + }, + "tool_choice": "auto", + "tools": [], + "top_p": 1, + "truncation": "disabled", + "usage": { + "input_tokens": 0, + "output_tokens": 0, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 0 + }, + "user": null, + "metadata": {} + } + } + ResponseContentPartAddedEvent: + type: object + description: Emitted when a new content part is added. properties: - model: + type: type: string - description: The base model to finetune - training_file: + 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 training file to use for the finetune job - validation_file: + 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 + x-oaiMeta: + name: response.content_part.added + group: responses + example: | + { + "type": "response.content_part.added", + "item_id": "msg_123", + "output_index": 0, + "content_index": 0, + "part": { + "type": "output_text", + "text": "", + "annotations": [] + } + } + ResponseContentPartDoneEvent: + type: object + description: Emitted when a content part is done. + properties: + type: type: string - description: The validation file to use for the finetune job - suffix: + 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 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: + 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 + x-oaiMeta: + name: response.content_part.done + group: responses + example: > + { + "type": "response.content_part.done", + "item_id": "msg_123", + "output_index": 0, + "content_index": 0, + "part": { + "type": "output_text", + "text": "In a shimmering forest under a sky full of stars, a lonely unicorn named Lila discovered a hidden pond that glowed with moonlight. Every night, she would leave sparkling, magical flowers by the water's edge, hoping to share her beauty with others. One enchanting evening, she woke to find a group of friendly animals gathered around, eager to be friends and share in her magic.", + "annotations": [] + } + } + ResponseCreatedEvent: type: object + description: | + An event that is emitted when a response is created. properties: - job_name: - type: string - description: Job name for the bedrock finetune job - role_arn: + type: type: string - description: Role ARN for the bedrock finetune job - output_file: + 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 + x-oaiMeta: + name: response.created + group: responses + example: | + { + "type": "response.created", + "response": { + "id": "resp_67ccfcdd16748190a91872c75d38539e09e4d4aac714747c", + "object": "response", + "created_at": 1741487325, + "status": "in_progress", + "error": null, + "incomplete_details": null, + "instructions": null, + "max_output_tokens": null, + "model": "gpt-4o-2024-08-06", + "output": [], + "parallel_tool_calls": true, + "previous_response_id": null, + "reasoning": { + "effort": null, + "generate_summary": null + }, + "store": true, + "temperature": 1, + "text": { + "format": { + "type": "text" + } + }, + "tool_choice": "auto", + "tools": [], + "top_p": 1, + "truncation": "disabled", + "usage": null, + "user": null, + "metadata": {} + } + } + 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: Finetune job's output s3 location, will be constructed based on `training_file` if not provided - - PortkeyFinetuneJob: + 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: - job_name: + type: type: string - description: Job name for the bedrock finetune job - role_arn: + description: | + The type of the event. Always `error`. + enum: + - error + x-stainless-const: true + code: type: string - description: Role ARN for the bedrock finetune job - output_file: + description: | + The error code. + nullable: true + message: 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 + description: | + The error message. + param: + type: string + description: | + The error parameter. + nullable: true required: - - x-portkey-virtual-key + - type + - code + - message + - param + x-oaiMeta: + name: error + group: responses + example: | + { + "type": "error", + "code": "ERR_SOMETHING", + "message": "Something went wrong", + "param": null + } + ResponseFailedEvent: + type: object + description: | + An event that is emitted when a response fails. properties: - x-portkey-virtual-key: + type: type: string - description: The virtual key to communicate with the provider - x-portkey-aws-s3-bucket: + 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 + x-oaiMeta: + name: response.failed + group: responses + example: | + { + "type": "response.failed", + "response": { + "id": "resp_123", + "object": "response", + "created_at": 1740855869, + "status": "failed", + "error": { + "code": "server_error", + "message": "The model failed to generate a response." + }, + "incomplete_details": null, + "instructions": null, + "max_output_tokens": null, + "model": "gpt-4o-mini-2024-07-18", + "output": [], + "previous_response_id": null, + "reasoning_effort": null, + "store": false, + "temperature": 1, + "text": { + "format": { + "type": "text" + } + }, + "tool_choice": "auto", + "tools": [], + "top_p": 1, + "truncation": "disabled", + "usage": null, + "user": null, + "metadata": {} + } + } + ResponseFileSearchCallCompletedEvent: + type: object + description: Emitted when a file search call is completed (results found). + properties: + type: type: string - description: The AWS S3 bucket to use for file upload during finetune - x-portkey-vertex-storage-bucket-name: + 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: 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: + description: | + The ID of the output item that the file search call is initiated. + required: + - type + - output_index + - item_id + x-oaiMeta: + name: response.file_search_call.completed + group: responses + example: | + { + "type": "response.file_search_call.completed", + "output_index": 0, + "item_id": "fs_123", + } + ResponseFileSearchCallInProgressEvent: type: object + description: Emitted when a file search call is initiated. properties: - data: - type: array - items: - $ref: "#/components/schemas/FineTuningJobEvent" - object: + type: type: string - enum: [list] + 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: - - object - - data - - ListFineTuningJobCheckpointsResponse: + - type + - output_index + - item_id + x-oaiMeta: + name: response.file_search_call.in_progress + group: responses + example: | + { + "type": "response.file_search_call.in_progress", + "output_index": 0, + "item_id": "fs_123", + } + ResponseFileSearchCallSearchingEvent: type: object + description: Emitted when a file search is currently searching. properties: - data: - type: array - items: - $ref: "#/components/schemas/FineTuningJobCheckpoint" - object: - type: string - enum: [list] - first_id: + type: type: string - nullable: true - last_id: + 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 - nullable: true - has_more: - type: boolean + description: | + The ID of the output item that the file search call is initiated. required: - - object - - data - - has_more + - type + - output_index + - item_id + x-oaiMeta: + name: response.file_search_call.searching + group: responses + example: | + { + "type": "response.file_search_call.searching", + "output_index": 0, + "item_id": "fs_123", + } + ResponseFormatJsonObject: + type: object + title: JSON object + description: > + JSON object response format. An older method of generating JSON + responses. - CreateEmbeddingRequest: + 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 - additionalProperties: false + title: JSON schema + description: | + JSON Schema response format. Used to generate structured JSON responses. + Learn more about [Structured Outputs](/docs/guides/structured-outputs). 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: type: string - enum: ["float", "base64"] - dimensions: + 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: | - 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 + 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. - CreateEmbeddingResponse: + 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: - 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: 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 + description: The type of response format being defined. Always `text`. + enum: + - text + x-stainless-const: true required: - - object - - model - - data - - usage - - CreateTranscriptionRequest: + - type + ResponseFunctionCallArgumentsDeltaEvent: type: object - additionalProperties: false + description: Emitted when there is a partial function-call arguments delta. 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: 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. + 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 - response_format: - description: | - The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`. + 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 - 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] + The function-call arguments delta that is added. required: - - file - - model - - # Note: This does not currently support the non-default response format types. - CreateTranscriptionResponseJson: + - type + - item_id + - output_index + - delta + x-oaiMeta: + name: response.function_call_arguments.delta + group: responses + example: | + { + "type": "response.function_call_arguments.delta", + "item_id": "item-abc", + "output_index": 0, + "delta": "{ \"arg\":" + } + ResponseFunctionCallArgumentsDoneEvent: type: object - description: Represents a transcription response returned by model, based on the provided input. + description: Emitted when function-call arguments are finalized. properties: - text: + type: type: string - description: The transcribed text. + 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: - - text - - TranscriptionSegment: + - type + - item_id + - output_index + - arguments + x-oaiMeta: + name: response.function_call_arguments.done + group: responses + example: | + { + "type": "response.function_call_arguments.done", + "item_id": "item-abc", + "output_index": 1, + "arguments": "{ \"arg\": 123 }" + } + ResponseInProgressEvent: type: object + description: Emitted when the response is in progress. 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: 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. + 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: - - id - - seek - - start - - end - - text - - tokens - - temperature - - avg_logprob - - compression_ratio - - no_speech_prob - - TranscriptionWord: + - type + - response + x-oaiMeta: + name: response.in_progress + group: responses + example: | + { + "type": "response.in_progress", + "response": { + "id": "resp_67ccfcdd16748190a91872c75d38539e09e4d4aac714747c", + "object": "response", + "created_at": 1741487325, + "status": "in_progress", + "error": null, + "incomplete_details": null, + "instructions": null, + "max_output_tokens": null, + "model": "gpt-4o-2024-08-06", + "output": [], + "parallel_tool_calls": true, + "previous_response_id": null, + "reasoning": { + "effort": null, + "generate_summary": null + }, + "store": true, + "temperature": 1, + "text": { + "format": { + "type": "text" + } + }, + "tool_choice": "auto", + "tools": [], + "top_p": 1, + "truncation": "disabled", + "usage": null, + "user": null, + "metadata": {} + } + } + ResponseIncompleteEvent: type: object + description: | + An event that is emitted when a response finishes as incomplete. properties: - word: + type: 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: + 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 + x-oaiMeta: + name: response.incomplete + group: responses + example: | + { + "type": "response.incomplete", + "response": { + "id": "resp_123", + "object": "response", + "created_at": 1740855869, + "status": "incomplete", + "error": null, + "incomplete_details": { + "reason": "max_tokens" + }, + "instructions": null, + "max_output_tokens": null, + "model": "gpt-4o-mini-2024-07-18", + "output": [], + "previous_response_id": null, + "reasoning_effort": null, + "store": false, + "temperature": 1, + "text": { + "format": { + "type": "text" + } + }, + "tool_choice": "auto", + "tools": [], + "top_p": 1, + "truncation": "disabled", + "usage": null, + "user": null, + "metadata": {} + } + } + ResponseItemList: type: object - description: Represents a verbose json transcription response returned by model, based on the provided input. + description: A list of Response items. 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: + object: + type: string + description: The type of object returned, must be `list`. + enum: + - list + x-stainless-const: true + data: type: array - description: Segments of the transcribed text and their corresponding details. + description: A list of items used to generate this response. items: - $ref: "#/components/schemas/TranscriptionSegment" - required: [language, duration, text] + $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 + x-oaiMeta: + name: The input item list + group: responses + example: > + { + "object": "list", + "data": [ + { + "id": "msg_abc123", + "type": "message", + "role": "user", + "content": [ + { + "type": "input_text", + "text": "Tell me a three sentence bedtime story about a unicorn." + } + ] + } + ], + "first_id": "msg_abc123", + "last_id": "msg_abc123", + "has_more": false + } + ResponseModalities: + type: array + nullable: true + description: > + Output types that you would like the model to generate. - CreateTranslationRequest: + 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 - additionalProperties: false + description: Emitted when a new output item is added. 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: 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: + 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 format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`. - type: string - default: json - temperature: + The index of the output item that was added. + item: + $ref: "#/components/schemas/OutputItem" + x-oaiExpandable: true 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 + The output item that was added. required: - - file - - model - - # Note: This does not currently support the non-default response format types. - CreateTranslationResponseJson: + - type + - output_index + - item + x-oaiMeta: + name: response.output_item.added + group: responses + example: | + { + "type": "response.output_item.added", + "output_index": 0, + "item": { + "id": "msg_123", + "status": "in_progress", + "type": "message", + "role": "assistant", + "content": [] + } + } + ResponseOutputItemDoneEvent: type: object + description: Emitted when an output item is marked done. properties: - text: + 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: - - text - - CreateTranslationResponseVerboseJson: + - type + - output_index + - item + x-oaiMeta: + name: response.output_item.done + group: responses + example: > + { + "type": "response.output_item.done", + "output_index": 0, + "item": { + "id": "msg_123", + "status": "completed", + "type": "message", + "role": "assistant", + "content": [ + { + "type": "output_text", + "text": "In a shimmering forest under a sky full of stars, a lonely unicorn named Lila discovered a hidden pond that glowed with moonlight. Every night, she would leave sparkling, magical flowers by the water's edge, hoping to share her beauty with others. One enchanting evening, she woke to find a group of friendly animals gathered around, eager to be friends and share in her magic.", + "annotations": [] + } + ] + } + } + ResponseProperties: type: object properties: - language: + previous_response_id: type: string - description: The language of the output translation (always `english`). - duration: + 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: The duration of the input audio. + 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: string - description: The translated text. - segments: + 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: Segments of the translated text and their corresponding details. + 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/TranscriptionSegment" - required: [language, duration, text] + $ref: "#/components/schemas/Tool" + tool_choice: + description: > + How the model should select which tool (or tools) to use when + generating - 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 + a response. See the `tools` parameter to see how to specify which + tools - 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: + 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 organization that owns the model. - required: - - id - - object - - created - - owned_by - - OpenAIFile: - title: OpenAIFile - description: The `File` object represents a document that has been uploaded to OpenAI. + 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: - 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: type: string - description: The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`. + description: | + The type of the event. Always `response.refusal.delta`. enum: - [ - "assistants", - "assistants_output", - "batch", - "batch_output", - "fine-tune", - "fine-tune-results", - "vision", - ] - status: + - response.refusal.delta + x-stainless-const: true + item_id: 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: + 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 - deprecated: true - description: Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. + description: | + The refusal text that is added. required: - - id - - object - - bytes - - created_at - - filename - - purpose - - status - x-code-samples: - name: The file object + - type + - item_id + - output_index + - content_index + - delta + x-oaiMeta: + name: response.refusal.delta + group: responses example: | { - "id": "file-abc123", - "object": "file", - "bytes": 120000, - "created_at": 1677610602, - "filename": "salesOverview.pdf", - "purpose": "assistants", + "type": "response.refusal.delta", + "item_id": "msg_123", + "output_index": 0, + "content_index": 0, + "delta": "refusal text so far" } - Embedding: + ResponseRefusalDoneEvent: type: object - description: | - Represents an embedding vector returned by embedding endpoint. + description: Emitted when refusal text is finalized. properties: - index: + 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 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: + 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 object type, which is always "embedding". - enum: [embedding] + description: | + The refusal text that is finalized. required: - - index - - object - - embedding - x-code-samples: - name: The embedding object + - type + - item_id + - output_index + - content_index + - refusal + x-oaiMeta: + name: response.refusal.done + group: responses example: | { - "object": "embedding", - "embedding": [ - 0.0023064255, - -0.009327292, - .... (1536 floats total for ada-002) - -0.0028842222, - ], - "index": 0 + "type": "response.refusal.done", + "item_id": "item-abc", + "output_index": 1, + "content_index": 2, + "refusal": "final refusal text" } - - FineTuningJob: + 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 - title: FineTuningJob - description: | - The `fine_tuning.job` object represents a fine-tuning job that has been created through the API. + description: Emitted when a text annotation is added. 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: type: string - description: The current status of the fine-tuning job, which can be either `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`. + description: > + The type of the event. Always + `response.output_text.annotation.added`. 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: + - response.output_text.annotation.added + x-stainless-const: true + item_id: 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: + description: | + The ID of the output item that the text annotation was added to. + output_index: type: integer - description: The seed used for the fine-tuning job. - estimated_finish: + description: | + The index of the output item that the text annotation was added to. + content_index: 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 + 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 - - wandb + - item_id + - output_index + - content_index + - annotation_index + - annotation + x-oaiMeta: + name: response.output_text.annotation.added + group: responses + example: | + { + "type": "response.output_text.annotation.added", + "item_id": "msg_abc123", + "output_index": 1, + "content_index": 0, + "annotation_index": 0, + "annotation": { + "type": "file_citation", + "index": 390, + "file_id": "file-4wDz5b167pAf72nx1h9eiN", + "filename": "dragons.pdf" + } + } + ResponseTextDeltaEvent: + type: object + description: Emitted when there is an additional text delta. 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: + 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 + x-oaiMeta: + name: response.output_text.delta + group: responses + example: | + { + "type": "response.output_text.delta", + "item_id": "msg_123", + "output_index": 0, + "content_index": 0, + "delta": "In" + } + ResponseTextDoneEvent: type: object - description: Fine-tuning job event object + description: Emitted when text content is finalized. properties: - id: - type: string - created_at: - type: integer - level: + type: type: string - enum: ["info", "warn", "error"] - message: + description: | + The type of the event. Always `response.output_text.done`. + enum: + - response.output_text.done + x-stainless-const: true + item_id: type: string - object: + 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 - enum: [fine_tuning.job.event] + description: | + The text content that is finalized. required: - - id - - object - - created_at - - level - - message - x-code-samples: - name: The fine-tuning job event object - example: | + - type + - item_id + - output_index + - content_index + - text + x-oaiMeta: + name: response.output_text.done + group: responses + example: > { - "object": "fine_tuning.job.event", - "id": "ftevent-abc123" - "created_at": 1677610602, - "level": "info", - "message": "Created fine-tuning job" + "type": "response.output_text.done", + "item_id": "msg_123", + "output_index": 0, + "content_index": 0, + "text": "In a shimmering forest under a sky full of stars, a lonely unicorn named Lila discovered a hidden pond that glowed with moonlight. Every night, she would leave sparkling, magical flowers by the water's edge, hoping to share her beauty with others. One enchanting evening, she woke to find a group of friendly animals gathered around, eager to be friends and share in her magic." } - - FineTuningJobCheckpoint: + ResponseUsage: 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. + Represents token usage details including input tokens, output tokens, + a breakdown of output tokens, and the total tokens used. properties: - id: - type: string - description: The checkpoint identifier, which can be referenced in the API endpoints. - created_at: + input_tokens: 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: + 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 step number that the checkpoint was created at. - metrics: + description: The number of output tokens. + output_tokens_details: type: object - description: Metrics at the step number during the fine-tuning job. + description: A detailed breakdown of the output tokens. 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: + 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 name of the fine-tuning job that this checkpoint was created from. - object: + 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: The object type, which is always "fine_tuning.job.checkpoint". - enum: [fine_tuning.job.checkpoint] + description: | + Unique ID for the output item associated with the web search call. 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 + - type + - output_index + - item_id + x-oaiMeta: + name: response.web_search_call.completed + group: responses 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 + "type": "response.web_search_call.completed", + "output_index": 0, + "item_id": "ws_123", } - - 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: + ResponseWebSearchCallInProgressEvent: type: object - description: The per-line training example of a fine-tuning input file for completions models + description: Emitted when a web search call is initiated. properties: - prompt: + type: type: string - description: The input prompt for this training example. - completion: + 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: The desired completion for this training example. - x-code-samples: - name: Training format for completions models + description: | + Unique ID for the output item associated with the web search call. + required: + - type + - output_index + - item_id + x-oaiMeta: + name: response.web_search_call.in_progress + group: responses example: | - {"prompt": "What is the answer to 2+2", "completion": "4"} - - CompletionUsage: + { + "type": "response.web_search_call.in_progress", + "output_index": 0, + "item_id": "ws_123", + } + ResponseWebSearchCallSearchingEvent: type: object - description: Usage statistics for the completion request. + description: Emitted when a web search call is executing. 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: + 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: Total number of tokens used in the request (prompt + completion). + 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: - - prompt_tokens - - completion_tokens - - total_tokens - + - type + - output_index + - item_id + x-oaiMeta: + name: response.web_search_call.searching + group: responses + example: | + { + "type": "response.web_search_call.searching", + "output_index": 0, + "item_id": "ws_123", + } 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.). @@ -19724,7 +24367,11 @@ components: 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 @@ -20026,7 +24673,80 @@ components: 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 @@ -20122,12 +24842,92 @@ components: type: boolean object: type: string - enum: [assistant.deleted] - required: - - id - - object - - deleted + 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: @@ -20666,7 +25466,84 @@ components: 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 @@ -20695,7 +25572,60 @@ components: - 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 @@ -22267,60 +27197,334 @@ components: - 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 + - 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 + x-oaiMeta: + name: Vector store search request + VectorStoreSearchResultContentObject: + type: object + additionalProperties: false + properties: + type: + description: The type of content. + type: string + enum: + - text + text: + description: The text content returned from search. + type: string + required: + - type + - text + x-oaiMeta: + name: Vector store search result content object + VectorStoreSearchResultItem: + type: object + additionalProperties: false + properties: + file_id: + type: string + description: The ID of the vector store file. + filename: + type: string + description: The name of the vector store file. + score: + type: number + description: The similarity score for the result. + minimum: 0 + maximum: 1 + attributes: + $ref: "#/components/schemas/VectorStoreFileAttributes" + content: + type: array + description: Content chunks from the file. + items: + $ref: "#/components/schemas/VectorStoreSearchResultContentObject" + required: + - file_id + - filename + - score + - attributes + - content + x-oaiMeta: + name: Vector store search result item + 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 + x-oaiMeta: + name: Vector store search results 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: | + The type of location approximation. Always `approximate`. + enum: + - approximate + x-stainless-const: true + required: + - type + 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 - - object - - usage_bytes - - created_at + - type - 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 - } - CreateVectorStoreRequest: type: object additionalProperties: false @@ -22348,7 +27552,28 @@ components: 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 @@ -22365,7 +27590,41 @@ components: 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: @@ -22622,7 +27881,31 @@ components: - 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 @@ -22758,7 +28041,79 @@ components: 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 @@ -23068,7 +28423,56 @@ components: 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: @@ -24753,84 +30157,6 @@ components: title: Vertex Params VertexBatchParams: type: object - 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 - required: - - type - ResponseFormatJsonSchema: - type: object - title: JSON schema - description: | - JSON Schema response format. Used to generate structured JSON responses. - Learn more about [Structured Outputs](/integrations/llms/openai/structured-outputs). - properties: - type: - type: string - description: The type of response format being defined. Always `json_schema`. - enum: - - json_schema - 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`. - 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 - required: - - type security: - Portkey-Key: [] From dcb1fbaf9a7efd59cbacc10c7e25d1fbb25b65ef Mon Sep 17 00:00:00 2001 From: Narendranath Gogineni Date: Tue, 22 Apr 2025 13:00:18 +0530 Subject: [PATCH 111/124] remove openai meta for responses api --- openapi.yaml | 1710 +------------------------------------------------- 1 file changed, 1 insertion(+), 1709 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 467175a8..81a66f8e 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -4804,21 +4804,7 @@ paths: tags: - Responses summary: > - Creates a model response. Provide [text](/docs/guides/text) or - - [image](/docs/guides/images) inputs to generate - [text](/docs/guides/text) - - or [JSON](/docs/guides/structured-outputs) outputs. Have the model call - - your own [custom code](/docs/guides/function-calling) or use built-in - - [tools](/docs/guides/tools) like [web - search](/docs/guides/tools-web-search) - - or [file search](/docs/guides/tools-file-search) to use your own data - - as input for the model's response. + Creates a model response requestBody: required: true content: @@ -4835,931 +4821,6 @@ paths: text/event-stream: schema: $ref: "#/components/schemas/ResponseStreamEvent" - x-oaiMeta: - name: Create a model response - group: responses - returns: | - Returns a [Response](/docs/api-reference/responses/object) object. - path: create - examples: - - title: Text input - request: - curl: > - curl https://api.openai.com/v1/responses \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "model": "gpt-4o", - "input": "Tell me a three sentence bedtime story about a unicorn." - }' - javascript: > - import OpenAI from "openai"; - - - const openai = new OpenAI(); - - - const response = await openai.responses.create({ - model: "gpt-4o", - input: "Tell me a three sentence bedtime story about a unicorn." - }); - - - console.log(response); - python: > - from openai import OpenAI - - - client = OpenAI() - - - response = client.responses.create( - model="gpt-4o", - input="Tell me a three sentence bedtime story about a unicorn." - ) - - - print(response) - response: > - { - "id": "resp_67ccd2bed1ec8190b14f964abc0542670bb6a6b452d3795b", - "object": "response", - "created_at": 1741476542, - "status": "completed", - "error": null, - "incomplete_details": null, - "instructions": null, - "max_output_tokens": null, - "model": "gpt-4o-2024-08-06", - "output": [ - { - "type": "message", - "id": "msg_67ccd2bf17f0819081ff3bb2cf6508e60bb6a6b452d3795b", - "status": "completed", - "role": "assistant", - "content": [ - { - "type": "output_text", - "text": "In a peaceful grove beneath a silver moon, a unicorn named Lumina discovered a hidden pool that reflected the stars. As she dipped her horn into the water, the pool began to shimmer, revealing a pathway to a magical realm of endless night skies. Filled with wonder, Lumina whispered a wish for all who dream to find their own hidden magic, and as she glanced back, her hoofprints sparkled like stardust.", - "annotations": [] - } - ] - } - ], - "parallel_tool_calls": true, - "previous_response_id": null, - "reasoning": { - "effort": null, - "generate_summary": null - }, - "store": true, - "temperature": 1.0, - "text": { - "format": { - "type": "text" - } - }, - "tool_choice": "auto", - "tools": [], - "top_p": 1.0, - "truncation": "disabled", - "usage": { - "input_tokens": 36, - "input_tokens_details": { - "cached_tokens": 0 - }, - "output_tokens": 87, - "output_tokens_details": { - "reasoning_tokens": 0 - }, - "total_tokens": 123 - }, - "user": null, - "metadata": {} - } - - title: Image input - request: - curl: > - curl https://api.openai.com/v1/responses \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "model": "gpt-4o", - "input": [ - { - "role": "user", - "content": [ - {"type": "input_text", "text": "what is in this image?"}, - { - "type": "input_image", - "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" - } - ] - } - ] - }' - javascript: > - import OpenAI from "openai"; - - - const openai = new OpenAI(); - - - const response = await openai.responses.create({ - model: "gpt-4o", - input: [ - { - role: "user", - content: [ - { type: "input_text", text: "what is in this image?" }, - { - type: "input_image", - 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); - python: > - from openai import OpenAI - - - client = OpenAI() - - - response = client.responses.create( - model="gpt-4o", - input=[ - { - "role": "user", - "content": [ - { "type": "input_text", "text": "what is in this image?" }, - { - "type": "input_image", - "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" - } - ] - } - ] - ) - - - print(response) - response: > - { - "id": "resp_67ccd3a9da748190baa7f1570fe91ac604becb25c45c1d41", - "object": "response", - "created_at": 1741476777, - "status": "completed", - "error": null, - "incomplete_details": null, - "instructions": null, - "max_output_tokens": null, - "model": "gpt-4o-2024-08-06", - "output": [ - { - "type": "message", - "id": "msg_67ccd3acc8d48190a77525dc6de64b4104becb25c45c1d41", - "status": "completed", - "role": "assistant", - "content": [ - { - "type": "output_text", - "text": "The image depicts a scenic landscape with a wooden boardwalk or pathway leading through lush, green grass under a blue sky with some clouds. The setting suggests a peaceful natural area, possibly a park or nature reserve. There are trees and shrubs in the background.", - "annotations": [] - } - ] - } - ], - "parallel_tool_calls": true, - "previous_response_id": null, - "reasoning": { - "effort": null, - "generate_summary": null - }, - "store": true, - "temperature": 1.0, - "text": { - "format": { - "type": "text" - } - }, - "tool_choice": "auto", - "tools": [], - "top_p": 1.0, - "truncation": "disabled", - "usage": { - "input_tokens": 328, - "input_tokens_details": { - "cached_tokens": 0 - }, - "output_tokens": 52, - "output_tokens_details": { - "reasoning_tokens": 0 - }, - "total_tokens": 380 - }, - "user": null, - "metadata": {} - } - - title: Web search - request: - curl: | - curl https://api.openai.com/v1/responses \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "model": "gpt-4o", - "tools": [{ "type": "web_search_preview" }], - "input": "What was a positive news story from today?" - }' - javascript: | - import OpenAI from "openai"; - - const openai = new OpenAI(); - - const response = await openai.responses.create({ - model: "gpt-4o", - tools: [{ type: "web_search_preview" }], - input: "What was a positive news story from today?", - }); - - console.log(response); - python: | - from openai import OpenAI - - client = OpenAI() - - response = client.responses.create( - model="gpt-4o", - tools=[{ "type": "web_search_preview" }], - input="What was a positive news story from today?", - ) - - print(response) - response: > - { - "id": "resp_67ccf18ef5fc8190b16dbee19bc54e5f087bb177ab789d5c", - "object": "response", - "created_at": 1741484430, - "status": "completed", - "error": null, - "incomplete_details": null, - "instructions": null, - "max_output_tokens": null, - "model": "gpt-4o-2024-08-06", - "output": [ - { - "type": "web_search_call", - "id": "ws_67ccf18f64008190a39b619f4c8455ef087bb177ab789d5c", - "status": "completed" - }, - { - "type": "message", - "id": "msg_67ccf190ca3881909d433c50b1f6357e087bb177ab789d5c", - "status": "completed", - "role": "assistant", - "content": [ - { - "type": "output_text", - "text": "As of today, March 9, 2025, one notable positive news story...", - "annotations": [ - { - "type": "url_citation", - "start_index": 442, - "end_index": 557, - "url": "https://.../?utm_source=chatgpt.com", - "title": "..." - }, - { - "type": "url_citation", - "start_index": 962, - "end_index": 1077, - "url": "https://.../?utm_source=chatgpt.com", - "title": "..." - }, - { - "type": "url_citation", - "start_index": 1336, - "end_index": 1451, - "url": "https://.../?utm_source=chatgpt.com", - "title": "..." - } - ] - } - ] - } - ], - "parallel_tool_calls": true, - "previous_response_id": null, - "reasoning": { - "effort": null, - "generate_summary": null - }, - "store": true, - "temperature": 1.0, - "text": { - "format": { - "type": "text" - } - }, - "tool_choice": "auto", - "tools": [ - { - "type": "web_search_preview", - "domains": [], - "search_context_size": "medium", - "user_location": { - "type": "approximate", - "city": null, - "country": "US", - "region": null, - "timezone": null - } - } - ], - "top_p": 1.0, - "truncation": "disabled", - "usage": { - "input_tokens": 328, - "input_tokens_details": { - "cached_tokens": 0 - }, - "output_tokens": 356, - "output_tokens_details": { - "reasoning_tokens": 0 - }, - "total_tokens": 684 - }, - "user": null, - "metadata": {} - } - - title: File search - request: - curl: > - curl https://api.openai.com/v1/responses \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "model": "gpt-4o", - "tools": [{ - "type": "file_search", - "vector_store_ids": ["vs_1234567890"], - "max_num_results": 20 - }], - "input": "What are the attributes of an ancient brown dragon?" - }' - javascript: > - import OpenAI from "openai"; - - - const openai = new OpenAI(); - - - const response = await openai.responses.create({ - model: "gpt-4o", - tools: [{ - type: "file_search", - vector_store_ids: ["vs_1234567890"], - max_num_results: 20 - }], - input: "What are the attributes of an ancient brown dragon?", - }); - - - console.log(response); - python: | - from openai import OpenAI - - client = OpenAI() - - response = client.responses.create( - model="gpt-4o", - tools=[{ - "type": "file_search", - "vector_store_ids": ["vs_1234567890"], - "max_num_results": 20 - }], - input="What are the attributes of an ancient brown dragon?", - ) - - print(response) - response: > - { - "id": "resp_67ccf4c55fc48190b71bd0463ad3306d09504fb6872380d7", - "object": "response", - "created_at": 1741485253, - "status": "completed", - "error": null, - "incomplete_details": null, - "instructions": null, - "max_output_tokens": null, - "model": "gpt-4o-2024-08-06", - "output": [ - { - "type": "file_search_call", - "id": "fs_67ccf4c63cd08190887ef6464ba5681609504fb6872380d7", - "status": "completed", - "queries": [ - "attributes of an ancient brown dragon" - ], - "results": null - }, - { - "type": "message", - "id": "msg_67ccf4c93e5c81909d595b369351a9d309504fb6872380d7", - "status": "completed", - "role": "assistant", - "content": [ - { - "type": "output_text", - "text": "The attributes of an ancient brown dragon include...", - "annotations": [ - { - "type": "file_citation", - "index": 320, - "file_id": "file-4wDz5b167pAf72nx1h9eiN", - "filename": "dragons.pdf" - }, - { - "type": "file_citation", - "index": 576, - "file_id": "file-4wDz5b167pAf72nx1h9eiN", - "filename": "dragons.pdf" - }, - { - "type": "file_citation", - "index": 815, - "file_id": "file-4wDz5b167pAf72nx1h9eiN", - "filename": "dragons.pdf" - }, - { - "type": "file_citation", - "index": 815, - "file_id": "file-4wDz5b167pAf72nx1h9eiN", - "filename": "dragons.pdf" - }, - { - "type": "file_citation", - "index": 1030, - "file_id": "file-4wDz5b167pAf72nx1h9eiN", - "filename": "dragons.pdf" - }, - { - "type": "file_citation", - "index": 1030, - "file_id": "file-4wDz5b167pAf72nx1h9eiN", - "filename": "dragons.pdf" - }, - { - "type": "file_citation", - "index": 1156, - "file_id": "file-4wDz5b167pAf72nx1h9eiN", - "filename": "dragons.pdf" - }, - { - "type": "file_citation", - "index": 1225, - "file_id": "file-4wDz5b167pAf72nx1h9eiN", - "filename": "dragons.pdf" - } - ] - } - ] - } - ], - "parallel_tool_calls": true, - "previous_response_id": null, - "reasoning": { - "effort": null, - "generate_summary": null - }, - "store": true, - "temperature": 1.0, - "text": { - "format": { - "type": "text" - } - }, - "tool_choice": "auto", - "tools": [ - { - "type": "file_search", - "filters": null, - "max_num_results": 20, - "ranking_options": { - "ranker": "auto", - "score_threshold": 0.0 - }, - "vector_store_ids": [ - "vs_1234567890" - ] - } - ], - "top_p": 1.0, - "truncation": "disabled", - "usage": { - "input_tokens": 18307, - "input_tokens_details": { - "cached_tokens": 0 - }, - "output_tokens": 348, - "output_tokens_details": { - "reasoning_tokens": 0 - }, - "total_tokens": 18655 - }, - "user": null, - "metadata": {} - } - - title: Streaming - request: - curl: | - curl https://api.openai.com/v1/responses \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "model": "gpt-4o", - "instructions": "You are a helpful assistant.", - "input": "Hello!", - "stream": true - }' - python: | - from openai import OpenAI - - client = OpenAI() - - response = client.responses.create( - model="gpt-4o", - instructions="You are a helpful assistant.", - input="Hello!", - stream=True - ) - - for event in response: - print(event) - javascript: | - import OpenAI from "openai"; - - const openai = new OpenAI(); - - const response = await openai.responses.create({ - model: "gpt-4o", - instructions: "You are a helpful assistant.", - input: "Hello!", - stream: true, - }); - - for await (const event of response) { - console.log(event); - } - response: > - event: response.created - - data: - {"type":"response.created","response":{"id":"resp_67c9fdcecf488190bdd9a0409de3a1ec07b8b0ad4e5eb654","object":"response","created_at":1741290958,"status":"in_progress","error":null,"incomplete_details":null,"instructions":"You - are a helpful - assistant.","max_output_tokens":null,"model":"gpt-4o-2024-08-06","output":[],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":null,"generate_summary":null},"store":true,"temperature":1.0,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":1.0,"truncation":"disabled","usage":null,"user":null,"metadata":{}}} - - - event: response.in_progress - - data: - {"type":"response.in_progress","response":{"id":"resp_67c9fdcecf488190bdd9a0409de3a1ec07b8b0ad4e5eb654","object":"response","created_at":1741290958,"status":"in_progress","error":null,"incomplete_details":null,"instructions":"You - are a helpful - assistant.","max_output_tokens":null,"model":"gpt-4o-2024-08-06","output":[],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":null,"generate_summary":null},"store":true,"temperature":1.0,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":1.0,"truncation":"disabled","usage":null,"user":null,"metadata":{}}} - - - event: response.output_item.added - - data: - {"type":"response.output_item.added","output_index":0,"item":{"id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","type":"message","status":"in_progress","role":"assistant","content":[]}} - - - event: response.content_part.added - - data: - {"type":"response.content_part.added","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"part":{"type":"output_text","text":"","annotations":[]}} - - - event: response.output_text.delta - - data: - {"type":"response.output_text.delta","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"delta":"Hi"} - - - ... - - - event: response.output_text.done - - data: - {"type":"response.output_text.done","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"text":"Hi - there! How can I assist you today?"} - - - event: response.content_part.done - - data: - {"type":"response.content_part.done","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"part":{"type":"output_text","text":"Hi - there! How can I assist you today?","annotations":[]}} - - - event: response.output_item.done - - data: - {"type":"response.output_item.done","output_index":0,"item":{"id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","type":"message","status":"completed","role":"assistant","content":[{"type":"output_text","text":"Hi - there! How can I assist you today?","annotations":[]}]}} - - - event: response.completed - - data: - {"type":"response.completed","response":{"id":"resp_67c9fdcecf488190bdd9a0409de3a1ec07b8b0ad4e5eb654","object":"response","created_at":1741290958,"status":"completed","error":null,"incomplete_details":null,"instructions":"You - are a helpful - assistant.","max_output_tokens":null,"model":"gpt-4o-2024-08-06","output":[{"id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","type":"message","status":"completed","role":"assistant","content":[{"type":"output_text","text":"Hi - there! How can I assist you - today?","annotations":[]}]}],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":null,"generate_summary":null},"store":true,"temperature":1.0,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":1.0,"truncation":"disabled","usage":{"input_tokens":37,"output_tokens":11,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":48},"user":null,"metadata":{}}} - - title: Functions - request: - curl: > - curl https://api.openai.com/v1/responses \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "model": "gpt-4o", - "input": "What is the weather like in Boston today?", - "tools": [ - { - "type": "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", "unit"] - } - } - ], - "tool_choice": "auto" - }' - python: > - from openai import OpenAI - - - client = OpenAI() - - - tools = [ - { - "type": "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", "unit"], - } - } - ] - - - response = client.responses.create( - model="gpt-4o", - tools=tools, - input="What is the weather like in Boston today?", - tool_choice="auto" - ) - - - print(response) - javascript: > - import OpenAI from "openai"; - - - const openai = new OpenAI(); - - - const tools = [ - { - type: "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", "unit"], - }, - }, - ]; - - - const response = await openai.responses.create({ - model: "gpt-4o", - tools: tools, - input: "What is the weather like in Boston today?", - tool_choice: "auto", - }); - - - console.log(response); - response: > - { - "id": "resp_67ca09c5efe0819096d0511c92b8c890096610f474011cc0", - "object": "response", - "created_at": 1741294021, - "status": "completed", - "error": null, - "incomplete_details": null, - "instructions": null, - "max_output_tokens": null, - "model": "gpt-4o-2024-08-06", - "output": [ - { - "type": "function_call", - "id": "fc_67ca09c6bedc8190a7abfec07b1a1332096610f474011cc0", - "call_id": "call_unLAR8MvFNptuiZK6K6HCy5k", - "name": "get_current_weather", - "arguments": "{\"location\":\"Boston, MA\",\"unit\":\"celsius\"}", - "status": "completed" - } - ], - "parallel_tool_calls": true, - "previous_response_id": null, - "reasoning": { - "effort": null, - "generate_summary": null - }, - "store": true, - "temperature": 1.0, - "text": { - "format": { - "type": "text" - } - }, - "tool_choice": "auto", - "tools": [ - { - "type": "function", - "description": "Get the current weather in a given location", - "name": "get_current_weather", - "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", - "unit" - ] - }, - "strict": true - } - ], - "top_p": 1.0, - "truncation": "disabled", - "usage": { - "input_tokens": 291, - "output_tokens": 23, - "output_tokens_details": { - "reasoning_tokens": 0 - }, - "total_tokens": 314 - }, - "user": null, - "metadata": {} - } - - title: Reasoning - request: - curl: | - curl https://api.openai.com/v1/responses \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -d '{ - "model": "o3-mini", - "input": "How much wood would a woodchuck chuck?", - "reasoning": { - "effort": "high" - } - }' - javascript: | - import OpenAI from "openai"; - const openai = new OpenAI(); - - const response = await openai.responses.create({ - model: "o3-mini", - input: "How much wood would a woodchuck chuck?", - reasoning: { - effort: "high" - } - }); - - console.log(response); - python: | - from openai import OpenAI - client = OpenAI() - - response = client.responses.create( - model="o3-mini", - input="How much wood would a woodchuck chuck?", - reasoning={ - "effort": "high" - } - ) - - print(response) - response: > - { - "id": "resp_67ccd7eca01881908ff0b5146584e408072912b2993db808", - "object": "response", - "created_at": 1741477868, - "status": "completed", - "error": null, - "incomplete_details": null, - "instructions": null, - "max_output_tokens": null, - "model": "o1-2024-12-17", - "output": [ - { - "type": "message", - "id": "msg_67ccd7f7b5848190a6f3e95d809f6b44072912b2993db808", - "status": "completed", - "role": "assistant", - "content": [ - { - "type": "output_text", - "text": "The classic tongue twister...", - "annotations": [] - } - ] - } - ], - "parallel_tool_calls": true, - "previous_response_id": null, - "reasoning": { - "effort": "high", - "generate_summary": null - }, - "store": true, - "temperature": 1.0, - "text": { - "format": { - "type": "text" - } - }, - "tool_choice": "auto", - "tools": [], - "top_p": 1.0, - "truncation": "disabled", - "usage": { - "input_tokens": 81, - "input_tokens_details": { - "cached_tokens": 0 - }, - "output_tokens": 1035, - "output_tokens_details": { - "reasoning_tokens": 832 - }, - "total_tokens": 1116 - }, - "user": null, - "metadata": {} - } /responses/{response_id}: get: operationId: getResponse @@ -5800,89 +4861,6 @@ paths: application/json: schema: $ref: "#/components/schemas/Response" - x-oaiMeta: - name: Get a model response - group: responses - returns: > - The [Response](/docs/api-reference/responses/object) object matching - the - - specified ID. - examples: - request: - curl: | - curl https://api.openai.com/v1/responses/resp_123 \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" - javascript: | - import OpenAI from "openai"; - const client = new OpenAI(); - - const response = await client.responses.retrieve("resp_123"); - console.log(response); - python: | - from openai import OpenAI - client = OpenAI() - - response = client.responses.retrieve("resp_123") - print(response) - response: > - { - "id": "resp_67cb71b351908190a308f3859487620d06981a8637e6bc44", - "object": "response", - "created_at": 1741386163, - "status": "completed", - "error": null, - "incomplete_details": null, - "instructions": null, - "max_output_tokens": null, - "model": "gpt-4o-2024-08-06", - "output": [ - { - "type": "message", - "id": "msg_67cb71b3c2b0819084d481baaaf148f206981a8637e6bc44", - "status": "completed", - "role": "assistant", - "content": [ - { - "type": "output_text", - "text": "Silent circuits hum, \nThoughts emerge in data streams— \nDigital dawn breaks.", - "annotations": [] - } - ] - } - ], - "parallel_tool_calls": true, - "previous_response_id": null, - "reasoning": { - "effort": null, - "generate_summary": null - }, - "store": true, - "temperature": 1.0, - "text": { - "format": { - "type": "text" - } - }, - "tool_choice": "auto", - "tools": [], - "top_p": 1.0, - "truncation": "disabled", - "usage": { - "input_tokens": 32, - "input_tokens_details": { - "cached_tokens": 0 - }, - "output_tokens": 18, - "output_tokens_details": { - "reasoning_tokens": 0 - }, - "total_tokens": 50 - }, - "user": null, - "metadata": {} - } delete: operationId: deleteResponse tags: @@ -5906,35 +4884,6 @@ paths: application/json: schema: $ref: "#/components/schemas/Error" - x-oaiMeta: - name: Delete a model response - group: responses - returns: | - A success message. - examples: - request: - curl: | - curl -X DELETE https://api.openai.com/v1/responses/resp_123 \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" - javascript: | - import OpenAI from "openai"; - const client = new OpenAI(); - - const response = await client.responses.del("resp_123"); - console.log(response); - python: | - from openai import OpenAI - client = OpenAI() - - response = client.responses.del("resp_123") - print(response) - response: | - { - "id": "resp_6786a1bec27481909a17d673315b29f6", - "object": "response", - "deleted": true - } /responses/{response_id}/input_items: get: operationId: listInputItems @@ -5989,52 +4938,6 @@ paths: application/json: schema: $ref: "#/components/schemas/ResponseItemList" - x-oaiMeta: - name: List input items - group: responses - returns: A list of input item objects. - examples: - request: - curl: | - curl https://api.openai.com/v1/responses/resp_abc123/input_items \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $OPENAI_API_KEY" - javascript: > - import OpenAI from "openai"; - - const client = new OpenAI(); - - - const response = await - client.responses.inputItems.list("resp_123"); - - console.log(response.data); - python: | - from openai import OpenAI - client = OpenAI() - - response = client.responses.input_items.list("resp_123") - print(response.data) - response: > - { - "object": "list", - "data": [ - { - "id": "msg_abc123", - "type": "message", - "role": "user", - "content": [ - { - "type": "input_text", - "text": "Tell me a three sentence bedtime story about a unicorn." - } - ] - } - ], - "first_id": "msg_abc123", - "last_id": "msg_abc123", - "has_more": false - } /threads: post: operationId: createThread @@ -21957,8 +20860,6 @@ components: - type - key - value - x-oaiMeta: - name: ComparisonFilter CompleteUploadRequest: type: object additionalProperties: false @@ -22018,8 +20919,6 @@ components: required: - type - filters - x-oaiMeta: - name: CompoundFilter ComputerAction: oneOf: - $ref: "#/components/schemas/Click" @@ -22278,18 +21177,6 @@ components: the grouped costs result. required: - object - x-oaiMeta: - name: Costs object - example: | - { - "object": "organization.costs.result", - "amount": { - "value": 0.06, - "currency": "usd" - }, - "line_item": "Image models", - "project_id": "proj_abc" - } Reasoning: type: object description: | @@ -22513,66 +21400,6 @@ components: - tool_choice - temperature - top_p - x-oaiMeta: - name: The response object - group: responses - example: > - { - "id": "resp_67ccd3a9da748190baa7f1570fe91ac604becb25c45c1d41", - "object": "response", - "created_at": 1741476777, - "status": "completed", - "error": null, - "incomplete_details": null, - "instructions": null, - "max_output_tokens": null, - "model": "gpt-4o-2024-08-06", - "output": [ - { - "type": "message", - "id": "msg_67ccd3acc8d48190a77525dc6de64b4104becb25c45c1d41", - "status": "completed", - "role": "assistant", - "content": [ - { - "type": "output_text", - "text": "The image depicts a scenic landscape with a wooden boardwalk or pathway leading through lush, green grass under a blue sky with some clouds. The setting suggests a peaceful natural area, possibly a park or nature reserve. There are trees and shrubs in the background.", - "annotations": [] - } - ] - } - ], - "parallel_tool_calls": true, - "previous_response_id": null, - "reasoning": { - "effort": null, - "generate_summary": null - }, - "store": true, - "temperature": 1.0, - "text": { - "format": { - "type": "text" - } - }, - "tool_choice": "auto", - "tools": [], - "top_p": 1.0, - "truncation": "disabled", - "usage": { - "input_tokens": 328, - "input_tokens_details": { - "cached_tokens": 0 - }, - "output_tokens": 52, - "output_tokens_details": { - "reasoning_tokens": 0 - }, - "total_tokens": 380 - }, - "user": null, - "metadata": {} - } ResponseAudioDeltaEvent: type: object description: Emitted when there is a partial audio response. @@ -22591,15 +21418,6 @@ components: required: - type - delta - x-oaiMeta: - name: response.audio.delta - group: responses - example: | - { - "type": "response.audio.delta", - "response_id": "resp_123", - "delta": "base64encoded..." - } ResponseAudioDoneEvent: type: object description: Emitted when the audio response is complete. @@ -22614,14 +21432,6 @@ components: required: - type - response_id - x-oaiMeta: - name: response.audio.done - group: responses - example: | - { - "type": "response.audio.done", - "response_id": "resp-123" - } ResponseAudioTranscriptDeltaEvent: type: object description: Emitted when there is a partial transcript of audio. @@ -22641,15 +21451,6 @@ components: - type - response_id - delta - x-oaiMeta: - name: response.audio.transcript.delta - group: responses - example: | - { - "type": "response.audio.transcript.delta", - "response_id": "resp_123", - "delta": " ... partial transcript ... " - } ResponseAudioTranscriptDoneEvent: type: object description: Emitted when the full audio transcript is completed. @@ -22664,14 +21465,6 @@ components: required: - type - response_id - x-oaiMeta: - name: response.audio.transcript.done - group: responses - example: | - { - "type": "response.audio.transcript.done", - "response_id": "resp_123" - } ResponseCodeInterpreterCallCodeDeltaEvent: type: object description: Emitted when a partial code snippet is added by the code interpreter. @@ -22698,16 +21491,6 @@ components: - response_id - output_index - delta - x-oaiMeta: - name: response.code_interpreter_call.code.delta - group: responses - example: | - { - "type": "response.code_interpreter_call.code.delta", - "response_id": "resp-123", - "output_index": 0, - "delta": "partial code" - } ResponseCodeInterpreterCallCodeDoneEvent: type: object description: Emitted when code snippet output is finalized by the code interpreter. @@ -22734,16 +21517,6 @@ components: - response_id - output_index - code - x-oaiMeta: - name: response.code_interpreter_call.code.done - group: responses - example: | - { - "type": "response.code_interpreter_call.code.done", - "response_id": "resp-123", - "output_index": 3, - "code": "console.log('done');" - } ResponseCodeInterpreterCallCompletedEvent: type: object description: Emitted when the code interpreter call is completed. @@ -22768,16 +21541,6 @@ components: - response_id - output_index - code_interpreter_call - x-oaiMeta: - name: response.code_interpreter_call.completed - group: responses - example: | - { - "type": "response.code_interpreter_call.completed", - "response_id": "resp-123", - "output_index": 5, - "code_interpreter_call": {} - } ResponseCodeInterpreterCallInProgressEvent: type: object description: Emitted when a code interpreter call is in progress. @@ -22802,16 +21565,6 @@ components: - response_id - output_index - code_interpreter_call - x-oaiMeta: - name: response.code_interpreter_call.in_progress - group: responses - example: | - { - "type": "response.code_interpreter_call.in.progress", - "response_id": "resp-123", - "output_index": 0, - "code_interpreter_call": {} - } ResponseCodeInterpreterCallInterpretingEvent: type: object description: @@ -22838,16 +21591,6 @@ components: - response_id - output_index - code_interpreter_call - x-oaiMeta: - name: response.code_interpreter_call.interpreting - group: responses - example: | - { - "type": "response.code_interpreter_call.interpreting", - "response_id": "resp-123", - "output_index": 4, - "code_interpreter_call": {} - } ResponseCompletedEvent: type: object description: Emitted when the model response is complete. @@ -22866,62 +21609,6 @@ components: required: - type - response - x-oaiMeta: - name: response.completed - group: responses - example: > - { - "type": "response.completed", - "response": { - "id": "resp_123", - "object": "response", - "created_at": 1740855869, - "status": "completed", - "error": null, - "incomplete_details": null, - "input": [], - "instructions": null, - "max_output_tokens": null, - "model": "gpt-4o-mini-2024-07-18", - "output": [ - { - "id": "msg_123", - "type": "message", - "role": "assistant", - "content": [ - { - "type": "output_text", - "text": "In a shimmering forest under a sky full of stars, a lonely unicorn named Lila discovered a hidden pond that glowed with moonlight. Every night, she would leave sparkling, magical flowers by the water's edge, hoping to share her beauty with others. One enchanting evening, she woke to find a group of friendly animals gathered around, eager to be friends and share in her magic.", - "annotations": [] - } - ] - } - ], - "previous_response_id": null, - "reasoning_effort": null, - "store": false, - "temperature": 1, - "text": { - "format": { - "type": "text" - } - }, - "tool_choice": "auto", - "tools": [], - "top_p": 1, - "truncation": "disabled", - "usage": { - "input_tokens": 0, - "output_tokens": 0, - "output_tokens_details": { - "reasoning_tokens": 0 - }, - "total_tokens": 0 - }, - "user": null, - "metadata": {} - } - } ResponseContentPartAddedEvent: type: object description: Emitted when a new content part is added. @@ -22956,21 +21643,6 @@ components: - output_index - content_index - part - x-oaiMeta: - name: response.content_part.added - group: responses - example: | - { - "type": "response.content_part.added", - "item_id": "msg_123", - "output_index": 0, - "content_index": 0, - "part": { - "type": "output_text", - "text": "", - "annotations": [] - } - } ResponseContentPartDoneEvent: type: object description: Emitted when a content part is done. @@ -23005,21 +21677,6 @@ components: - output_index - content_index - part - x-oaiMeta: - name: response.content_part.done - group: responses - example: > - { - "type": "response.content_part.done", - "item_id": "msg_123", - "output_index": 0, - "content_index": 0, - "part": { - "type": "output_text", - "text": "In a shimmering forest under a sky full of stars, a lonely unicorn named Lila discovered a hidden pond that glowed with moonlight. Every night, she would leave sparkling, magical flowers by the water's edge, hoping to share her beauty with others. One enchanting evening, she woke to find a group of friendly animals gathered around, eager to be friends and share in her magic.", - "annotations": [] - } - } ResponseCreatedEvent: type: object description: | @@ -23039,45 +21696,6 @@ components: required: - type - response - x-oaiMeta: - name: response.created - group: responses - example: | - { - "type": "response.created", - "response": { - "id": "resp_67ccfcdd16748190a91872c75d38539e09e4d4aac714747c", - "object": "response", - "created_at": 1741487325, - "status": "in_progress", - "error": null, - "incomplete_details": null, - "instructions": null, - "max_output_tokens": null, - "model": "gpt-4o-2024-08-06", - "output": [], - "parallel_tool_calls": true, - "previous_response_id": null, - "reasoning": { - "effort": null, - "generate_summary": null - }, - "store": true, - "temperature": 1, - "text": { - "format": { - "type": "text" - } - }, - "tool_choice": "auto", - "tools": [], - "top_p": 1, - "truncation": "disabled", - "usage": null, - "user": null, - "metadata": {} - } - } ResponseError: type: object description: | @@ -23146,16 +21764,6 @@ components: - code - message - param - x-oaiMeta: - name: error - group: responses - example: | - { - "type": "error", - "code": "ERR_SOMETHING", - "message": "Something went wrong", - "param": null - } ResponseFailedEvent: type: object description: | @@ -23175,44 +21783,6 @@ components: required: - type - response - x-oaiMeta: - name: response.failed - group: responses - example: | - { - "type": "response.failed", - "response": { - "id": "resp_123", - "object": "response", - "created_at": 1740855869, - "status": "failed", - "error": { - "code": "server_error", - "message": "The model failed to generate a response." - }, - "incomplete_details": null, - "instructions": null, - "max_output_tokens": null, - "model": "gpt-4o-mini-2024-07-18", - "output": [], - "previous_response_id": null, - "reasoning_effort": null, - "store": false, - "temperature": 1, - "text": { - "format": { - "type": "text" - } - }, - "tool_choice": "auto", - "tools": [], - "top_p": 1, - "truncation": "disabled", - "usage": null, - "user": null, - "metadata": {} - } - } ResponseFileSearchCallCompletedEvent: type: object description: Emitted when a file search call is completed (results found). @@ -23236,15 +21806,6 @@ components: - type - output_index - item_id - x-oaiMeta: - name: response.file_search_call.completed - group: responses - example: | - { - "type": "response.file_search_call.completed", - "output_index": 0, - "item_id": "fs_123", - } ResponseFileSearchCallInProgressEvent: type: object description: Emitted when a file search call is initiated. @@ -23269,15 +21830,6 @@ components: - type - output_index - item_id - x-oaiMeta: - name: response.file_search_call.in_progress - group: responses - example: | - { - "type": "response.file_search_call.in_progress", - "output_index": 0, - "item_id": "fs_123", - } ResponseFileSearchCallSearchingEvent: type: object description: Emitted when a file search is currently searching. @@ -23301,15 +21853,6 @@ components: - type - output_index - item_id - x-oaiMeta: - name: response.file_search_call.searching - group: responses - example: | - { - "type": "response.file_search_call.searching", - "output_index": 0, - "item_id": "fs_123", - } ResponseFormatJsonObject: type: object title: JSON object @@ -23442,16 +21985,6 @@ components: - item_id - output_index - delta - x-oaiMeta: - name: response.function_call_arguments.delta - group: responses - example: | - { - "type": "response.function_call_arguments.delta", - "item_id": "item-abc", - "output_index": 0, - "delta": "{ \"arg\":" - } ResponseFunctionCallArgumentsDoneEvent: type: object description: Emitted when function-call arguments are finalized. @@ -23475,16 +22008,6 @@ components: - item_id - output_index - arguments - x-oaiMeta: - name: response.function_call_arguments.done - group: responses - example: | - { - "type": "response.function_call_arguments.done", - "item_id": "item-abc", - "output_index": 1, - "arguments": "{ \"arg\": 123 }" - } ResponseInProgressEvent: type: object description: Emitted when the response is in progress. @@ -23503,45 +22026,6 @@ components: required: - type - response - x-oaiMeta: - name: response.in_progress - group: responses - example: | - { - "type": "response.in_progress", - "response": { - "id": "resp_67ccfcdd16748190a91872c75d38539e09e4d4aac714747c", - "object": "response", - "created_at": 1741487325, - "status": "in_progress", - "error": null, - "incomplete_details": null, - "instructions": null, - "max_output_tokens": null, - "model": "gpt-4o-2024-08-06", - "output": [], - "parallel_tool_calls": true, - "previous_response_id": null, - "reasoning": { - "effort": null, - "generate_summary": null - }, - "store": true, - "temperature": 1, - "text": { - "format": { - "type": "text" - } - }, - "tool_choice": "auto", - "tools": [], - "top_p": 1, - "truncation": "disabled", - "usage": null, - "user": null, - "metadata": {} - } - } ResponseIncompleteEvent: type: object description: | @@ -23561,43 +22045,6 @@ components: required: - type - response - x-oaiMeta: - name: response.incomplete - group: responses - example: | - { - "type": "response.incomplete", - "response": { - "id": "resp_123", - "object": "response", - "created_at": 1740855869, - "status": "incomplete", - "error": null, - "incomplete_details": { - "reason": "max_tokens" - }, - "instructions": null, - "max_output_tokens": null, - "model": "gpt-4o-mini-2024-07-18", - "output": [], - "previous_response_id": null, - "reasoning_effort": null, - "store": false, - "temperature": 1, - "text": { - "format": { - "type": "text" - } - }, - "tool_choice": "auto", - "tools": [], - "top_p": 1, - "truncation": "disabled", - "usage": null, - "user": null, - "metadata": {} - } - } ResponseItemList: type: object description: A list of Response items. @@ -23629,29 +22076,6 @@ components: - first_id - last_id x-oaiExpandable: true - x-oaiMeta: - name: The input item list - group: responses - example: > - { - "object": "list", - "data": [ - { - "id": "msg_abc123", - "type": "message", - "role": "user", - "content": [ - { - "type": "input_text", - "text": "Tell me a three sentence bedtime story about a unicorn." - } - ] - } - ], - "first_id": "msg_abc123", - "last_id": "msg_abc123", - "has_more": false - } ResponseModalities: type: array nullable: true @@ -23720,21 +22144,6 @@ components: - type - output_index - item - x-oaiMeta: - name: response.output_item.added - group: responses - example: | - { - "type": "response.output_item.added", - "output_index": 0, - "item": { - "id": "msg_123", - "status": "in_progress", - "type": "message", - "role": "assistant", - "content": [] - } - } ResponseOutputItemDoneEvent: type: object description: Emitted when an output item is marked done. @@ -23759,27 +22168,6 @@ components: - type - output_index - item - x-oaiMeta: - name: response.output_item.done - group: responses - example: > - { - "type": "response.output_item.done", - "output_index": 0, - "item": { - "id": "msg_123", - "status": "completed", - "type": "message", - "role": "assistant", - "content": [ - { - "type": "output_text", - "text": "In a shimmering forest under a sky full of stars, a lonely unicorn named Lila discovered a hidden pond that glowed with moonlight. Every night, she would leave sparkling, magical flowers by the water's edge, hoping to share her beauty with others. One enchanting evening, she woke to find a group of friendly animals gathered around, eager to be friends and share in her magic.", - "annotations": [] - } - ] - } - } ResponseProperties: type: object properties: @@ -23930,17 +22318,6 @@ components: - output_index - content_index - delta - x-oaiMeta: - name: response.refusal.delta - group: responses - example: | - { - "type": "response.refusal.delta", - "item_id": "msg_123", - "output_index": 0, - "content_index": 0, - "delta": "refusal text so far" - } ResponseRefusalDoneEvent: type: object description: Emitted when refusal text is finalized. @@ -23974,17 +22351,6 @@ components: - output_index - content_index - refusal - x-oaiMeta: - name: response.refusal.done - group: responses - example: | - { - "type": "response.refusal.done", - "item_id": "item-abc", - "output_index": 1, - "content_index": 2, - "refusal": "final refusal text" - } ResponseStreamEvent: anyOf: - $ref: "#/components/schemas/ResponseAudioDeltaEvent" @@ -24058,23 +22424,6 @@ components: - content_index - annotation_index - annotation - x-oaiMeta: - name: response.output_text.annotation.added - group: responses - example: | - { - "type": "response.output_text.annotation.added", - "item_id": "msg_abc123", - "output_index": 1, - "content_index": 0, - "annotation_index": 0, - "annotation": { - "type": "file_citation", - "index": 390, - "file_id": "file-4wDz5b167pAf72nx1h9eiN", - "filename": "dragons.pdf" - } - } ResponseTextDeltaEvent: type: object description: Emitted when there is an additional text delta. @@ -24108,17 +22457,6 @@ components: - output_index - content_index - delta - x-oaiMeta: - name: response.output_text.delta - group: responses - example: | - { - "type": "response.output_text.delta", - "item_id": "msg_123", - "output_index": 0, - "content_index": 0, - "delta": "In" - } ResponseTextDoneEvent: type: object description: Emitted when text content is finalized. @@ -24152,17 +22490,6 @@ components: - output_index - content_index - text - x-oaiMeta: - name: response.output_text.done - group: responses - example: > - { - "type": "response.output_text.done", - "item_id": "msg_123", - "output_index": 0, - "content_index": 0, - "text": "In a shimmering forest under a sky full of stars, a lonely unicorn named Lila discovered a hidden pond that glowed with moonlight. Every night, she would leave sparkling, magical flowers by the water's edge, hoping to share her beauty with others. One enchanting evening, she woke to find a group of friendly animals gathered around, eager to be friends and share in her magic." - } ResponseUsage: type: object description: | @@ -24228,15 +22555,6 @@ components: - type - output_index - item_id - x-oaiMeta: - name: response.web_search_call.completed - group: responses - example: | - { - "type": "response.web_search_call.completed", - "output_index": 0, - "item_id": "ws_123", - } ResponseWebSearchCallInProgressEvent: type: object description: Emitted when a web search call is initiated. @@ -24261,15 +22579,6 @@ components: - type - output_index - item_id - x-oaiMeta: - name: response.web_search_call.in_progress - group: responses - example: | - { - "type": "response.web_search_call.in_progress", - "output_index": 0, - "item_id": "ws_123", - } ResponseWebSearchCallSearchingEvent: type: object description: Emitted when a web search call is executing. @@ -24294,15 +22603,6 @@ components: - type - output_index - item_id - x-oaiMeta: - name: response.web_search_call.searching - group: responses - example: | - { - "type": "response.web_search_call.searching", - "output_index": 0, - "item_id": "ws_123", - } 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.). @@ -27299,8 +25599,6 @@ components: default: 0 required: - query - x-oaiMeta: - name: Vector store search request VectorStoreSearchResultContentObject: type: object additionalProperties: false @@ -27316,8 +25614,6 @@ components: required: - type - text - x-oaiMeta: - name: Vector store search result content object VectorStoreSearchResultItem: type: object additionalProperties: false @@ -27346,8 +25642,6 @@ components: - score - attributes - content - x-oaiMeta: - name: Vector store search result item VectorStoreSearchResultsPage: type: object additionalProperties: false @@ -27382,8 +25676,6 @@ components: - data - has_more - next_page - x-oaiMeta: - name: Vector store search results page VoiceIdsShared: example: ash anyOf: From 202b5a644c191ce0f4fcbf9aec4a2e3410fc45b3 Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Thu, 24 Apr 2025 14:59:39 +0530 Subject: [PATCH 112/124] feat: refactor servers --- openapi.yaml | 403 +++++++++++++++++---------------------------------- 1 file changed, 137 insertions(+), 266 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 81a66f8e..1ece1390 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -11,8 +11,31 @@ info: license: name: MIT url: https://github.com/Portkey-AI/portkey-openapi/blob/master/LICENSE +x-server-defs: + sharedServer: &sharedServer + url: https://api.portkey.ai/v1 + description: Portkey API public endpoint + + controlPlaneSelfHosted: &controlPlaneSelfHosted + url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + description: Self-Hosted Control Plane + + dataPlaneSelfHosted: &dataPlaneSelfHosted + url: SELF_HOSTED_GATEWAY_URL/v1 + description: Self-Hosted Data Plane + +x-server-groups: + ControlPlaneServers: &ControlPlaneServers + - *sharedServer + - *controlPlaneSelfHosted + + DataPlaneServers: &DataPlaneServers + - *sharedServer + - *dataPlaneSelfHosted + servers: - - url: https://api.portkey.ai/v1 + - *sharedServer + tags: - name: Assistants description: Build Assistants that can call models and use tools. @@ -81,11 +104,9 @@ 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 - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - Chat summary: Chat @@ -247,11 +268,9 @@ paths: main(); /completions: + servers: *DataPlaneServers post: operationId: createCompletion - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - Completions summary: Completions @@ -392,6 +411,7 @@ paths: }' /collections: + servers: *ControlPlaneServers post: summary: Create a new collection description: Creates a new collection in the specified workspace @@ -504,6 +524,7 @@ paths: description: Server error /collections/{collectionId}: + servers: *ControlPlaneServers parameters: - name: collectionId in: path @@ -608,6 +629,7 @@ paths: description: Server error /labels: + servers: *ControlPlaneServers post: summary: Create a new label description: Creates a new label in the system @@ -700,6 +722,7 @@ paths: description: Server error /labels/{labelId}: + servers: *ControlPlaneServers get: summary: Get a label by ID description: Returns a specific label by its ID @@ -801,7 +824,7 @@ paths: delete: summary: Delete a label - description: Deletes a label (marks it as archived) + description: Deletes a label operationId: deleteLabel security: - Portkey-Key: [] @@ -844,6 +867,7 @@ paths: description: Server err /prompts: + servers: *ControlPlaneServers post: summary: Create a new prompt operationId: createPrompt @@ -979,6 +1003,7 @@ paths: description: Server error /prompts/{promptId}: + servers: *ControlPlaneServers get: summary: Get a prompt by ID or slug operationId: getPrompt @@ -1119,6 +1144,7 @@ paths: description: Server error /prompts/{promptId}/versions: + servers: *ControlPlaneServers get: summary: Get all versions of a prompt operationId: getPromptVersions @@ -1153,6 +1179,7 @@ paths: description: Server error /prompts/{promptId}/versions/{versionId}: + servers: *ControlPlaneServers get: summary: Get a specific version of a prompt operationId: getPromptByVersion @@ -1239,6 +1266,7 @@ paths: description: Server error /prompts/{promptId}/makeDefault: + servers: *ControlPlaneServers put: summary: Set a version as the default for a prompt operationId: updatePromptDefault @@ -1284,6 +1312,7 @@ paths: description: Server error /prompts/partials: + servers: *ControlPlaneServers post: summary: Create a new prompt partial operationId: createPromptPartial @@ -1369,6 +1398,7 @@ paths: description: Server error /prompts/partials/{promptPartialId}: + servers: *ControlPlaneServers get: summary: Get a prompt partial by ID or slug operationId: getPromptPartial @@ -1483,6 +1513,7 @@ paths: description: Server error /prompts/partials/{promptPartialId}/versions: + servers: *ControlPlaneServers get: summary: Get all versions of a prompt partial operationId: getPromptPartialVersions @@ -1517,6 +1548,7 @@ paths: description: Server error /prompts/partials/{promptPartialId}/makeDefault: + servers: *ControlPlaneServers put: summary: Set a version as the default for a prompt partial operationId: updatePromptPartialDefault @@ -1562,11 +1594,9 @@ paths: description: Server error /prompts/{promptId}/completions: + servers: *DataPlaneServers post: operationId: createPromptCompletion - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - Prompts summary: Prompts Completions @@ -1736,10 +1766,8 @@ paths: console.log(completion); /prompts/{promptId}/render: + servers: *DataPlaneServers post: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 operationId: createPromptRender tags: - Prompts @@ -1894,11 +1922,9 @@ paths: console.log(completion); /images/generations: + servers: *DataPlaneServers post: operationId: createImage - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - Images summary: Create Image @@ -2027,11 +2053,9 @@ paths: console.log(image.data); /images/edits: + servers: *DataPlaneServers post: operationId: createImageEdit - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - Images summary: Create Image Edit @@ -2169,11 +2193,9 @@ paths: main(); /images/variations: + servers: *DataPlaneServers post: operationId: createImageVariation - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - Images summary: Creates Image Variation @@ -2299,11 +2321,9 @@ paths: main(); /embeddings: + servers: *DataPlaneServers post: operationId: createEmbedding - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - Embeddings summary: Embeddings @@ -2437,11 +2457,9 @@ paths: main(); /audio/speech: + servers: *DataPlaneServers post: operationId: createSpeech - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - Audio summary: Create Speech @@ -2595,11 +2613,9 @@ paths: main(); /audio/transcriptions: + servers: *DataPlaneServers post: operationId: createTranscription - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - Audio summary: Create Transcription @@ -2730,11 +2746,9 @@ paths: main(); /audio/translations: + servers: *DataPlaneServers post: operationId: createTranslation - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 tags: - Audio summary: Create Translation @@ -2865,6 +2879,7 @@ paths: main(); /files: + servers: *DataPlaneServers get: operationId: listFiles tags: @@ -3009,6 +3024,7 @@ paths: main(); /files/{file_id}: + servers: *DataPlaneServers delete: operationId: deleteFile tags: @@ -3143,6 +3159,7 @@ paths: main(); /files/{file_id}/content: + servers: *DataPlaneServers get: operationId: downloadFile tags: @@ -3210,10 +3227,8 @@ paths: main(); /fine_tuning/jobs: + servers: *DataPlaneServers post: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 operationId: createFineTuningJob summary: Create a Finetune Job description: Finetune a provider model @@ -3343,9 +3358,6 @@ paths: main(); get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 operationId: listPaginatedFineTuningJobs tags: - Fine-tuning @@ -3463,10 +3475,8 @@ paths: main(); /fine_tuning/jobs/{fine_tuning_job_id}: + servers: *DataPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 operationId: retrieveFineTuningJob tags: - Fine-tuning @@ -3577,10 +3587,8 @@ paths: main(); /fine_tuning/jobs/{fine_tuning_job_id}/events: + servers: *DataPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 operationId: listFineTuningEvents tags: - Fine-tuning @@ -3712,10 +3720,8 @@ paths: main(); /fine_tuning/jobs/{fine_tuning_job_id}/cancel: + servers: *DataPlaneServers post: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 operationId: cancelFineTuningJob tags: - Fine-tuning @@ -3822,10 +3828,8 @@ paths: main(); /fine_tuning/jobs/{fine_tuning_job_id}/checkpoints: + servers: *DataPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 operationId: listFineTuningJobCheckpoints tags: - Fine-tuning @@ -4144,10 +4148,8 @@ paths: main(); /moderations: + servers: *DataPlaneServers post: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 operationId: createModeration tags: - Moderations @@ -4261,6 +4263,7 @@ paths: main(); /assistants: + servers: *DataPlaneServers get: operationId: listAssistants tags: @@ -4516,6 +4519,7 @@ paths: "response_format": "auto" } /assistants/{assistant_id}: + servers: *DataPlaneServers get: operationId: getAssistant tags: @@ -4799,6 +4803,7 @@ paths: "deleted": true } /responses: + servers: *DataPlaneServers post: operationId: createResponse tags: @@ -4822,6 +4827,7 @@ paths: schema: $ref: "#/components/schemas/ResponseStreamEvent" /responses/{response_id}: + servers: *DataPlaneServers get: operationId: getResponse tags: @@ -4885,6 +4891,7 @@ paths: schema: $ref: "#/components/schemas/Error" /responses/{response_id}/input_items: + servers: *DataPlaneServers get: operationId: listInputItems tags: @@ -4939,6 +4946,7 @@ paths: schema: $ref: "#/components/schemas/ResponseItemList" /threads: + servers: *DataPlaneServers post: operationId: createThread tags: @@ -5047,6 +5055,7 @@ paths: } /threads/{thread_id}: + servers: *DataPlaneServers get: operationId: getThread tags: @@ -5307,6 +5316,7 @@ paths: } /threads/{thread_id}/messages: + servers: *DataPlaneServers get: operationId: listMessages tags: @@ -5564,6 +5574,7 @@ paths: } /threads/{thread_id}/messages/{message_id}: + servers: *DataPlaneServers get: operationId: getMessage tags: @@ -5872,6 +5883,7 @@ paths: } /threads/runs: + servers: *DataPlaneServers post: operationId: createThreadAndRun tags: @@ -5998,6 +6010,7 @@ paths: } /threads/{thread_id}/runs: + servers: *DataPlaneServers get: operationId: listRuns tags: @@ -6320,6 +6333,7 @@ paths: } /threads/{thread_id}/runs/{run_id}: + servers: *DataPlaneServers get: operationId: getRun tags: @@ -6590,6 +6604,7 @@ paths: } /threads/{thread_id}/runs/{run_id}/submit_tool_outputs: + servers: *DataPlaneServers post: operationId: submitToolOuputsToRun tags: @@ -6755,6 +6770,7 @@ paths: } /threads/{thread_id}/runs/{run_id}/cancel: + servers: *DataPlaneServers post: operationId: cancelRun tags: @@ -6872,6 +6888,7 @@ paths: } /threads/{thread_id}/runs/{run_id}/steps: + servers: *DataPlaneServers get: operationId: listRunSteps tags: @@ -7013,6 +7030,7 @@ paths: } /threads/{thread_id}/runs/{run_id}/steps/{step_id}: + servers: *DataPlaneServers get: operationId: getRunStep tags: @@ -8427,10 +8445,8 @@ paths: } /batches: + servers: *DataPlaneServers post: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 summary: Creates and executes a batch from an uploaded file of requests operationId: createBatch tags: @@ -8568,9 +8584,6 @@ paths: get: operationId: listBatches - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL tags: - Batch summary: List your organization's batches. @@ -8688,10 +8701,8 @@ paths: main(); /batches/{batch_id}: + servers: *DataPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 operationId: retrieveBatch tags: - Batch @@ -8799,11 +8810,9 @@ paths: main(); /batches/{batch_id}/cancel: + servers: *DataPlaneServers post: operationId: cancelBatch - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL 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. @@ -8912,10 +8921,8 @@ paths: main(); /configs: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 summary: List all configs tags: - Configs @@ -9048,9 +9055,6 @@ paths: }) console.log(config); post: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 summary: Create a config tags: - Configs @@ -9211,10 +9215,8 @@ paths: console.log(config); /configs/{slug}: + servers: *ControlPlaneServers delete: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 summary: Delete a config tags: - Configs @@ -9286,9 +9288,7 @@ paths: id:"CONFIG_SLUG" }) get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + servers: *ControlPlaneServers summary: Get a config tags: - Configs @@ -9440,9 +9440,7 @@ paths: console.log(config); put: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 + servers: *ControlPlaneServers summary: Update a config tags: - Configs @@ -9601,10 +9599,8 @@ paths: console.log(config); /feedback: + servers: *ControlPlaneServers post: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 summary: Create new feedback description: This endpoint allows users to submit feedback for a particular interaction or response. operationId: createFeedback @@ -9704,10 +9700,8 @@ paths: -d '{"trace_id":"REQUEST_TRACE_ID","value":1}' /feedback/{id}: + servers: *ControlPlaneServers put: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 summary: Updates existing feedback description: This endpoint allows users to update existing feedback. operationId: updateFeedback @@ -9815,10 +9809,8 @@ paths: -d '{"value":1}' /virtual-keys: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 summary: List All Virtual Keys tags: - Virtual-keys @@ -9925,9 +9917,6 @@ paths: -H "x-portkey-virtual-key: PROVIDER_VIRTUAL_KEY" post: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 summary: Create a Virtual Key tags: - Virtual-keys @@ -10011,6 +10000,9 @@ paths: $ref: "#/components/schemas/UsageLimits" rate_limits: $ref: "#/components/schemas/RateLimits" + expires_at: + type: string + format: date-time examples: generic: value: @@ -10197,10 +10189,8 @@ paths: }' /virtual-keys/{slug}: + servers: *ControlPlaneServers get: - servers: - - url: "https://api.portkey.ai/v1" - - url: "SELF_HOSTED_CONTROL_PLANE_URL/v1" summary: Get a Virtual Key tags: - Virtual-keys @@ -10309,9 +10299,6 @@ paths: put: summary: Update a Virtual Key - servers: - - url: "https://api.portkey.ai/v1" - - url: "SELF_HOSTED_CONTROL_PLANE_URL/v1" tags: - Virtual-keys parameters: @@ -10486,9 +10473,6 @@ paths: delete: summary: Delete a Virtual Key - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Virtual-keys parameters: @@ -10594,10 +10578,8 @@ paths: console.log(result); /admin/users/invites: + servers: *ControlPlaneServers post: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 operationId: Invites_create summary: Invite User description: Send an invite to user for your organization @@ -10789,9 +10771,6 @@ paths: console.log(user); get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - User-invites summary: Get All Invites @@ -10931,10 +10910,8 @@ paths: console.log(user); /admin/users/invites/{inviteId}: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - User-invites summary: Get Invite @@ -11042,9 +11019,6 @@ paths: }); console.log(user); delete: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - User-invites summary: Delete Invite By ID @@ -11144,10 +11118,8 @@ paths: console.log(user); /admin/users/invites/{inviteId}/resend: + servers: *ControlPlaneServers post: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - User-invites summary: Resend Invite @@ -11253,10 +11225,8 @@ paths: console.log(user); /admin/users: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai - - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - Users summary: Get users @@ -11382,10 +11352,8 @@ paths: console.log(users); /admin/users/{userId}: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai - - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - Users summary: Get user @@ -11491,9 +11459,6 @@ paths: console.log(user); delete: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Users summary: Remove a user @@ -11590,9 +11555,6 @@ paths: console.log(user); put: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Users summary: Update user @@ -11709,10 +11671,8 @@ paths: console.log(user); /admin/workspaces/{workspaceId}/users: + servers: *ControlPlaneServers post: - servers: - - url: https://api.portkey.ai - - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - Workspaces > Members summary: Add workspace member @@ -11853,9 +11813,6 @@ paths: console.log(user); get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Workspaces > Members summary: Get workspace members @@ -11968,10 +11925,8 @@ paths: console.log(user); /admin/workspaces/{workspaceId}/users/{userId}: + servers: *ControlPlaneServers put: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Workspaces > Members summary: Update workspace member @@ -12095,9 +12050,6 @@ paths: console.log(user); delete: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Workspaces > Members summary: Remove workspace member @@ -12206,9 +12158,6 @@ paths: console.log(user) get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Workspaces > Members summary: Get member @@ -12324,10 +12273,8 @@ paths: console.log(user); /admin/workspaces: + servers: *ControlPlaneServers post: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Workspaces summary: Create Workspace @@ -12495,9 +12442,6 @@ paths: console.log(workspace) get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Workspaces summary: Get All Workspaces @@ -12609,10 +12553,8 @@ paths: console.log(workspaces); /admin/workspaces/{workspaceId}: + servers: *ControlPlaneServers put: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Workspaces summary: Update Workspace @@ -12754,9 +12696,6 @@ paths: console.log(workspace); get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Workspaces summary: Get workspace @@ -12851,9 +12790,6 @@ paths: console.log(workspace); delete: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Workspaces summary: Delete a workspace @@ -12939,10 +12875,8 @@ paths: console.log(workspace); /logs: + servers: *DataPlaneServers post: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_GATEWAY_URL/v1 summary: Insert New logs tags: - Logs @@ -13142,10 +13076,8 @@ paths: main(); /logs/exports/{exportId}: + servers: *ControlPlaneServers get: - servers: - - url: "https://api.portkey.ai/v1" - - url: "SELF_HOSTED_CONTROL_PLANE_URL" tags: - Logs Export summary: Get a specific logs export @@ -13240,9 +13172,6 @@ paths: main() put: - servers: - - url: "https://api.portkey.ai/v1" - - url: "SELF_HOSTED_CONTROL_PLANE_URL" tags: - Logs Export summary: Update a logs export @@ -13372,10 +13301,8 @@ paths: main(); /logs/exports: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - Logs Export summary: Get all logs exports @@ -13469,9 +13396,6 @@ paths: main(); post: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - Logs Export summary: Create log export @@ -13710,10 +13634,8 @@ paths: main(); /logs/exports/{exportId}/start: + servers: *ControlPlaneServers post: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - Logs Export summary: Start log export @@ -13805,10 +13727,8 @@ paths: main(); /logs/exports/{exportId}/cancel: + servers: *ControlPlaneServers post: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - Logs Export summary: Cancel log export @@ -13900,10 +13820,8 @@ paths: main(); /logs/exports/{exportId}/download: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - Logs Export summary: Download log export @@ -13995,10 +13913,8 @@ paths: main() /audit-logs: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - Audit Logs summary: Get Audit Logs @@ -14113,10 +14029,8 @@ paths: $ref: "#/components/schemas/AuditLogObjectList" /api-keys/{type}/{sub-type}: + servers: *ControlPlaneServers post: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - Api-Keys summary: Create Api Keys @@ -14354,10 +14268,8 @@ paths: print(api_key) /api-keys: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai - - url: SELF_HOSTED_CONTROL_PLANE_URL tags: - Api-Keys summary: Get All @@ -14427,10 +14339,8 @@ paths: -H "x-portkey-api-key: PORTKEY_API_KEY" /api-keys/{id}: + servers: *ControlPlaneServers put: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Api-Keys summary: Update Api Keys @@ -14814,9 +14724,6 @@ paths: console.log(apiKey); get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Api-Keys summary: Get Api Keys @@ -14914,9 +14821,6 @@ paths: console.log(apiKey); delete: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Api-Keys summary: Remove a Api Key @@ -15013,10 +14917,8 @@ paths: console.log(apiKey); /analytics/graphs/requests: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get requests graph @@ -15090,10 +14992,8 @@ paths: - object /analytics/graphs/cost: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get cost graph @@ -15175,10 +15075,8 @@ paths: - object /analytics/graphs/latency: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get latency graph @@ -15277,10 +15175,8 @@ paths: - object /analytics/graphs/tokens: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get tokens graph @@ -15362,10 +15258,8 @@ paths: - object /analytics/graphs/users: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get users graph. Returns unique user count across different time buckets @@ -15439,10 +15333,8 @@ paths: - object /analytics/graphs/users/requests: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get users requests graph. Returns average requests per user across different time buckets @@ -15524,10 +15416,8 @@ paths: - object /analytics/graphs/errors: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get errors graph @@ -15601,10 +15491,8 @@ paths: - object /analytics/graphs/errors/rate: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get percentage error rate graph @@ -15678,10 +15566,8 @@ paths: - object /analytics/graphs/errors/stacks: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get status code wise stacked error graph @@ -15763,10 +15649,8 @@ paths: - object /analytics/graphs/errors/status-codes: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get status code wise grouped error graph. @@ -15843,10 +15727,8 @@ paths: - object /analytics/graphs/requests/rescued: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get retry and fallback rescued requests graph @@ -15936,10 +15818,8 @@ paths: - object /analytics/graphs/cache/hit-rate: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get cache hit rate graph @@ -16033,10 +15913,8 @@ paths: - object /analytics/graphs/cache/latency: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get cache hit latency graph @@ -16104,10 +15982,8 @@ paths: - object /analytics/graphs/feedbacks: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get feedbacks graph @@ -16181,10 +16057,8 @@ paths: - object /analytics/graphs/feedbacks/scores: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get score-wise feedbacks distribution graph @@ -16257,10 +16131,8 @@ paths: - object /analytics/graphs/feedbacks/weighted: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get weighted feedbacks graph. Weighted feedback is (value * score) @@ -16334,10 +16206,8 @@ paths: - object /analytics/graphs/feedbacks/ai-models: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Graphs summary: Get feedbacks per ai_models graph @@ -16408,10 +16278,8 @@ paths: - object /analytics/summary/cache: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Summary summary: Get cache summary data for the selected time period @@ -16475,10 +16343,8 @@ paths: - object /analytics/groups/users: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Groups summary: Get metadata users grouped data. @@ -16550,10 +16416,8 @@ paths: - data /analytics/groups/ai-models: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Groups summary: Get ai model grouped data. @@ -16622,10 +16486,8 @@ paths: - data /analytics/groups/metadata/{metadataKey}: + servers: *ControlPlaneServers get: - servers: - - url: https://api.portkey.ai/v1 - - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 tags: - Analytics > Groups summary: Get metadata key based grouped data. @@ -27109,6 +26971,9 @@ components: items: $ref: "#/components/schemas/RateLimits" nullable: true + expires_at: + type: string + format: date-time object: type: string enum: [virtual-key] @@ -28131,6 +27996,9 @@ components: type: string format: email example: "foo@bar.com" + expires_at: + type: string + format: date-time object: type: string enum: ["api-key"] @@ -28206,6 +28074,9 @@ components: type: string format: email example: "foo@bar.com" + expires_at: + type: string + format: date-time UpdateApiKeyObject: type: object From 843360076ea9fb422ada4a74502816739547a215 Mon Sep 17 00:00:00 2001 From: Vrushank Vyas <134934501+vrushankportkey@users.noreply.github.com> Date: Sat, 26 Apr 2025 11:40:48 +0530 Subject: [PATCH 113/124] make virtual key a required param for prompt create API --- openapi.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index 1ece1390..fc5df425 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -886,6 +886,7 @@ paths: - collection_id - string - parameters + - virtual_key properties: name: type: string @@ -28793,4 +28794,4 @@ x-code-samples: path: create - type: object key: CreateCompletionResponse - path: object \ No newline at end of file + path: object From 573c2a90f013e617e893b906348ff967b2c05e49 Mon Sep 17 00:00:00 2001 From: Vrushank Vyas <134934501+vrushankportkey@users.noreply.github.com> Date: Tue, 29 Apr 2025 18:46:48 +0530 Subject: [PATCH 114/124] Add more speech models that are supported --- openapi.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index fc5df425..38410a43 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -19677,7 +19677,7 @@ components: 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. + 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 @@ -19839,7 +19839,7 @@ components: 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. + 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 From deaf7be897a3ecd68485379b432b441448d00179 Mon Sep 17 00:00:00 2001 From: Vrushank Vyas <134934501+vrushankportkey@users.noreply.github.com> Date: Mon, 26 May 2025 14:40:10 +0530 Subject: [PATCH 115/124] Update openapi.yaml --- openapi.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index 38410a43..5102ecb5 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1,4 +1,3 @@ - openapi: 3.0.0 info: title: Portkey API From 8066fb5d538c27916b1e67f2d95ac2df7f663333 Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Wed, 28 May 2025 10:38:55 +0530 Subject: [PATCH 116/124] fix: add missing /v1 to the control plane endpoint --- openapi.yaml | 96 ++++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 5102ecb5..4b976eb2 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -9031,7 +9031,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Retrieve the configuration @@ -9171,7 +9171,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Create a new configuration @@ -9268,7 +9268,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) portkey.configs.delete( @@ -9281,7 +9281,7 @@ paths: const portkey = new Portkey({ apiKey:"PORTKEY_API_KEY", - baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL/v1" }) await portkey.configs.delete({ @@ -9414,7 +9414,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Retrieve the configuration @@ -9555,7 +9555,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Update the configuration @@ -9662,7 +9662,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) feedback = portkey.feedback.create( @@ -9771,7 +9771,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) feedback = portkey.feedback.update( @@ -9889,7 +9889,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # List virtual keys @@ -10149,7 +10149,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Add a new virtual key @@ -10167,7 +10167,7 @@ paths: const portkey = new Portkey({ apiKey: "PORTKEY_API_KEY", - baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL/v1" }) const newVkey=await portkey.virtualKeys.create({ @@ -10273,7 +10273,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Get a specific virtual key @@ -10441,7 +10441,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Update a specific virtual key @@ -10553,7 +10553,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Delete a specific virtual key @@ -10715,7 +10715,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Add a user invite @@ -10885,7 +10885,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # List user invites @@ -10995,7 +10995,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Get a user invite @@ -11092,7 +11092,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Delete a user invite @@ -11199,7 +11199,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Delete a user invite @@ -11315,12 +11315,12 @@ paths: - lang: curl label: Default source: | - curl -X GET "https://api.portkey.ai/admin/users" + 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" + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users" -H "x-portkey-api-key: PORTKEY_API_KEY" - lang: python label: Self-Hosted @@ -11330,7 +11330,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # List users @@ -11434,7 +11434,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Get a specific user @@ -11530,7 +11530,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Delete a user @@ -11643,7 +11643,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Update a user @@ -11777,7 +11777,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Add user to workspace @@ -11900,7 +11900,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Get user from workspace @@ -12021,7 +12021,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Update user in workspace @@ -12129,7 +12129,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Delete user from workspace @@ -12246,7 +12246,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Get user from workspace @@ -12402,7 +12402,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Add a workspace @@ -12532,7 +12532,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # List workspaces @@ -12661,7 +12661,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Update workspace @@ -12850,7 +12850,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Delete workspace @@ -13135,7 +13135,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/logs/exports/EXPORT_ID" \ + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/logs/exports/EXPORT_ID" \ -H "x-portkey-api-key: PORTKEY_API_KEY" - lang: python label: Self-Hosted @@ -13144,7 +13144,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) res = portkey.logs.exports.retrieve( @@ -13253,7 +13253,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/logs/exports/EXPORT_ID" \ + curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/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"}}' @@ -13264,7 +13264,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) res = portkey.logs.exports.update( @@ -13359,7 +13359,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/logs/exports?workspace_id=WORKSPACE_ID" \ + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/logs/exports?workspace_id=WORKSPACE_ID" \ -H "x-portkey-api-key: PORTKEY_API_KEY" - lang: python label: Self-Hosted @@ -13368,7 +13368,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) res = portkey.logs.exports.list( @@ -13551,7 +13551,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) res = portkey.logs.exports.create( @@ -13698,7 +13698,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) res = portkey.logs.exports.start( @@ -13791,7 +13791,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) res = portkey.logs.exports.cancel( @@ -13884,7 +13884,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) res = portkey.logs.exports.download( @@ -14240,7 +14240,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) api_key = portkey.admin.api_keys.create( @@ -14617,7 +14617,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Update the API key @@ -14795,7 +14795,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Get API keys @@ -14892,7 +14892,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL" + base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" ) # Delete the API key From 129af1aeb87eb85604dd934cf4f273c0b81c5d3e Mon Sep 17 00:00:00 2001 From: vrushankportkey Date: Wed, 28 May 2025 12:43:37 +0530 Subject: [PATCH 117/124] URL Changes --- openapi.yaml | 279 ++++++++++++++++++++++++++++----------------------- 1 file changed, 156 insertions(+), 123 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 4b976eb2..35c093d1 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -10,30 +10,22 @@ info: license: name: MIT url: https://github.com/Portkey-AI/portkey-openapi/blob/master/LICENSE -x-server-defs: - sharedServer: &sharedServer - url: https://api.portkey.ai/v1 - description: Portkey API public endpoint - - controlPlaneSelfHosted: &controlPlaneSelfHosted - url: SELF_HOSTED_CONTROL_PLANE_URL/v1 - description: Self-Hosted Control Plane - - dataPlaneSelfHosted: &dataPlaneSelfHosted - url: SELF_HOSTED_GATEWAY_URL/v1 - description: Self-Hosted Data Plane - x-server-groups: ControlPlaneServers: &ControlPlaneServers - - *sharedServer - - *controlPlaneSelfHosted + - 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 - - *sharedServer - - *dataPlaneSelfHosted + - url: https://api.portkey.ai/v1 + description: Portkey API Public Endpoint + - url: SELF_HOSTED_GATEWAY_URL + description: Self-Hosted Gateway URL servers: - - *sharedServer + - url: https://api.portkey.ai/v1 + description: Portkey API Public Endpoint tags: - name: Assistants @@ -168,7 +160,7 @@ paths: - lang: cURL label: Self-Hosted source: | - curl SELF_HOSTED_GATEWAY_URL/v1/chat/completions \ + 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" \ @@ -398,7 +390,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl https://SELF_HOSTED_GATEWAY_URL/v1/completions \ + 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" \ @@ -1714,7 +1706,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/prompts/YOUR_PROMPT_ID/completions" \ + 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 '{ @@ -1869,7 +1861,7 @@ paths: - lang: "cURL" label: Self-Hosted source: | - curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/prompts/YOUR_PROMPT_ID/render" \ + 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 '{ @@ -2003,7 +1995,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/images/generations" \ + 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" \ @@ -2138,7 +2130,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/images/edits" \ + 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" \ @@ -2272,7 +2264,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/images/variations" \ + 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" \ @@ -2405,7 +2397,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/embeddings" \ + 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" \ @@ -2556,7 +2548,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/audio/speech" \ + 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" \ @@ -2696,7 +2688,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/audio/transcriptions" \ + 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" \ @@ -2829,7 +2821,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/audio/translations" \ + 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" \ @@ -3313,7 +3305,7 @@ paths: - lang: curl label: Self-hosted source: | - curl https://SELF_HOSTED_GATEWAY_URL/v1/fine_tuning/jobs \ + 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" \ @@ -3438,7 +3430,7 @@ paths: - lang: curl label: Self-hosted source: | - curl https://SELF_HOSTED_GATEWAY_URL/v1/fine_tuning/jobs?limit=2 \ + 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 @@ -3552,7 +3544,7 @@ paths: - lang: curl label: Self-hosted source: | - curl SELF_HOSTED_GATEWAY_URL/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F \ + 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 @@ -3680,7 +3672,7 @@ paths: - lang: curl label: Self-hosted source: | - curl SELF_HOSTED_GATEWAY_URL/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F/events \ + 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 @@ -3794,7 +3786,7 @@ paths: - lang: curl label: Self-hosted source: | - curl -X POST SELF_HOSTED_GATEWAY_URL/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F/cancel \ + 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 @@ -3888,7 +3880,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl SELF_HOSTED_GATEWAY_URL/v1/fine_tuning/jobs/ftjob-abc123/checkpoints \ + 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 @@ -4224,7 +4216,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl https://SELF_HOSTED_GATEWAY_URL/v1/moderations \ + 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" \ @@ -8534,7 +8526,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl SELF_HOSTED_GATEWAY_URL/v1/batches \ + 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" \ @@ -8663,7 +8655,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl SELF_HOSTED_GATEWAY_URL/v1/batches?limit=2 \ + 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" @@ -8774,7 +8766,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl SELF_HOSTED_GATEWAY_URL/v1/batches/batch_abc123 \ + 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" \ @@ -8884,7 +8876,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl SELF_HOSTED_GATEWAY_URL/v1/batches/batch_abc123/cancel \ + 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" \ @@ -9031,7 +9023,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Retrieve the configuration @@ -9171,7 +9163,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Create a new configuration @@ -9268,7 +9260,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) portkey.configs.delete( @@ -9281,7 +9273,7 @@ paths: const portkey = new Portkey({ apiKey:"PORTKEY_API_KEY", - baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL/v1" + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) await portkey.configs.delete({ @@ -9414,7 +9406,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Retrieve the configuration @@ -9555,7 +9547,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Update the configuration @@ -9662,7 +9654,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) feedback = portkey.feedback.create( @@ -9694,7 +9686,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/v1/feedback \ + 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}' @@ -9771,7 +9763,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) feedback = portkey.feedback.update( @@ -9803,7 +9795,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/v1/feedback/{id} \ + 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}' @@ -9889,7 +9881,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # List virtual keys @@ -9912,7 +9904,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X GET SELF_HOSTED_CONTROL_PLANE_URL/v1/virtual-keys \ + 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" @@ -10149,7 +10141,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Add a new virtual key @@ -10167,7 +10159,7 @@ paths: const portkey = new Portkey({ apiKey: "PORTKEY_API_KEY", - baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL/v1" + baseUrl: "SELF_HOSTED_CONTROL_PLANE_URL" }) const newVkey=await portkey.virtualKeys.create({ @@ -10179,7 +10171,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/v1/virtual-keys \ + curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/virtual-keys \ -H "x-portkey-api-key: PORTKEY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ @@ -10263,7 +10255,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X GET SELF_HOSTED_CONTROL_PLANE_URL/v1/virtual-keys/VIRTUAL_KEY_SLUG \ + 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 @@ -10273,7 +10265,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Get a specific virtual key @@ -10419,7 +10411,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/v1/virtual_keys/VIRTUAL_KEY_SLUG" \ + 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 '{ @@ -10441,7 +10433,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Update a specific virtual key @@ -10544,7 +10536,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X DELETE https://SELF_HOSTED_CONTROL_PLANE_URL/v1/virtual_keys/VIRTUAL_KEY_SLUG + curl -X DELETE https://SELF_HOSTED_CONTROL_PLANE_URL/virtual_keys/VIRTUAL_KEY_SLUG - lang: python label: Self-Hosted source: | @@ -10553,7 +10545,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Delete a specific virtual key @@ -10686,7 +10678,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users/invites + 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 '{ @@ -10715,7 +10707,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Add a user invite @@ -10875,7 +10867,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users/invites?email=user@example.com" + 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 @@ -10885,7 +10877,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # List user invites @@ -10985,7 +10977,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users/invites/INVITE_ID" + 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 @@ -10995,7 +10987,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Get a user invite @@ -11082,7 +11074,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X DELETE "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users/invites/INVITE_ID" + 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 @@ -11092,7 +11084,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Delete a user invite @@ -11189,7 +11181,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users/invites/INVITE_ID/resend" + 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 @@ -11199,7 +11191,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Delete a user invite @@ -11225,7 +11217,9 @@ paths: console.log(user); /admin/users: - servers: *ControlPlaneServers + servers: + - url: https://api.portkey.ai/v1 + - url: https://SELF_HOSTED_CONTROL_PLANE_URL get: tags: - Users @@ -11320,7 +11314,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users" + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/admin/users" -H "x-portkey-api-key: PORTKEY_API_KEY" - lang: python label: Self-Hosted @@ -11330,7 +11324,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # List users @@ -11352,7 +11346,9 @@ paths: console.log(users); /admin/users/{userId}: - servers: *ControlPlaneServers + servers: + - url: https://api.portkey.ai/v1 + - url: https://SELF_HOSTED_CONTROL_PLANE_URL get: tags: - Users @@ -11424,7 +11420,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users/USER_ID" + 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 @@ -11434,7 +11430,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Get a specific user @@ -11520,7 +11516,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X DELETE "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users/USER_ID" + 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 @@ -11530,7 +11526,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Delete a user @@ -11632,7 +11628,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/users/USER_ID" + 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 @@ -11643,7 +11639,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Update a user @@ -11671,7 +11667,9 @@ paths: console.log(user); /admin/workspaces/{workspaceId}/users: - servers: *ControlPlaneServers + servers: + - url: https://api.portkey.ai/v1 + - url: https://SELF_HOSTED_CONTROL_PLANE_URL post: tags: - Workspaces > Members @@ -11766,7 +11764,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/workspaces/{workspaceId}/users" + 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 @@ -11777,7 +11775,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Add user to workspace @@ -11890,7 +11888,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/workspaces/{workspaceId}/users" + 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 @@ -11900,7 +11898,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Get user from workspace @@ -12010,7 +12008,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/workspaces/{workspaceId}/users/{userId}" + 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 @@ -12021,7 +12019,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Update user in workspace @@ -12119,7 +12117,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X DELETE "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/workspaces/{workspaceId}/users/{userId}" + 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 @@ -12129,7 +12127,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Delete user from workspace @@ -12236,7 +12234,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/workspaces/{workspaceId}/users/{userId}" + 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 @@ -12246,7 +12244,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Get user from workspace @@ -12381,7 +12379,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/workspaces \ + curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/admin/workspaces \ -H "x-portkey-api-key: PORTKEY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ @@ -12402,7 +12400,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Add a workspace @@ -12523,7 +12521,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X GET SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/workspaces + curl -X GET SELF_HOSTED_CONTROL_PLANE_URL/admin/workspaces - lang: python label: Self-Hosted source: | @@ -12532,7 +12530,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # List workspaces @@ -12649,7 +12647,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/workspaces/{workspaceId}" \ + 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"}}' @@ -12661,7 +12659,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Update workspace @@ -12755,7 +12753,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/workspaces/{workspaceId}" \ + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/admin/workspaces/{workspaceId}" \ -H "x-portkey-api-key: PORTKEY_API_KEY" - lang: python label: Self-Hosted @@ -12840,7 +12838,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X DELETE "SELF_HOSTED_CONTROL_PLANE_URL/v1/admin/workspaces/{workspaceId}" \ + curl -X DELETE "SELF_HOSTED_CONTROL_PLANE_URL/admin/workspaces/{workspaceId}" \ -H "x-portkey-api-key: PORTKEY_API_KEY" - lang: python label: Self-Hosted @@ -12850,7 +12848,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Delete workspace @@ -12987,7 +12985,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST "SELF_HOSTED_GATEWAY_URL/v1/logs" \ + curl -X POST "SELF_HOSTED_GATEWAY_URL/logs" \ -H "x-portkey-api-key: PORTKEY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ @@ -13135,7 +13133,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/logs/exports/EXPORT_ID" \ + 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 @@ -13144,7 +13142,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) res = portkey.logs.exports.retrieve( @@ -13253,7 +13251,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X PUT "SELF_HOSTED_CONTROL_PLANE_URL/v1/logs/exports/EXPORT_ID" \ + 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"}}' @@ -13264,7 +13262,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) res = portkey.logs.exports.update( @@ -13359,7 +13357,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/logs/exports?workspace_id=WORKSPACE_ID" \ + 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 @@ -13368,7 +13366,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) res = portkey.logs.exports.list( @@ -13551,7 +13549,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) res = portkey.logs.exports.create( @@ -13698,7 +13696,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) res = portkey.logs.exports.start( @@ -13791,7 +13789,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) res = portkey.logs.exports.cancel( @@ -13884,7 +13882,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) res = portkey.logs.exports.download( @@ -14175,7 +14173,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X POST SELF_HOSTED_CONTROL_PLANE_URL/v1/api-keys/organisation/service + 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 '{ @@ -14240,7 +14238,7 @@ paths: portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) api_key = portkey.admin.api_keys.create( @@ -14268,7 +14266,9 @@ paths: print(api_key) /api-keys: - servers: *ControlPlaneServers + servers: + - url: https://api.portkey.ai/v1 + - url: https://SELF_HOSTED_CONTROL_PLANE_URL get: tags: - Api-Keys @@ -14307,12 +14307,10 @@ paths: source: | from portkey_ai import Portkey - # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY" ) - # List API keys api_keys = portkey.api_keys.list( workspace_id="WORKSPACE_SLUG" ) @@ -14337,6 +14335,41 @@ paths: 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 @@ -14548,7 +14581,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/api-keys/{id}" \ + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/api-keys/{id}" \ -H "x-portkey-api-key: PORTKEY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ @@ -14617,7 +14650,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Update the API key @@ -14785,7 +14818,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/v1/api_keys/{id}" \ + curl -X GET "SELF_HOSTED_CONTROL_PLANE_URL/api_keys/{id}" \ -H "x-portkey-api-key: PORTKEY_API_KEY" - lang: python label: Self-Hosted @@ -14795,7 +14828,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Get API keys @@ -14882,7 +14915,7 @@ paths: - lang: curl label: Self-Hosted source: | - curl -X DELETE "SELF_HOSTED_CONTROL_PLANE_URL/v1/api_keys/{id}" \ + curl -X DELETE "SELF_HOSTED_CONTROL_PLANE_URL/api_keys/{id}" \ -H "x-portkey-api-key: PORTKEY_API_KEY" - lang: python label: Self-Hosted @@ -14892,7 +14925,7 @@ paths: # Initialize the Portkey client portkey = Portkey( api_key="PORTKEY_API_KEY", - base_url="SELF_HOSTED_CONTROL_PLANE_URL/v1" + base_url="SELF_HOSTED_CONTROL_PLANE_URL" ) # Delete the API key From 9fd59a562ae7024fbdbfcecee7a151027c381bfd Mon Sep 17 00:00:00 2001 From: Vrushank Vyas <134934501+vrushankportkey@users.noreply.github.com> Date: Thu, 29 May 2025 19:56:45 +0530 Subject: [PATCH 118/124] add mcp true --- openapi.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 35c093d1..2448b2fd 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -23,6 +23,9 @@ x-server-groups: - url: SELF_HOSTED_GATEWAY_URL description: Self-Hosted Gateway URL +x-mcp: + enabled: true + servers: - url: https://api.portkey.ai/v1 description: Portkey API Public Endpoint From 030c273473e297ff03a78fe1f11295c2e8602706 Mon Sep 17 00:00:00 2001 From: Vrushank Vyas <134934501+vrushankportkey@users.noreply.github.com> Date: Fri, 30 May 2025 13:07:06 +0530 Subject: [PATCH 119/124] Update OpenAI links for Responses API --- openapi.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 2448b2fd..66cac1f5 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -19275,15 +19275,15 @@ components: Learn more: - - [Text inputs and outputs](/docs/guides/text) + - [Text inputs and outputs](https://platform.openai.com/docs/guides/text?api-mode=responses) - - [Image inputs](/docs/guides/images) + - [Image inputs](https://platform.openai.com/docs/guides/images-vision?api-mode=responses) - - [File inputs](/docs/guides/pdf-files) + - [File inputs](https://platform.openai.com/docs/guides/pdf-files?api-mode=responses) - - [Conversation state](/docs/guides/conversation-state) + - [Conversation state](https://platform.openai.com/docs/guides/conversation-state?api-mode=responses) - - [Function calling](/docs/guides/function-calling) + - [Function calling](https://platform.openai.com/docs/guides/function-calling?api-mode=responses) x-oaiExpandable: true oneOf: - type: string From 65daade5aaa564c2036a877875f68cbbb7ea673c Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Tue, 1 Jul 2025 00:55:24 +0530 Subject: [PATCH 120/124] chore: guardrails apis --- openapi.yaml | 1788 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1788 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 66cac1f5..8aacaac1 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -47,6 +47,8 @@ tags: 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 @@ -1916,6 +1918,733 @@ paths: 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" + + 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" + + pangea_security: + summary: "[PARTNER] Pangea Security Suite" + value: + name: "Pangea Text & PII Guard" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "pangea.textGuard" + parameters: + recipe: "default_text_recipe" + debug: true + overrides: + prompt_guard: + state: "enabled" + timeout: 5000 + - id: "pangea.pii" + parameters: + redact: true + timeout: 5000 + actions: + onFail: "block" + message: "Pangea security scan failed" + + 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" + + # MULTI-PROVIDER COMPREHENSIVE EXAMPLE + enterprise_security_stack: + summary: "[COMPREHENSIVE] Enterprise Multi-Layer Security" + value: + name: "Enterprise Security Pipeline" + workspace_id: "550e8400-e29b-41d4-a716-446655440000" + checks: + - id: "default.jwt" + parameters: + jwksUri: "https://auth.company.com/.well-known/jwks.json" + headerKey: "Authorization" + algorithms: ["RS256"] + - id: "default.modelWhitelist" + parameters: + models: ["gpt-4", "claude-3-sonnet"] + - id: "sydelabs.sydeguard" + parameters: + prompt_injection_threshold: 0.3 + toxicity_threshold: 0.2 + - id: "azure.contentSafety" + parameters: + severity: 1 + categories: ["Hate", "Violence"] + - id: "patronus.pii" + parameters: + redact: true + - id: "acuvity.scan" + parameters: + prompt_injection: true + toxic: true + pii: true + secrets: true + actions: + onFail: "block" + message: "Enterprise security pipeline blocked request" + logLevel: "error" + metadata: + severity: "high" + alert_team: "security" + 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: @@ -28179,6 +28908,1065 @@ components: - 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: + onFail: + type: string + enum: ["block", "log", "warn", "continue"] + description: Action to take when guardrail check fails + default: "block" + onPass: + type: string + enum: ["continue", "log"] + description: Action to take when guardrail check passes + default: "continue" + message: + type: string + description: Custom message to return on failure + logLevel: + type: string + enum: ["debug", "info", "warn", "error"] + description: Log level for the action + default: "info" + metadata: + type: object + description: Additional metadata for the action + additionalProperties: true + + 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" + # 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" + - "pangea.textGuard" + - "pangea.pii" + - "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/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/PangeaTextGuardParameters' + - $ref: '#/components/schemas/PangeaPIIParameters' + - $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 + 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: + 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: + 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: + type: object + required: + - models + properties: + models: + type: array + items: + type: string + description: List of allowed models + + WordCountParameters: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + 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: + type: object + properties: + not: + type: boolean + description: If true, the verdict will be inverted + default: false + + RequiredMetadataKeysParameters: + 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" + + SydeGuardParameters: + 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: + type: object + required: + - projectID + properties: + projectID: + type: string + description: Aporia Project ID to validate + timeout: + type: number + description: Timeout in milliseconds + default: 5000 + + PillarScanParameters: + 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: + type: object + properties: + redact: + type: boolean + description: Whether to redact detected content + default: false + timeout: + type: number + description: Timeout in milliseconds + default: 5000 + + PatronusCustomParameters: + 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: + 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: + 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: + 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: + 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 + + PangeaTextGuardParameters: + type: object + required: + - recipe + properties: + recipe: + type: string + description: Recipe key for Pangea configuration + debug: + type: boolean + description: Enable detailed analysis + overrides: + type: object + additionalProperties: true + description: Pangea overrides + timeout: + type: number + description: Timeout in milliseconds + default: 5000 + + PangeaPIIParameters: + type: object + properties: + redact: + type: boolean + description: Whether to redact detected PII + default: false + timeout: + type: number + description: Timeout in milliseconds + default: 5000 + + BedrockGuardParameters: + 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: + type: object + properties: + redact: + type: boolean + description: Whether to redact detected content + default: false + timeout: + type: number + description: Timeout in milliseconds + default: 5000 + + AcuvityScanParameters: + 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: + 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: + 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: + 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: + type: object + description: Basic parameters with no specific requirements + additionalProperties: true + BedrockBatchJob: type: object required: From 9cdc265c975cc8c098507568212cb26f2053bc04 Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Tue, 1 Jul 2025 01:13:04 +0530 Subject: [PATCH 121/124] chore: remove redundant example --- openapi.yaml | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 8aacaac1..66cfed7c 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -2417,45 +2417,6 @@ paths: onFail: "block" message: "Prisma AIRS blocked request" - # MULTI-PROVIDER COMPREHENSIVE EXAMPLE - enterprise_security_stack: - summary: "[COMPREHENSIVE] Enterprise Multi-Layer Security" - value: - name: "Enterprise Security Pipeline" - workspace_id: "550e8400-e29b-41d4-a716-446655440000" - checks: - - id: "default.jwt" - parameters: - jwksUri: "https://auth.company.com/.well-known/jwks.json" - headerKey: "Authorization" - algorithms: ["RS256"] - - id: "default.modelWhitelist" - parameters: - models: ["gpt-4", "claude-3-sonnet"] - - id: "sydelabs.sydeguard" - parameters: - prompt_injection_threshold: 0.3 - toxicity_threshold: 0.2 - - id: "azure.contentSafety" - parameters: - severity: 1 - categories: ["Hate", "Violence"] - - id: "patronus.pii" - parameters: - redact: true - - id: "acuvity.scan" - parameters: - prompt_injection: true - toxic: true - pii: true - secrets: true - actions: - onFail: "block" - message: "Enterprise security pipeline blocked request" - logLevel: "error" - metadata: - severity: "high" - alert_team: "security" responses: '200': description: Guardrail created successfully From 2f84e4d76f314dd24ae9079dc05f2647f5a52d4c Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Tue, 8 Jul 2025 19:28:47 +0530 Subject: [PATCH 122/124] chore: get and update workspaces --- openapi.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 66cfed7c..72f36d0c 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -13266,6 +13266,14 @@ paths: type: object additionalProperties: type: string + input_guardrails: + type: array + items: + type: string + output_guardrails: + type: array + items: + type: string example: name: My Workspace description: My Description @@ -27901,6 +27909,14 @@ components: is_default: type: integer example: 0 + input_guardrails: + type: array + items: + type: string + output_guardrails: + type: array + items: + type: string object: type: string enum: @@ -27958,6 +27974,14 @@ components: is_default: type: integer example: 0 + input_guardrails: + type: array + items: + type: string + output_guardrails: + type: array + items: + type: string object: type: string enum: From 6cd9c2ba3b2045593a64b4646fb8911ecbc199fe Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Tue, 8 Jul 2025 19:30:09 +0530 Subject: [PATCH 123/124] chore: remove redundant defaults from list --- openapi.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 72f36d0c..4aab8bac 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -13168,18 +13168,12 @@ paths: description: This is a production workspace created_at: "2023-07-13 13:51:27" last_updated_at: "2023-07-13 14:51:27" - defaults: - metadata: - foo: bar 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" - defaults: - metadata: - foo: bar object: workspace x-code-samples: - lang: python From 5ed9c59068ad44f5219f38136b8d14b25617bf6e Mon Sep 17 00:00:00 2001 From: sk-portkey Date: Thu, 10 Jul 2025 00:50:30 +0530 Subject: [PATCH 124/124] chore: update workspace put response --- openapi.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index 4aab8bac..93f17479 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -13291,7 +13291,8 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Workspace" + type: object + example: {} x-code-samples: - lang: python label: Default