Loading...

Docs · Integrations

LiteLLM with TopxAI: proxy config and the Python SDK

Route LiteLLM to TopxAI with model openai/<id> and api_base https://ai.topxea.com/v1, in the proxy’s model_list or a completion() call.

LiteLLM reaches any OpenAI-compatible endpoint with the openai/ prefix and an api_base, and the Anthropic endpoint with anthropic/. That covers every TopxAI text model.

Python SDK

import litellm

reply = litellm.completion(
    model="openai/claude-sonnet-5-5",
    api_base="https://ai.topxea.com/v1",
    api_key="sk-...",
    messages=[{"role": "user", "content": "Say hello in one sentence."}],
)
print(reply.choices[0].message.content)

For Claude with prompt caching through the Messages API:

reply = litellm.completion(
    model="anthropic/claude-sonnet-5-5",
    api_base="https://ai.topxea.com",
    api_key="sk-...",
    messages=[...],
)

Proxy config.yaml

model_list:
  - model_name: claude-sonnet-5-5
    litellm_params:
      model: openai/claude-sonnet-5-5
      api_base: https://ai.topxea.com/v1
      api_key: os.environ/TOPXAI_API_KEY
  - model_name: gpt-6.1-sol
    litellm_params:
      model: openai/gpt-6.1-sol
      api_base: https://ai.topxea.com/v1
      api_key: os.environ/TOPXAI_API_KEY
  - model_name: kimi-k3.1-pro
    litellm_params:
      model: openai/kimi-k3.1-pro
      api_base: https://ai.topxea.com/v1
      api_key: os.environ/TOPXAI_API_KEY

Start it with litellm --config config.yaml; clients then call the proxy with the model_name values.

Cost tracking

LiteLLM prices by model name and knows nothing about TopxAI's routes. To make its cost column match the usage log, set input_cost_per_token and output_cost_per_token in litellm_params from the model's page (for example 0.000001 and 0.000005 for claude-sonnet-5-5 on the shared pool).

If it fails

Models: claude-sonnet-5-5, gpt-6.1-sol · Models & pricing

Related

Previous: Vercel AI SDK with TopxAI: createOpenAI, createAnthropic and openai-compatible · Next: Dify with TopxAI: the OpenAI-API-compatible provider

Other languages: 简体中文