Skip to main content

OpenAI-Compatible Models

Many LLM providers expose an OpenAI-compatible Chat Completions API. Agentium lets you connect to any of them by simply providing a baseURL and apiKey — no custom provider code required. This works for providers like Together AI, Groq, Fireworks, OpenRouter, NVIDIA, DeepInfra, Cerebras, SambaNova, LM Studio, vLLM, and any other service that implements the OpenAI format.

Two Ways to Connect

Option 1: openai() Factory with Custom baseURL

The simplest approach — use the existing openai() factory:
This works because these providers use the same API format as OpenAI.

Option 2: OpenAICompatibleProvider Class

For more control or when building reusable providers, use the class directly:

Provider Examples

Together AI

Access 100+ open-source models including Llama, Mistral, Qwen, and more.
Environment:

Groq

Ultra-fast inference for open models.
Environment:

Fireworks AI

Optimized inference for open-source models.
Environment:

OpenRouter

Access models from multiple providers through a single API.
Environment:

NVIDIA NIM

NVIDIA-hosted inference for optimized models.
Environment:

DeepInfra

Serverless inference at low cost.
Environment:

LM Studio (Local)

Connect to a locally-running LM Studio server.

vLLM (Self-Hosted)

Connect to a self-hosted vLLM server.

Tool Calling

Tool calling works with any OpenAI-compatible provider that supports function calling:
Not all models or providers support tool calling. Check your provider’s documentation for function calling support. Larger models (70B+) generally have better tool calling reliability.

Registering a Custom Provider

If you use a specific endpoint frequently, register it as a named provider:

Supported Provider Endpoints


Full Example


Cross-References