STATEK
API Reference
Providers

Providers

Provider APIs adapt STATEK requests to model-provider wire formats. Application code usually configures providers through settings; custom integrations implement LLM_API.

SymbolImport pathPurposeStability
LLM_APIstatek.llm_api or statekAbstract provider interfaceAdvanced extension API
LLM_Responsestatek.llm_api or statekProvider response tupleAdvanced
LLM_Statsstatek.llm_api or statekUsage accounting tupleAdvanced
ModelPricingstatek.model_pricingPer-model price metadataAdvanced
get_model_pricingstatek.model_pricingLook up or create model pricingAdvanced
set_model_pricingstatek.model_pricingSet model pricing programmaticallyAdvanced
init_model_pricingstatek.model_pricingLoad pricing CSV or TXT filesAdvanced
LLM_Usagestatek.executors.llm_usagePer-job accumulated usage and costAdvanced
add_providerstatek.llm_api or statekRegister a custom providerAdvanced
Built-in provider classesstatek.llm_api or statekTyped provider wrappersAdvanced

LLM_API

class LLM_API(ABC):
    def preview_request(..., enable_reasoning: bool = False) -> dict
    async def process_request(..., enable_reasoning: bool = False) -> LLM_Response

Base class for provider integrations. Subclasses implement _build_request_payload(...) and _process_request(...).

Request parameters

NameDescription
system_promptOptional system prompt passed separately from chat history.
modelRequired provider model.
metadataOptional metadata. LLM_TOOLS_SCOPE, TEMPERATURE, and reasoning metadata are interpreted by request preparation paths.
available_toolsTool callables available for provider tool payload selection.
chat_historyIterable of ChatHistoryItem objects.
chat_styleOptional chat style that affects history formatting and tool selection.
temperatureOptional float from 0.0 to 1.0.
enable_reasoningWhether provider reasoning support should be requested.

Static helpers

MethodReturnsErrors
LLM_API.get(provider_name=None, model=None, **kwargs)LLM_APIValueError for missing settings or unsupported providers.
parse_temperature(value)`floatNone`
require_model(model)strValueError if empty.
parse_enable_reasoning(value)boolNo 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 keysClass
OPENAIOpenAI_API
OPENROUTEROpenRouter_API
GROQGroq_API
MISTRAL, MISTRALAI, MISTRAL_AIMistralAI_API
DEEPSEEK, DEEP_SEEKDeepSeek_API
XAI, X_AI, GROKXAI_API
TOGETHER, TOGETHERAI, TOGETHER_AITogetherAI_API
FIREWORKS, FIREWORKSAI, FIREWORKS_AIFireworksAI_API
CEREBRASCerebras_API
PERPLEXITYPerplexity_API
SAMBANOVA, SAMBA_NOVASambaNova_API
NVIDIA, NVIDIA_NIM, NIMNvidiaNIM_API
NEBIUSNebius_API
COHERECohere_API
MOONSHOT, MOONSHOTAI, MOONSHOT_AI, KIMIMoonshotAI_API
DASHSCOPE, DASH_SCOPE, ALIBABA, ALIBABA_CLOUD, QWENDashScope_API
CLOUDFLARE, CLOUDFLARE_WORKERS_AI, WORKERS_AICloudflareWorkersAI_API
CLOUDFLARE_AI_GATEWAY, AI_GATEWAYCloudflareAIGateway_API
GITHUB, GITHUB_MODELSGitHubModels_API
BEDROCK, AMAZON_BEDROCK, AWS_BEDROCKBedrock_API
MICROSOFT_FOUNDRY, MS_FOUNDRY, AZURE_FOUNDRYMicrosoftFoundry_API
AZURE_OPENAI, AZURE_OPEN_AIAzureOpenAI_API
GEMINI_ENTERPRISE, GOOGLE_GEMINI_ENTERPRISE, GOOGLE_OPENAIGeminiEnterprise_API
OLLAMAOllama_API
LMSTUDIO, LM_STUDIOLMStudio_API
VLLMVLLM_API
SGLANGSGLang_API
LLAMA_CPP, LLAMACPP, LLAMA_CPP_PYTHONLlamaCpp_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.