Struktur
Explanation

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:

ProviderEnvironment VariablePackage
OpenAIOPENAI_API_KEY@ai-sdk/openai
AnthropicANTHROPIC_API_KEY@ai-sdk/anthropic
GoogleGOOGLE_GENERATIVE_AI_API_KEY@ai-sdk/google
CerebrasCEREBRAS_API_KEY@ai-sdk/openai*
OpenCodeOPENCODE_API_KEY@ai-sdk/openai*
OpenRouterOPENROUTER_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 file

On 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:

VariantEffect
:nitroFastest available provider — often roughly halves wall-clock time
:floorCheapest available provider
:freeFree-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:

  1. 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.

  2. Create a provider resolver

    Add a case to resolveModel in packages/sdk/src/llm/resolveModel.ts:

    case "newprovider": {
      const { createNewProvider } = await import("@ai-sdk/newprovider");
      return createNewProvider({ apiKey })(modelName);
    }
  3. Add environment variable mapping

    Update resolveProviderEnvVar in packages/sdk/src/auth/tokens.ts:

    case "newprovider":
      return "NEWPROVIDER_API_KEY";
  4. (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:

CapabilityConsiderations
Structured OutputAll supported providers support JSON schema output
Vision/MultimodalCheck if the model supports image input for PDF/image extraction
Rate LimitsConsider provider rate limits for batch processing
CostDifferent 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 --default

See Also

On this page