---
source_url: "https://docs.valyu.ai/sdk/python-sdk"
title: "Python Quickstart | Valyu"
mirrored_at: 2026-08-07T15:39:37.283Z
host: docs.valyu.ai
cited_in_42a: true
mirror_canonical: "https://index.42a.ai/docs.valyu.ai/sdk/python-sdk"
---

> **Original source:** https://docs.valyu.ai/sdk/python-sdk

The Valyu Python SDK gives you search, content extraction, answers, and deep research through one API.

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](https://platform.valyu.ai/) ($10 free credits, $20 with a work email). The SDK reads `VALYU_API_KEY` from the environment automatically:

## First call

Every method returns a typed response with a `success` flag - check it before reading results.

## APIs

## 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

Cap how many requests are in flight with a semaphore (keep it aligned with `max_connections`):

Use `asyncio.as_completed` to process each result the moment it’s ready instead of waiting for the whole batch.

FastAPI lifecycle

Instantiate the client once at startup and share it - don’t create a fresh `AsyncValyu` per request, or you throw away the connection pool every time.

Prefer `async with` for scripts so the pool is released deterministically. For long-lived services, call `aclose()` on shutdown (it’s idempotent).

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`

## Support

-   **Discord**: [Join our community](https://discord.gg/umtmSsppRY)
-   **GitHub**: [valyuAI/valyu-py](https://github.com/valyuAI/valyu-py)
-   **Email**: [contact@valyu.ai](mailto:contact@valyu.ai)