Chat Completions
import requests
url = "https://api.parallel.ai/v1beta/chat/completions"
payload = {
"model": "<string>",
"messages": [
{
"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)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: '<string>', messages: [{content: '<string>', name: '<string>'}]})
};
fetch('https://api.parallel.ai/v1beta/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://api.parallel.ai/v1beta/chat/completions \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"model": "<string>",
"messages": [
{
"content": "<string>",
"name": "<string>"
}
]
}
'{
"id": "<string>",
"choices": [
{
"delta": {
"audio": {
"id": "<string>",
"data": "<string>",
"expires_at": 123,
"transcript": "<string>"
},
"content": "<string>",
"function_call": {
"arguments": "<string>",
"name": "<string>"
},
"refusal": "<string>",
"role": "developer",
"tool_calls": [
{
"index": 123,
"id": "<string>",
"function": {
"arguments": "<string>",
"name": "<string>"
},
"type": "function"
}
]
},
"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": "chat.completion",
"moderation": {
"input": {
"model": "<string>",
"results": [
{
"categories": {},
"category_applied_input_types": {},
"category_scores": {},
"flagged": true,
"model": "<string>",
"type": "moderation_result"
}
],
"type": "moderation_results"
},
"output": {
"model": "<string>",
"results": [
{
"categories": {},
"category_applied_input_types": {},
"category_scores": {},
"flagged": true,
"model": "<string>",
"type": "moderation_result"
}
],
"type": "moderation_results"
}
},
"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,
"text_tokens": 123
},
"prompt_tokens_details": {
"audio_tokens": 123,
"cache_write_tokens": 123,
"cached_tokens": 123,
"image_tokens": 123,
"text_tokens": 123
}
},
"basis": [],
"interaction_id": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Chat API (Beta)
Chat Completions
Chat completions.
This endpoint can be used to get realtime chat completions. It can also be used with the Task API processors to get structured, research outputs via a chat interface.
POST
/
v1beta
/
chat
/
completions
Chat Completions
import requests
url = "https://api.parallel.ai/v1beta/chat/completions"
payload = {
"model": "<string>",
"messages": [
{
"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)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: '<string>', messages: [{content: '<string>', name: '<string>'}]})
};
fetch('https://api.parallel.ai/v1beta/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://api.parallel.ai/v1beta/chat/completions \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"model": "<string>",
"messages": [
{
"content": "<string>",
"name": "<string>"
}
]
}
'{
"id": "<string>",
"choices": [
{
"delta": {
"audio": {
"id": "<string>",
"data": "<string>",
"expires_at": 123,
"transcript": "<string>"
},
"content": "<string>",
"function_call": {
"arguments": "<string>",
"name": "<string>"
},
"refusal": "<string>",
"role": "developer",
"tool_calls": [
{
"index": 123,
"id": "<string>",
"function": {
"arguments": "<string>",
"name": "<string>"
},
"type": "function"
}
]
},
"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": "chat.completion",
"moderation": {
"input": {
"model": "<string>",
"results": [
{
"categories": {},
"category_applied_input_types": {},
"category_scores": {},
"flagged": true,
"model": "<string>",
"type": "moderation_result"
}
],
"type": "moderation_results"
},
"output": {
"model": "<string>",
"results": [
{
"categories": {},
"category_applied_input_types": {},
"category_scores": {},
"flagged": true,
"model": "<string>",
"type": "moderation_result"
}
],
"type": "moderation_results"
}
},
"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,
"text_tokens": 123
},
"prompt_tokens_details": {
"audio_tokens": 123,
"cache_write_tokens": 123,
"cached_tokens": 123,
"image_tokens": 123,
"text_tokens": 123
}
},
"basis": [],
"interaction_id": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Body
application/json
Request for the chat completions endpoint.
Note that all parameters except for model, stream, and response_format
are ignored.
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.