LiteLLM

LiteLLM is an AI gateway that provides unified access to over 100 language models, supporting features like fallback handling and usage tracking, all through an OpenAI-compatible interface.

Method 1: Direct Integration (Recommended, Simplest)

Add your provider to litellm/llms/openai_like/providers.json:

{
  "rygen": {
    "base_url": "https://api.rygen.io/v1",
    "api_key_env": "RYGEN_API_KEY"
  }
}

Or set the environment variable and use it directly:

export RYGEN_API_KEY="your-rygen-api-key"
import litellm

response = litellm.completion(
    model='your-model-name',
    messages=[{'role': 'user', 'content': 'Hello!'}]
)

Method 2: LiteLLM Library Directly

pip install litellm
import litellm, os
os.environ["RYGEN_API_KEY"] = "your-rygen-api-key"
response = litellm.completion(model='your-model-name', messages=[{'role': 'user', 'content': 'Hi there!'}])
print(response.choices[0].message.content)

Method 3: LiteLLM Proxy

Create a config.yaml file:

model_list:
  - model_name: your-model-name
    litellm_params:
      model: your-model-name
      api_base: https://api.rygen.io/v1
      api_key: os.environ/RYGEN_API_KEY

Set the environment variable and start the proxy:

export RYGEN_API_KEY="your-rygen-api-key"
pip install 'litellm[proxy]'
litellm --config config.yaml

Call through the unified API:

curl https://your-proxy:4000/v1/chat/completions \
  -H "Authorization: Bearer YOUR_KEY" \
  -d '{
    "model": "your-model-name",
    "messages": [
      {"role": "user", "content": "Hi, How are you doing?"}
    ]
  }'