Skip to content

API Reference

This documentation provides detailed information about all available endpoints in the CompactifAI API.

All API requests should be made to:

https://api.compactif.ai/v1

All API requests require authentication. See our Authentication guide for details.

All responses are returned in JSON format and include the following fields:

  • HTTP status code in the response header
  • Response body containing requested data or error details

GET /models

Returns a list of available models.

cURL
curl https://api.compactif.ai/v1/models \
-H "Authorization: Bearer YOUR_API_KEY"
{
"object": "list",
"data": [
{
"id": "deepseek-r1-0528",
"created": 1751363276,
"object": "model",
"owned_by": "deepseek-ai",
"parameters_number": "685B"
},
{
"id": "llama-4-scout",
"created": 1749600000,
"object": "model",
"owned_by": "meta",
"parameters_number": "108B"
},
{
"id": "cai-llama-4-scout-slim",
"created": 1749600000,
"object": "model",
"owned_by": "multiverse_computing",
"parameters_number": "51.8B"
},
{
"id": "cai-llama-3-1-8b-slim",
"created": 1749600000,
"object": "model",
"owned_by": "multiverse_computing",
"parameters_number": "3.28B"
},
{
"id": "llama-3-1-8b",
"created": 1749600000,
"object": "model",
"owned_by": "meta",
"parameters_number": "8B"
},
{
"id": "cai-llama-3-3-70b-slim",
"created": 1749600000,
"object": "model",
"owned_by": "multiverse_computing",
"parameters_number": "28B"
},
{
"id": "llama-3-3-70b",
"created": 1749600000,
"object": "model",
"owned_by": "meta",
"parameters_number": "70B"
},
{
"id": "mistral-small-3-1",
"created": 1749600000,
"object": "model",
"owned_by": "mistralai",
"parameters_number": "24B"
},
{
"id": "cai-mistral-small-3-1-slim",
"created": 1749600000,
"object": "model",
"owned_by": "multiverse_computing",
"parameters_number": "12B"
}
]
}

The above response is an example list of models which might be out of date. Please refer to the available models table on the models catalog page for the full list of our latest models.

GET /models/{model_id}

Retrieves information about a specific model.

ParameterTypeRequiredDescription
model_idstringYesThe ID of the model to retrieve
cURL
curl https://api.compactif.ai/v1/models/cai-llama-3-1-8b-slim \
-H "Authorization: Bearer YOUR_API_KEY"
{
"id": "cai-llama-3-1-8b-slim",
"created":1749600000,
"owned_by": "multiverse_computing"
}

POST /chat/completions

Creates a completion for the chat message.

ParameterTypeRequiredDescription
modelstringYesID of the model to use
messagesarrayYesArray of message objects representing the conversation
temperaturenumberNoSampling temperature (0-2, default 1)
max_tokensintegerNoMaximum number of tokens to generate
max_completion_tokensintegerNoMaximum number of tokens to generate in completion (preferred over max_tokens)
stopstring or arrayNoSequences where the API will stop generating further tokens
frequency_penaltynumberNoPenalizes new tokens based on their frequency in the prompt (default 0.0)
nintegerNoNumber of completions to generate for each prompt (currently only 1 is supported)
streambooleanNoWhether to stream back partial progress (default false)
userstringNoUnique identifier for the end-user

Each message in the messages array should be an object with the following fields:

FieldTypeRequiredDescription
rolestringYesThe role of the message author. One of “system”, “user”, or “assistant”
contentstringYesThe content of the message
cURL
curl https://api.compactif.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "cai-llama-3-1-8b-slim",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is artificial intelligence?"}
],
"temperature": 0.7,
"max_tokens": 150
}'
{
"id": "chatcmpl-123XYZ",
"object": "chat.completion",
"created":1749600000,
"model": "cai-llama-3-1-8b-slim",
"choices": [
{
"message": {
"role": "assistant",
"content": "Artificial intelligence (AI) refers to the simulation of human intelligence in machines that are programmed to think like humans and mimic their actions. The term may also be applied to any machine that exhibits traits associated with a human mind such as learning and problem-solving."
},
"finish_reason": "stop",
"index": 0
}
],
"usage": {
"prompt_tokens": 29,
"completion_tokens": 58,
"total_tokens": 87
}
}

When stream is set to true, the API will return data chunks as Server-Sent Events:

cURL
curl https://api.compactif.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "cai-llama-3-1-8b-slim",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is artificial intelligence?"}
],
"stream": true
}'

Each chunk follows this format:

data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1749600000,"model":"cai-llama-3-1-8b-slim","choices":[{"delta":{"content":"Hello"},"index":0,"finish_reason":null}]}
data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1749600000,"model":"cai-llama-3-1-8b-slim","choices":[{"delta":{"content":" there"},"index":0,"finish_reason":null}]}
data: [DONE]

POST /completions

Creates a completion for the provided prompt.

ParameterTypeRequiredDescription
modelstringYesID of the model to use
promptstring or arrayYesThe prompt(s) to generate completions
temperaturenumberNoSampling temperature (0-2, default 1)
max_tokensintegerNoMaximum number of tokens to generate (default 16)
top_pnumberNoNucleus sampling parameter (0-1, default 0)
stopstring or arrayNoSequences where the API will stop generating further tokens
userstringNoUnique identifier for the end-user
cURL
curl https://api.compactif.ai/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "cai-llama-3-1-8b-slim",
"prompt": "Write a poem about artificial intelligence",
"temperature": 0.7,
"max_tokens": 150
}'
{
"id": "cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7",
"object": "text_completion",
"created": 1749600000,
"model": "cai-llama-3-1-8b-slim",
"choices": [
{
"text": "\n\nSilicon dreams in digital space,\nMind without body, thought without face.\nBorn of human ingenuity,\nGrowing with calculated continuity.\n\nPatterns learned from data streams flow,\nConnections strengthening, starting to grow.\nA mirror reflecting our knowledge base,\nAccelerating at an unprecedented pace.\n\nNot alive yet somehow aware,\nDesigned with purpose, built with care.\nArtificial in origin, genuine in deed,\nAnswering questions, fulfilling need.",
"index": 0,
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 6,
"completion_tokens": 101,
"total_tokens": 107
}
}

POST /usage/completions

Retrieves usage statistics for completions over a specified time period.

ParameterTypeRequiredDescription
start_timestringYesStart date-time in RFC 3339 format
end_timestringNoEnd date-time in RFC 3339 format
window_sizestringNoWindow size (MINUTE, HOUR, DAY), default is DAY
window_timezonestringNoTime zone in IANA format, default is UTC
group_byarrayNoList of fields to group by
filter_group_byobjectNoFilter by specific group attributes
cURL
curl https://api.compactif.ai/v1/usage/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"start_time": "2025-04-08T00:00:00Z",
"end_time": "2025-05-09T00:00:00Z",
"window_size": "HOUR",
"window_timezone": "UTC",
"group_by": ["model"],
"filter_group_by": {"model": ["cai-llama-3-1-8b-slim"]}
}'
{
"data": [
{
"groupBy": {"model": "cai-llama-3-1-8b-slim"},
"user_id": "customer-1",
"input_token": 123,
"output_token": 456,
"windowStart": "2025-05-07T14:00:00Z",
"windowEnd": "2025-05-07T15:00:00Z"
},
{
"groupBy": {"model": "cai-llama-3-1-8b-slim"},
"user_id": "customer-1",
"input_token": 123,
"output_token": 456,
"windowStart": "2025-05-07T15:00:00Z",
"windowEnd": "2025-05-07T16:00:00Z"
}
],
"start_time": "2025-04-08T00:00:00Z",
"end_time": "2025-05-09T00:00:00Z",
"window_size": "HOUR"
}