Follow these recommendations to optimize cost, performance, and reliability when using the Claudexia API.
Match the model to the task complexity:
| Task | Recommended model |
|---|---|
| Complex reasoning, research | claude-opus-5-5 |
| General coding, everyday tasks | claude-sonnet-5 |
| Quick completions, classification | gpt-6-luna |
Using a smaller model for simple tasks significantly reduces cost and latency.
If you send the same system prompt across multiple requests, use prompt caching to reduce input token costs.
Include cache_control in your system message block:
{
"system": [
{
"type": "text",
"text": "You are a helpful coding assistant...",
"cache_control": { "type": "ephemeral" }
}
]
}Set max_tokens to the minimum needed for your use case:
Lower values reduce cost and can decrease latency.
Enable streaming to receive tokens as they are generated, improving perceived latency:
curl https://api.claudexia.tech/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: sk_cdx_YOUR_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-5",
"max_tokens": 1024,
"stream": true,
"messages": [
{"role": "user", "content": "Hello!"}
]
}'Create dedicated keys for each environment to isolate usage and simplify debugging:
This makes it easy to track costs, rotate keys, and revoke access per environment.
Use the Analytics dashboard to track:
Set up low-balance alerts in Settings to get notified before your balance runs out.