LiteLLM → AI24X
LiteLLM unifies many LLM providers behind one SDK/proxy. Register AI24X as an OpenAI-compatible endpoint and call flash/pro with one key.
1) Prerequisites
Sign up → Console → create an API key → keep a small credit balance. Python with litellm installed, or a LiteLLM proxy.
2) Python SDK
import os
from litellm import completion
os.environ["OPENAI_API_KEY"] = "YOUR_AI24X_API_KEY"
resp = completion(
model="openai/flash",
api_base="https://api.ai24x.com/v1",
messages=[{"role": "user", "content": "hello"}],
)
print(resp.choices[0].message.content)
Use openai/pro the same way. VIP ids: openai/vip-kimi (membership required).
3) Proxy config.yaml
model_list:
- model_name: flash
litellm_params:
model: openai/flash
api_base: https://api.ai24x.com/v1
api_key: os.environ/AI24X_API_KEY
- model_name: pro
litellm_params:
model: openai/pro
api_base: https://api.ai24x.com/v1
api_key: os.environ/AI24X_API_KEY
Set AI24X_API_KEY in the proxy environment, then call your LiteLLM proxy as usual.
4) Pitfalls
- Prefix models with
openai/so LiteLLM uses the OpenAI-compatible driver. api_baseends at/v1—do not append/chat/completions.- 401 = bad key; 402 = top up credits in Console.