Skip to content

zidane/providers/baseten

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

import { … } from 'zidane/providers/baseten'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.

TypeScript
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#

basetenFunction#

Baseten Model APIs provider.

Thin wrapper around 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.

TypeScript
function baseten(params?: BasetenParams): Provider
Parameters
NameTypeDescription
params?BasetenParams

API key, base URL, default model, capabilities, extra headers and prompt-cache key settings.

Example
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.' })

src/providers/baseten.ts:128

planBasetenReasoningFunction#

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.

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

Request model id and thinking level.

Record<string, unknown> | undefined

src/providers/baseten.ts:92

Interfaces#

BasetenParamsInterface#

Options for baseten.

TypeScript
interface BasetenParams
BasetenParams properties
NameTypeDefaultDescription
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'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 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.

src/providers/baseten.ts:24