POST
/
chat
/
completions
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!"
}
]
}'
{
  "id": "<string>",
  "choices": [
    {
      "finish_reason": "stop",
      "index": 123,
      "message": {
        "content": "<string>",
        "tool_calls": [
          {
            "id": "<string>",
            "type": "function",
            "function": {
              "name": "<string>",
              "arguments": "<string>"
            }
          }
        ],
        "role": "assistant",
        "function_call": {
          "arguments": "<string>",
          "name": "<string>"
        },
        "content_blocks": [
          {
            "type": "text",
            "text": "<string>"
          }
        ]
      },
      "logprobs": {
        "content": [
          {
            "token": "<string>",
            "logprob": 123,
            "bytes": [
              123
            ],
            "top_logprobs": [
              {
                "token": "<string>",
                "logprob": 123,
                "bytes": [
                  123
                ]
              }
            ]
          }
        ]
      }
    }
  ],
  "created": 123,
  "model": "<string>",
  "system_fingerprint": "<string>",
  "object": "chat.completion",
  "usage": {
    "completion_tokens": 123,
    "prompt_tokens": 123,
    "total_tokens": 123
  }
}

Authorizations

x-portkey-api-key
string
header
required
x-portkey-virtual-key
string
header
required

Headers

x-portkey-trace-id
string

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

x-portkey-span-id
string

An ID you can pass to refer to a span under a trace.

x-portkey-parent-span-id
string

Link a child span to a parent span

x-portkey-span-name
string

Name for the Span ID

x-portkey-metadata
object

Pass any arbitrary metadata along with your request

x-portkey-cache-namespace
string

Partition your Portkey cache store based on custom strings, ignoring metadata and other headers

x-portkey-cache-force-refresh
boolean

Forces a cache refresh for your request by making a new API call and storing the updated value

Body

application/json

Response

200 - application/json

OK

Represents a chat completion response returned by model, based on the provided input.