This file provides guidance to WARP (warp.dev) when working with code in this repository.
This is the official Python SDK for the Warp API, providing convenient access to the Warp API REST API. The SDK is generated code created using Stainless from an OpenAPI specification. Most files are auto-generated, with exceptions for src/warp_agent_sdk/lib/ and examples/ directories which are manually maintained.
# Bootstrap the development environment (installs uv, Python, and dependencies)
./scripts/bootstrap# Run full test suite (tests with both Pydantic v1 and v2, multiple Python versions)
./scripts/test
# Run specific tests
uv run pytest tests/test_client.py
# Tests require a mock Prism server running on port 4010
# The test script will automatically start one if not running
# To manually start: ./scripts/mock --daemon# Run all linters (ruff, pyright, mypy)
./scripts/lint
# Run with auto-fix
./scripts/lint --fix
# Format code
./scripts/format# Build distribution packages (.tar.gz and .whl)
uv buildGenerated code (DO NOT manually edit - changes will be overwritten):
src/warp_agent_sdk/_client.py- Main client classes (WarpAPI, AsyncWarpAPI)src/warp_agent_sdk/resources/- API resource classessrc/warp_agent_sdk/types/- Type definitions and models- Most utility files in
src/warp_agent_sdk/_utils/
Manual code (safe to edit):
src/warp_agent_sdk/lib/- Custom library codeexamples/- Example scriptstests/- Test files
Client Architecture:
WarpAPI(sync) andAsyncWarpAPI(async) are the main entry points- Both inherit from
SyncAPIClientandAsyncAPIClientbase classes - Support for both
httpx(default) andaiohttp(optional) HTTP backends - API key authentication via
Authorization: Bearerheader - Default base URL:
https://app.warp.dev/api/v1
Resource Structure:
- Resources are organized hierarchically (e.g.,
client.agent.tasks.retrieve()) - Each resource has sync/async variants and raw/streaming response wrappers
- Main resource:
AgentResourcewithrun()method and nestedTasksResource
Type System:
- Uses Pydantic models for request/response validation
- TypedDict for nested parameters
- Custom types:
NotGiven,Omitfor optional parameters - Supports both Pydantic v1 and v2
WARP_API_KEY- API key for authentication (required)WARP_API_BASE_URL- Override default base URLWARP_API_LOG- Enable logging (infoordebug)TEST_API_BASE_URL- Use custom API endpoint for tests
- Tests use
pytestwithpytest-asynciofor async tests - Both sync and async variants must be tested
- Tests run against a mock Prism server based on OpenAPI spec
- Tests run with both Pydantic v1 and v2 on Python 3.9 and 3.14+
- Use
respxfor mocking HTTP requests in tests
-
Making changes:
- Only edit files in
lib/andexamples/directories - Other changes should be made to the OpenAPI spec and regenerated
- Only edit files in
-
Adding examples:
- Create executable Python scripts in
examples/ - Use shebang:
#!/usr/bin/env -S uv run python - Make executable:
chmod +x examples/<your-example>.py
- Create executable Python scripts in
-
Code quality:
- Run
./scripts/formatbefore committing - Ensure
./scripts/lintpasses - Run
./scripts/testto verify changes
- Run
- Uses uv for fast, reliable dependency management
pyproject.tomldefines project metadata and dependenciesuv.lockpins exact versions for reproducibilityrequirements-dev.lockexported for pip compatibility