DeepInfra
Route your DeepInfra API calls through AI SpendOps for automatic usage tracking and cost attribution.
Configuration
| Setting | Value |
|---|---|
| Route | /v1/deepinfra/* |
| Upstream | https://api.deepinfra.com/v1/openai |
| Auth header | Authorization: Bearer ... |
| Streaming usage | Native. stream_options is not injected |
SDK base URL
https://proxy.aispendops.com/v1/deepinfra/v1
Example
curl https://proxy.aispendops.com/v1/deepinfra/v1/chat/completions \
-H "Authorization: Bearer your-deepinfra-key" \
-H "X-ASO-API-Key: aso_k_yourkey.secret" \
-H "Content-Type: application/json" \
-d '{"model":"meta-llama/Llama-3.3-70B-Instruct","messages":[{"role":"user","content":"Hello"}]}'
Usage fields
| Field | Description |
|---|---|
prompt_tokens | Input tokens |
completion_tokens | Output tokens |
A large catalogue changes the cost problem
DeepInfra's appeal is breadth: a long list of open-weight models at very different price points, from small models costing a few cents per million tokens to large ones costing orders of magnitude more. That makes model choice, rather than request volume, the main driver of your bill.
Two AI SpendOps features matter more here than on a single-family provider:
Per-model cost breakdown. Because every event records the exact model string DeepInfra returned, you can see spend split by model rather than by provider. A single team quietly switching from an 8B to a 70B model is a large cost change that a provider-level total will hide completely.
Model allow-lists. You can restrict an ASO key to an approved set of models, so a change in application code cannot silently move traffic onto a more expensive model. See Restrictions.
If you call a model AI SpendOps does not yet have a rate for, the usage event is still recorded in full and the model is flagged for pricing. Usage is never dropped for being unrecognised, so token counts stay complete even when a cost figure has to be filled in slightly later.
What AI SpendOps records
| Field | Populated |
|---|---|
cache_read_tokens | No |
cache_write_tokens | No |
reasoning_tokens | Only where the model returns completion_tokens_details |
provider_cost | No. Cost is calculated from token counts and the current DeepInfra rate card |
Notes
- The proxy does not inject
stream_optionsfor DeepInfra. Streamed responses carry usage natively, and any response that completes without a usage block is recorded withusage_source: estimate. See Streaming. - Model identifiers are Hugging Face style paths such as
meta-llama/Llama-3.3-70B-Instruct, and allow-list entries must use the full path. - Full field definitions are in the usage event field reference.