Skip to content
Need an API key for this client? One token for Claude, GPT-6.2, Gemini 4 & DeepSeek V4 — top up via USDT or Alipay

Connect LlamaIndex to byesu API ​

Connect LlamaIndex RAG query engines, chat engines, and FunctionAgent workflows to byesu using llama-index-llms-openai-like so you can call Claude 5.5, GPT-6.2, DeepSeek V4, Gemini 4, and Grok with a single pay-as-you-go API key.

Quick configuration

  • Package: llama-index-llms-openai-like (OpenAILike)
  • api_base: https://byesu.com/v1
  • Required flags: is_chat_model=True, is_function_calling_model=True, context_window=1000000, timeout=120.0
  • Environment variable: BYESU_API_KEY=sk-... (created in the default auto group)

Why OpenAILike Beats llama_index.llms.openai.OpenAI ​

When routing through an OpenAI-compatible gateway to non-gpt-* model IDs (claude-opus-5-5, claude-sonnet-5-5, deepseek-v4-pro, gemini-4-argon, grok-4.7) — or newly released GPT models before upgrading LlamaIndex — llama_index.llms.openai.OpenAI validates model against a hardcoded dictionary of OpenAI model names to look up context window metadata and raises ValueError: Unknown model ....

OpenAILike (from llama-index-llms-openai-like) skips hardcoded model-name validation and accepts any gateway model ID cleanly while preserving chat completions, streaming, structured outputs, and native tool calling.

Prerequisites ​

  1. Create an sk-... token in the byesu Console under the default auto group (see Choosing a Group).
  2. Install llama-index-core and llama-index-llms-openai-like:
bash
pip install llama-index-core llama-index-llms-openai-like
export BYESU_API_KEY="sk-your-byesu-token"

Configure OpenAILike for Chat, RAG & Tool Agents ​

Initialize OpenAILike with api_base="https://byesu.com/v1" and register it on Settings.llm:

python
import os
from llama_index.core import Document, Settings, SummaryIndex
from llama_index.core.llms import ChatMessage
from llama_index.llms.openai_like import OpenAILike

llm = OpenAILike(
    model="claude-sonnet-5-5",  # swap to "claude-opus-5-5", "gpt-6.2-sol", "deepseek-v4-pro", "gemini-4-argon"
    api_base="https://byesu.com/v1",
    api_key=os.environ["BYESU_API_KEY"],
    context_window=1000000,
    is_chat_model=True,
    is_function_calling_model=True,
    timeout=120.0,
)

# 1. Direct streaming chat
for chunk in llm.stream_chat([ChatMessage(role="user", content="Give 3 indexing tips for hybrid BM25 + vector RAG.")]):
    print(chunk.delta, end="", flush=True)
print()

# 2. Register globally for LlamaIndex query engines & synthesizers
Settings.llm = llm

docs = [
    Document(text="Runbook: Checkout service scales automatically up to 40 pods; Redis failover takes ~8 seconds."),
    Document(text="SLO policy: Checkout p99 latency target is 350ms; paging triggers above 1.5% 5xx over 5 minutes."),
]
index = SummaryIndex.from_documents(docs)
query_engine = index.as_query_engine(response_mode="compact")
print(query_engine.query("When does on-call get paged for checkout, and how long is Redis failover?"))

(When using VectorStoreIndex, pair Settings.llm = llm with your local HuggingFaceEmbedding or vector database's embedding model.)

Tool-Calling FunctionAgent Example ​

Because is_function_calling_model=True enables OpenAI-compatible tools payloads on OpenAILike, you can run LlamaIndex's async FunctionAgent across Claude, GPT, DeepSeek, or Gemini:

python
import asyncio
import os
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai_like import OpenAILike


def lookup_shard_status(shard_id: str) -> str:
    """Look up replication lag in milliseconds for a database shard."""
    return f"Shard {shard_id}: primary healthy, replica lag 14ms."


llm = OpenAILike(
    model="deepseek-v4-pro",
    api_base="https://byesu.com/v1",
    api_key=os.environ["BYESU_API_KEY"],
    context_window=128000,
    is_chat_model=True,
    is_function_calling_model=True,
    timeout=120.0,
)

agent = FunctionAgent(
    tools=[lookup_shard_status],
    llm=llm,
    system_prompt="You are a database reliability assistant. Always check shard status before answering.",
)


async def main() -> None:
    response = await agent.run("Is shard eu-west-02 safe for read-after-write traffic?")
    print(response)


if __name__ == "__main__":
    asyncio.run(main())

Production Engineering Notes ​

  • Sampling parameters on Claude 5.5 & GPT-6.2: LlamaIndex's OpenAI base classes default temperature to a float (0.1). If a strict reasoning route (gpt-6.2-sol) or native Anthropic 2026-10-21 schema rejects sampling fields with HTTP 400, pass temperature=None (and avoid setting top_p) so sampling keys are omitted (Claude 400 sampling fix).
  • Match context_window to your target model: Set context_window=1000000 for 1M-window models (claude-opus-5-5, claude-sonnet-5-5, gemini-4-argon) or 128000–400000 for smaller windows so LlamaIndex's chunk splitter budgets prompts accurately (context length exceeded).
  • Token groups & billing: The default auto group covers Claude, GPT, Gemini, DeepSeek, and Grok. Create separate tokens in Glm (glm-5.3), Kimi (kimi-k3), or media (gpt-image-2, gemini-3.1-flash-image-ultra) when needed. Billing is pay-as-you-go per token with live rates displayed in the byesu Console after sign-in.

Troubleshooting & Benchmarks ​

  • ValueError: Unknown model: switch from llama_index.llms.openai.OpenAI to llama_index.llms.openai_like.OpenAILike as shown above.
  • 401 invalid_api_key: verify api_base="https://byesu.com/v1" and BYESU_API_KEY (OpenAI 401 fix).
  • 404 / no available channel: check exact model spelling and token group (no available channel).
  • Timeouts on long RAG synthesis: keep timeout=120.0 or higher and use streaming response synthesis (Anthropic timeout, weekly production benchmarks).

Got a problem? Contact support or join our group.