> ## Documentation Index
> Fetch the complete documentation index at: https://docs.standardagentbuilder.com/llms.txt
> Use this file to discover all available pages before exploring further.

# @standardagents/deepinfra

> Use DeepInfra chat models with live catalog metadata, streaming, tools, structured output, reasoning, and request-cost reporting.

The `@standardagents/deepinfra` package is the first-party DeepInfra provider for Standard Agents. It targets DeepInfra's OpenAI-compatible Chat Completions API and reads model capabilities and per-million-token prices from the live public catalog.

## Install

```bash theme={null}
pnpm add @standardagents/deepinfra
```

Scaffolded projects already include the package. Set `DEEPINFRA_API_KEY` to use your own DeepInfra account; when that key is absent and the project has `STANDARD_AGENTS_API_KEY`, requests use hosted Standard Agents routing.

## Define a model

```typescript agents/models/deepinfra_chat.ts theme={null}
import { defineModel } from '@standardagents/builder';
import { deepinfra } from '@standardagents/deepinfra';

export default defineModel({
  name: 'deepinfra-chat',
  provider: deepinfra,
  model: 'deepseek-ai/DeepSeek-V3',
});
```

The Builder's model picker queries `https://api.deepinfra.com/v1/models`, keeps models tagged `chat`, and maps catalog context length, vision tags, and `input_tokens`, `output_tokens`, and `cache_read_tokens` pricing. Each result uses bundled local artwork for the model ID's lab namespace, so model rows show DeepSeek, Meta, Qwen, and other creator marks rather than the DeepInfra provider mark.

## Provider options

DeepInfra options belong in `providerOptions`:

```typescript theme={null}
providerOptions: {
  service_tier: 'priority',
  reasoning_effort: 'high',
  prompt_cache_key: 'thread-stable-id',
  top_k: 40,
  min_p: 0.05,
}
```

Supported typed options include `n`, `seed`, frequency/presence/repetition penalties, `top_k`, `min_p`, `logit_bias`, log probabilities, `stop_token_ids`, `reasoning_effort`, `reasoning`, `service_tier`, and `prompt_cache_key`. The schema is passthrough so newly introduced DeepInfra request fields can be used without waiting for a package release.

Standard Agents `reasoning.level` maps to DeepInfra's `none`, `low`, `medium`, or `high` effort. A `responseFormat` JSON schema is converted to strict `json_schema` output, and Standard Agents tools are converted to strict OpenAI-compatible function definitions.

## Pricing and usage

The package exposes live catalog prices on discovered models. DeepInfra returns request-level USD cost as `usage.estimated_cost`; the provider preserves that value as Standard Agents `usage.cost`. If an upstream response omits it, the provider falls back to the cached live catalog rates, including cache-read tokens when present.

Hosted routing uses the same upstream-reported value for billing, then adds the plan's router fee. This avoids a stale platform pricing table as DeepInfra's catalog changes.

## Connection configuration

| Slot        | Default                               | Purpose                             |
| ----------- | ------------------------------------- | ----------------------------------- |
| `apiKey`    | `DEEPINFRA_API_KEY`                   | Bearer token for inference requests |
| `baseUrl`   | `https://api.deepinfra.com/v1/openai` | OpenAI-compatible API base          |
| `modelsUrl` | `https://api.deepinfra.com/v1/models` | Public model catalog                |
| `timeout`   | `30000`                               | Request timeout in milliseconds     |

The package honors provider `fetch` and `defaultHeaders` overrides, so test transports, instrumentation, and `defineProvider` sub-providers work without patching the implementation.
