Paste into your AI coding assistant to install the Valyu Python SDK and make your first search call.
Install
Authenticate
Get your API key from the Valyu Platform ($10 free credits, $20 with a work email). The SDK readsVALYU_API_KEY from the environment automatically:
First call
success flag - check it before reading results.
APIs
Search
Search web and proprietary sources
Contents
Extract and process web content
Answer
Generate cited answers from search
DeepResearch
Autonomous async research reports
Async client
AsyncValyu is the async/await counterpart to Valyu: same arguments, same response objects, same validation. Every method is a coroutine you await. Reach for it when a single request fans out several Valyu calls (research agents, multi-source lookups) or runs inside an async web service. For one-off scripts and notebooks, the synchronous client is simpler.
Bounded fan-out and streaming results
Bounded fan-out and streaming results
Cap how many requests are in flight with a semaphore (keep it aligned with Use
max_connections):asyncio.as_completed to process each result the moment it’s ready instead of waiting for the whole batch.FastAPI lifecycle
FastAPI lifecycle
Instantiate the client once at startup and share it - don’t create a fresh Prefer
AsyncValyu per request, or you throw away the connection pool every time.async with for scripts so the pool is released deterministically. For long-lived services, call aclose() on shutdown (it’s idempotent).Constructor options
Constructor options
| Parameter | Type | Description | Default |
|---|---|---|---|
api_key | Optional[str] | API key. Falls back to VALYU_API_KEY. | None |
base_url | str | Base URL of the Valyu API. | https://api.valyu.ai/v1 |
max_connections | int | Max simultaneous HTTP connections. Match it to your expected peak concurrency. | 100 |
max_keepalive_connections | Optional[int] | Idle connections kept warm for reuse. | max(20, max_connections // 5) |
timeout | float | Per-request timeout in seconds. | 600.0 |
http_client | Optional[httpx.AsyncClient] | Pre-configured client to use instead of the default. Ownership stays with the caller. | None |
AsyncValyu currently exposes search, contents, get_contents_job, and wait_for_contents_job. The remaining endpoints (answer, deepresearch, datasources) are synchronous-only today; async counterparts will follow.Support
- Discord: Join our community
- GitHub: valyuAI/valyu-py
- Email: contact@valyu.ai

