@aetheros/provider-openai-compatible
v0.2.0
Published
Adapter for OpenAI-style Chat Completions services (xAI, Mistral, DeepSeek, Groq, OpenRouter, Together, Moonshot Kimi, Z.ai, Perplexity, local models and named custom endpoints) for AetherOS and Aevron.
Readme
@aetheros/provider-openai-compatible
One adapter for services with an OpenAI-style Chat Completions API: xAI, Mistral, DeepSeek, Groq, OpenRouter, Together, Moonshot Kimi, Z.ai (GLM), Perplexity, local models (Ollama, LM Studio, vLLM and similar) and any other compatible endpoint you name yourself.
import {createPreset, createCustom, OpenAICompatibleProvider} from '@aetheros/provider-openai-compatible';
createPreset('xai', {model: '<model id>'}); // XAI_API_KEY
createPreset('mistral', {model: '<model id>'}); // MISTRAL_API_KEY
createPreset('deepseek'); // DEEPSEEK_API_KEY; DEEPSEEK_MODEL or deepseek-flash
createPreset('local', {model: 'llama3.1'}); // no key; LOCAL_MODEL_URL or http://127.0.0.1:11434/v1
createCustom({id: 'acme-llm', label: 'Acme LLM', baseUrl: 'https://llm.acme.example/v1', keyVar: 'ACME_LLM_KEY', model: 'acme-large'});
new OpenAICompatibleProvider({id: 'my-host', baseUrl: 'https://llm.example.com/v1', apiKey, model});| Preset | Address | Key variable | Model variable (default) | Effort | PDF |
|---|---|---|---|---|---|
| xai | https://api.x.ai/v1 | XAI_API_KEY | XAI_MODEL | low, medium, high | no |
| mistral | https://api.mistral.ai/v1 | MISTRAL_API_KEY | MISTRAL_MODEL | no | no |
| deepseek | https://api.deepseek.com | DEEPSEEK_API_KEY | DEEPSEEK_MODEL (deepseek-flash) | no | no |
| groq | https://api.groq.com/openai/v1 | GROQ_API_KEY | GROQ_MODEL (openai/gpt-oss-120b) | low, medium, high | no |
| openrouter | https://openrouter.ai/api/v1 | OPENROUTER_API_KEY | OPENROUTER_MODEL (openrouter/auto) | low, medium, high | yes |
| together | https://api.together.xyz/v1 | TOGETHER_API_KEY | TOGETHER_MODEL (moonshotai/Kimi-K3) | no | no |
| moonshot | https://api.moonshot.ai/v1 | MOONSHOT_API_KEY | MOONSHOT_MODEL (kimi-k3.1-pro) | low, high | no |
| zai | https://api.z.ai/api/paas/v4 | ZAI_API_KEY | ZAI_MODEL (glm-5.3) | low, high | no |
| perplexity | https://api.perplexity.ai/v1 (route /sonar, no tools) | PERPLEXITY_API_KEY | PERPLEXITY_MODEL (sonar) | no | no |
| local | LOCAL_MODEL_URL or http://127.0.0.1:11434/v1 | LOCAL_MODEL_API_KEY (optional) | LOCAL_MODEL | no | no |
Effort: the neutral
effort(low,medium,high, on the request or itscontext) is sent as the service's reasoning effort where the table says so; elsewhere, or for a level the service doesn't take, the request is refused with codeunsupportedbefore anything is sent. Whether a given model honours it is up to the service.Prompt caching: system prompt first and history in order, so services that cache prompt prefixes can reuse them; cached prompt tokens are reported as
usage.cachedInputTokens(part ofinputTokens).Documents:
{type: 'document', mediaType: 'application/pdf', data, name?}in user messages goes as a file part where the table says yes; otherwise it is refused with codeunsupported.Custom providers (
createCustom, checked bycheckCustomProvider):{id, label, baseUrl, keyVar?, model?, modelVar?, path?, tools?, structuredOutput?, documents?, effort?}.keyVarnames the environment variable with the key (never the key itself) and may be left out only for a server on this machine; the address must be https without credentials or a query.Streaming (
onEvent), tools and structured output (responseFormat; turn it off withstructuredOutput: falsefor servers without JSON mode).Images: a user message's
contentmay be a list of{type: 'text', text}and{type: 'image', mediaType, data}blocks (base64); images go asimage_urldata URLs. Assistant messages stay text. Only models that read images can use them (visionin@aetheros/models).httpsonly, except plainhttpto this machine. Keys never go in the URL and are never logged.Errors carry
code,statusandretryablefor@aetheros/modelsfallbacks.Tools: function calling through the toolset Aevron hands over, so the host's approval, actor and tenant checks apply. Calls streamed in pieces are put back together, and bad tool input is reported back to the model rather than run. At most 8 tool rounds by default (
maxToolRounds). For servers without function calling, passtools: false.
