LiteLLM integration

Use LiteLLM with Chinese AI models through ChinaAPI.

Add ChinaAPI as an OpenAI-compatible backend in LiteLLM proxy or the Python SDK, then route applications to Chinese models with one key.

Prerequisites

Before editing config.

LiteLLM installed

Use either the LiteLLM proxy server or the Python SDK.

ChinaAPI endpoint

Base URL is https://api.chinaapi.ai/v1. API keys are created under Dashboard -> Console -> Tokens.

Proxy setup

Use openai/<model> entries in config.yaml.

model_list:
  - model_name: deepseek-fast
    litellm_params:
      model: openai/deepseek-flash
      api_base: https://api.chinaapi.ai/v1
      api_key: os.environ/CHINAAPI_API_KEY

  - model_name: kimi-code
    litellm_params:
      model: openai/kimi-k2.7-code
      api_base: https://api.chinaapi.ai/v1
      api_key: os.environ/CHINAAPI_API_KEY

  - model_name: qwen-max
    litellm_params:
      model: openai/qwen3.7-max
      api_base: https://api.chinaapi.ai/v1
      api_key: os.environ/CHINAAPI_API_KEY
export CHINAAPI_API_KEY="sk-..."
litellm --config config.yaml --port 4000

Python SDK

Call ChinaAPI directly from LiteLLM.

import os
from litellm import completion

response = completion(
    model="openai/deepseek-flash",
    api_base="https://api.chinaapi.ai/v1",
    api_key=os.environ["CHINAAPI_API_KEY"],
    messages=[{"role": "user", "content": "Say LiteLLM is connected to ChinaAPI."}],
    stream=True,
)

for chunk in response:
    print(chunk, end="")

Recommended models

Good LiteLLM routes.

For current model details and rate evidence, review DeepSeek-V4 Flash and Kimi K2.7 Code before setting a production route.

deepseek-flash

Fast fallback route for chat, coding help, and agent loops.

kimi-k2.7-code

Good coding route for repository-level tasks and longer sessions.

qwen3.7-max

Reasoning-heavy route when quality matters more than latency.

glm-5.2

Long-context route for larger documents and codebases.

MiniMax-M3

Multimodal coding and long-context model for alternate routing.

Troubleshooting

Common LiteLLM issues.

Thinking models such as qwen3.7-max can generate reasoning tokens before final output. Use streaming in clients behind LiteLLM or raise upstream/client timeouts.

Model not found: check the exact model ID on live pricing, then update litellm_params.model. Keep the openai/ prefix for OpenAI-compatible routing.

401: confirm CHINAAPI_API_KEY resolves to an sk-... key and LiteLLM is passing it as the provider API key.

Pricing and signup

Use gateway-synchronized token pricing behind your LiteLLM gateway.

Standard model rates follow providers' international list prices at 100%; some models have a separate Paid rate after the first top-up. Register for $2 free credit, then check live pricing before routing production traffic.