Types API¶
These public types are exported from nagents. Generation configuration belongs
on Agent.run(config=...) or Provider.generate(config=...). A field's presence
does not guarantee support by every provider, contract, or model.
nagents.GenerationConfig
dataclass
¶
Configuration for generation.
Source code in src/nagents/types.py
nagents.RetryConfig
dataclass
¶
Configuration for automatic retry on rate limit (429) and server error (5xx) responses.
Retry is enabled by default. Set max_retries=0 to disable.
When respect_retry_after is True (default), the Retry-After header from the server takes priority over exponential backoff for determining delay.
Exponential backoff formula: delay = min(base_delay * 2^attempt, max_delay) Default progression: 5s, 10s, 20s (capped at max_delay).
Source code in src/nagents/types.py
nagents.Message
dataclass
¶
A message in a conversation.
Content can be: - str: Plain text content - list[ContentPart]: Multimodal content (text, images, audio, documents) - None: For assistant messages with only tool calls
Source code in src/nagents/types.py
Content Parts¶
Use str for plain message content or a list of supported content parts.
Media support depends on the destination model and adapter; constructing a
content part alone does not establish support.
nagents.TextContent
dataclass
¶
nagents.ImageContent
dataclass
¶
Image content part.
Requires base64-encoded image data with media type.
Source code in src/nagents/types.py
nagents.AudioContent
dataclass
¶
Audio content part (OpenAI-specific for input).
Used for audio input in OpenAI's GPT-4o and similar models.
Source code in src/nagents/types.py
nagents.DocumentContent
dataclass
¶
Document/PDF content part (Anthropic-specific).
Used for PDF and document input in Claude models.
Source code in src/nagents/types.py
Tools and Schemas¶
nagents.ToolCall
dataclass
¶
A function/tool call requested by the model.
Source code in src/nagents/types.py
nagents.ToolDefinition
dataclass
¶
Definition of a tool/function the model can call.
Source code in src/nagents/types.py
nagents.JsonSchema
¶
nagents.JsonSchemaProperty
¶
Bases: TypedDict
JSON Schema property definition.