LiteLLM + APIMaster.ai
Connect APIMaster.ai OpenAI-compatible API via LiteLLM Python SDK or LiteLLM Proxy.
LiteLLM provides a unified LLM SDK and a local Proxy server. APIMaster.ai exposes an OpenAI-compatible API — use the openai/<model id> format and set api_base.
Get an API Key first. Copy the exact model id from the marketplace.
Base URL:
https://apimaster.ai/v1
LiteLLM model name format:
openai/<APIMaster model id>
Example: openai/claude-sonnet-4-6.
Prerequisites
- Python 3.10+ (3.11+ recommended).
- An APIMaster API Key from the console.
- A target model id from the marketplace.
Step 1 — Install LiteLLM
SDK only:
pip install litellm
With Proxy support:
pip install "litellm[proxy]"
Step 2 — Minimal Python SDK test
Create minimal_apimaster_test.py:
import litellm
API_KEY = "your APIMaster key"
response = litellm.completion(
model="openai/claude-sonnet-4-6",
api_base="https://apimaster.ai/v1",
api_key=API_KEY,
messages=[
{"role": "user", "content": "Say hi in one short sentence."},
],
max_tokens=64,
)
print(response.choices[0].message.content)
Or download the sample script.
python minimal_apimaster_test.py
Step 3 — LiteLLM Proxy config
Create config.apimaster.yaml:
model_list:
- model_name: apimaster-claude-sonnet
litellm_params:
model: openai/claude-sonnet-4-6
api_base: https://apimaster.ai/v1
api_key: os.environ/APIMASTER_API_KEY
general_settings:
master_key: sk-local-test
Or download the sample config.
| Key | Purpose |
|---|---|
APIMASTER_API_KEY |
Real APIMaster key — LiteLLM uses this upstream |
master_key |
Local Proxy access key — clients use this |
Step 4 — Start LiteLLM Proxy
export APIMASTER_API_KEY="your APIMaster key"
litellm --config config.apimaster.yaml --port 4000
If litellm is not on PATH:
python -m litellm --config config.apimaster.yaml --port 4000
Step 5 — Test local Proxy
curl http://localhost:4000/v1/chat/completions \
-H "Authorization: Bearer sk-local-test" \
-H "Content-Type: application/json" \
-d '{
"model": "apimaster-claude-sonnet",
"messages": [{"role": "user", "content": "Say hi in one short sentence."}],
"max_tokens": 64
}'
Step 6 — Multiple models
model_list:
- model_name: apimaster-claude-sonnet
litellm_params:
model: openai/claude-sonnet-4-6
api_base: https://apimaster.ai/v1
api_key: os.environ/APIMASTER_API_KEY
- model_name: apimaster-gpt
litellm_params:
model: openai/gpt-5.4
api_base: https://apimaster.ai/v1
api_key: os.environ/APIMASTER_API_KEY
general_settings:
master_key: sk-local-test
Clients call apimaster-gpt, not openai/gpt-5.4.
Troubleshooting
401 Invalid token
Key is wrong or disabled. Verify:
curl https://apimaster.ai/v1/models \
-H "Authorization: Bearer YOUR_KEY"
Model not found
Use marketplace model id with openai/ prefix:
model: openai/claude-sonnet-4-6
Wrong api_base
Must include /v1:
api_base: https://apimaster.ai/v1
Recommended verification order
- Python SDK minimal script — validates APIMaster key and model.
- Start LiteLLM Proxy.
- Call local Proxy with OpenAI-compatible JSON.
Checklist
- Installed
litellm(litellm[proxy]for Proxy) - SDK:
openai/<model id>+api_base=https://apimaster.ai/v1 - Proxy:
APIMASTER_API_KEYvsmaster_keyconfigured separately - SDK or Proxy test returns a reply