LiteLLM
Use AICredits behind LiteLLM or migrate from LiteLLM by changing the OpenAI-compatible base URL and API key.
Use this page with an AI assistant
Opens a new chat with this docs URL and the correct AICredits base URLs.
LiteLLM can proxy many providers. You can either replace a LiteLLM proxy with AICredits directly, or configure LiteLLM to call AICredits as an OpenAI-compatible upstream.
Direct Replacement
If your app already uses the OpenAI SDK with LiteLLM:
from openai import OpenAI
client = OpenAI(
api_key="sk-your-aicredits-key",
base_url="https://api.aicredits.in/v1",
)
response = client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[{"role": "user", "content": "Hello from AICredits"}],
)
print(response.choices[0].message.content)LiteLLM Upstream Config
If you still want to run LiteLLM for local routing or policy logic, add AICredits as an OpenAI-compatible upstream:
model_list:
- model_name: aicredits-gpt-4o-mini
litellm_params:
model: openai/openai/gpt-4o-mini
api_base: https://api.aicredits.in/v1
api_key: sk-your-aicredits-key
- model_name: aicredits-claude-sonnet
litellm_params:
model: anthropic/claude-sonnet-4.5
api_base: https://api.aicredits.in/v1
api_key: sk-your-aicredits-keyThe openai/ prefix in LiteLLM tells LiteLLM to use its OpenAI-compatible adapter. The model ID after that is the AICredits model ID.
When To Use Each Setup
| Setup | Best for |
|---|---|
| App → AICredits | Simplest production setup, INR billing, no proxy to maintain |
| App → LiteLLM → AICredits | Teams that already rely on LiteLLM-local policies or routing |
| App → AICredits and LiteLLM side-by-side | Migration testing and fallback experiments |
Migration Checklist
- Replace
base_urlwithhttps://api.aicredits.in/v1. - Replace provider keys with an AICredits API key.
- Confirm model IDs exist on Models.
- Run one low-cost request.
- Check Dashboard → Usage for model, token, and cost attribution.
Troubleshooting
Double provider prefix — LiteLLM may need openai/<aicredits-model-id> in its config, while direct OpenAI SDK calls should use only the AICredits model ID.
404 model not found — Use the exact model ID from Models.
Cost mismatch — Compare LiteLLM logs with AICredits usage logs. AICredits billing is based on the final routed request and token usage.