# zidane/providers/baseten

> The Baseten Model APIs provider, with per-model reasoning settings.

Import: `import { … } from 'zidane/providers/baseten'`. Source: [src/providers/baseten.ts](https://github.com/Tahul/zidane/blob/main/src/providers/baseten.ts).

Use `baseten()` when your agent runs on Baseten Model APIs. It reads `BASETEN_API_KEY` when you pass no key, and you can point `baseURL` at a dedicated deployment. `planBasetenReasoning()` maps a thinking level to the request shape each model expects.

```ts
import { createAgent } from 'zidane'
import { baseten } from 'zidane/providers/baseten'

const agent = createAgent({ provider: baseten({ defaultModel: 'zai-org/GLM-5.3' }) })
const stats = await agent.run({ prompt: 'Summarize README.md in three bullets.' })
console.log(stats.turns)
```

## Functions

### `baseten`

Function.

Baseten Model APIs provider.

Thin wrapper around [`openaiCompat`](https://zidane.si/docs/reference/providers-openai-compat.md#openaiCompat) pinned to the `reasoning_content`
round-trip mode: thinking arrives in the `reasoning_content` delta field and
is echoed back on assistant messages under the same name so reasoning
models resume their chain-of-thought across tool calls. The thinking level
maps to Baseten's request shape via [`planBasetenReasoning`](https://zidane.si/docs/reference/providers-baseten.md#planBasetenReasoning).

```ts
function baseten(params?: BasetenParams): Provider
```

**Parameters**

- `params?` (`BasetenParams`): API key, base URL, default model, capabilities, extra headers and prompt-cache key settings.

**Returns** `Provider`

**Example**

```ts
import { createAgent } from 'zidane'
import { baseten } from 'zidane/providers/baseten'

const agent = createAgent({
  provider: baseten({ apiKey: process.env.BASETEN_API_KEY }),
})
await agent.run({ prompt: 'Say hello.' })
```

Source: [src/providers/baseten.ts:128](https://github.com/Tahul/zidane/blob/main/src/providers/baseten.ts#L128)

### `planBasetenReasoning`

Function.

Map zidane's thinking level to Baseten's per-model reasoning request shape:

- `reasoning_effort` models (DeepSeek V4 Pro, GPT-OSS 120B) reason by
  default; the effort string tunes depth. `'minimal'` maps to `'low'`,
  Anthropic-only upper tiers map to `'high'`, `'adaptive'` sends nothing
  (server default = medium); `'off'` sends nothing (cannot be disabled).
- All other models opt in via `chat_template_args.enable_thinking` — any
  non-off level enables it (the template arg is boolean, no depth knob).

Exported for tests.

```ts
function planBasetenReasoning(
  ctx: { model: string; thinking?: 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'adaptive' },
): Record<string, unknown> | undefined
```

**Parameters**

- `ctx` (`{ model: string; thinking?: 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'adaptive' }`): Request model id and thinking level.

**Returns** `Record<string, unknown> | undefined`

Source: [src/providers/baseten.ts:92](https://github.com/Tahul/zidane/blob/main/src/providers/baseten.ts#L92)

## Interfaces

### `BasetenParams`

Interface.

Options for [`baseten`](https://zidane.si/docs/reference/providers-baseten.md#baseten).

```ts
interface BasetenParams
```

**Properties**

- `apiKey?` (`string`): API key. Falls back to the `BASETEN_API_KEY` environment variable.
- `baseURL?` (`string`): Override the base URL — e.g. point at a dedicated Baseten deployment's
  OpenAI-compatible bridge instead of the shared Model APIs endpoint.
- `capabilities?` (`ProviderCapabilities`): Provider capability flags. Default: `{ vision: false, imageInToolResult: false }`
  — conservative, since most Model APIs are text-only. Set `vision: true`
  when pinning a Kimi K2.x model (the only vision-capable ones).
- `defaultModel?` (`string`, default `'zai-org/GLM-5.3'`): Model used when a request does not set one.
- `extraHeaders?` (`Record<string, string>`): Extra HTTP headers sent on every request. Forwarded to the underlying
  [`openaiCompat`](https://zidane.si/docs/reference/providers-openai-compat.md#openaiCompat) client.
- `promptCacheKey?` (`PromptCacheKeyOption`): Prompt-cache affinity key, sent as `prompt_cache_key`. Off by default.

  Expect no measurable effect on Baseten's own Model APIs: their load
  balancer already routes on replica KV-cache state and caching is
  unconditional. Worth enabling when a proxy or AI gateway sits in front (via
  `BasetenParams.baseURL`) and routes on the key. `'session'` keys on
  the agent's session id. See `./prompt-cache-key.ts`.
- `promptCacheKeyHeader?` (`string`): Additionally send the affinity key as this HTTP header, for gateways that
  route on a header rather than a body field.

Source: [src/providers/baseten.ts:24](https://github.com/Tahul/zidane/blob/main/src/providers/baseten.ts#L24)
