Agents and integrations

Use Foundry with LiteLLM.

Call the gateway's models through LiteLLM's SDK or its proxy, with the openai/ prefix, the gateway's address and your key.

On this page

You need a Foundry API key with USDF on its balance. Create one in the dashboard; see Accounts and keys.

LiteLLM reaches the gateway through its OpenAI-compatible API at https://api.usdf.fi/v1. Replace sk_YOUR_KEY below with your key.

Name the model with the openai/ prefix and pass the gateway's address as api_base:

completion

Python
Install
pip install litellm
Code
import os
from litellm import completion

response = completion(
    model="openai/claude-sonnet-5-5",
    api_base="https://api.usdf.fi/v1",
    api_key=os.environ["USDF_API_KEY"],
    messages=[{"role": "user", "content": "Hello"}],
    max_tokens=256,
)
print(response.choices[0].message.content)

In the proxy's config.yaml, each entry of model_list names a model for the proxy's clients and where it is served. os.environ/USDF_API_KEY reads the key from the environment, so the file holds no key.

config.yaml

model_list:
  - model_name: foundry
    litellm_params:
      model: openai/claude-sonnet-5-5
      api_base: https://api.usdf.fi/v1
      api_key: os.environ/USDF_API_KEY

The proxy is LiteLLM's proxy extra. It also needs a key of its own, LITELLM_MASTER_KEY, and refuses to start without one. Install it, then start the proxy where both variables are set. Its clients send the master key as their key and ask for the model foundry.

Shell

pip install 'litellm[proxy]'
export USDF_API_KEY=sk_YOUR_KEY
export LITELLM_MASTER_KEY="sk-$(openssl rand -hex 32)"
litellm --config config.yaml --port 4000

openai/ tells LiteLLM to call an OpenAI-compatible API; the rest is the gateway's own id, such as claude-sonnet-5-5, as Models and GET /v1/models list it.

If LiteLLM answers Not Found, check that api_base ends in /v1. A 401 means the key was not read; a 404 model_not_found names the closest ids the gateway serves.

With the proxy running, ask it for foundry from another shell where LITELLM_MASTER_KEY holds the same key. An answer with a reply means the proxy reached the gateway with your key:

Ask the proxy

curl -sS http://localhost:4000/v1/chat/completions \
  -H "Authorization: Bearer $LITELLM_MASTER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "foundry", "messages": [{"role": "user", "content": "Say hello in one word"}], "max_tokens": 256}'

To check the key and the model on their own, send one request from a shell where USDF_API_KEY holds your key:

Check

curl -sS https://api.usdf.fi/v1/chat/completions \
  -H "Authorization: Bearer $USDF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "claude-sonnet-5-5", "messages": [{"role": "user", "content": "Say hello in one word"}], "max_tokens": 256}'
AnswerWhat it means
200The key and the model work. The answer ends with its receipt: what was charged, and the request id.
401 invalid_api_keyNo valid key reached the gateway. Send a key that starts with sk_.
402 insufficient_balanceThe balance does not cover the request. Add USDF; see Accounts and keys.
404 model_not_foundThe id is not one the gateway serves. The error names the closest ids; every id is on Models.

See every client and coding agent

Foundry documentation

Confirm it's you

Confirm to continue the action you started.

Checking confirmation options…