Quickstart
- Create an API key in the console (Developer → API Keys). Copy the secret immediately — it is shown once.
- Set
ATOMESUS_API_KEY=atms_sk_YOUR_KEY_HEREin your environment (never commit real keys). - Call list models or chat completions (examples below).
curl https://api.atomesus.com/v1/models \
-H "Authorization: Bearer $ATOMESUS_API_KEY"Authentication
All /v1/* routes require an API key via either header:
Authorization: Bearer atms_sk_...X-API-Key: atms_sk_...
Keys use prefix atms_sk_ and length ≥ 20. JWT is only for console key management (POST/GET/DELETE /api/gateway/keys), not for /v1/*.
Endpoints
| Method | Path | Auth | Purpose |
|---|---|---|---|
| GET | /api/gateway/health | None | Health check |
| GET | /v1/models | API key | List models |
| POST | /v1/chat/completions | API key | Chat (stream or not) |
Request — chat completions
{
"model": "cipher",
"messages": [
{ "role": "user", "content": "Hello!" }
]
}Response — non-streaming
1{
2 "id": "chatcmpl-...",
3 "object": "chat.completion",
4 "created": 1716900000,
5 "model": "cipher",
6 "choices": [{
7 "index": 0,
8 "message": { "role": "assistant", "content": "..." },
9 "finish_reason": "stop"
10 }],
11 "usage": {
12 "prompt_tokens": 10,
13 "completion_tokens": 20,
14 "total_tokens": 30
15 },
16 "system_fingerprint": "atms-fp-1"
17}Primary model id: cipher. Assistant text: choices[0].message.content
Code examples
List models
curl https://api.atomesus.com/v1/models \
-H "Authorization: Bearer $ATOMESUS_API_KEY"Chat (non-streaming)
curl https://api.atomesus.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ATOMESUS_API_KEY" \
-d '{"model":"cipher","messages":[{"role":"user","content":"Hello!"}]}' \
-iChat (streaming)
curl https://api.atomesus.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ATOMESUS_API_KEY" \
-d '{"model":"cipher","messages":[{"role":"user","content":"Hello!"}],"stream":true}' \
-NRead billing headers
1# After chat request, inspect headers from -i output:
2# X-Credit-Balance-INR, X-Request-Cost-INR, X-Tokens-Input, X-Tokens-Output
3
4curl -s https://api.atomesus.com/v1/chat/completions \
5 -H "Content-Type: application/json" \
6 -H "Authorization: Bearer $ATOMESUS_API_KEY" \
7 -d '{"model":"cipher","messages":[{"role":"user","content":"Hello!"}]}' \
8 -D headers.txt -o body.json
9
10grep -i x-credit-balance-inr headers.txt
11cat body.jsonError handling (401 / 402)
1# 401 invalid_api_key / 402 insufficient_credits
2curl -s https://api.atomesus.com/v1/chat/completions \
3 -H "Content-Type: application/json" \
4 -H "Authorization: Bearer $ATOMESUS_API_KEY" \
5 -w "\nHTTP %{http_code}\n" \
6 -d '{"model":"cipher","messages":[{"role":"user","content":"Hi"}]}'
7
8# Parse JSON error:
9# {"error":{"message":"...","type":"authentication_error","code":"invalid_api_key"}}Streaming
Add "stream": true to the chat body. Responses use Server-Sent Events: lines prefixed with data: containing JSON chunks, ending with data: [DONE].
Parse each chunk's choices[0].delta.content for incremental text. Billing headers are available when the stream completes.
Billing
| Header | Meaning |
|---|---|
| X-Credit-Balance-INR | Balance after call (4 decimals) |
| X-Credit-Spent-INR | Lifetime spend on key |
| X-Request-Cost-INR | This request cost (6 decimals) |
| X-Tokens-Input | Prompt tokens |
| X-Tokens-Output | Completion tokens |
| X-Powered-By | atomesus |
| X-Credit-Warning | Optional low-balance warning |
Errors
1{
2 "error": {
3 "message": "Invalid API key or key has been revoked.",
4 "type": "authentication_error",
5 "code": "invalid_api_key"
6 }
7}| HTTP | code | When |
|---|---|---|
| 401 | missing_api_key | No key sent |
| 401 | invalid_key_format | Bad format (prefix / length) |
| 401 | invalid_api_key | Invalid or revoked key |
| 402 | insufficient_credits | No balance / estimate too high |
| 502 | upstream_unavailable | Backend unavailable |
| 502 | bad_upstream_response | Invalid upstream response |
| 504 | upstream_timeout | Timeout (~60s) |
402 responses may include top_up_url:
Pricing
| Input | ₹25 / 1M tokens |
| Output | ₹100 / 1M tokens |
| New key welcome credit | ₹25,000 |
| Low balance warning | < ₹10 |
Security
- Store keys in environment variables, not source control.
- Never log full API keys in production.
- Rotate and revoke compromised keys in the API Keys console.
- Use separate keys per environment (dev/staging/prod).
FAQ
- Why are my system messages ignored?
- Atomesus manages identity and behavior at the gateway level to ensure consistent, safe responses across all API users. Client-side system role messages are not forwarded to the model..
- Which model id should I use?
- Use "cipher" — it is the primary branded model in all responses.
- How do I read usage for streaming?
- Token counts and X-Credit-* headers are available on the final response headers when the stream completes. Parse SSE chunks for content deltas.
- Where do I create API keys?
- In the app: Sidebar → Developer, or Profile → API Keys. The full secret is shown once at creation.
Ready to integrate?
Create and manage keys in the developer console.
Keys shown once at creation. Use atms_sk_YOUR_KEY_HERE in examples only.