Skip to main content
POST
/
openai
/
chat
/
completions
Chat Completions
import requests

url = "https://api.opper.ai/v2/openai/chat/completions"

payload = {
    "messages": [
        {
            "content": "<string>",
            "role": "<string>",
            "name": "<string>"
        }
    ],
    "model": "<string>",
    "audio": {
        "format": "wav",
        "voice": "<string>"
    },
    "frequency_penalty": 123,
    "function_call": "none",
    "functions": [
        {
            "name": "<string>",
            "description": "<string>",
            "parameters": {}
        }
    ],
    "logit_bias": {},
    "logprobs": True,
    "max_completion_tokens": 123,
    "max_tokens": 123,
    "metadata": {},
    "modalities": ["text"],
    "n": 123,
    "parallel_tool_calls": True,
    "prediction": {
        "content": "<string>",
        "type": "<string>"
    },
    "presence_penalty": 123,
    "prompt_cache_key": "<string>",
    "reasoning_effort": "minimal",
    "response_format": { "type": "<string>" },
    "safety_identifier": "<string>",
    "seed": 123,
    "service_tier": "auto",
    "stop": "<string>",
    "store": True,
    "stream_options": {
        "include_obfuscation": True,
        "include_usage": True
    },
    "temperature": 123,
    "tool_choice": "none",
    "tools": [
        {
            "function": {
                "name": "<string>",
                "description": "<string>",
                "parameters": {},
                "strict": True
            },
            "type": "<string>"
        }
    ],
    "top_logprobs": 123,
    "top_p": 123,
    "user": "<string>",
    "verbosity": "low",
    "web_search_options": {
        "search_context_size": "low",
        "user_location": {
            "approximate": {
                "city": "<string>",
                "country": "<string>",
                "region": "<string>",
                "timezone": "<string>"
            },
            "type": "<string>"
        }
    },
    "stream": True,
    "tags": {},
    "parent_span_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
{
  "id": "<string>",
  "choices": [
    {
      "finish_reason": "stop",
      "index": 123,
      "message": {
        "role": "<string>",
        "content": "<string>",
        "refusal": "<string>",
        "annotations": [
          {
            "type": "<string>",
            "url_citation": {
              "end_index": 123,
              "start_index": 123,
              "title": "<string>",
              "url": "<string>"
            }
          }
        ],
        "audio": {
          "id": "<string>",
          "data": "<string>",
          "expires_at": 123,
          "transcript": "<string>"
        },
        "function_call": {
          "arguments": "<string>",
          "name": "<string>"
        },
        "tool_calls": [
          {
            "id": "<string>",
            "function": {
              "arguments": "<string>",
              "name": "<string>"
            },
            "type": "<string>"
          }
        ]
      },
      "logprobs": {
        "content": [
          {
            "token": "<string>",
            "logprob": 123,
            "top_logprobs": [
              {
                "token": "<string>",
                "logprob": 123,
                "bytes": [
                  123
                ]
              }
            ],
            "bytes": [
              123
            ]
          }
        ],
        "refusal": [
          {
            "token": "<string>",
            "logprob": 123,
            "top_logprobs": [
              {
                "token": "<string>",
                "logprob": 123,
                "bytes": [
                  123
                ]
              }
            ],
            "bytes": [
              123
            ]
          }
        ]
      }
    }
  ],
  "created": 123,
  "model": "<string>",
  "object": "<string>",
  "service_tier": "auto",
  "system_fingerprint": "<string>",
  "usage": {
    "completion_tokens": 123,
    "prompt_tokens": 123,
    "total_tokens": 123,
    "completion_tokens_details": {
      "accepted_prediction_tokens": 123,
      "audio_tokens": 123,
      "reasoning_tokens": 123,
      "rejected_prediction_tokens": 123
    },
    "prompt_tokens_details": {
      "audio_tokens": 123,
      "cached_tokens": 123
    }
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
messages
(ChatCompletionDeveloperMessageParam · object | ChatCompletionSystemMessageParam · object | ChatCompletionUserMessageParam · object | ChatCompletionAssistantMessageParam · object | ChatCompletionToolMessageParam · object | ChatCompletionFunctionMessageParam · object)[]
required
model
audio
ChatCompletionAudioParam · object
frequency_penalty
number | null
function_call
Available options:
none,
auto
functions
Function · object[]
logit_bias
Logit Bias · object
logprobs
boolean | null
max_completion_tokens
integer | null
max_tokens
integer | null
metadata
Metadata · object
modalities
enum<string>[] | null
Available options:
text,
audio
n
integer | null
parallel_tool_calls
boolean
prediction
ChatCompletionPredictionContentParam · object
presence_penalty
number | null
prompt_cache_key
string
reasoning_effort
enum<string> | null
Available options:
minimal,
low,
medium,
high
response_format
ResponseFormatText · object
safety_identifier
string
seed
integer | null
service_tier
enum<string> | null
Available options:
auto,
default,
flex,
scale,
priority
stop
store
boolean | null
stream_options
ChatCompletionStreamOptionsParam · object
temperature
number | null
tool_choice
Available options:
none,
auto,
required
tools
(ChatCompletionFunctionToolParam · object | ChatCompletionCustomToolParam · object)[]
top_logprobs
integer | null
top_p
number | null
user
string
verbosity
enum<string> | null
Available options:
low,
medium,
high
web_search_options
WebSearchOptions · object
stream
boolean | null
tags
Tags · object
parent_span_id
string<uuid> | null

Response

Successful Response

id
string
required
choices
Choice · object[]
required
created
integer
required
model
string
required
object
string
required
Allowed value: "chat.completion"
service_tier
enum<string> | null
Available options:
auto,
default,
flex,
scale,
priority
system_fingerprint
string | null
usage
CompletionUsage · object