Providers
Provider APIs adapt STATEK requests to model-provider wire formats. Application code usually configures providers through settings; custom integrations implement LLM_API.
| Symbol | Import path | Purpose | Stability |
|---|---|---|---|
LLM_API | statek.llm_api or statek | Abstract provider interface | Advanced extension API |
LLM_Response | statek.llm_api or statek | Provider response tuple | Advanced |
LLM_Stats | statek.llm_api or statek | Usage accounting tuple | Advanced |
ModelPricing | statek.model_pricing | Per-model price metadata | Advanced |
get_model_pricing | statek.model_pricing | Look up or create model pricing | Advanced |
set_model_pricing | statek.model_pricing | Set model pricing programmatically | Advanced |
init_model_pricing | statek.model_pricing | Load pricing CSV or TXT files | Advanced |
LLM_Usage | statek.executors.llm_usage | Per-job accumulated usage and cost | Advanced |
add_provider | statek.llm_api or statek | Register a custom provider | Advanced |
| Built-in provider classes | statek.llm_api or statek | Typed provider wrappers | Advanced |
LLM_API
class LLM_API(ABC):
def preview_request(..., enable_reasoning: bool = False) -> dict
async def process_request(..., enable_reasoning: bool = False) -> LLM_ResponseBase class for provider integrations. Subclasses implement _build_request_payload(...) and _process_request(...).
Request parameters
| Name | Description |
|---|---|
system_prompt | Optional system prompt passed separately from chat history. |
model | Required provider model. |
metadata | Optional metadata. LLM_TOOLS_SCOPE, TEMPERATURE, and reasoning metadata are interpreted by request preparation paths. |
available_tools | Tool callables available for provider tool payload selection. |
chat_history | Iterable of ChatHistoryItem objects. |
chat_style | Optional chat style that affects history formatting and tool selection. |
temperature | Optional float from 0.0 to 1.0. |
enable_reasoning | Whether provider reasoning support should be requested. |
Static helpers
| Method | Returns | Errors |
|---|---|---|
LLM_API.get(provider_name=None, model=None, **kwargs) | LLM_API | ValueError for missing settings or unsupported providers. |
parse_temperature(value) | `float | None` |
require_model(model) | str | ValueError if empty. |
parse_enable_reasoning(value) | bool | No documented exception for ordinary strings. |
from statek import LLM_API
api = LLM_API.get("OPENAI")
payload = api.preview_request(model="gpt-5-mini", system_prompt="Be concise.")Response types
LLM_Response(text, stats, call_requests)
LLM_Stats(total_bytes_sent, total_bytes_received, cost, input_tokens, output_tokens, cached_tokens)LLM_Response separates generated text, usage stats, and provider tool-call requests. LLM_Stats stores per-request accounting values; unavailable provider cost is represented as None. Worker execution accumulates these values into job.usage.
Metering types
ModelPricing stores optional input, cached-input, and output prices per million tokens. get_model_pricing(...), set_model_pricing(...), and init_model_pricing(...) manage pricing records used by LLM_Usage.total_cost.
LLM_Usage stores accumulated byte counts, provider token counts, cached-token counts, provider-reported cost, and calculated total_cost for a job.
See STATEK Metering for pricing file format, examples, and caveats.
Built-in provider classes
OpenAI-compatible subclasses share the default chat-completions implementation:
| Provider keys | Class |
|---|---|
OPENAI | OpenAI_API |
OPENROUTER | OpenRouter_API |
GROQ | Groq_API |
MISTRAL, MISTRALAI, MISTRAL_AI | MistralAI_API |
DEEPSEEK, DEEP_SEEK | DeepSeek_API |
XAI, X_AI, GROK | XAI_API |
TOGETHER, TOGETHERAI, TOGETHER_AI | TogetherAI_API |
FIREWORKS, FIREWORKSAI, FIREWORKS_AI | FireworksAI_API |
CEREBRAS | Cerebras_API |
PERPLEXITY | Perplexity_API |
SAMBANOVA, SAMBA_NOVA | SambaNova_API |
NVIDIA, NVIDIA_NIM, NIM | NvidiaNIM_API |
NEBIUS | Nebius_API |
COHERE | Cohere_API |
MOONSHOT, MOONSHOTAI, MOONSHOT_AI, KIMI | MoonshotAI_API |
DASHSCOPE, DASH_SCOPE, ALIBABA, ALIBABA_CLOUD, QWEN | DashScope_API |
CLOUDFLARE, CLOUDFLARE_WORKERS_AI, WORKERS_AI | CloudflareWorkersAI_API |
CLOUDFLARE_AI_GATEWAY, AI_GATEWAY | CloudflareAIGateway_API |
GITHUB, GITHUB_MODELS | GitHubModels_API |
BEDROCK, AMAZON_BEDROCK, AWS_BEDROCK | Bedrock_API |
MICROSOFT_FOUNDRY, MS_FOUNDRY, AZURE_FOUNDRY | MicrosoftFoundry_API |
AZURE_OPENAI, AZURE_OPEN_AI | AzureOpenAI_API |
GEMINI_ENTERPRISE, GOOGLE_GEMINI_ENTERPRISE, GOOGLE_OPENAI | GeminiEnterprise_API |
OLLAMA | Ollama_API |
LMSTUDIO, LM_STUDIO | LMStudio_API |
VLLM | VLLM_API |
SGLANG | SGLang_API |
LLAMA_CPP, LLAMACPP, LLAMA_CPP_PYTHON | LlamaCpp_API |
Specialized non-default implementations are VertexAI_API for Vertex/Gemini aliases and ClaudeAI_API for Claude/Anthropic aliases. Claude_API is exported as an alias.
add_provider
def add_provider(name: str, llm_api_impl: type[LLM_API] = None, **kwargs)Registers a custom provider name. If llm_api_impl is omitted, STATEK uses the OpenAI-compatible default implementation. api_url, api_key, response_format_file, and use_prompt_caching are consumed as provider settings; other keyword arguments are passed to the provider implementation.
Raises: ValueError when the provider name is already registered or reserved.
from statek import add_provider
add_provider(
"LOCAL_OPENAI_COMPAT",
api_url="http://localhost:8000/v1/chat/completions",
api_key="local",
)Related APIs: Model Providers, Custom Providers, Settings.