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));HttpResponse<String> response = Unirest.post("https://api.parallel.ai/v1beta/chat/completions")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"name\": \"<string>\"\n }\n ]\n}")
.asString();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": {
"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
},
"prompt_tokens_details": {
"audio_tokens": 123,
"cached_tokens": 123
}
},
"basis": [],
"interaction_id": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}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.
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));HttpResponse<String> response = Unirest.post("https://api.parallel.ai/v1beta/chat/completions")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"name\": \"<string>\"\n }\n ]\n}")
.asString();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": {
"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
},
"prompt_tokens_details": {
"audio_tokens": 123,
"cached_tokens": 123
}
},
"basis": [],
"interaction_id": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
Body
Request for the chat completions endpoint.
Note that all parameters except for model, stream, and response_format
are ignored.
The model to use for chat completions.
The messages to use for chat completions.
Show child attributes
Show child attributes
Whether to stream the chat completions.
Default response format. Used to generate text responses.
- ResponseFormatText
- ResponseFormatJSONSchema
- ResponseFormatJSONObject
Show child attributes
Show child attributes
The maximum number of tokens to generate. Unsupported.
The temperature to use for chat completions. Unsupported.
The top p to use for chat completions. Unsupported.
The number of chat completions to generate. Unsupported.
The presence penalty to use for chat completions. Unsupported.
The frequency penalty to use for chat completions. Unsupported.
Interaction ID from a previous chat completion to use as context.
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.
The id of the chat completion.
Show child attributes
Show child attributes
"chat.completion"Moderation results for the request input and generated output, if moderated completions were requested.
Show child attributes
Show child attributes
auto, default, flex, scale, priority Usage statistics for the completion request.
Show child attributes
Show child attributes
Basis for the chat completion, including citations and reasoning supporting the output.
Show child attributes
Show child attributes
Identifier for this interaction. Pass as previous_interaction_id for follow-ups.