Skip to main content

LLM Interface

The interface layer handles model communication, key rotation, and rate limiting.

OpenAICompatible

Works with any provider that implements the OpenAI Chat Completions API:
Compatible with: OpenAI, OpenRouter, Together, Groq, local vLLM, Ollama, etc.

OpenAIResponsesCompatible

For providers implementing OpenAI’s Responses API:
Differences from OpenAICompatible:
  • Maps system prompts to instructions field
  • Handles Responses-specific streaming events
  • Supports reasoning={...} kwargs for reasoning effort
  • Different wire format for tool calls
From your decorator code, both adapters look the same. The wire-format differences are handled internally.

APIKeyPool

Manages multiple keys with round-robin rotation:
When a key hits rate limits, the pool rotates to the next. Put your highest-rate keys first.

Rate Limiting

Built-in token bucket rate limiter:
The rate limiter is per-instance. Multiple OpenAICompatible instances for the same model can have different rate limits.

Passing LLM kwargs

Extra parameters are forwarded to the provider:
For OpenAIResponsesCompatible, you can pass reasoning effort:

Context Window

Set context_window to enable framework features that depend on knowing the model’s capacity:
Used by: auto-compaction threshold calculations, token usage tracking. Default: 200,000 tokens. API Reference: Interfaces