Skip to main content
Add Valyu Search to an application using OpenAI’s Responses API with OpenAIProvider. Your application runs the model and tool loop; Valyu returns content and source URLs. To use Valyu inside ChatGPT, connect via MCP.

Installation

Install the Valyu and OpenAI packages:
Set your API keys as environment variables:

Basic usage

The OpenAI provider handles the integration with the Responses API:
This example performs one round of search and then asks the model to write a response. For an agent that can search repeatedly, add a bounded tool loop and handle tool errors explicitly. Model-provider charges are separate from Valyu usage.

How it works

The OpenAIProvider handles tool registration, execution, and conversation flow for you. The model decides when to search; the provider runs the call and feeds results back.
This uses OpenAI’s Responses API (responses.create()), not Chat Completions.
The model chooses these per query based on context:
  • max_num_results - 1-20 for standard keys, up to 100 with a special API key
  • included_sources / excluded_sources - target or exclude datasets
  • category - guide search to a topic
  • start_date / end_date - time-bounded searches
  • relevance_threshold - filter by relevance (0-1)
Steer behaviour with a system prompt: cite sources, use natural-language queries (not operators). See the Prompting Guide.

Additional resources

OpenAI Responses API

Official OpenAI Responses API documentation

Valyu API Reference

Complete Valyu API documentation

Python SDK

Full Python SDK documentation

Get API Key

Sign up for $10 free credits ($20 with a company email)