API Reference¶
Quick reference for the current public API.
For provider-level feature differences, see Provider Capabilities.
Which Entry Point?¶
| If you want to... | Use | Learn the workflow in... |
|---|---|---|
| Ask one prompt about one source (or no source) | run() → Output |
Sending Content to Models |
| Ask many prompts against shared sources | run_many() → OutputCollection |
Analyzing Collections with Source Patterns |
| Run one explicit interaction (environment + input), incl. tools/continuation | interact() |
Building an Agent Loop |
| Stream one explicit interaction as it arrives | stream() → Event timeline |
Building an Agent Loop |
| Prepare a reusable environment (and front-load cache/upload I/O) | prepare_environment() → Environment |
Reducing Costs with Context Caching |
| Submit non-urgent work and collect it later | defer() → DeferredHandle |
Building With Deferred Delivery |
| Check deferred job status or collect terminal results | inspect_deferred() / collect_deferred() / cancel_deferred() |
Submitting Work for Later Collection |
2.0 cutover:
run()/run_many()return theOutput/OutputCollectionmodel (named facets, not dict envelopes).continue_tool()is replaced byinteract(environment, Input(continuation=..., tool_results=...)); persistent caching moves toprepare_environment()/Environment(cache=...); anddefer()returns anOutputCollectionfromcollect_deferred()(the singledefer_many()entry point is removed).
Entry Points¶
The primary execution functions are exported from pollux:
Run a single prompt, optionally with sources for context.
The simple v2 facade: returns an :class:Output with named facets
(text, structured, reasoning, usage, metrics, …). For
stable environments, continuation, or tool loops, use :func:interact.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str | None
|
The prompt to run. |
None
|
source
|
Source | None
|
A single source for context (convenience for |
None
|
sources
|
Sequence[Source]
|
Stable sources for context. |
()
|
config
|
Config
|
Configuration specifying provider and model. |
required |
environment
|
Environment | None
|
Optional prepared :class: |
None
|
instructions
|
str | None
|
Optional system-level instruction. |
None
|
output
|
ResponseSchemaInput | None
|
Optional Pydantic model or JSON Schema for structured output. |
None
|
temperature
|
float | None
|
Optional sampling temperature. |
None
|
top_p
|
float | None
|
Optional nucleus-sampling probability. |
None
|
max_tokens
|
int | None
|
Optional hard cap on output tokens. |
None
|
seed
|
int | None
|
Optional sampling seed where supported. |
None
|
reasoning_effort
|
str | None
|
Optional qualitative reasoning effort. |
None
|
reasoning_budget_tokens
|
int | None
|
Optional explicit reasoning token budget. |
None
|
tool_choice
|
ToolChoice | None
|
Optional tool-choice control. |
None
|
tools
|
Sequence[ToolDeclaration] | None
|
Optional tool declarations. |
None
|
provider_options
|
dict[str, dict[str, Any]] | None
|
Optional raw provider-scoped generation options. |
None
|
Returns:
| Type | Description |
|---|---|
Output
|
The completed :class: |
Example
config = Config(provider="anthropic", model="claude-haiku-4-5") result = await run("Summarize.", source=Source.from_file("doc.pdf"), config=config) print(result.text)
Source code in src/pollux/__init__.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
Run multiple prompts with shared sources for source-pattern execution.
Returns an :class:OutputCollection whose outputs preserve input order;
.answers / .structured give ergonomic per-prompt lists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompts
|
str | Sequence[str | None] | None
|
One or more prompts to run. |
None
|
sources
|
Sequence[Source]
|
Stable sources shared across the prompts. |
()
|
config
|
Config
|
Configuration specifying provider and model. |
required |
environment
|
Environment | None
|
Optional prepared :class: |
None
|
instructions
|
str | None
|
Optional system-level instruction. |
None
|
output
|
ResponseSchemaInput | None
|
Optional Pydantic model or JSON Schema for structured output. |
None
|
temperature
|
float | None
|
Optional sampling temperature. |
None
|
top_p
|
float | None
|
Optional nucleus-sampling probability. |
None
|
max_tokens
|
int | None
|
Optional hard cap on output tokens. |
None
|
seed
|
int | None
|
Optional sampling seed where supported. |
None
|
reasoning_effort
|
str | None
|
Optional qualitative reasoning effort. |
None
|
reasoning_budget_tokens
|
int | None
|
Optional explicit reasoning token budget. |
None
|
tool_choice
|
ToolChoice | None
|
Optional tool-choice control. |
None
|
tools
|
Sequence[ToolDeclaration] | None
|
Optional tool declarations. |
None
|
provider_options
|
dict[str, dict[str, Any]] | None
|
Optional raw provider-scoped generation options. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
The |
OutputCollection
|
class: |
Example
config = Config(provider="anthropic", model="claude-haiku-4-5") results = await run_many( ["Question 1?", "Question 2?"], sources=[Source.from_text("Context...")], config=config, ) for answer in results.answers: print(answer)
Source code in src/pollux/__init__.py
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 | |
Run one explicit v2 interaction over an environment and input.
The v2 interaction facade: build an :class:Environment once (instructions,
sources, tools, cache preference), then send :class:Input turns. Returns an
:class:Output with named facets (text, structured, reasoning,
tool_calls, continuation, usage, metrics, diagnostics).
Continue by passing the prior output's continuation and any
tool_results in the next Input.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
environment
|
Environment
|
Reusable model-facing setup for the interaction. |
required |
input
|
Input
|
The per-turn payload (user content, continuation, tool results). |
required |
config
|
Config
|
Configuration specifying provider and model. |
required |
output
|
ResponseSchemaInput | None
|
Optional Pydantic model or JSON Schema for structured output. |
None
|
temperature
|
float | None
|
Optional sampling temperature. |
None
|
top_p
|
float | None
|
Optional nucleus-sampling probability. |
None
|
max_tokens
|
int | None
|
Optional hard cap on output tokens. |
None
|
seed
|
int | None
|
Optional sampling seed where supported. |
None
|
reasoning_effort
|
str | None
|
Optional qualitative reasoning effort. |
None
|
reasoning_budget_tokens
|
int | None
|
Optional explicit reasoning token budget. |
None
|
tool_choice
|
ToolChoice | None
|
Optional tool-choice control. |
None
|
provider_options
|
dict[str, dict[str, Any]] | None
|
Optional raw provider-scoped generation options. |
None
|
Returns:
| Type | Description |
|---|---|
Output
|
The completed :class: |
Example
environment = Environment(instructions=system_prompt, tools=tool_decls) result = await interact(environment, Input("Inspect the repo."), config=cfg) while result.tool_calls: results = [ToolResult(call_id=c.id, content=run_tool(c)) for c in result.tool_calls] result = await interact( environment, Input(continuation=result.continuation, tool_results=results), config=cfg, )
Source code in src/pollux/__init__.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | |
Stream one explicit v2 interaction as :class:Event objects.
The streaming sibling of :func:interact: same environment/input/config and
the same completed result, observed as a timeline. Iterate the events
(text_delta, reasoning_delta, tool_call_delta, tool_call,
usage, finish) and read the final assembled :class:Output from the
terminal done event, whose output matches what :func:interact would
return for the same interaction. Consumers never parse SSE or provider chunks.
A provider that does not support streaming raises ConfigurationError. A
mid-stream provider failure raises from the iterator rather than emitting a
done event, so a failed interaction never yields a final output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
environment
|
Environment
|
Reusable model-facing setup for the interaction. |
required |
input
|
Input
|
The per-turn payload (user content, continuation, tool results). |
required |
config
|
Config
|
Configuration specifying provider and model. |
required |
output
|
ResponseSchemaInput | None
|
Optional Pydantic model or JSON Schema for structured output. |
None
|
temperature
|
float | None
|
Optional sampling temperature. |
None
|
top_p
|
float | None
|
Optional nucleus-sampling probability. |
None
|
max_tokens
|
int | None
|
Optional hard cap on output tokens. |
None
|
seed
|
int | None
|
Optional sampling seed where supported. |
None
|
reasoning_effort
|
str | None
|
Optional qualitative reasoning effort. |
None
|
reasoning_budget_tokens
|
int | None
|
Optional explicit reasoning token budget. |
None
|
tool_choice
|
ToolChoice | None
|
Optional tool-choice control. |
None
|
provider_options
|
dict[str, dict[str, Any]] | None
|
Optional raw provider-scoped generation options. |
None
|
Yields:
| Name | Type | Description |
|---|---|---|
Each |
AsyncGenerator[Event, None]
|
class: |
Example
async for event in stream(environment, Input("Inspect the repo."), config=cfg): if event.type == "text_delta": print(event.text, end="") elif event.type == "done": result = event.output
Source code in src/pollux/__init__.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
Prepare a reusable :class:Environment, front-loading cache/upload I/O.
Build the stable model-facing setup once and reuse it across
:func:interact, :func:run, and :func:run_many calls. When cache is
a :class:CachePolicy, the persistent cache is created now (uploading
sources and surfacing capability errors early); later interactions over the
returned environment reuse it by identity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sources
|
Sequence[Source]
|
Stable sources to bake into the environment (and its cache). |
()
|
config
|
Config
|
Configuration specifying provider and model. |
required |
instructions
|
str | None
|
Optional system-level instruction. |
None
|
tools
|
Sequence[ToolDeclaration] | None
|
Optional tool declarations. |
None
|
cache
|
CacheSetting
|
Cache preference: a :class: |
None
|
metadata
|
dict[str, Any] | None
|
Optional provider-neutral metadata for planning. |
None
|
Returns:
| Type | Description |
|---|---|
Environment
|
The prepared :class: |
Example
environment = await prepare_environment( sources=[Source.from_file("paper.pdf")], instructions=system_prompt, cache=CachePolicy(ttl_seconds=3600), config=config, ) results = await run_many(prompts, environment=environment, config=config)
Source code in src/pollux/__init__.py
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 | |
Submit one or more deferred requests and return a serializable handle.
The v2 deferred frontdoor: submit a single interaction or a source-pattern
collection on a provider-side timeline, then :func:inspect_deferred and
:func:collect_deferred later. Collection returns an
:class:OutputCollection, the same shape as :func:run_many.
Tool calling, continuation, and persistent caching are out of scope for deferred delivery and are intentionally not part of this surface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompts
|
str | Sequence[str | None] | None
|
One or more prompts to submit. |
None
|
sources
|
Sequence[Source]
|
Stable sources shared across the prompts. |
()
|
config
|
Config
|
Configuration specifying provider and model. |
required |
instructions
|
str | None
|
Optional system-level instruction. |
None
|
output
|
ResponseSchemaInput | None
|
Optional Pydantic model or JSON Schema for structured output.
Pass the same schema to :func: |
None
|
temperature
|
float | None
|
Optional sampling temperature. |
None
|
top_p
|
float | None
|
Optional nucleus-sampling probability. |
None
|
max_tokens
|
int | None
|
Optional hard cap on output tokens. |
None
|
seed
|
int | None
|
Optional sampling seed where supported. |
None
|
reasoning_effort
|
str | None
|
Optional qualitative reasoning effort. |
None
|
reasoning_budget_tokens
|
int | None
|
Optional explicit reasoning token budget. |
None
|
provider_options
|
dict[str, dict[str, Any]] | None
|
Optional raw provider-scoped generation options. |
None
|
Returns:
| Type | Description |
|---|---|
DeferredHandle
|
A serializable :class: |
Source code in src/pollux/__init__.py
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 | |
Inspect the current state of a deferred job.
Source code in src/pollux/__init__.py
755 756 757 758 759 760 761 762 763 | |
Collect a terminal deferred job into an :class:OutputCollection.
Returns the same shape as :func:run_many: one :class:Output per
submitted request, in submission order. Each output's
diagnostics.raw["deferred"] carries the job id and per-item status.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
DeferredHandle
|
The deferred handle returned by :func: |
required |
response_schema
|
type[Any] | dict[str, Any] | None
|
Optional Pydantic model or JSON Schema for structured output rehydration. Must match the schema used at submission time. |
None
|
Source code in src/pollux/__init__.py
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 | |
Request provider-side cancellation for a deferred job.
Source code in src/pollux/__init__.py
793 794 795 796 797 798 799 800 801 | |
Core Types¶
Source includes both the generic source constructors and narrow
provider-specific helpers such as Source.with_gemini_video_settings(...) and
Source.with_gemini_url_context().
A structured representation of a single input source.
Source code in src/pollux/source.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
Functions¶
from_text
classmethod
¶
from_text(text, *, identifier=None)
Create a Source from text content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The text content. |
required |
identifier
|
str | None
|
Display label. Defaults to the first 50 characters of text. |
None
|
Source code in src/pollux/source.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
from_json
classmethod
¶
from_json(data, *, identifier=None)
Create a Source from a JSON-serializable object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any] | Any
|
A dictionary or object to serialize into a JSON string. If the object
has a |
required |
identifier
|
str | None
|
Display label. Defaults to "json-data". |
None
|
Source code in src/pollux/source.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
from_file
classmethod
¶
from_file(path, *, mime_type=None)
Create a Source from a local file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to the file. Must exist or |
required |
mime_type
|
str | None
|
MIME type override. Auto-detected from extension when None. |
None
|
Source code in src/pollux/source.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
from_youtube
classmethod
¶
from_youtube(url)
Create a Source from a YouTube URL reference (no download).
Source code in src/pollux/source.py
121 122 123 124 125 126 127 128 129 130 131 | |
from_uri
classmethod
¶
from_uri(uri, *, mime_type='application/octet-stream')
Create a Source from a URI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
Remote URI (e.g. |
required |
mime_type
|
str
|
MIME type. Defaults to |
'application/octet-stream'
|
Source code in src/pollux/source.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
from_arxiv
classmethod
¶
from_arxiv(ref)
Create an arXiv PDF Source from an arXiv ID or URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ref
|
str
|
An arXiv ID (e.g. |
required |
Source code in src/pollux/source.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
gemini_video_settings_for ¶
gemini_video_settings_for(provider)
Return Gemini video settings when the active provider can use them.
Source code in src/pollux/source.py
207 208 209 210 211 212 213 214 | |
provider_hints_for ¶
provider_hints_for(provider)
Return immutable provider hints as plain dictionaries for transport.
Source code in src/pollux/source.py
216 217 218 219 220 221 222 223 224 225 226 227 228 | |
cache_identity_hash ¶
cache_identity_hash(*, provider=None)
Compute SHA256 hash for cache identity.
Includes provider-visible source semantics such as Gemini video settings. Falls back to raw content hash when no provider-specific settings apply, preserving backward-compatible cache keys.
Source code in src/pollux/source.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
with_gemini_video_settings ¶
with_gemini_video_settings(
*, start_offset=None, end_offset=None, fps=None
)
Return a copy with validated Gemini video controls attached.
Pollux keeps this API provider-specific and stable even if Google's underlying wire fields evolve. The Gemini adapter maps these settings to the current SDK request shape. These settings only affect Gemini requests and Gemini explicit-cache identity.
Source code in src/pollux/source.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | |
with_gemini_url_context ¶
with_gemini_url_context()
Return a copy that asks Gemini to retrieve this HTTP(S) URI at request time.
Source code in src/pollux/source.py
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | |
Immutable configuration for Pollux execution.
Provider and model are required for cloud providers—Pollux does not guess
what you want. Local OpenAI-compatible servers may omit model when the
server has a single configured model or otherwise does not require it.
API keys are auto-resolved from standard environment variables.
Example
config = Config(provider="gemini", model="gemini-2.0-flash")
API key is automatically resolved from GEMINI_API_KEY¶
For self-hosted OpenAI-compatible servers, use provider="local" with
a base_url (or set POLLUX_LOCAL_BASE_URL). No API key is required.
Source code in src/pollux/config.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
Serializable Pollux handle for a deferred job.
Source code in src/pollux/deferred.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
Functions¶
to_dict ¶
to_dict()
Serialize the handle for persistence.
Source code in src/pollux/deferred.py
67 68 69 | |
from_dict
classmethod
¶
from_dict(data)
Rebuild a handle from serialized data.
Source code in src/pollux/deferred.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
Normalized snapshot of a deferred job lifecycle.
Source code in src/pollux/deferred.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
Bounded retry policy with exponential backoff and optional jitter.
Source code in src/pollux/retry.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
Interaction Types (2.0)¶
The canonical v2 interaction model. interact() takes an Environment and an
Input and returns an Output; OutputCollection is the source-pattern
aggregate that run_many() and collect_deferred() return. The 1.x Options
and ResultEnvelope types are no longer part of the public API.
The reusable, stable model-facing setup around interactions.
sources and tools accept any ordered sequence and are frozen to
tuples. Tool declarations must be :class:ToolDeclaration objects; build one
from a raw dict schema with :meth:ToolDeclaration.from_dict.
Source code in src/pollux/interaction/environment.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
Functions¶
fingerprint ¶
fingerprint(*, provider)
Return stable identity for the provider-visible environment.
The fingerprint covers instructions, ordered sources, ordered tools,
and the active provider. Model identity belongs to :class:Config and
must be composed separately by durable runtimes. Cache preferences and
metadata are deliberately excluded because they do not change the
model-visible environment.
Fingerprints remain stable across compatible Pollux releases. A future semantic change will increment the embedded fingerprint version.
Source code in src/pollux/interaction/environment.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
One model turn: user content plus optional prior state and tool results.
history and tool_results accept any ordered sequence and are frozen
to tuples.
Source code in src/pollux/interaction/input.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
The completed result of one model interaction, as named facets.
Source code in src/pollux/interaction/output.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
Functions¶
to_jsonable ¶
to_jsonable()
Serialize to a JSON-compatible dict (optional facets omitted).
Source code in src/pollux/interaction/output.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
One event in the timeline of a streamed interaction.
Only the facet relevant to type is set: text for text_delta /
reasoning_delta, delta for tool_call_delta, tool_call for
tool_call, usage for usage, finish_reason for finish, and
output for done.
Source code in src/pollux/interaction/event.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
Aggregate result for a multi-call source pattern.
Source code in src/pollux/interaction/collection.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
Attributes¶
Functions¶
to_jsonable ¶
to_jsonable()
Serialize to a JSON-compatible dict with per-output detail and aggregates.
Source code in src/pollux/interaction/collection.py
82 83 84 85 86 87 88 89 90 91 92 93 | |
Per-interaction controls for the response Pollux asks the model to produce.
Source code in src/pollux/interaction/requirements.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
Functions¶
output_schema_json ¶
output_schema_json()
Return JSON Schema for provider APIs.
Source code in src/pollux/interaction/requirements.py
95 96 97 | |
output_schema_model ¶
output_schema_model()
Return the Pydantic model class when one was provided.
Source code in src/pollux/interaction/requirements.py
99 100 101 | |
output_schema_hash ¶
output_schema_hash()
Return a stable hash of the JSON Schema.
Source code in src/pollux/interaction/requirements.py
103 104 105 | |
provider_options_for ¶
provider_options_for(provider)
Return raw generation options for the active provider.
Source code in src/pollux/interaction/requirements.py
107 108 109 110 111 112 | |
Opaque, serializable state for provider-correct replay.
Applications receive this value from :attr:Output.continuation, persist it
through :meth:to_jsonable / :meth:from_jsonable, and pass it back through
Input(continuation=...). Replay fields are intentionally not public.
Source code in src/pollux/interaction/continuation.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | |
Functions¶
to_jsonable ¶
to_jsonable()
Return a defensive JSON-compatible serialization of this handle.
Source code in src/pollux/interaction/continuation.py
254 255 256 257 258 259 260 261 262 263 264 265 266 | |
from_jsonable
classmethod
¶
from_jsonable(data, *, expected_provider=None)
Restore a versioned artifact and optionally verify its provider.
Source code in src/pollux/interaction/continuation.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | |
A portable, application-authored text or tool transcript message.
Source code in src/pollux/interaction/continuation.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
Functions¶
to_jsonable ¶
to_jsonable()
Serialize this portable transcript message.
Source code in src/pollux/interaction/continuation.py
86 87 88 89 90 91 92 93 | |
from_jsonable
classmethod
¶
from_jsonable(data)
Parse and validate a portable transcript message.
Source code in src/pollux/interaction/continuation.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
from_openai
classmethod
¶
from_openai(data)
Build a portable message from one OpenAI Chat Completions message.
System messages are intentionally rejected: stable system context belongs
on :attr:Environment.instructions, not in portable turn history.
Source code in src/pollux/interaction/continuation.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
to_openai ¶
to_openai()
Serialize as one OpenAI Chat Completions transcript message.
Source code in src/pollux/interaction/continuation.py
159 160 161 162 163 164 165 166 | |
A provider-neutral description of a tool the model may request.
Source code in src/pollux/interaction/tools.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
Functions¶
from_dict
classmethod
¶
from_dict(data)
Build a declaration from a flat or OpenAI-style function dict.
Source code in src/pollux/interaction/tools.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
A normalized tool request emitted by the model.
arguments_text is the exact raw provider argument string (after any
stream fragments are assembled). arguments is the parsed JSON; when the
text is not valid JSON it is None and arguments_error explains why.
This preserves both convenience and recoverability.
Source code in src/pollux/interaction/tools.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
Functions¶
from_text
classmethod
¶
from_text(
*,
id,
name,
arguments_text="",
index=None,
provider_state=None,
)
Build a call from raw provider fields, parsing arguments once.
Source code in src/pollux/interaction/tools.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
from_openai
classmethod
¶
from_openai(data)
Build a tool call from an OpenAI Chat Completions tool_calls item.
Source code in src/pollux/interaction/tools.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
arguments_dict ¶
arguments_dict()
Return parsed JSON-object arguments or raise an explicit config error.
Agent loops usually dispatch tools from object-shaped JSON arguments. This helper keeps that path strict: malformed JSON and non-object JSON are rejected instead of being silently treated as an empty dict.
Source code in src/pollux/interaction/tools.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
to_jsonable ¶
to_jsonable()
Serialize to a compact JSON-compatible dict (optional facets omitted).
Source code in src/pollux/interaction/tools.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
to_openai ¶
to_openai()
Serialize as an OpenAI Chat Completions tool_calls item.
Source code in src/pollux/interaction/tools.py
170 171 172 173 174 175 176 177 178 179 180 181 182 | |
Application-produced output returned to the model for a prior tool call.
Source code in src/pollux/interaction/tools.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
Functions¶
from_value
classmethod
¶
from_value(*, call_id, value, is_error=False)
Build a tool result from a JSON value, serializing non-strings.
Strings are preserved as-is. Other JSON values are encoded compactly so
agent loops can return structured tool output without repeating
json.dumps at every dispatch site.
Source code in src/pollux/interaction/tools.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
to_jsonable ¶
to_jsonable()
Serialize to a JSON-compatible dict.
Source code in src/pollux/interaction/tools.py
236 237 238 239 240 241 | |
Error Types¶
Bases: Exception
Base exception for all Pollux errors.
Source code in src/pollux/errors.py
11 12 13 14 15 16 | |
Bases: PolluxError
Configuration validation or resolution failed.
Source code in src/pollux/errors.py
19 20 | |
Bases: PolluxError
Source validation or loading failed.
Source code in src/pollux/errors.py
23 24 | |
Bases: PolluxError
Execution planning failed.
Source code in src/pollux/errors.py
27 28 | |
Bases: PolluxError
A Pollux internal error (bug) or invariant violation.
Source code in src/pollux/errors.py
31 32 | |
Bases: PolluxError
API call failed.
Providers attach retry metadata so core execution can perform bounded retries without brittle substring matching.
Source code in src/pollux/errors.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
Bases: APIError
Rate limit exceeded (HTTP 429).
Source code in src/pollux/errors.py
128 129 | |
Bases: APIError
Cache operation failed.
Source code in src/pollux/errors.py
124 125 | |
Bases: PolluxError
Deferred job is not yet in a terminal state.
Source code in src/pollux/errors.py
132 133 134 135 136 137 138 139 140 | |