Skip to main content

DSPy

DSPy connects to OpenAI-compatible APIs through LiteLLM. Prefix the Radium model with openai/, then provide Radium’s API key and base URL.

Before you start

You need Python 3.10 or newer, a Radium API key, and a terminal or PowerShell window.

1. Create a project and install DSPy

2. Set your Radium credentials

3. Create main.py

DSPy may return a string or a dictionary containing text and reasoning_content. The code handles both response shapes.

4. Run it

Expected output:

Choose a model

Migrate an existing DSPy program

Configure the global language model, then keep using your existing signatures and modules:
DSPy optimizers can make many model calls. Test latency and usage on a small dataset before starting a large optimization.

Tool-calling note

Known issue with hal-1.0: DSPy ReAct executed tools and returned grounded answers with all three models. With hal-1.0, DSPy logged an output-truncation warning during the agent trace at both 512 and 1024 output tokens, though the tool still ran once and the final answer was correct. Test longer ReAct workflows before relying on them in production.

Troubleshooting

Validation

These instructions were verified with Python 3.12.7 and dspy==3.3.0 on August 20, 2026. You do not need that exact package version.
Text generation passed with hal-1.0, clarke-1.0, and tycho-1.0; ReAct tool calling passed with the caveat above.

Next steps

API quickstart

Call Radium directly

Tool calling

The tool_use and tool_result contract