conv.api is a dynamic API client generated from the APIs tab in Agent Studio.
Each API you define there becomes a namespaced client on the Conversation object, with one callable method per operation.
This lets you keep API configuration (base URLs, auth, resources) in the UI, while keeping function logic clean and environment-safe.

How it works
-
You define an API in Agent Studio → APIs
- Name
- Base URL (per environment)
- Auth type
- One or more operations (method + resource path)
- Agent Studio generates a client at runtime.
-
Inside a function, you call it via:
conv.api.<api_name>.<operation_name>(...)
Naming rules
- API name in the UI becomes the client name under
conv.apisweet_booking_api→conv.api.sweet_booking_api
- Operation name becomes the callable method
create_booking→conv.api.sweet_booking_api.create_booking()
Basic example
API defined in UI:- API name:
sweet_booking_api - Base URL:
https://api.sweets.example - Operation:
- Method: POST
- Operation name:
create_booking - Resource:
/bookings
Path variables
Path parameters defined in the resource can be passed positionally or by name. Resource:/bookings/{booking_id}
Both of these are valid:
Query parameters
Use theparams argument for query string parameters.
Request body
Usejson (recommended) or data depending on the API.
Custom headers
You can pass additional headers at call time.Responses
The return value is a standard HTTP response object. Typical fields you’ll use:response.status_coderesponse.json()response.text
Error handling
Always check status codes explicitly. Recommended pattern:Logging API responses
For debugging and review, log responses explicitly.- Conversation Review → Diagnosis
- Conversations API
Environment awareness
The same function code runs across environments.conv.api automatically uses:
- Sandbox base URL in Sandbox
- Pre-release base URL in Pre-release
- Live base URL in Live

