Skip to content

LiteLLM

Call HopBase from the LiteLLM Python SDK or route to it from a LiteLLM Proxy config.yaml.

LiteLLM gives one interface over many model providers, either as a Python SDK (litellm.completion) or as a self-hosted proxy server. HopBase plugs into both as an OpenAI-compatible provider: prefix the model ID with openai/ and set api_base.

SettingValue
modelopenai/<HopBase model ID>, such as openai/deepseek-v4.1-flash-1017
api_basehttps://api.hop-base.com/v1
api_keyA key from the console

Verified in production with LiteLLM 1.106: litellm.completion with and without stream=True, and a LiteLLM Proxy serving both regular and streamed requests.

Pick the group that contains your model.

A HopBase key reaches only the models of the groups it includes. When you create the key in the console, select the group that serves the model you want — for example DeepSeek for deepseek-v4.1-flash-1017, DeepSeek Singapore Data Center for deepseek-v4.1-flash-1017-sg, or Gemini (all models, incl. image) for gemini-3.8-flash. A key without the model's group returns 404 model_not_found.

The openai/ prefix only tells LiteLLM which wire protocol to use; it is stripped before the request is sent, so HopBase receives the plain model ID.

Python SDK

pip install litellm
export HOPBASE_API_KEY=sk-your-key
import os
import litellm

response = litellm.completion(
    model="openai/deepseek-v4.1-flash-1017",
    api_base="https://api.hop-base.com/v1",
    api_key=os.environ["HOPBASE_API_KEY"],
    messages=[{"role": "user", "content": "Reply with one word: hello."}],
)
print(response.choices[0].message.content)

Streaming takes the same arguments plus stream=True:

stream = litellm.completion(
    model="openai/deepseek-v4.1-flash-1017",
    api_base="https://api.hop-base.com/v1",
    api_key=os.environ["HOPBASE_API_KEY"],
    messages=[{"role": "user", "content": "Count from 1 to 5."}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

LiteLLM Proxy

Map each name your clients will call to a HopBase model in config.yaml:

model_list:
  - model_name: deepseek-v4.1-flash-1017
    litellm_params:
      model: openai/deepseek-v4.1-flash-1017
      api_base: https://api.hop-base.com/v1
      api_key: os.environ/HOPBASE_API_KEY

general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY

os.environ/HOPBASE_API_KEY makes the proxy read the HopBase key from the environment. Recent LiteLLM versions refuse to start without a master_key; it is the key your own clients send to the proxy, separate from the HopBase key.

pip install 'litellm[proxy]'
export HOPBASE_API_KEY=sk-your-key
export LITELLM_MASTER_KEY=sk-your-proxy-key
litellm --config config.yaml --port 4000

Then call the proxy like any OpenAI-compatible endpoint:

curl http://localhost:4000/v1/chat/completions \
  -H "Authorization: Bearer $LITELLM_MASTER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "deepseek-v4.1-flash-1017", "messages": [{"role": "user", "content": "Reply with one word: hello."}]}'

To expose more models, add one model_list entry per model ID, such as openai/deepseek-v4.1-flash-1017-sg or openai/gemini-3.8-flash, each served by a group your key includes.

Prices for every model are on the pricing page.

Troubleshooting

SymptomCause
AuthenticationError / 401The HopBase key is unset where LiteLLM runs, or the key is disabled
404 model_not_foundThe key does not include the model's group, or the ID after openai/ is shortened. Re-read GET /v1/models
LLM Provider NOT providedThe model ID is missing the openai/ prefix
Proxy exits with "no master key is set"Add general_settings.master_key or set LITELLM_MASTER_KEY

Next steps