LlamaIndex with an OpenAI-compatible API: setup

Use Claude, GPT, Gemini and open models in LlamaIndex through one OpenAI-compatible key: OpenAILike setup, embeddings, function calling and the common errors.

Checked 2026-11-21

·All guides·Models

To use UplinkSwitch in LlamaIndex, install llama-index-llms-openai-like and create OpenAILike(model="claude-sonnet-5-5", api_base="https://api.uplinkswitch.com/v1", api_key=..., is_chat_model=True). Every chat model in the catalog then works in query engines, chat engines and agents, priced per token from prepaid credit.

Install

bash
pip install llama-index-core llama-index-llms-openai-like

The LLM

python
import os
from llama_index.llms.openai_like import OpenAILike
from llama_index.core import Settings

Settings.llm = OpenAILike(
    model="claude-sonnet-5-5",
    api_base="https://api.uplinkswitch.com/v1",
    api_key=os.environ["UPLINKSWITCH_API_KEY"],
    is_chat_model=True,
    is_function_calling_model=True,   # for models that support tool calling
    context_window=200000,            # set to what you'll actually send, at most the model's window
)

is_chat_model=True sends requests to the Chat Completions endpoint. Leave it off and LlamaIndex uses the legacy completions route, which many chat models don't serve well.

Embeddings on the same key

The catalog includes embedding models such as bge-m3 ($0.0295 per million tokens) and gemini-embedding-001 ($0.15), served at /v1/embeddings. Use OpenAILikeEmbedding from llama-index-embeddings-openai-like with the same api_base.

Which model for which job

JobModel idPrice per 1M (in / out)
Answer synthesis over retrieved chunksclaude-sonnet-5-5$1.164 / $2.91
High-volume summarising and routingdeepseek-v4.1-flash$0.0564 / $0.1692
Long documents in one callgemini-4-argon (1M)$0.582 / $2.91

Errors you may see

  • "Unknown model": the plain OpenAI class validates names against OpenAI's list. Use OpenAILike.
  • 401: the key is missing or mistyped; it starts with sk-uplink-live-.
  • 402 insufficient_balance: top up; nothing was charged.

Questions and answers

Use OpenAILike. The regular class expects OpenAI model names, and its token-limit lookups fail for other ids.

Yes. Point the Anthropic LLM at https://api.uplinkswitch.com with base_url=… and your key. Both formats bill the same price.

Retrieve fewer, tighter chunks, synthesise on a low-cost model and use a frontier one only for hard questions. Repeated system prompts bill at the cached-input rate.
Join on Telegram
Help