> ## Documentation Index
> Fetch the complete documentation index at: https://docs.radium.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Framework integration

> Use Radium with LangChain, OpenAI SDK, Vercel AI SDK, and other frameworks

<Error>
  The Pydantic AI, LiteLLM, and Vercel AI SDK snippets below were written from documentation inference and have <strong>not been end-to-end tested</strong> against the live Radium API. Verify each snippet with the respective framework's current version before publishing.
</Error>

# Framework integration

Radium is a drop-in replacement for OpenAI and Anthropic endpoints. This recipe shows how to configure popular frameworks to route through Radium with zero code changes beyond `base_url` and `api_key`.

## OpenAI SDK (official)

```python theme={null}
from openai import OpenAI
import os

client = OpenAI(
    api_key=os.environ["RADIUM_API_KEY"],
    base_url="https://api.radium.cloud/v1",
)

response = client.chat.completions.create(
    model="clarke-1.0",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
```

## LangChain

```python langchain_example.py theme={null}
from langchain_openai import ChatOpenAI
from langchain_core.messages import HumanMessage
import os

llm = ChatOpenAI(
    model="clarke-1.0",
    openai_api_key=os.environ["RADIUM_API_KEY"],
    openai_api_base="https://api.radium.cloud/v1",
    temperature=0.7,
)

response = llm.invoke([HumanMessage(content="Explain Docker in one sentence.")])
print(response.content)
```

## Vercel AI SDK

```typescript vercel-sdk.ts theme={null}
import { OpenAI } from "@ai-sdk/openai";
import { generateText } from "ai";

const openai = new OpenAI({
  apiKey: process.env.RADIUM_API_KEY,
  baseURL: "https://api.radium.cloud/v1",
});

const { text } = await generateText({
  model: openai("clarke-1.0"),
  prompt: "Write a haiku about cloud computing.",
});
console.log(text);
```

## Pydantic AI

```python pydantic_ai_example.py theme={null}
from pydantic_ai import Agent
import os

agent = Agent(
    "openai:clarke-1.0",
    api_key=os.environ["RADIUM_API_KEY"],
    base_url="https://api.radium.cloud/v1",
)

result = agent.run_sync("What is 2 + 2?")
print(result.data)
```

## Anthropic SDK

```python anthropic_example.py theme={null}
from anthropic import Anthropic
import os

client = Anthropic(
    api_key=os.environ["RADIUM_API_KEY"],
    base_url="https://api.radium.cloud",
)

response = client.messages.create(
    model="clarke-1.0",
    max_tokens=256,
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.content[-1].text)
```

## LiteLLM (universal gateway)

```python litellm_example.py theme={null}
import litellm
import os

response = litellm.completion(
    model="openai/clarke-1.0",
    messages=[{"role": "user", "content": "Hello!"}],
    api_key=os.environ["RADIUM_API_KEY"],
    api_base="https://api.radium.cloud/v1",
)
print(response.choices[0].message.content)
```

## Run any example

```bash theme={null}
export RADIUM_API_KEY="YOUR_RADIUM_API_KEY"
python langchain_example.py
```

## Tips

* **Every framework uses the same two values**: `api_key` and `base_url` (or `api_base`).
* **Model names** on Radium are `tycho-1.0`, `clarke-1.0`, and `hal-1.0` — pass them directly wherever the framework expects a model string.
* **Streaming works out of the box** — no special config needed beyond what the framework already supports.
* **Tool calling** follows the OpenAI schema — supported in LangChain, Pydantic AI, and LiteLLM without extra setup.
* **Embeddings** use `text-embedding-3-small` — configure it the same way you'd configure `text-embedding-3-small` on OpenAI.

## Next steps

<CardGroup cols={2}>
  <Card title="Switching with fallback" icon="code-compare" href="/examples/switching-with-fallback">Route intelligently between Radium models</Card>
  <Card title="Tool calling agent" icon="robot" href="/examples/tool-calling-agent">Build an agent using your favorite framework</Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.