Skip to main content
Helicone OSS LLM Observability

DSPy

Integrate Helicone AI Gateway with DSPy to access 100+ LLM providers with unified observability and optimization.
2 min read

Introduction#

DSPy is a declarative framework for building modular AI software with structured code instead of brittle prompts, offering algorithms that compile AI programs into effective prompts and weights for language models across classifiers, RAG pipelines, and agent loops.

Integration Steps#

Create an account and generate an API key

Log into Helicone or create an account. Once you have an account, you can generate an API key here.

Set up your Helicone API key in your .env file

Create a .env file in your project.

Install DSPy

Install required dependencies

Python

Start using DSPy with Helicone

View requests in the Helicone dashboard

Python
You can find all 100+ supported models at helicone.ai/models.

Verify your requests in Helicone

With the above setup, any calls to DSPy will automatically be logged and monitored by Helicone. Review them in your Helicone dashboard.
Tip

While you're here, why not give us a star on GitHub? It helps us a lot!

Complete Working Examples#

Basic Chain of Thought#

Python

Custom Generation Configuration#

Configure temperature, max_tokens, and other parameters:

Python

Tracking with Custom Properties#

Add custom properties to track and filter your requests in the Helicone dashboard:

Python

Helicone Prompts Integration#

Use Helicone Prompts for centralized prompt management with DSPy signatures:

Python
Note

Learn more about Prompts with AI Gateway.

Advanced Features#

Rate Limiting#

Configure rate limits for your DSPy applications:

Python

Caching#

Enable intelligent caching to reduce costs:

Python

Session Tracking for Multi-Turn Conversations#

Track entire conversation flows in DSPy programs:

Python