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

url = "https://api.parallel.ai/v1beta/chat/completions"

payload = {
    "model": "<string>",
    "messages": [
        {
            "role": "system",
            "content": "<string>",
            "name": "<string>"
        }
    ]
}
headers = {
    "x-api-key": "<api-key>",
    "Content-Type": "application/json"
}

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

print(response.text)
{
  "id": "<string>",
  "choices": [
    {
      "delta": {
        "content": "<string>",
        "function_call": {
          "arguments": "<string>",
          "name": "<string>"
        },
        "refusal": "<string>",
        "role": "developer",
        "tool_calls": [
          {
            "index": 123,
            "id": "<string>",
            "function": {
              "arguments": "<string>",
              "name": "<string>"
            },
            "type": "<string>"
          }
        ]
      },
      "index": 123,
      "finish_reason": "stop",
      "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
    }
  },
  "basis": []
}

Authorizations

x-api-key
string
header
required

Body

application/json

Request for the chat completions endpoint.

Note that all parameters except for model, stream, and response_format are ignored.

model
string
required

The model to use for chat completions.

messages
ChatMessage · object[]
required

The messages to use for chat completions.

stream
boolean | null

Whether to stream the chat completions.

response_format
ResponseFormatText · object

The response format to use for chat completions. OpenAI compatible.

max_tokens
integer | null

The maximum number of tokens to generate. Unsupported.

temperature
number | null

The temperature to use for chat completions. Unsupported.

top_p
number | null

The top p to use for chat completions. Unsupported.

n
integer | null

The number of chat completions to generate. Unsupported.

presence_penalty
number | null

The presence penalty to use for chat completions. Unsupported.

frequency_penalty
number | null

The frequency penalty to use for chat completions. Unsupported.

Response

Returns a ChatCompletion object for non-streaming requests (application/json), or a stream of ChatCompletionResponseChunk objects for streaming requests (text/event-stream) when stream=true is set in the request.

Chat completion response.

id
string
required

The id of the chat completion.

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
basis
FieldBasis · object[]

Basis for the chat completion, including citations and reasoning supporting the output.