🎉 New Models Available: grok-4 now live!
→ Explore New Features
POST https://api.cometapi.com/v1/chat/completions
is used to send a request to generate chat completions. The request should include a model
parameter specifying the model to use, a list of messages
containing the role and content of the messages, and a stream
parameter to indicate whether to stream the response.model
(string): Specifies the model to use for generating completions.messages
(array): Contains the role and content of the messages for which completions are to be generated.role
(string): Specifies the role of the message (e.g., "user", "assistant", "system").content
(string): The content of the message for which completions are to be generated.stream
(boolean): Indicates whether to stream the response.{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "Hello!"
}
],
"stream": false
}
curl --location --request POST 'https://api.cometapi.com/v1/chat/completions' \
--header 'Authorization: Bearer {{api-key}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "Hello!"
}
],
"stream": false
}'
{
"id": "chatcmpl-AreYSBEwmzB0kY3GxzBEhE1Olct83",
"object": "chat.completion",
"created": 1737350640,
"model": "gpt-4o-2024-08-06",
"system_fingerprint": "fp_f3927aa00d",
"choices": [
{
"index": 0,
"message": {
"content": "Hello! How can I assist you today?",
"role": "assistant"
},
"finish_reason": "stop"
}
],
"usage": {
"completion_tokens": 9,
"completion_tokens_details": {},
"prompt_tokens": 9,
"prompt_tokens_details": {},
"total_tokens": 18
}
}