Models and Providers
How Struktur integrates with LLM providers through the Vercel AI SDK.
Struktur is built on the Vercel AI SDK, which provides a unified interface to multiple LLM providers. This architecture makes it straightforward to use any model from supported providers—or add new ones.
Supported Providers
Struktur currently supports the following providers out of the box:
| Provider | Environment Variable | Package |
|---|---|---|
| OpenAI | OPENAI_API_KEY | @ai-sdk/openai |
| Anthropic | ANTHROPIC_API_KEY | @ai-sdk/anthropic |
GOOGLE_GENERATIVE_AI_API_KEY | @ai-sdk/google | |
| Cerebras | CEREBRAS_API_KEY | @ai-sdk/openai* |
| OpenCode | OPENCODE_API_KEY | @ai-sdk/openai* |
| OpenRouter | OPENROUTER_API_KEY | @openrouter/ai-sdk-provider |
| Ollama | (none — base URL) | ollama-ai-provider-v2 |
*OpenCode and Cerebras use OpenAI-compatible APIs via the Vercel SDK's OpenAI provider. Cerebras honours CEREBRAS_BASE_URL (default https://api.cerebras.ai/v1). Ollama expects a base URL (default http://localhost:11434/api) instead of an API key.
Model names change frequently. Rather than document specific models, Struktur focuses on provider integration. Check your provider's documentation for available models and their capabilities.
Specifying Models
Models are specified using the format provider/model-name:
import { extract } from "@struktur/sdk";
// OpenAI
const result = await extract({
artifacts,
schema,
strategy: { type: "simple", model: "openai/gpt-4o" }
});
// Anthropic
const result = await extract({
artifacts,
schema,
strategy: { type: "simple", model: "anthropic/claude-3-5-sonnet" }
});
// Google
const result = await extract({
artifacts,
schema,
strategy: { type: "simple", model: "google/gemini-1.5-pro" }
});Authentication
Struktur supports two authentication methods:
Environment Variables
Set the appropriate API key for your provider:
export OPENAI_API_KEY="sk-..."
export ANTHROPIC_API_KEY="sk-ant-..."
export GOOGLE_GENERATIVE_AI_API_KEY="..."
export OPENCODE_API_KEY="..."
export OPENROUTER_API_KEY="..."Secure Token Storage
For CLI usage, Struktur can store tokens securely:
# Store in macOS Keychain (preferred on macOS)
struktur auth set --provider openai --token "sk-..."
# Or store in file
struktur auth set --provider openai --token "sk-..." --storage fileOn macOS, Struktur defaults to the system Keychain. On other platforms, tokens are stored in ~/.config/struktur/tokens.json with strict permissions (0o600).
Special Providers
OpenCode (PyCoding Agent)
OpenCode provides access to multiple model families through a single API:
// OpenAI-compatible models
"opencode/gpt-5.2"
"opencode/gpt-5.1"
// Anthropic-compatible models
"opencode/claude-opus-4-6"
"opencode/claude-sonnet-4-5"
// Google-compatible models
"opencode/gemini-3.1-pro"
"opencode/gemini-3-flash"
// Other providers
"opencode/kimi-k2.5"
"opencode/glm-5"Struktur automatically routes OpenCode requests to the correct Vercel SDK provider based on the model prefix (gpt-, claude-, gemini-).
OpenRouter
OpenRouter provides access to models from multiple providers through a unified API. Two suffixes are supported.
Pin an upstream provider with #:
// Basic usage
"openrouter/anthropic/claude-3.5-sonnet"
// With preferred upstream provider (hashtag syntax)
"openrouter/anthropic/claude-3.5-sonnet#cerebras"Use OpenRouter's own routing variants with :. These are passed through to OpenRouter and select the upstream provider by policy:
| Variant | Effect |
|---|---|
:nitro | Fastest available provider — often roughly halves wall-clock time |
:floor | Cheapest available provider |
:free | Free-tier endpoints only |
"openrouter/deepseek/deepseek-v4.1-flash:nitro"
"openrouter/anthropic/claude-3.5-sonnet:floor"Variants are stripped before catalogue lookups, so capability detection (such as vision support) still resolves to the base model.
Adding New Providers
Because Struktur uses the Vercel AI SDK, adding support for new providers is straightforward:
-
Check if Vercel AI SDK supports the provider
The Vercel AI SDK has a growing ecosystem of community providers. If your provider is listed there, integration is simple.
-
Create a provider resolver
Add a case to
resolveModelinpackages/sdk/src/llm/resolveModel.ts:case "newprovider": { const { createNewProvider } = await import("@ai-sdk/newprovider"); return createNewProvider({ apiKey })(modelName); } -
Add environment variable mapping
Update
resolveProviderEnvVarinpackages/sdk/src/auth/tokens.ts:case "newprovider": return "NEWPROVIDER_API_KEY"; -
(Optional) Add model listing support
If the provider has a models API, add support in
packages/sdk/src/llm/models.ts.
Model Capabilities
When selecting a model, consider:
| Capability | Considerations |
|---|---|
| Structured Output | All supported providers support JSON schema output |
| Vision/Multimodal | Check if the model supports image input for PDF/image extraction |
| Rate Limits | Consider provider rate limits for batch processing |
| Cost | Different models have vastly different pricing |
Not all models support image inputs. If you're extracting from PDFs or images with visual content, use a vision-capable model (e.g. GPT-4o, Claude 3.5 Sonnet, Gemini 1.5 Pro).
The agent strategy queries the provider's model catalogue for the input modalities a model accepts and enables image tools only when image is present. If the catalogue cannot be reached, or reports nothing for the model, vision is left enabled — the extraction fails loudly at the provider instead of silently running text-only. Override the detection explicitly with the agent strategy's vision: false option.
Listing Available Models
The CLI can list available models from configured providers:
# List models for a specific provider
struktur config models list --provider openai
# List models for all configured providers
struktur config models list
# Set a provider's cheapest model as the default
struktur config providers add openai --defaultSee Also
- Extraction Strategies — How strategies use models
- CLI Authentication — Managing provider tokens
- Vercel AI SDK Documentation — Full provider documentation