Use the Chat Completions request and response format to work with your Snaga agents. Configure the base address, API key and agent ID in your client. The examples below use HTTP requests.
Use this base address in your HTTP client, together with your Snaga API key and an agent ID from your company.
/v1Pass your platform API key in the Authorization header using the Bearer scheme, the same way you would with the upstream API.
Authorization: Bearer YOUR_API_KEYAPI keys can be created and rotated in Settings → API keys.
/v1/modelsLists your company’s agents and teams in the model-list format. Use an agent ID for chat completions and responses.
Response
{
"object": "list",
"data": [
{
"id": "AGENT_ID",
"object": "model",
"created": 1700000000,
"owned_by": "organization"
}
]
}Examples
curl https://api.snaga.ai/v1/models \
-H "Authorization: Bearer YOUR_API_KEY"/v1/chat/completionsCreates a chat completion. The answer can stream, or arrive whole.
Request body
{
"model": "AGENT_ID",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Hello!" }
],
"stream": false,
"temperature": 0.7,
"max_tokens": 1024
}Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1700000000,
"model": "AGENT_ID",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 10,
"total_tokens": 30
}
}Examples
curl https://api.snaga.ai/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "AGENT_ID",
"messages": [
{"role": "user", "content": "Hello!"}
]
}'Set stream: true to receive Server-Sent Events. The streaming format is identical to the upstream API.
/v1/embeddingsCreate embeddings for the given input text. Returns vector representations that can be used for search.
Request body
{
"model": "EMBEDDING_MODEL_ID",
"input": "The quick brown fox jumps over the lazy dog"
}Response
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.0023, -0.0091, 0.0152, ...]
}
],
"model": "EMBEDDING_MODEL_ID",
"usage": {
"prompt_tokens": 9,
"total_tokens": 9
}
}Examples
curl https://api.snaga.ai/v1/embeddings \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "EMBEDDING_MODEL_ID",
"input": "Hello world"
}'/v1/responsesCreate a response using the Responses API. This is an alternative to chat completions that supports richer output.
Request body
{
"model": "AGENT_ID",
"input": "Explain quantum computing in simple terms."
}Response
{
"id": "resp-abc123",
"object": "response",
"created_at": 1700000000,
"model": "AGENT_ID",
"output": [
{
"type": "message",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "Quantum computing uses..."
}
]
}
]
}Examples
curl https://api.snaga.ai/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "AGENT_ID",
"input": "Explain quantum computing."
}'Choose an agent from GET /v1/models and try one of the HTTP examples below with your API key.
pip install requests
import requests
r = requests.post(
"https://api.snaga.ai/v1/chat/completions",
headers={"Authorization": "Bearer YOUR_API_KEY"}, # from Settings > API keys
json={
"model": "AGENT_ID",
"messages": [{"role": "user", "content": "Hello!"}],
},
)
print(r.json()["choices"][0]["message"]["content"])How this differs from the upstream API, and what it does not do.