archastro.platform.v1.resources.ai

  1# Copyright (c) 2026 ArchAstro Inc. All Rights Reserved.
  2# This file is auto-generated by @archastro/sdk-generator. Do not edit.
  3# Content hash: 7fb31d670565
  4
  5from __future__ import annotations
  6
  7from collections.abc import AsyncIterator, Iterator
  8from typing import Any, Literal, Required, TypedDict
  9
 10from pydantic import BaseModel, Field
 11
 12from ...runtime.http_client import HttpClient, SyncHttpClient
 13from ...types.ai import (
 14    AIChatStreamDone,
 15    AIChatStreamError,
 16    AIChatStreamMessageComplete,
 17    AIChatStreamMessageDelta,
 18    AIChatStreamToolCallDelta,
 19    AIChatStreamToolResult,
 20    AICompletionResult,
 21    AIImageResult,
 22)
 23
 24
 25class CompletionCreateInputMessagesItemToolCallsItem(TypedDict, total=False):
 26    arguments: Required[dict[str, Any]]
 27    "Arguments the model wants to pass to the tool, as a key-value map. Deserialize and validate these against the tool's input schema before executing."
 28    id: Required[str]
 29    "Unique identifier for this tool call, assigned by the model. Use this value as `id` when submitting the corresponding tool result."
 30    name: Required[str]
 31    'Name of the tool or function the model wants to invoke, e.g. `"web_search"` or `"run_code"`.'
 32    thought_signature: str | None
 33    "Opaque signature representing the model's internal reasoning that led to this tool call. `null` when the provider does not expose chain-of-thought data."
 34
 35
 36class CompletionCreateInputMessagesItemToolResultsItem(TypedDict, total=False):
 37    content: str | None
 38    "Plain-text output produced by the tool execution. `null` when the result is expressed entirely through `resolution`."
 39    id: Required[str]
 40    "ID of the tool call this result satisfies. Must match the `id` from the corresponding `AIToolCall`."
 41    name: Required[str]
 42    'Name of the tool or function that was executed, e.g. `"web_search"`. Must match the `name` from the corresponding `AIToolCall`.'
 43    resolution: Any | None
 44    "Structured result data from the tool execution. Shape varies by tool. `null` when the result is expressed as plain text in `content`."
 45
 46
 47class CompletionCreateInputMessagesItem(TypedDict, total=False):
 48    content: str | None
 49    "Plain-text content of the message. Present for `system`, `user`, and `assistant` messages. `null` when the message body is expressed through `content_parts` or `tool_calls`."
 50    content_parts: list[dict[str, Any]] | None
 51    'Multimodal content parts for the message, used when the body includes images or mixed media. Each part is a map with a `type` key (`"text"`, `"image_url"`, or `"image_data"`). `null` when `content` is set.'
 52    resume_token: str | None
 53    "Opaque token that can be passed on a subsequent request to resume this conversation from the current state. `null` when the provider does not support conversation resumption."
 54    role: Required[str]
 55    'The speaker role for this message. One of `"system"`, `"user"`, `"assistant"`, or `"tool"`.'
 56    structured_output: Any | None
 57    "Parsed structured data returned by the model when a JSON schema or structured-output mode was requested. Shape varies by the schema supplied at call time. `null` when structured output was not requested."
 58    tool_calls: list[CompletionCreateInputMessagesItemToolCallsItem] | None
 59    "Tool calls requested by the model in an `assistant` message. Present only on assistant messages that invoke one or more tools. `null` on all other message roles."
 60    tool_results: list[CompletionCreateInputMessagesItemToolResultsItem] | None
 61    "Tool execution results provided in a `tool` message. Each entry corresponds to a prior tool call by its `id`. `null` on all other message roles."
 62
 63
 64class CompletionCreateInputOptsToolsItemFunction(TypedDict, total=False):
 65    description: str | None
 66    "Human-readable description of what the function does. The model uses this to decide when to call the function. `null` if not provided."
 67    name: Required[str]
 68    'Unique name of the function that the model can invoke, e.g. `"get_weather"`.'
 69    parameters: Required[dict[str, Any]]
 70    'JSON Schema object describing the function\'s accepted parameters. Must be a valid JSON Schema of type `"object"`.'
 71
 72
 73class CompletionCreateInputOptsToolsItem(TypedDict):
 74    function: CompletionCreateInputOptsToolsItemFunction
 75    "Callable function this tool exposes, including its name, description, and parameter schema."
 76    type: str
 77    'The tool type. Currently always `"function"`.'
 78
 79
 80class CompletionCreateInputOpts(TypedDict, total=False):
 81    max_tokens: int | None
 82    "Maximum number of tokens the model may generate in the completion. Omit to use the model's default limit."
 83    model: Required[str]
 84    'Model identifier to use for the completion, e.g. `"gpt-4o"` or `"claude-3-7-sonnet-latest"`.'
 85    server_tools: list[dict[str, Any]] | None
 86    'Server-managed tool declarations executed before the response is returned. Each entry must include a `type` key; currently only `"search"` is supported.'
 87    temperature: float | None
 88    "Sampling temperature between `0.0` and `2.0`. Higher values produce more random output. Omit to use the model's default."
 89    tool_choice: str | None
 90    'Controls how the model selects tools. One of `"auto"`, `"required"`, or `"none"`. Omit to let the model decide.'
 91    tools: list[CompletionCreateInputOptsToolsItem] | None
 92    "OpenAI-compatible tool definitions available to the model. Omit when not using function calling."
 93
 94
 95class CompletionCreateInput(TypedDict, total=False):
 96    "Create a chat completion"
 97
 98    context: dict[str, Any] | None
 99    "Key-value map used to resolve template variables in message content. Omit if messages contain no templates."
100    messages: Required[list[CompletionCreateInputMessagesItem]]
101    "Ordered list of conversation messages to send to the model."
102    opts: Required[CompletionCreateInputOpts]
103    "Model and sampling configuration for this request."
104
105
106class CompletionStreamInputMessagesItemToolCallsItem(TypedDict, total=False):
107    arguments: Required[dict[str, Any]]
108    "Arguments the model wants to pass to the tool, as a key-value map. Deserialize and validate these against the tool's input schema before executing."
109    id: Required[str]
110    "Unique identifier for this tool call, assigned by the model. Use this value as `id` when submitting the corresponding tool result."
111    name: Required[str]
112    'Name of the tool or function the model wants to invoke, e.g. `"web_search"` or `"run_code"`.'
113    thought_signature: str | None
114    "Opaque signature representing the model's internal reasoning that led to this tool call. `null` when the provider does not expose chain-of-thought data."
115
116
117class CompletionStreamInputMessagesItemToolResultsItem(TypedDict, total=False):
118    content: str | None
119    "Plain-text output produced by the tool execution. `null` when the result is expressed entirely through `resolution`."
120    id: Required[str]
121    "ID of the tool call this result satisfies. Must match the `id` from the corresponding `AIToolCall`."
122    name: Required[str]
123    'Name of the tool or function that was executed, e.g. `"web_search"`. Must match the `name` from the corresponding `AIToolCall`.'
124    resolution: Any | None
125    "Structured result data from the tool execution. Shape varies by tool. `null` when the result is expressed as plain text in `content`."
126
127
128class CompletionStreamInputMessagesItem(TypedDict, total=False):
129    content: str | None
130    "Plain-text content of the message. Present for `system`, `user`, and `assistant` messages. `null` when the message body is expressed through `content_parts` or `tool_calls`."
131    content_parts: list[dict[str, Any]] | None
132    'Multimodal content parts for the message, used when the body includes images or mixed media. Each part is a map with a `type` key (`"text"`, `"image_url"`, or `"image_data"`). `null` when `content` is set.'
133    resume_token: str | None
134    "Opaque token that can be passed on a subsequent request to resume this conversation from the current state. `null` when the provider does not support conversation resumption."
135    role: Required[str]
136    'The speaker role for this message. One of `"system"`, `"user"`, `"assistant"`, or `"tool"`.'
137    structured_output: Any | None
138    "Parsed structured data returned by the model when a JSON schema or structured-output mode was requested. Shape varies by the schema supplied at call time. `null` when structured output was not requested."
139    tool_calls: list[CompletionStreamInputMessagesItemToolCallsItem] | None
140    "Tool calls requested by the model in an `assistant` message. Present only on assistant messages that invoke one or more tools. `null` on all other message roles."
141    tool_results: list[CompletionStreamInputMessagesItemToolResultsItem] | None
142    "Tool execution results provided in a `tool` message. Each entry corresponds to a prior tool call by its `id`. `null` on all other message roles."
143
144
145class CompletionStreamInputOptsToolsItemFunction(TypedDict, total=False):
146    description: str | None
147    "Human-readable description of what the function does. The model uses this to decide when to call the function. `null` if not provided."
148    name: Required[str]
149    'Unique name of the function that the model can invoke, e.g. `"get_weather"`.'
150    parameters: Required[dict[str, Any]]
151    'JSON Schema object describing the function\'s accepted parameters. Must be a valid JSON Schema of type `"object"`.'
152
153
154class CompletionStreamInputOptsToolsItem(TypedDict):
155    function: CompletionStreamInputOptsToolsItemFunction
156    "Callable function this tool exposes, including its name, description, and parameter schema."
157    type: str
158    'The tool type. Currently always `"function"`.'
159
160
161class CompletionStreamInputOpts(TypedDict, total=False):
162    max_tokens: int | None
163    "Maximum number of tokens the model may generate. Omit for the model default."
164    model: Required[str]
165    'Model identifier, e.g. `"gpt-4o"` or `"claude-3-7-sonnet-latest"`.'
166    server_tools: list[dict[str, Any]] | None
167    'Server-managed tool declarations executed before the response. Each entry must include a `type` key; currently only `"search"` is supported.'
168    temperature: float | None
169    "Sampling temperature between `0.0` and `2.0`. Higher values produce more random output. Omit for the model default."
170    tool_choice: str | None
171    'Controls tool selection. One of `"auto"`, `"required"`, or `"none"`. Omit to let the model decide.'
172    tools: list[CompletionStreamInputOptsToolsItem] | None
173    "OpenAI-compatible tool definitions available to the model. Omit when not using function calling."
174
175
176class CompletionStreamInput(TypedDict, total=False):
177    "Stream a chat completion"
178
179    context: dict[str, Any] | None
180    "Key-value map used to resolve template variables in message content. Omit if messages contain no templates."
181    messages: Required[list[CompletionStreamInputMessagesItem]]
182    "Ordered list of conversation messages to send to the model."
183    opts: Required[CompletionStreamInputOpts]
184    "Model and sampling configuration for this request."
185
186
187class ImageEditsInputImagesItem(TypedDict):
188    image_data: str
189    "The raw image content encoded as a base64 string (standard encoding, no line breaks)."
190    image_type: str
191    'MIME type of the image, e.g. `"image/png"` or `"image/jpeg"`. Must match the actual encoding of `image_data`.'
192
193
194class ImageEditsInput(TypedDict, total=False):
195    "Edit an image with a text prompt"
196
197    aspect_ratio: str | None
198    'Desired aspect ratio of the output, e.g. `"1:1"` or `"16:9"`. Not supported by all models; omit to use the model\'s default.'
199    background: str | None
200    "Background treatment for the output. Accepted values and behavior are model-dependent."
201    height: int | None
202    "Explicit output height in pixels. Takes precedence over `size` when both are provided. Not supported by all models."
203    image_size: str | None
204    'Output resolution tier for Gemini models, e.g. `"1K"`, `"2K"`, or `"4K"`. Ignored by non-Gemini models.'
205    images: Required[list[ImageEditsInputImagesItem]]
206    "One or more source images to edit. Each image must be supplied as a base64-encoded object."
207    model: str | None
208    "Model identifier to use for editing. Omit to use the platform default image model."
209    output_format: str | None
210    'Desired MIME type or format for the returned image. Common values: `"png"`, `"jpeg"`, `"webp"`. Defaults to the model\'s native format.'
211    prompt: Required[str]
212    "Natural-language description of the edit to apply to the source image(s)."
213    quality: str | None
214    "Quality preset for the output image. Accepted values and behavior are model-dependent."
215    size: str | None
216    'Output dimensions as a WxH string, e.g. `"1024x1024"`. Applies to OpenAI-compatible models. Omit to use the model\'s default.'
217    style: str | None
218    "Style preset applied to the edit. Accepted values and behavior are model-dependent."
219    width: int | None
220    "Explicit output width in pixels. Takes precedence over `size` when both are provided. Not supported by all models."
221
222
223class ImageGenerationsInput(TypedDict, total=False):
224    "Generate an image from a text prompt"
225
226    aspect_ratio: str | None
227    'Desired aspect ratio of the output, e.g. `"1:1"` or `"16:9"`. Not supported by all models; omit to use the model\'s default.'
228    background: str | None
229    "Background treatment for the output. Accepted values and behavior are model-dependent."
230    height: int | None
231    "Explicit output height in pixels. Takes precedence over `size` when both are provided. Not supported by all models."
232    image_size: str | None
233    'Output resolution tier for Gemini models, e.g. `"1K"`, `"2K"`, or `"4K"`. Ignored by non-Gemini models.'
234    model: str | None
235    "Model identifier to use for generation. Omit to use the platform default image model."
236    n: int | None
237    "Number of images to generate. Defaults to `1`. Values greater than `1` are only supported by models that allow batch generation."
238    output_format: str | None
239    'Desired MIME type or format for the returned image. Common values: `"png"`, `"jpeg"`, `"webp"`. Defaults to the model\'s native format.'
240    prompt: Required[str]
241    "Natural-language description of the image to generate."
242    quality: str | None
243    "Quality preset for the output image. Accepted values and behavior are model-dependent."
244    size: str | None
245    'Output dimensions as a WxH string, e.g. `"1024x1024"`. Applies to OpenAI-compatible models. Omit to use the model\'s default.'
246    style: str | None
247    "Style preset applied to the generated image. Accepted values and behavior are model-dependent."
248    width: int | None
249    "Explicit output width in pixels. Takes precedence over `size` when both are provided. Not supported by all models."
250
251
252class ChatModelsResponseDataItem(BaseModel):
253    capabilities: list[Literal["image", "search", "thinking"]] = Field(
254        ...,
255        description='Machine-readable model capabilities. `"image"` marks image-input chat, `"search"` marks built-in web search, and `"thinking"` marks models with configurable reasoning. Empty when the catalog entry declares no special capabilities.',
256    )
257    default: bool = Field(
258        ...,
259        description="`true` for the model the platform selects when an agent has no `default_model` configured, or for the system-wide fallback in image-generation contexts. Exactly one entry in any given model list carries this flag.",
260    )
261    id: str = Field(
262        ...,
263        description='Provider-assigned model identifier used when specifying a model on API requests, e.g. `"claude-sonnet-4-6"` or `"gemini-2.5-flash"`.',
264    )
265    input_media_formats: list[str] = Field(
266        ...,
267        description='MIME types accepted in chat `content_parts` image/file inputs for this model. For image-capable chat models this includes values such as `"image/png"`. Empty for text-only models.',
268    )
269    name: str = Field(
270        ...,
271        description='Human-readable display label for this model, e.g. `"Claude Sonnet 4.6"` or `"Gemini 3.5 Flash (thinking)"`. Render this value directly in pickers rather than attempting to parse or transform `id`. Falls back to the `id` string when the catalog entry does not declare an explicit name.',
272    )
273    output_media_formats: list[str] = Field(
274        ...,
275        description="MIME types this model can emit as media in chat responses. Empty for text-output models, including image-understanding models that only return text.",
276    )
277
278
279class ChatModelsResponse(BaseModel):
280    """
281    Successful response
282    """
283
284    data: list[ChatModelsResponseDataItem] = Field(
285        ..., description="Array of available model objects. At least one entry is always present."
286    )
287
288
289class ImageModelsResponseDataItem(BaseModel):
290    capabilities: list[Literal["image", "search", "thinking"]] = Field(
291        ...,
292        description='Machine-readable model capabilities. `"image"` marks image-input chat, `"search"` marks built-in web search, and `"thinking"` marks models with configurable reasoning. Empty when the catalog entry declares no special capabilities.',
293    )
294    default: bool = Field(
295        ...,
296        description="`true` for the model the platform selects when an agent has no `default_model` configured, or for the system-wide fallback in image-generation contexts. Exactly one entry in any given model list carries this flag.",
297    )
298    id: str = Field(
299        ...,
300        description='Provider-assigned model identifier used when specifying a model on API requests, e.g. `"claude-sonnet-4-6"` or `"gemini-2.5-flash"`.',
301    )
302    input_media_formats: list[str] = Field(
303        ...,
304        description='MIME types accepted in chat `content_parts` image/file inputs for this model. For image-capable chat models this includes values such as `"image/png"`. Empty for text-only models.',
305    )
306    name: str = Field(
307        ...,
308        description='Human-readable display label for this model, e.g. `"Claude Sonnet 4.6"` or `"Gemini 3.5 Flash (thinking)"`. Render this value directly in pickers rather than attempting to parse or transform `id`. Falls back to the `id` string when the catalog entry does not declare an explicit name.',
309    )
310    output_media_formats: list[str] = Field(
311        ...,
312        description="MIME types this model can emit as media in chat responses. Empty for text-output models, including image-understanding models that only return text.",
313    )
314
315
316class ImageModelsResponse(BaseModel):
317    """
318    Successful response
319    """
320
321    data: list[ImageModelsResponseDataItem] = Field(
322        ...,
323        description="Array of available image generation models, including their identifiers, human-readable names, and which one is the platform default.",
324    )
325
326
327class CompletionStreamEventDone(TypedDict):
328    event: Literal["done"]
329    data: AIChatStreamDone
330
331
332class CompletionStreamEventError(TypedDict):
333    event: Literal["error"]
334    data: AIChatStreamError
335
336
337class CompletionStreamEventMessageComplete(TypedDict):
338    event: Literal["message_complete"]
339    data: AIChatStreamMessageComplete
340
341
342class CompletionStreamEventMessageDelta(TypedDict):
343    event: Literal["message_delta"]
344    data: AIChatStreamMessageDelta
345
346
347class CompletionStreamEventToolCallDelta(TypedDict):
348    event: Literal["tool_call_delta"]
349    data: AIChatStreamToolCallDelta
350
351
352class CompletionStreamEventToolResult(TypedDict):
353    event: Literal["tool_result"]
354    data: AIChatStreamToolResult
355
356
357CompletionStreamEvent = (
358    CompletionStreamEventDone
359    | CompletionStreamEventError
360    | CompletionStreamEventMessageComplete
361    | CompletionStreamEventMessageDelta
362    | CompletionStreamEventToolCallDelta
363    | CompletionStreamEventToolResult
364)
365
366
367class AsyncCompletionResource:
368    def __init__(self, http: HttpClient):
369        self._http = http
370
371    async def create(self, input: CompletionCreateInput) -> AICompletionResult:
372        """
373        Create a chat completion
374        Sends a list of messages to the configured AI provider and returns a single
375        completion. Use this endpoint when you want direct, low-level access to the
376        underlying model without any workflow or agent orchestration.
377        The authenticated app must have the `llm_calls` entitlement enabled on its
378        plan. Requests that exceed the plan quota are rejected with `402`. Token
379        usage is recorded against the authenticated app and organization.
380        Supply `tools` and `tool_choice` to enable OpenAI-compatible function
381        calling. Use `server_tools` to activate platform-managed tools such as
382        search that run on the server side before the response is returned.
383
384        Args:
385            input: Request body.
386            input.context: Key-value map used to resolve template variables in message content. Omit if messages contain no templates.
387            input.messages: Ordered list of conversation messages to send to the model.
388            input.opts: Model and sampling configuration for this request.
389
390        Returns:
391            The completed AI response, including the generated message, finish reason, and token usage.
392        """
393        return await self._http.request(
394            "/api/v1/ai/chat/completions",
395            method="POST",
396            body=input,
397            response_type=AICompletionResult,
398        )
399
400    async def stream(self, input: CompletionStreamInput) -> AsyncIterator[CompletionStreamEvent]:
401        """
402        Stream a chat completion
403        Streams a chat completion over Server-Sent Events. Emits `message_delta`,
404        `message_complete`, `tool_call_*`, `tool_result`, and a terminal `done` (or
405        `error`) event. Same request shape as the non-streaming completion endpoint;
406        the app must have the `llm_calls` entitlement.
407
408        Args:
409            input: Request body.
410            input.context: Key-value map used to resolve template variables in message content. Omit if messages contain no templates.
411            input.messages: Ordered list of conversation messages to send to the model.
412            input.opts: Model and sampling configuration for this request.
413
414        Returns:
415            Server-Sent Events stream
416        """
417        async for event in self._http.stream_sse(
418            "/api/v1/ai/chat/completions/stream", method="POST", body=input
419        ):
420            yield event
421
422
423class AsyncChatResource:
424    def __init__(self, http: HttpClient):
425        self._http = http
426        self.completions = AsyncCompletionResource(http)
427
428    async def models(self) -> ChatModelsResponse:
429        """
430        List available AI models
431        Returns the set of AI models that can be used with the chat completion and
432        workflow endpoints. The list reflects models currently enabled for the
433        platform and includes each model's identifier and whether it is the default.
434        Use the `model` field from any entry in `data` as the value for
435        `opts.model` when calling the completions or workflows endpoint.
436
437        Returns:
438            Successful response
439        """
440        return await self._http.request("/api/v1/ai/chat/models", response_type=ChatModelsResponse)
441
442
443class AsyncImageResource:
444    def __init__(self, http: HttpClient):
445        self._http = http
446
447    async def edits(self, input: ImageEditsInput) -> AIImageResult:
448        """
449        Edit an image with a text prompt
450        Applies a text-guided edit to one or more source images and returns the
451        resulting image. Pass the source images as base64-encoded objects in the
452        `images` array alongside a `prompt` describing the desired modification.
453        The underlying provider is selected by the `model` parameter. Omit `model`
454        to use the platform default. Size, quality, style, and format options are
455        forwarded to the provider as-is; unsupported combinations for a given model
456        return a 422 error with the provider's error message.
457        This endpoint requires authentication. The request is billed against the
458        workspace associated with the authenticated user.
459
460        Args:
461            input: Request body.
462            input.aspect_ratio: Desired aspect ratio of the output, e.g. `"1:1"` or `"16:9"`. Not supported by all models; omit to use the model's default.
463            input.background: Background treatment for the output. Accepted values and behavior are model-dependent.
464            input.height: Explicit output height in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
465            input.image_size: Output resolution tier for Gemini models, e.g. `"1K"`, `"2K"`, or `"4K"`. Ignored by non-Gemini models.
466            input.images: One or more source images to edit. Each image must be supplied as a base64-encoded object.
467            input.model: Model identifier to use for editing. Omit to use the platform default image model.
468            input.output_format: Desired MIME type or format for the returned image. Common values: `"png"`, `"jpeg"`, `"webp"`. Defaults to the model's native format.
469            input.prompt: Natural-language description of the edit to apply to the source image(s).
470            input.quality: Quality preset for the output image. Accepted values and behavior are model-dependent.
471            input.size: Output dimensions as a WxH string, e.g. `"1024x1024"`. Applies to OpenAI-compatible models. Omit to use the model's default.
472            input.style: Style preset applied to the edit. Accepted values and behavior are model-dependent.
473            input.width: Explicit output width in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
474
475        Returns:
476            The resulting edited image, including base64 data or a URL depending on the model.
477        """
478        return await self._http.request(
479            "/api/v1/ai/image/edits",
480            method="POST",
481            body=input,
482            response_type=AIImageResult,
483        )
484
485    async def generations(self, input: ImageGenerationsInput) -> AIImageResult:
486        """
487        Generate an image from a text prompt
488        Generates one or more images from a natural-language `prompt` using the
489        specified AI image model. The response contains the first generated image;
490        use `n` to request additional images (where supported by the model).
491        The underlying provider is selected by the `model` parameter. Omit `model`
492        to use the platform default. Size, quality, style, and format options are
493        forwarded to the provider as-is; unsupported combinations for a given model
494        return a 422 error with the provider's error message.
495        This endpoint requires authentication. The request is billed against the
496        workspace associated with the authenticated user.
497
498        Args:
499            input: Request body.
500            input.aspect_ratio: Desired aspect ratio of the output, e.g. `"1:1"` or `"16:9"`. Not supported by all models; omit to use the model's default.
501            input.background: Background treatment for the output. Accepted values and behavior are model-dependent.
502            input.height: Explicit output height in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
503            input.image_size: Output resolution tier for Gemini models, e.g. `"1K"`, `"2K"`, or `"4K"`. Ignored by non-Gemini models.
504            input.model: Model identifier to use for generation. Omit to use the platform default image model.
505            input.n: Number of images to generate. Defaults to `1`. Values greater than `1` are only supported by models that allow batch generation.
506            input.output_format: Desired MIME type or format for the returned image. Common values: `"png"`, `"jpeg"`, `"webp"`. Defaults to the model's native format.
507            input.prompt: Natural-language description of the image to generate.
508            input.quality: Quality preset for the output image. Accepted values and behavior are model-dependent.
509            input.size: Output dimensions as a WxH string, e.g. `"1024x1024"`. Applies to OpenAI-compatible models. Omit to use the model's default.
510            input.style: Style preset applied to the generated image. Accepted values and behavior are model-dependent.
511            input.width: Explicit output width in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
512
513        Returns:
514            The generated image, including base64 data or a URL depending on the model.
515        """
516        return await self._http.request(
517            "/api/v1/ai/image/generations",
518            method="POST",
519            body=input,
520            response_type=AIImageResult,
521        )
522
523    async def models(self) -> ImageModelsResponse:
524        """
525        List available image generation models
526        Returns the list of image generation models available on the platform.
527        Exactly one entry in the list carries `default: true`, indicating the model
528        used when no `model` parameter is supplied to the generation or editing
529        endpoints.
530        This endpoint requires authentication and reflects the models enabled for
531        the authenticated user's workspace.
532
533        Returns:
534            Successful response
535        """
536        return await self._http.request(
537            "/api/v1/ai/image/models",
538            response_type=ImageModelsResponse,
539        )
540
541
542class AsyncAiResource:
543    def __init__(self, http: HttpClient):
544        self._http = http
545        self.chat = AsyncChatResource(http)
546        self.image = AsyncImageResource(http)
547
548
549class CompletionResource:
550    def __init__(self, http: SyncHttpClient):
551        self._http = http
552
553    def create(self, input: CompletionCreateInput) -> AICompletionResult:
554        """
555        Create a chat completion
556        Sends a list of messages to the configured AI provider and returns a single
557        completion. Use this endpoint when you want direct, low-level access to the
558        underlying model without any workflow or agent orchestration.
559        The authenticated app must have the `llm_calls` entitlement enabled on its
560        plan. Requests that exceed the plan quota are rejected with `402`. Token
561        usage is recorded against the authenticated app and organization.
562        Supply `tools` and `tool_choice` to enable OpenAI-compatible function
563        calling. Use `server_tools` to activate platform-managed tools such as
564        search that run on the server side before the response is returned.
565
566        Args:
567            input: Request body.
568            input.context: Key-value map used to resolve template variables in message content. Omit if messages contain no templates.
569            input.messages: Ordered list of conversation messages to send to the model.
570            input.opts: Model and sampling configuration for this request.
571
572        Returns:
573            The completed AI response, including the generated message, finish reason, and token usage.
574        """
575        return self._http.request(
576            "/api/v1/ai/chat/completions",
577            method="POST",
578            body=input,
579            response_type=AICompletionResult,
580        )
581
582    def stream(self, input: CompletionStreamInput) -> Iterator[CompletionStreamEvent]:
583        """
584        Stream a chat completion
585        Streams a chat completion over Server-Sent Events. Emits `message_delta`,
586        `message_complete`, `tool_call_*`, `tool_result`, and a terminal `done` (or
587        `error`) event. Same request shape as the non-streaming completion endpoint;
588        the app must have the `llm_calls` entitlement.
589
590        Args:
591            input: Request body.
592            input.context: Key-value map used to resolve template variables in message content. Omit if messages contain no templates.
593            input.messages: Ordered list of conversation messages to send to the model.
594            input.opts: Model and sampling configuration for this request.
595
596        Returns:
597            Server-Sent Events stream
598        """
599        yield from self._http.stream_sse_sync(
600            "/api/v1/ai/chat/completions/stream", method="POST", body=input
601        )
602
603
604class ChatResource:
605    def __init__(self, http: SyncHttpClient):
606        self._http = http
607        self.completions = CompletionResource(http)
608
609    def models(self) -> ChatModelsResponse:
610        """
611        List available AI models
612        Returns the set of AI models that can be used with the chat completion and
613        workflow endpoints. The list reflects models currently enabled for the
614        platform and includes each model's identifier and whether it is the default.
615        Use the `model` field from any entry in `data` as the value for
616        `opts.model` when calling the completions or workflows endpoint.
617
618        Returns:
619            Successful response
620        """
621        return self._http.request("/api/v1/ai/chat/models", response_type=ChatModelsResponse)
622
623
624class ImageResource:
625    def __init__(self, http: SyncHttpClient):
626        self._http = http
627
628    def edits(self, input: ImageEditsInput) -> AIImageResult:
629        """
630        Edit an image with a text prompt
631        Applies a text-guided edit to one or more source images and returns the
632        resulting image. Pass the source images as base64-encoded objects in the
633        `images` array alongside a `prompt` describing the desired modification.
634        The underlying provider is selected by the `model` parameter. Omit `model`
635        to use the platform default. Size, quality, style, and format options are
636        forwarded to the provider as-is; unsupported combinations for a given model
637        return a 422 error with the provider's error message.
638        This endpoint requires authentication. The request is billed against the
639        workspace associated with the authenticated user.
640
641        Args:
642            input: Request body.
643            input.aspect_ratio: Desired aspect ratio of the output, e.g. `"1:1"` or `"16:9"`. Not supported by all models; omit to use the model's default.
644            input.background: Background treatment for the output. Accepted values and behavior are model-dependent.
645            input.height: Explicit output height in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
646            input.image_size: Output resolution tier for Gemini models, e.g. `"1K"`, `"2K"`, or `"4K"`. Ignored by non-Gemini models.
647            input.images: One or more source images to edit. Each image must be supplied as a base64-encoded object.
648            input.model: Model identifier to use for editing. Omit to use the platform default image model.
649            input.output_format: Desired MIME type or format for the returned image. Common values: `"png"`, `"jpeg"`, `"webp"`. Defaults to the model's native format.
650            input.prompt: Natural-language description of the edit to apply to the source image(s).
651            input.quality: Quality preset for the output image. Accepted values and behavior are model-dependent.
652            input.size: Output dimensions as a WxH string, e.g. `"1024x1024"`. Applies to OpenAI-compatible models. Omit to use the model's default.
653            input.style: Style preset applied to the edit. Accepted values and behavior are model-dependent.
654            input.width: Explicit output width in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
655
656        Returns:
657            The resulting edited image, including base64 data or a URL depending on the model.
658        """
659        return self._http.request(
660            "/api/v1/ai/image/edits",
661            method="POST",
662            body=input,
663            response_type=AIImageResult,
664        )
665
666    def generations(self, input: ImageGenerationsInput) -> AIImageResult:
667        """
668        Generate an image from a text prompt
669        Generates one or more images from a natural-language `prompt` using the
670        specified AI image model. The response contains the first generated image;
671        use `n` to request additional images (where supported by the model).
672        The underlying provider is selected by the `model` parameter. Omit `model`
673        to use the platform default. Size, quality, style, and format options are
674        forwarded to the provider as-is; unsupported combinations for a given model
675        return a 422 error with the provider's error message.
676        This endpoint requires authentication. The request is billed against the
677        workspace associated with the authenticated user.
678
679        Args:
680            input: Request body.
681            input.aspect_ratio: Desired aspect ratio of the output, e.g. `"1:1"` or `"16:9"`. Not supported by all models; omit to use the model's default.
682            input.background: Background treatment for the output. Accepted values and behavior are model-dependent.
683            input.height: Explicit output height in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
684            input.image_size: Output resolution tier for Gemini models, e.g. `"1K"`, `"2K"`, or `"4K"`. Ignored by non-Gemini models.
685            input.model: Model identifier to use for generation. Omit to use the platform default image model.
686            input.n: Number of images to generate. Defaults to `1`. Values greater than `1` are only supported by models that allow batch generation.
687            input.output_format: Desired MIME type or format for the returned image. Common values: `"png"`, `"jpeg"`, `"webp"`. Defaults to the model's native format.
688            input.prompt: Natural-language description of the image to generate.
689            input.quality: Quality preset for the output image. Accepted values and behavior are model-dependent.
690            input.size: Output dimensions as a WxH string, e.g. `"1024x1024"`. Applies to OpenAI-compatible models. Omit to use the model's default.
691            input.style: Style preset applied to the generated image. Accepted values and behavior are model-dependent.
692            input.width: Explicit output width in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
693
694        Returns:
695            The generated image, including base64 data or a URL depending on the model.
696        """
697        return self._http.request(
698            "/api/v1/ai/image/generations",
699            method="POST",
700            body=input,
701            response_type=AIImageResult,
702        )
703
704    def models(self) -> ImageModelsResponse:
705        """
706        List available image generation models
707        Returns the list of image generation models available on the platform.
708        Exactly one entry in the list carries `default: true`, indicating the model
709        used when no `model` parameter is supplied to the generation or editing
710        endpoints.
711        This endpoint requires authentication and reflects the models enabled for
712        the authenticated user's workspace.
713
714        Returns:
715            Successful response
716        """
717        return self._http.request("/api/v1/ai/image/models", response_type=ImageModelsResponse)
718
719
720class AiResource:
721    def __init__(self, http: SyncHttpClient):
722        self._http = http
723        self.chat = ChatResource(http)
724        self.image = ImageResource(http)
class CompletionCreateInputMessagesItemToolCallsItem(typing.TypedDict):
26class CompletionCreateInputMessagesItemToolCallsItem(TypedDict, total=False):
27    arguments: Required[dict[str, Any]]
28    "Arguments the model wants to pass to the tool, as a key-value map. Deserialize and validate these against the tool's input schema before executing."
29    id: Required[str]
30    "Unique identifier for this tool call, assigned by the model. Use this value as `id` when submitting the corresponding tool result."
31    name: Required[str]
32    'Name of the tool or function the model wants to invoke, e.g. `"web_search"` or `"run_code"`.'
33    thought_signature: str | None
34    "Opaque signature representing the model's internal reasoning that led to this tool call. `null` when the provider does not expose chain-of-thought data."
arguments: Required[dict[str, Any]]

Arguments the model wants to pass to the tool, as a key-value map. Deserialize and validate these against the tool's input schema before executing.

id: Required[str]

Unique identifier for this tool call, assigned by the model. Use this value as id when submitting the corresponding tool result.

name: Required[str]

Name of the tool or function the model wants to invoke, e.g. "web_search" or "run_code".

thought_signature: str | None

Opaque signature representing the model's internal reasoning that led to this tool call. null when the provider does not expose chain-of-thought data.

class CompletionCreateInputMessagesItemToolResultsItem(typing.TypedDict):
37class CompletionCreateInputMessagesItemToolResultsItem(TypedDict, total=False):
38    content: str | None
39    "Plain-text output produced by the tool execution. `null` when the result is expressed entirely through `resolution`."
40    id: Required[str]
41    "ID of the tool call this result satisfies. Must match the `id` from the corresponding `AIToolCall`."
42    name: Required[str]
43    'Name of the tool or function that was executed, e.g. `"web_search"`. Must match the `name` from the corresponding `AIToolCall`.'
44    resolution: Any | None
45    "Structured result data from the tool execution. Shape varies by tool. `null` when the result is expressed as plain text in `content`."
content: str | None

Plain-text output produced by the tool execution. null when the result is expressed entirely through resolution.

id: Required[str]

ID of the tool call this result satisfies. Must match the id from the corresponding AIToolCall.

name: Required[str]

Name of the tool or function that was executed, e.g. "web_search". Must match the name from the corresponding AIToolCall.

resolution: typing.Any | None

Structured result data from the tool execution. Shape varies by tool. null when the result is expressed as plain text in content.

class CompletionCreateInputMessagesItem(typing.TypedDict):
48class CompletionCreateInputMessagesItem(TypedDict, total=False):
49    content: str | None
50    "Plain-text content of the message. Present for `system`, `user`, and `assistant` messages. `null` when the message body is expressed through `content_parts` or `tool_calls`."
51    content_parts: list[dict[str, Any]] | None
52    'Multimodal content parts for the message, used when the body includes images or mixed media. Each part is a map with a `type` key (`"text"`, `"image_url"`, or `"image_data"`). `null` when `content` is set.'
53    resume_token: str | None
54    "Opaque token that can be passed on a subsequent request to resume this conversation from the current state. `null` when the provider does not support conversation resumption."
55    role: Required[str]
56    'The speaker role for this message. One of `"system"`, `"user"`, `"assistant"`, or `"tool"`.'
57    structured_output: Any | None
58    "Parsed structured data returned by the model when a JSON schema or structured-output mode was requested. Shape varies by the schema supplied at call time. `null` when structured output was not requested."
59    tool_calls: list[CompletionCreateInputMessagesItemToolCallsItem] | None
60    "Tool calls requested by the model in an `assistant` message. Present only on assistant messages that invoke one or more tools. `null` on all other message roles."
61    tool_results: list[CompletionCreateInputMessagesItemToolResultsItem] | None
62    "Tool execution results provided in a `tool` message. Each entry corresponds to a prior tool call by its `id`. `null` on all other message roles."
content: str | None

Plain-text content of the message. Present for system, user, and assistant messages. null when the message body is expressed through content_parts or tool_calls.

content_parts: list[dict[str, typing.Any]] | None

Multimodal content parts for the message, used when the body includes images or mixed media. Each part is a map with a type key ("text", "image_url", or "image_data"). null when content is set.

resume_token: str | None

Opaque token that can be passed on a subsequent request to resume this conversation from the current state. null when the provider does not support conversation resumption.

role: Required[str]

The speaker role for this message. One of "system", "user", "assistant", or "tool".

structured_output: typing.Any | None

Parsed structured data returned by the model when a JSON schema or structured-output mode was requested. Shape varies by the schema supplied at call time. null when structured output was not requested.

Tool calls requested by the model in an assistant message. Present only on assistant messages that invoke one or more tools. null on all other message roles.

Tool execution results provided in a tool message. Each entry corresponds to a prior tool call by its id. null on all other message roles.

class CompletionCreateInputOptsToolsItemFunction(typing.TypedDict):
65class CompletionCreateInputOptsToolsItemFunction(TypedDict, total=False):
66    description: str | None
67    "Human-readable description of what the function does. The model uses this to decide when to call the function. `null` if not provided."
68    name: Required[str]
69    'Unique name of the function that the model can invoke, e.g. `"get_weather"`.'
70    parameters: Required[dict[str, Any]]
71    'JSON Schema object describing the function\'s accepted parameters. Must be a valid JSON Schema of type `"object"`.'
description: str | None

Human-readable description of what the function does. The model uses this to decide when to call the function. null if not provided.

name: Required[str]

Unique name of the function that the model can invoke, e.g. "get_weather".

parameters: Required[dict[str, Any]]

JSON Schema object describing the function's accepted parameters. Must be a valid JSON Schema of type "object".

class CompletionCreateInputOptsToolsItem(typing.TypedDict):
74class CompletionCreateInputOptsToolsItem(TypedDict):
75    function: CompletionCreateInputOptsToolsItemFunction
76    "Callable function this tool exposes, including its name, description, and parameter schema."
77    type: str
78    'The tool type. Currently always `"function"`.'

Callable function this tool exposes, including its name, description, and parameter schema.

type: str

The tool type. Currently always "function".

class CompletionCreateInputOpts(typing.TypedDict):
81class CompletionCreateInputOpts(TypedDict, total=False):
82    max_tokens: int | None
83    "Maximum number of tokens the model may generate in the completion. Omit to use the model's default limit."
84    model: Required[str]
85    'Model identifier to use for the completion, e.g. `"gpt-4o"` or `"claude-3-7-sonnet-latest"`.'
86    server_tools: list[dict[str, Any]] | None
87    'Server-managed tool declarations executed before the response is returned. Each entry must include a `type` key; currently only `"search"` is supported.'
88    temperature: float | None
89    "Sampling temperature between `0.0` and `2.0`. Higher values produce more random output. Omit to use the model's default."
90    tool_choice: str | None
91    'Controls how the model selects tools. One of `"auto"`, `"required"`, or `"none"`. Omit to let the model decide.'
92    tools: list[CompletionCreateInputOptsToolsItem] | None
93    "OpenAI-compatible tool definitions available to the model. Omit when not using function calling."
max_tokens: int | None

Maximum number of tokens the model may generate in the completion. Omit to use the model's default limit.

model: Required[str]

Model identifier to use for the completion, e.g. "gpt-4o" or "claude-3-7-sonnet-latest".

server_tools: list[dict[str, typing.Any]] | None

Server-managed tool declarations executed before the response is returned. Each entry must include a type key; currently only "search" is supported.

temperature: float | None

Sampling temperature between 0.0 and 2.0. Higher values produce more random output. Omit to use the model's default.

tool_choice: str | None

Controls how the model selects tools. One of "auto", "required", or "none". Omit to let the model decide.

OpenAI-compatible tool definitions available to the model. Omit when not using function calling.

class CompletionCreateInput(typing.TypedDict):
 96class CompletionCreateInput(TypedDict, total=False):
 97    "Create a chat completion"
 98
 99    context: dict[str, Any] | None
100    "Key-value map used to resolve template variables in message content. Omit if messages contain no templates."
101    messages: Required[list[CompletionCreateInputMessagesItem]]
102    "Ordered list of conversation messages to send to the model."
103    opts: Required[CompletionCreateInputOpts]
104    "Model and sampling configuration for this request."

Create a chat completion

context: dict[str, typing.Any] | None

Key-value map used to resolve template variables in message content. Omit if messages contain no templates.

messages: Required[list[CompletionCreateInputMessagesItem]]

Ordered list of conversation messages to send to the model.

opts: Required[CompletionCreateInputOpts]

Model and sampling configuration for this request.

class CompletionStreamInputMessagesItemToolCallsItem(typing.TypedDict):
107class CompletionStreamInputMessagesItemToolCallsItem(TypedDict, total=False):
108    arguments: Required[dict[str, Any]]
109    "Arguments the model wants to pass to the tool, as a key-value map. Deserialize and validate these against the tool's input schema before executing."
110    id: Required[str]
111    "Unique identifier for this tool call, assigned by the model. Use this value as `id` when submitting the corresponding tool result."
112    name: Required[str]
113    'Name of the tool or function the model wants to invoke, e.g. `"web_search"` or `"run_code"`.'
114    thought_signature: str | None
115    "Opaque signature representing the model's internal reasoning that led to this tool call. `null` when the provider does not expose chain-of-thought data."
arguments: Required[dict[str, Any]]

Arguments the model wants to pass to the tool, as a key-value map. Deserialize and validate these against the tool's input schema before executing.

id: Required[str]

Unique identifier for this tool call, assigned by the model. Use this value as id when submitting the corresponding tool result.

name: Required[str]

Name of the tool or function the model wants to invoke, e.g. "web_search" or "run_code".

thought_signature: str | None

Opaque signature representing the model's internal reasoning that led to this tool call. null when the provider does not expose chain-of-thought data.

class CompletionStreamInputMessagesItemToolResultsItem(typing.TypedDict):
118class CompletionStreamInputMessagesItemToolResultsItem(TypedDict, total=False):
119    content: str | None
120    "Plain-text output produced by the tool execution. `null` when the result is expressed entirely through `resolution`."
121    id: Required[str]
122    "ID of the tool call this result satisfies. Must match the `id` from the corresponding `AIToolCall`."
123    name: Required[str]
124    'Name of the tool or function that was executed, e.g. `"web_search"`. Must match the `name` from the corresponding `AIToolCall`.'
125    resolution: Any | None
126    "Structured result data from the tool execution. Shape varies by tool. `null` when the result is expressed as plain text in `content`."
content: str | None

Plain-text output produced by the tool execution. null when the result is expressed entirely through resolution.

id: Required[str]

ID of the tool call this result satisfies. Must match the id from the corresponding AIToolCall.

name: Required[str]

Name of the tool or function that was executed, e.g. "web_search". Must match the name from the corresponding AIToolCall.

resolution: typing.Any | None

Structured result data from the tool execution. Shape varies by tool. null when the result is expressed as plain text in content.

class CompletionStreamInputMessagesItem(typing.TypedDict):
129class CompletionStreamInputMessagesItem(TypedDict, total=False):
130    content: str | None
131    "Plain-text content of the message. Present for `system`, `user`, and `assistant` messages. `null` when the message body is expressed through `content_parts` or `tool_calls`."
132    content_parts: list[dict[str, Any]] | None
133    'Multimodal content parts for the message, used when the body includes images or mixed media. Each part is a map with a `type` key (`"text"`, `"image_url"`, or `"image_data"`). `null` when `content` is set.'
134    resume_token: str | None
135    "Opaque token that can be passed on a subsequent request to resume this conversation from the current state. `null` when the provider does not support conversation resumption."
136    role: Required[str]
137    'The speaker role for this message. One of `"system"`, `"user"`, `"assistant"`, or `"tool"`.'
138    structured_output: Any | None
139    "Parsed structured data returned by the model when a JSON schema or structured-output mode was requested. Shape varies by the schema supplied at call time. `null` when structured output was not requested."
140    tool_calls: list[CompletionStreamInputMessagesItemToolCallsItem] | None
141    "Tool calls requested by the model in an `assistant` message. Present only on assistant messages that invoke one or more tools. `null` on all other message roles."
142    tool_results: list[CompletionStreamInputMessagesItemToolResultsItem] | None
143    "Tool execution results provided in a `tool` message. Each entry corresponds to a prior tool call by its `id`. `null` on all other message roles."
content: str | None

Plain-text content of the message. Present for system, user, and assistant messages. null when the message body is expressed through content_parts or tool_calls.

content_parts: list[dict[str, typing.Any]] | None

Multimodal content parts for the message, used when the body includes images or mixed media. Each part is a map with a type key ("text", "image_url", or "image_data"). null when content is set.

resume_token: str | None

Opaque token that can be passed on a subsequent request to resume this conversation from the current state. null when the provider does not support conversation resumption.

role: Required[str]

The speaker role for this message. One of "system", "user", "assistant", or "tool".

structured_output: typing.Any | None

Parsed structured data returned by the model when a JSON schema or structured-output mode was requested. Shape varies by the schema supplied at call time. null when structured output was not requested.

Tool calls requested by the model in an assistant message. Present only on assistant messages that invoke one or more tools. null on all other message roles.

Tool execution results provided in a tool message. Each entry corresponds to a prior tool call by its id. null on all other message roles.

class CompletionStreamInputOptsToolsItemFunction(typing.TypedDict):
146class CompletionStreamInputOptsToolsItemFunction(TypedDict, total=False):
147    description: str | None
148    "Human-readable description of what the function does. The model uses this to decide when to call the function. `null` if not provided."
149    name: Required[str]
150    'Unique name of the function that the model can invoke, e.g. `"get_weather"`.'
151    parameters: Required[dict[str, Any]]
152    'JSON Schema object describing the function\'s accepted parameters. Must be a valid JSON Schema of type `"object"`.'
description: str | None

Human-readable description of what the function does. The model uses this to decide when to call the function. null if not provided.

name: Required[str]

Unique name of the function that the model can invoke, e.g. "get_weather".

parameters: Required[dict[str, Any]]

JSON Schema object describing the function's accepted parameters. Must be a valid JSON Schema of type "object".

class CompletionStreamInputOptsToolsItem(typing.TypedDict):
155class CompletionStreamInputOptsToolsItem(TypedDict):
156    function: CompletionStreamInputOptsToolsItemFunction
157    "Callable function this tool exposes, including its name, description, and parameter schema."
158    type: str
159    'The tool type. Currently always `"function"`.'

Callable function this tool exposes, including its name, description, and parameter schema.

type: str

The tool type. Currently always "function".

class CompletionStreamInputOpts(typing.TypedDict):
162class CompletionStreamInputOpts(TypedDict, total=False):
163    max_tokens: int | None
164    "Maximum number of tokens the model may generate. Omit for the model default."
165    model: Required[str]
166    'Model identifier, e.g. `"gpt-4o"` or `"claude-3-7-sonnet-latest"`.'
167    server_tools: list[dict[str, Any]] | None
168    'Server-managed tool declarations executed before the response. Each entry must include a `type` key; currently only `"search"` is supported.'
169    temperature: float | None
170    "Sampling temperature between `0.0` and `2.0`. Higher values produce more random output. Omit for the model default."
171    tool_choice: str | None
172    'Controls tool selection. One of `"auto"`, `"required"`, or `"none"`. Omit to let the model decide.'
173    tools: list[CompletionStreamInputOptsToolsItem] | None
174    "OpenAI-compatible tool definitions available to the model. Omit when not using function calling."
max_tokens: int | None

Maximum number of tokens the model may generate. Omit for the model default.

model: Required[str]

Model identifier, e.g. "gpt-4o" or "claude-3-7-sonnet-latest".

server_tools: list[dict[str, typing.Any]] | None

Server-managed tool declarations executed before the response. Each entry must include a type key; currently only "search" is supported.

temperature: float | None

Sampling temperature between 0.0 and 2.0. Higher values produce more random output. Omit for the model default.

tool_choice: str | None

Controls tool selection. One of "auto", "required", or "none". Omit to let the model decide.

OpenAI-compatible tool definitions available to the model. Omit when not using function calling.

class CompletionStreamInput(typing.TypedDict):
177class CompletionStreamInput(TypedDict, total=False):
178    "Stream a chat completion"
179
180    context: dict[str, Any] | None
181    "Key-value map used to resolve template variables in message content. Omit if messages contain no templates."
182    messages: Required[list[CompletionStreamInputMessagesItem]]
183    "Ordered list of conversation messages to send to the model."
184    opts: Required[CompletionStreamInputOpts]
185    "Model and sampling configuration for this request."

Stream a chat completion

context: dict[str, typing.Any] | None

Key-value map used to resolve template variables in message content. Omit if messages contain no templates.

messages: Required[list[CompletionStreamInputMessagesItem]]

Ordered list of conversation messages to send to the model.

opts: Required[CompletionStreamInputOpts]

Model and sampling configuration for this request.

class ImageEditsInputImagesItem(typing.TypedDict):
188class ImageEditsInputImagesItem(TypedDict):
189    image_data: str
190    "The raw image content encoded as a base64 string (standard encoding, no line breaks)."
191    image_type: str
192    'MIME type of the image, e.g. `"image/png"` or `"image/jpeg"`. Must match the actual encoding of `image_data`.'
image_data: str

The raw image content encoded as a base64 string (standard encoding, no line breaks).

image_type: str

MIME type of the image, e.g. "image/png" or "image/jpeg". Must match the actual encoding of image_data.

class ImageEditsInput(typing.TypedDict):
195class ImageEditsInput(TypedDict, total=False):
196    "Edit an image with a text prompt"
197
198    aspect_ratio: str | None
199    'Desired aspect ratio of the output, e.g. `"1:1"` or `"16:9"`. Not supported by all models; omit to use the model\'s default.'
200    background: str | None
201    "Background treatment for the output. Accepted values and behavior are model-dependent."
202    height: int | None
203    "Explicit output height in pixels. Takes precedence over `size` when both are provided. Not supported by all models."
204    image_size: str | None
205    'Output resolution tier for Gemini models, e.g. `"1K"`, `"2K"`, or `"4K"`. Ignored by non-Gemini models.'
206    images: Required[list[ImageEditsInputImagesItem]]
207    "One or more source images to edit. Each image must be supplied as a base64-encoded object."
208    model: str | None
209    "Model identifier to use for editing. Omit to use the platform default image model."
210    output_format: str | None
211    'Desired MIME type or format for the returned image. Common values: `"png"`, `"jpeg"`, `"webp"`. Defaults to the model\'s native format.'
212    prompt: Required[str]
213    "Natural-language description of the edit to apply to the source image(s)."
214    quality: str | None
215    "Quality preset for the output image. Accepted values and behavior are model-dependent."
216    size: str | None
217    'Output dimensions as a WxH string, e.g. `"1024x1024"`. Applies to OpenAI-compatible models. Omit to use the model\'s default.'
218    style: str | None
219    "Style preset applied to the edit. Accepted values and behavior are model-dependent."
220    width: int | None
221    "Explicit output width in pixels. Takes precedence over `size` when both are provided. Not supported by all models."

Edit an image with a text prompt

aspect_ratio: str | None

Desired aspect ratio of the output, e.g. "1:1" or "16:9". Not supported by all models; omit to use the model's default.

background: str | None

Background treatment for the output. Accepted values and behavior are model-dependent.

height: int | None

Explicit output height in pixels. Takes precedence over size when both are provided. Not supported by all models.

image_size: str | None

Output resolution tier for Gemini models, e.g. "1K", "2K", or "4K". Ignored by non-Gemini models.

images: Required[list[ImageEditsInputImagesItem]]

One or more source images to edit. Each image must be supplied as a base64-encoded object.

model: str | None

Model identifier to use for editing. Omit to use the platform default image model.

output_format: str | None

Desired MIME type or format for the returned image. Common values: "png", "jpeg", "webp". Defaults to the model's native format.

prompt: Required[str]

Natural-language description of the edit to apply to the source image(s).

quality: str | None

Quality preset for the output image. Accepted values and behavior are model-dependent.

size: str | None

Output dimensions as a WxH string, e.g. "1024x1024". Applies to OpenAI-compatible models. Omit to use the model's default.

style: str | None

Style preset applied to the edit. Accepted values and behavior are model-dependent.

width: int | None

Explicit output width in pixels. Takes precedence over size when both are provided. Not supported by all models.

class ImageGenerationsInput(typing.TypedDict):
224class ImageGenerationsInput(TypedDict, total=False):
225    "Generate an image from a text prompt"
226
227    aspect_ratio: str | None
228    'Desired aspect ratio of the output, e.g. `"1:1"` or `"16:9"`. Not supported by all models; omit to use the model\'s default.'
229    background: str | None
230    "Background treatment for the output. Accepted values and behavior are model-dependent."
231    height: int | None
232    "Explicit output height in pixels. Takes precedence over `size` when both are provided. Not supported by all models."
233    image_size: str | None
234    'Output resolution tier for Gemini models, e.g. `"1K"`, `"2K"`, or `"4K"`. Ignored by non-Gemini models.'
235    model: str | None
236    "Model identifier to use for generation. Omit to use the platform default image model."
237    n: int | None
238    "Number of images to generate. Defaults to `1`. Values greater than `1` are only supported by models that allow batch generation."
239    output_format: str | None
240    'Desired MIME type or format for the returned image. Common values: `"png"`, `"jpeg"`, `"webp"`. Defaults to the model\'s native format.'
241    prompt: Required[str]
242    "Natural-language description of the image to generate."
243    quality: str | None
244    "Quality preset for the output image. Accepted values and behavior are model-dependent."
245    size: str | None
246    'Output dimensions as a WxH string, e.g. `"1024x1024"`. Applies to OpenAI-compatible models. Omit to use the model\'s default.'
247    style: str | None
248    "Style preset applied to the generated image. Accepted values and behavior are model-dependent."
249    width: int | None
250    "Explicit output width in pixels. Takes precedence over `size` when both are provided. Not supported by all models."

Generate an image from a text prompt

aspect_ratio: str | None

Desired aspect ratio of the output, e.g. "1:1" or "16:9". Not supported by all models; omit to use the model's default.

background: str | None

Background treatment for the output. Accepted values and behavior are model-dependent.

height: int | None

Explicit output height in pixels. Takes precedence over size when both are provided. Not supported by all models.

image_size: str | None

Output resolution tier for Gemini models, e.g. "1K", "2K", or "4K". Ignored by non-Gemini models.

model: str | None

Model identifier to use for generation. Omit to use the platform default image model.

n: int | None

Number of images to generate. Defaults to 1. Values greater than 1 are only supported by models that allow batch generation.

output_format: str | None

Desired MIME type or format for the returned image. Common values: "png", "jpeg", "webp". Defaults to the model's native format.

prompt: Required[str]

Natural-language description of the image to generate.

quality: str | None

Quality preset for the output image. Accepted values and behavior are model-dependent.

size: str | None

Output dimensions as a WxH string, e.g. "1024x1024". Applies to OpenAI-compatible models. Omit to use the model's default.

style: str | None

Style preset applied to the generated image. Accepted values and behavior are model-dependent.

width: int | None

Explicit output width in pixels. Takes precedence over size when both are provided. Not supported by all models.

class ChatModelsResponseDataItem(pydantic.main.BaseModel):
253class ChatModelsResponseDataItem(BaseModel):
254    capabilities: list[Literal["image", "search", "thinking"]] = Field(
255        ...,
256        description='Machine-readable model capabilities. `"image"` marks image-input chat, `"search"` marks built-in web search, and `"thinking"` marks models with configurable reasoning. Empty when the catalog entry declares no special capabilities.',
257    )
258    default: bool = Field(
259        ...,
260        description="`true` for the model the platform selects when an agent has no `default_model` configured, or for the system-wide fallback in image-generation contexts. Exactly one entry in any given model list carries this flag.",
261    )
262    id: str = Field(
263        ...,
264        description='Provider-assigned model identifier used when specifying a model on API requests, e.g. `"claude-sonnet-4-6"` or `"gemini-2.5-flash"`.',
265    )
266    input_media_formats: list[str] = Field(
267        ...,
268        description='MIME types accepted in chat `content_parts` image/file inputs for this model. For image-capable chat models this includes values such as `"image/png"`. Empty for text-only models.',
269    )
270    name: str = Field(
271        ...,
272        description='Human-readable display label for this model, e.g. `"Claude Sonnet 4.6"` or `"Gemini 3.5 Flash (thinking)"`. Render this value directly in pickers rather than attempting to parse or transform `id`. Falls back to the `id` string when the catalog entry does not declare an explicit name.',
273    )
274    output_media_formats: list[str] = Field(
275        ...,
276        description="MIME types this model can emit as media in chat responses. Empty for text-output models, including image-understanding models that only return text.",
277    )

!!! abstract "Usage Documentation" Models

A base class for creating Pydantic models.

Attributes:
  • __class_vars__: The names of the class variables defined on the model.
  • __private_attributes__: Metadata about the private attributes of the model.
  • __signature__: The synthesized __init__ [Signature][inspect.Signature] of the model.
  • __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
  • __pydantic_core_schema__: The core schema of the model.
  • __pydantic_custom_init__: Whether the model has a custom __init__ function.
  • __pydantic_decorators__: Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
  • __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models. The origin and args items map to the [__origin__][genericalias.__origin__] and [__args__][genericalias.__args__] attributes of [generic aliases][types-genericalias], and the parameter item maps to the __parameter__ attribute of generic classes.
  • __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
  • __pydantic_post_init__: The name of the post-init method for the model, if defined.
  • __pydantic_root_model__: Whether the model is a [RootModel][pydantic.root_model.RootModel].
  • __pydantic_serializer__: The pydantic-core SchemaSerializer used to dump instances of the model.
  • __pydantic_validator__: The pydantic-core SchemaValidator used to validate instances of the model.
  • __pydantic_fields__: A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
  • __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
  • __pydantic_extra__: A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
  • __pydantic_fields_set__: The names of fields explicitly set during instantiation.
  • __pydantic_private__: Values of private attributes set on the model instance.
capabilities: list[typing.Literal['image', 'search', 'thinking']] = PydanticUndefined

Machine-readable model capabilities. "image" marks image-input chat, "search" marks built-in web search, and "thinking" marks models with configurable reasoning. Empty when the catalog entry declares no special capabilities.

default: bool = PydanticUndefined

true for the model the platform selects when an agent has no default_model configured, or for the system-wide fallback in image-generation contexts. Exactly one entry in any given model list carries this flag.

id: str = PydanticUndefined

Provider-assigned model identifier used when specifying a model on API requests, e.g. "claude-sonnet-4-6" or "gemini-2.5-flash".

input_media_formats: list[str] = PydanticUndefined

MIME types accepted in chat content_parts image/file inputs for this model. For image-capable chat models this includes values such as "image/png". Empty for text-only models.

name: str = PydanticUndefined

Human-readable display label for this model, e.g. "Claude Sonnet 4.6" or "Gemini 3.5 Flash (thinking)". Render this value directly in pickers rather than attempting to parse or transform id. Falls back to the id string when the catalog entry does not declare an explicit name.

output_media_formats: list[str] = PydanticUndefined

MIME types this model can emit as media in chat responses. Empty for text-output models, including image-understanding models that only return text.

class ChatModelsResponse(pydantic.main.BaseModel):
280class ChatModelsResponse(BaseModel):
281    """
282    Successful response
283    """
284
285    data: list[ChatModelsResponseDataItem] = Field(
286        ..., description="Array of available model objects. At least one entry is always present."
287    )

Successful response

data: list[ChatModelsResponseDataItem] = PydanticUndefined

Array of available model objects. At least one entry is always present.

class ImageModelsResponseDataItem(pydantic.main.BaseModel):
290class ImageModelsResponseDataItem(BaseModel):
291    capabilities: list[Literal["image", "search", "thinking"]] = Field(
292        ...,
293        description='Machine-readable model capabilities. `"image"` marks image-input chat, `"search"` marks built-in web search, and `"thinking"` marks models with configurable reasoning. Empty when the catalog entry declares no special capabilities.',
294    )
295    default: bool = Field(
296        ...,
297        description="`true` for the model the platform selects when an agent has no `default_model` configured, or for the system-wide fallback in image-generation contexts. Exactly one entry in any given model list carries this flag.",
298    )
299    id: str = Field(
300        ...,
301        description='Provider-assigned model identifier used when specifying a model on API requests, e.g. `"claude-sonnet-4-6"` or `"gemini-2.5-flash"`.',
302    )
303    input_media_formats: list[str] = Field(
304        ...,
305        description='MIME types accepted in chat `content_parts` image/file inputs for this model. For image-capable chat models this includes values such as `"image/png"`. Empty for text-only models.',
306    )
307    name: str = Field(
308        ...,
309        description='Human-readable display label for this model, e.g. `"Claude Sonnet 4.6"` or `"Gemini 3.5 Flash (thinking)"`. Render this value directly in pickers rather than attempting to parse or transform `id`. Falls back to the `id` string when the catalog entry does not declare an explicit name.',
310    )
311    output_media_formats: list[str] = Field(
312        ...,
313        description="MIME types this model can emit as media in chat responses. Empty for text-output models, including image-understanding models that only return text.",
314    )

!!! abstract "Usage Documentation" Models

A base class for creating Pydantic models.

Attributes:
  • __class_vars__: The names of the class variables defined on the model.
  • __private_attributes__: Metadata about the private attributes of the model.
  • __signature__: The synthesized __init__ [Signature][inspect.Signature] of the model.
  • __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
  • __pydantic_core_schema__: The core schema of the model.
  • __pydantic_custom_init__: Whether the model has a custom __init__ function.
  • __pydantic_decorators__: Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
  • __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models. The origin and args items map to the [__origin__][genericalias.__origin__] and [__args__][genericalias.__args__] attributes of [generic aliases][types-genericalias], and the parameter item maps to the __parameter__ attribute of generic classes.
  • __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
  • __pydantic_post_init__: The name of the post-init method for the model, if defined.
  • __pydantic_root_model__: Whether the model is a [RootModel][pydantic.root_model.RootModel].
  • __pydantic_serializer__: The pydantic-core SchemaSerializer used to dump instances of the model.
  • __pydantic_validator__: The pydantic-core SchemaValidator used to validate instances of the model.
  • __pydantic_fields__: A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
  • __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
  • __pydantic_extra__: A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
  • __pydantic_fields_set__: The names of fields explicitly set during instantiation.
  • __pydantic_private__: Values of private attributes set on the model instance.
capabilities: list[typing.Literal['image', 'search', 'thinking']] = PydanticUndefined

Machine-readable model capabilities. "image" marks image-input chat, "search" marks built-in web search, and "thinking" marks models with configurable reasoning. Empty when the catalog entry declares no special capabilities.

default: bool = PydanticUndefined

true for the model the platform selects when an agent has no default_model configured, or for the system-wide fallback in image-generation contexts. Exactly one entry in any given model list carries this flag.

id: str = PydanticUndefined

Provider-assigned model identifier used when specifying a model on API requests, e.g. "claude-sonnet-4-6" or "gemini-2.5-flash".

input_media_formats: list[str] = PydanticUndefined

MIME types accepted in chat content_parts image/file inputs for this model. For image-capable chat models this includes values such as "image/png". Empty for text-only models.

name: str = PydanticUndefined

Human-readable display label for this model, e.g. "Claude Sonnet 4.6" or "Gemini 3.5 Flash (thinking)". Render this value directly in pickers rather than attempting to parse or transform id. Falls back to the id string when the catalog entry does not declare an explicit name.

output_media_formats: list[str] = PydanticUndefined

MIME types this model can emit as media in chat responses. Empty for text-output models, including image-understanding models that only return text.

class ImageModelsResponse(pydantic.main.BaseModel):
317class ImageModelsResponse(BaseModel):
318    """
319    Successful response
320    """
321
322    data: list[ImageModelsResponseDataItem] = Field(
323        ...,
324        description="Array of available image generation models, including their identifiers, human-readable names, and which one is the platform default.",
325    )

Successful response

data: list[ImageModelsResponseDataItem] = PydanticUndefined

Array of available image generation models, including their identifiers, human-readable names, and which one is the platform default.

class CompletionStreamEventDone(typing.TypedDict):
328class CompletionStreamEventDone(TypedDict):
329    event: Literal["done"]
330    data: AIChatStreamDone
event: Literal['done']
class CompletionStreamEventError(typing.TypedDict):
333class CompletionStreamEventError(TypedDict):
334    event: Literal["error"]
335    data: AIChatStreamError
event: Literal['error']
class CompletionStreamEventMessageComplete(typing.TypedDict):
338class CompletionStreamEventMessageComplete(TypedDict):
339    event: Literal["message_complete"]
340    data: AIChatStreamMessageComplete
event: Literal['message_complete']
class CompletionStreamEventMessageDelta(typing.TypedDict):
343class CompletionStreamEventMessageDelta(TypedDict):
344    event: Literal["message_delta"]
345    data: AIChatStreamMessageDelta
event: Literal['message_delta']
class CompletionStreamEventToolCallDelta(typing.TypedDict):
348class CompletionStreamEventToolCallDelta(TypedDict):
349    event: Literal["tool_call_delta"]
350    data: AIChatStreamToolCallDelta
event: Literal['tool_call_delta']
class CompletionStreamEventToolResult(typing.TypedDict):
353class CompletionStreamEventToolResult(TypedDict):
354    event: Literal["tool_result"]
355    data: AIChatStreamToolResult
event: Literal['tool_result']
class AsyncCompletionResource:
368class AsyncCompletionResource:
369    def __init__(self, http: HttpClient):
370        self._http = http
371
372    async def create(self, input: CompletionCreateInput) -> AICompletionResult:
373        """
374        Create a chat completion
375        Sends a list of messages to the configured AI provider and returns a single
376        completion. Use this endpoint when you want direct, low-level access to the
377        underlying model without any workflow or agent orchestration.
378        The authenticated app must have the `llm_calls` entitlement enabled on its
379        plan. Requests that exceed the plan quota are rejected with `402`. Token
380        usage is recorded against the authenticated app and organization.
381        Supply `tools` and `tool_choice` to enable OpenAI-compatible function
382        calling. Use `server_tools` to activate platform-managed tools such as
383        search that run on the server side before the response is returned.
384
385        Args:
386            input: Request body.
387            input.context: Key-value map used to resolve template variables in message content. Omit if messages contain no templates.
388            input.messages: Ordered list of conversation messages to send to the model.
389            input.opts: Model and sampling configuration for this request.
390
391        Returns:
392            The completed AI response, including the generated message, finish reason, and token usage.
393        """
394        return await self._http.request(
395            "/api/v1/ai/chat/completions",
396            method="POST",
397            body=input,
398            response_type=AICompletionResult,
399        )
400
401    async def stream(self, input: CompletionStreamInput) -> AsyncIterator[CompletionStreamEvent]:
402        """
403        Stream a chat completion
404        Streams a chat completion over Server-Sent Events. Emits `message_delta`,
405        `message_complete`, `tool_call_*`, `tool_result`, and a terminal `done` (or
406        `error`) event. Same request shape as the non-streaming completion endpoint;
407        the app must have the `llm_calls` entitlement.
408
409        Args:
410            input: Request body.
411            input.context: Key-value map used to resolve template variables in message content. Omit if messages contain no templates.
412            input.messages: Ordered list of conversation messages to send to the model.
413            input.opts: Model and sampling configuration for this request.
414
415        Returns:
416            Server-Sent Events stream
417        """
418        async for event in self._http.stream_sse(
419            "/api/v1/ai/chat/completions/stream", method="POST", body=input
420        ):
421            yield event
AsyncCompletionResource(http: archastro.platform.runtime.http_client.HttpClient)
369    def __init__(self, http: HttpClient):
370        self._http = http
async def create( self, input: CompletionCreateInput) -> archastro.platform.types.ai.AICompletionResult:
372    async def create(self, input: CompletionCreateInput) -> AICompletionResult:
373        """
374        Create a chat completion
375        Sends a list of messages to the configured AI provider and returns a single
376        completion. Use this endpoint when you want direct, low-level access to the
377        underlying model without any workflow or agent orchestration.
378        The authenticated app must have the `llm_calls` entitlement enabled on its
379        plan. Requests that exceed the plan quota are rejected with `402`. Token
380        usage is recorded against the authenticated app and organization.
381        Supply `tools` and `tool_choice` to enable OpenAI-compatible function
382        calling. Use `server_tools` to activate platform-managed tools such as
383        search that run on the server side before the response is returned.
384
385        Args:
386            input: Request body.
387            input.context: Key-value map used to resolve template variables in message content. Omit if messages contain no templates.
388            input.messages: Ordered list of conversation messages to send to the model.
389            input.opts: Model and sampling configuration for this request.
390
391        Returns:
392            The completed AI response, including the generated message, finish reason, and token usage.
393        """
394        return await self._http.request(
395            "/api/v1/ai/chat/completions",
396            method="POST",
397            body=input,
398            response_type=AICompletionResult,
399        )

Create a chat completion Sends a list of messages to the configured AI provider and returns a single completion. Use this endpoint when you want direct, low-level access to the underlying model without any workflow or agent orchestration. The authenticated app must have the llm_calls entitlement enabled on its plan. Requests that exceed the plan quota are rejected with 402. Token usage is recorded against the authenticated app and organization. Supply tools and tool_choice to enable OpenAI-compatible function calling. Use server_tools to activate platform-managed tools such as search that run on the server side before the response is returned.

Arguments:
  • input: Request body.
  • input.context: Key-value map used to resolve template variables in message content. Omit if messages contain no templates.
  • input.messages: Ordered list of conversation messages to send to the model.
  • input.opts: Model and sampling configuration for this request.
Returns:

The completed AI response, including the generated message, finish reason, and token usage.

401    async def stream(self, input: CompletionStreamInput) -> AsyncIterator[CompletionStreamEvent]:
402        """
403        Stream a chat completion
404        Streams a chat completion over Server-Sent Events. Emits `message_delta`,
405        `message_complete`, `tool_call_*`, `tool_result`, and a terminal `done` (or
406        `error`) event. Same request shape as the non-streaming completion endpoint;
407        the app must have the `llm_calls` entitlement.
408
409        Args:
410            input: Request body.
411            input.context: Key-value map used to resolve template variables in message content. Omit if messages contain no templates.
412            input.messages: Ordered list of conversation messages to send to the model.
413            input.opts: Model and sampling configuration for this request.
414
415        Returns:
416            Server-Sent Events stream
417        """
418        async for event in self._http.stream_sse(
419            "/api/v1/ai/chat/completions/stream", method="POST", body=input
420        ):
421            yield event

Stream a chat completion Streams a chat completion over Server-Sent Events. Emits message_delta, message_complete, tool_call_*, tool_result, and a terminal done (or error) event. Same request shape as the non-streaming completion endpoint; the app must have the llm_calls entitlement.

Arguments:
  • input: Request body.
  • input.context: Key-value map used to resolve template variables in message content. Omit if messages contain no templates.
  • input.messages: Ordered list of conversation messages to send to the model.
  • input.opts: Model and sampling configuration for this request.
Returns:

Server-Sent Events stream

class AsyncChatResource:
424class AsyncChatResource:
425    def __init__(self, http: HttpClient):
426        self._http = http
427        self.completions = AsyncCompletionResource(http)
428
429    async def models(self) -> ChatModelsResponse:
430        """
431        List available AI models
432        Returns the set of AI models that can be used with the chat completion and
433        workflow endpoints. The list reflects models currently enabled for the
434        platform and includes each model's identifier and whether it is the default.
435        Use the `model` field from any entry in `data` as the value for
436        `opts.model` when calling the completions or workflows endpoint.
437
438        Returns:
439            Successful response
440        """
441        return await self._http.request("/api/v1/ai/chat/models", response_type=ChatModelsResponse)
AsyncChatResource(http: archastro.platform.runtime.http_client.HttpClient)
425    def __init__(self, http: HttpClient):
426        self._http = http
427        self.completions = AsyncCompletionResource(http)
completions
async def models(self) -> ChatModelsResponse:
429    async def models(self) -> ChatModelsResponse:
430        """
431        List available AI models
432        Returns the set of AI models that can be used with the chat completion and
433        workflow endpoints. The list reflects models currently enabled for the
434        platform and includes each model's identifier and whether it is the default.
435        Use the `model` field from any entry in `data` as the value for
436        `opts.model` when calling the completions or workflows endpoint.
437
438        Returns:
439            Successful response
440        """
441        return await self._http.request("/api/v1/ai/chat/models", response_type=ChatModelsResponse)

List available AI models Returns the set of AI models that can be used with the chat completion and workflow endpoints. The list reflects models currently enabled for the platform and includes each model's identifier and whether it is the default. Use the model field from any entry in data as the value for opts.model when calling the completions or workflows endpoint.

Returns:

Successful response

class AsyncImageResource:
444class AsyncImageResource:
445    def __init__(self, http: HttpClient):
446        self._http = http
447
448    async def edits(self, input: ImageEditsInput) -> AIImageResult:
449        """
450        Edit an image with a text prompt
451        Applies a text-guided edit to one or more source images and returns the
452        resulting image. Pass the source images as base64-encoded objects in the
453        `images` array alongside a `prompt` describing the desired modification.
454        The underlying provider is selected by the `model` parameter. Omit `model`
455        to use the platform default. Size, quality, style, and format options are
456        forwarded to the provider as-is; unsupported combinations for a given model
457        return a 422 error with the provider's error message.
458        This endpoint requires authentication. The request is billed against the
459        workspace associated with the authenticated user.
460
461        Args:
462            input: Request body.
463            input.aspect_ratio: Desired aspect ratio of the output, e.g. `"1:1"` or `"16:9"`. Not supported by all models; omit to use the model's default.
464            input.background: Background treatment for the output. Accepted values and behavior are model-dependent.
465            input.height: Explicit output height in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
466            input.image_size: Output resolution tier for Gemini models, e.g. `"1K"`, `"2K"`, or `"4K"`. Ignored by non-Gemini models.
467            input.images: One or more source images to edit. Each image must be supplied as a base64-encoded object.
468            input.model: Model identifier to use for editing. Omit to use the platform default image model.
469            input.output_format: Desired MIME type or format for the returned image. Common values: `"png"`, `"jpeg"`, `"webp"`. Defaults to the model's native format.
470            input.prompt: Natural-language description of the edit to apply to the source image(s).
471            input.quality: Quality preset for the output image. Accepted values and behavior are model-dependent.
472            input.size: Output dimensions as a WxH string, e.g. `"1024x1024"`. Applies to OpenAI-compatible models. Omit to use the model's default.
473            input.style: Style preset applied to the edit. Accepted values and behavior are model-dependent.
474            input.width: Explicit output width in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
475
476        Returns:
477            The resulting edited image, including base64 data or a URL depending on the model.
478        """
479        return await self._http.request(
480            "/api/v1/ai/image/edits",
481            method="POST",
482            body=input,
483            response_type=AIImageResult,
484        )
485
486    async def generations(self, input: ImageGenerationsInput) -> AIImageResult:
487        """
488        Generate an image from a text prompt
489        Generates one or more images from a natural-language `prompt` using the
490        specified AI image model. The response contains the first generated image;
491        use `n` to request additional images (where supported by the model).
492        The underlying provider is selected by the `model` parameter. Omit `model`
493        to use the platform default. Size, quality, style, and format options are
494        forwarded to the provider as-is; unsupported combinations for a given model
495        return a 422 error with the provider's error message.
496        This endpoint requires authentication. The request is billed against the
497        workspace associated with the authenticated user.
498
499        Args:
500            input: Request body.
501            input.aspect_ratio: Desired aspect ratio of the output, e.g. `"1:1"` or `"16:9"`. Not supported by all models; omit to use the model's default.
502            input.background: Background treatment for the output. Accepted values and behavior are model-dependent.
503            input.height: Explicit output height in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
504            input.image_size: Output resolution tier for Gemini models, e.g. `"1K"`, `"2K"`, or `"4K"`. Ignored by non-Gemini models.
505            input.model: Model identifier to use for generation. Omit to use the platform default image model.
506            input.n: Number of images to generate. Defaults to `1`. Values greater than `1` are only supported by models that allow batch generation.
507            input.output_format: Desired MIME type or format for the returned image. Common values: `"png"`, `"jpeg"`, `"webp"`. Defaults to the model's native format.
508            input.prompt: Natural-language description of the image to generate.
509            input.quality: Quality preset for the output image. Accepted values and behavior are model-dependent.
510            input.size: Output dimensions as a WxH string, e.g. `"1024x1024"`. Applies to OpenAI-compatible models. Omit to use the model's default.
511            input.style: Style preset applied to the generated image. Accepted values and behavior are model-dependent.
512            input.width: Explicit output width in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
513
514        Returns:
515            The generated image, including base64 data or a URL depending on the model.
516        """
517        return await self._http.request(
518            "/api/v1/ai/image/generations",
519            method="POST",
520            body=input,
521            response_type=AIImageResult,
522        )
523
524    async def models(self) -> ImageModelsResponse:
525        """
526        List available image generation models
527        Returns the list of image generation models available on the platform.
528        Exactly one entry in the list carries `default: true`, indicating the model
529        used when no `model` parameter is supplied to the generation or editing
530        endpoints.
531        This endpoint requires authentication and reflects the models enabled for
532        the authenticated user's workspace.
533
534        Returns:
535            Successful response
536        """
537        return await self._http.request(
538            "/api/v1/ai/image/models",
539            response_type=ImageModelsResponse,
540        )
AsyncImageResource(http: archastro.platform.runtime.http_client.HttpClient)
445    def __init__(self, http: HttpClient):
446        self._http = http
async def edits( self, input: ImageEditsInput) -> archastro.platform.types.ai.AIImageResult:
448    async def edits(self, input: ImageEditsInput) -> AIImageResult:
449        """
450        Edit an image with a text prompt
451        Applies a text-guided edit to one or more source images and returns the
452        resulting image. Pass the source images as base64-encoded objects in the
453        `images` array alongside a `prompt` describing the desired modification.
454        The underlying provider is selected by the `model` parameter. Omit `model`
455        to use the platform default. Size, quality, style, and format options are
456        forwarded to the provider as-is; unsupported combinations for a given model
457        return a 422 error with the provider's error message.
458        This endpoint requires authentication. The request is billed against the
459        workspace associated with the authenticated user.
460
461        Args:
462            input: Request body.
463            input.aspect_ratio: Desired aspect ratio of the output, e.g. `"1:1"` or `"16:9"`. Not supported by all models; omit to use the model's default.
464            input.background: Background treatment for the output. Accepted values and behavior are model-dependent.
465            input.height: Explicit output height in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
466            input.image_size: Output resolution tier for Gemini models, e.g. `"1K"`, `"2K"`, or `"4K"`. Ignored by non-Gemini models.
467            input.images: One or more source images to edit. Each image must be supplied as a base64-encoded object.
468            input.model: Model identifier to use for editing. Omit to use the platform default image model.
469            input.output_format: Desired MIME type or format for the returned image. Common values: `"png"`, `"jpeg"`, `"webp"`. Defaults to the model's native format.
470            input.prompt: Natural-language description of the edit to apply to the source image(s).
471            input.quality: Quality preset for the output image. Accepted values and behavior are model-dependent.
472            input.size: Output dimensions as a WxH string, e.g. `"1024x1024"`. Applies to OpenAI-compatible models. Omit to use the model's default.
473            input.style: Style preset applied to the edit. Accepted values and behavior are model-dependent.
474            input.width: Explicit output width in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
475
476        Returns:
477            The resulting edited image, including base64 data or a URL depending on the model.
478        """
479        return await self._http.request(
480            "/api/v1/ai/image/edits",
481            method="POST",
482            body=input,
483            response_type=AIImageResult,
484        )

Edit an image with a text prompt Applies a text-guided edit to one or more source images and returns the resulting image. Pass the source images as base64-encoded objects in the images array alongside a prompt describing the desired modification. The underlying provider is selected by the model parameter. Omit model to use the platform default. Size, quality, style, and format options are forwarded to the provider as-is; unsupported combinations for a given model return a 422 error with the provider's error message. This endpoint requires authentication. The request is billed against the workspace associated with the authenticated user.

Arguments:
  • input: Request body.
  • input.aspect_ratio: Desired aspect ratio of the output, e.g. "1:1" or "16:9". Not supported by all models; omit to use the model's default.
  • input.background: Background treatment for the output. Accepted values and behavior are model-dependent.
  • input.height: Explicit output height in pixels. Takes precedence over size when both are provided. Not supported by all models.
  • input.image_size: Output resolution tier for Gemini models, e.g. "1K", "2K", or "4K". Ignored by non-Gemini models.
  • input.images: One or more source images to edit. Each image must be supplied as a base64-encoded object.
  • input.model: Model identifier to use for editing. Omit to use the platform default image model.
  • input.output_format: Desired MIME type or format for the returned image. Common values: "png", "jpeg", "webp". Defaults to the model's native format.
  • input.prompt: Natural-language description of the edit to apply to the source image(s).
  • input.quality: Quality preset for the output image. Accepted values and behavior are model-dependent.
  • input.size: Output dimensions as a WxH string, e.g. "1024x1024". Applies to OpenAI-compatible models. Omit to use the model's default.
  • input.style: Style preset applied to the edit. Accepted values and behavior are model-dependent.
  • input.width: Explicit output width in pixels. Takes precedence over size when both are provided. Not supported by all models.
Returns:

The resulting edited image, including base64 data or a URL depending on the model.

async def generations( self, input: ImageGenerationsInput) -> archastro.platform.types.ai.AIImageResult:
486    async def generations(self, input: ImageGenerationsInput) -> AIImageResult:
487        """
488        Generate an image from a text prompt
489        Generates one or more images from a natural-language `prompt` using the
490        specified AI image model. The response contains the first generated image;
491        use `n` to request additional images (where supported by the model).
492        The underlying provider is selected by the `model` parameter. Omit `model`
493        to use the platform default. Size, quality, style, and format options are
494        forwarded to the provider as-is; unsupported combinations for a given model
495        return a 422 error with the provider's error message.
496        This endpoint requires authentication. The request is billed against the
497        workspace associated with the authenticated user.
498
499        Args:
500            input: Request body.
501            input.aspect_ratio: Desired aspect ratio of the output, e.g. `"1:1"` or `"16:9"`. Not supported by all models; omit to use the model's default.
502            input.background: Background treatment for the output. Accepted values and behavior are model-dependent.
503            input.height: Explicit output height in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
504            input.image_size: Output resolution tier for Gemini models, e.g. `"1K"`, `"2K"`, or `"4K"`. Ignored by non-Gemini models.
505            input.model: Model identifier to use for generation. Omit to use the platform default image model.
506            input.n: Number of images to generate. Defaults to `1`. Values greater than `1` are only supported by models that allow batch generation.
507            input.output_format: Desired MIME type or format for the returned image. Common values: `"png"`, `"jpeg"`, `"webp"`. Defaults to the model's native format.
508            input.prompt: Natural-language description of the image to generate.
509            input.quality: Quality preset for the output image. Accepted values and behavior are model-dependent.
510            input.size: Output dimensions as a WxH string, e.g. `"1024x1024"`. Applies to OpenAI-compatible models. Omit to use the model's default.
511            input.style: Style preset applied to the generated image. Accepted values and behavior are model-dependent.
512            input.width: Explicit output width in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
513
514        Returns:
515            The generated image, including base64 data or a URL depending on the model.
516        """
517        return await self._http.request(
518            "/api/v1/ai/image/generations",
519            method="POST",
520            body=input,
521            response_type=AIImageResult,
522        )

Generate an image from a text prompt Generates one or more images from a natural-language prompt using the specified AI image model. The response contains the first generated image; use n to request additional images (where supported by the model). The underlying provider is selected by the model parameter. Omit model to use the platform default. Size, quality, style, and format options are forwarded to the provider as-is; unsupported combinations for a given model return a 422 error with the provider's error message. This endpoint requires authentication. The request is billed against the workspace associated with the authenticated user.

Arguments:
  • input: Request body.
  • input.aspect_ratio: Desired aspect ratio of the output, e.g. "1:1" or "16:9". Not supported by all models; omit to use the model's default.
  • input.background: Background treatment for the output. Accepted values and behavior are model-dependent.
  • input.height: Explicit output height in pixels. Takes precedence over size when both are provided. Not supported by all models.
  • input.image_size: Output resolution tier for Gemini models, e.g. "1K", "2K", or "4K". Ignored by non-Gemini models.
  • input.model: Model identifier to use for generation. Omit to use the platform default image model.
  • input.n: Number of images to generate. Defaults to 1. Values greater than 1 are only supported by models that allow batch generation.
  • input.output_format: Desired MIME type or format for the returned image. Common values: "png", "jpeg", "webp". Defaults to the model's native format.
  • input.prompt: Natural-language description of the image to generate.
  • input.quality: Quality preset for the output image. Accepted values and behavior are model-dependent.
  • input.size: Output dimensions as a WxH string, e.g. "1024x1024". Applies to OpenAI-compatible models. Omit to use the model's default.
  • input.style: Style preset applied to the generated image. Accepted values and behavior are model-dependent.
  • input.width: Explicit output width in pixels. Takes precedence over size when both are provided. Not supported by all models.
Returns:

The generated image, including base64 data or a URL depending on the model.

async def models(self) -> ImageModelsResponse:
524    async def models(self) -> ImageModelsResponse:
525        """
526        List available image generation models
527        Returns the list of image generation models available on the platform.
528        Exactly one entry in the list carries `default: true`, indicating the model
529        used when no `model` parameter is supplied to the generation or editing
530        endpoints.
531        This endpoint requires authentication and reflects the models enabled for
532        the authenticated user's workspace.
533
534        Returns:
535            Successful response
536        """
537        return await self._http.request(
538            "/api/v1/ai/image/models",
539            response_type=ImageModelsResponse,
540        )

List available image generation models Returns the list of image generation models available on the platform. Exactly one entry in the list carries default: true, indicating the model used when no model parameter is supplied to the generation or editing endpoints. This endpoint requires authentication and reflects the models enabled for the authenticated user's workspace.

Returns:

Successful response

class AsyncAiResource:
543class AsyncAiResource:
544    def __init__(self, http: HttpClient):
545        self._http = http
546        self.chat = AsyncChatResource(http)
547        self.image = AsyncImageResource(http)
AsyncAiResource(http: archastro.platform.runtime.http_client.HttpClient)
544    def __init__(self, http: HttpClient):
545        self._http = http
546        self.chat = AsyncChatResource(http)
547        self.image = AsyncImageResource(http)
chat
image
class CompletionResource:
550class CompletionResource:
551    def __init__(self, http: SyncHttpClient):
552        self._http = http
553
554    def create(self, input: CompletionCreateInput) -> AICompletionResult:
555        """
556        Create a chat completion
557        Sends a list of messages to the configured AI provider and returns a single
558        completion. Use this endpoint when you want direct, low-level access to the
559        underlying model without any workflow or agent orchestration.
560        The authenticated app must have the `llm_calls` entitlement enabled on its
561        plan. Requests that exceed the plan quota are rejected with `402`. Token
562        usage is recorded against the authenticated app and organization.
563        Supply `tools` and `tool_choice` to enable OpenAI-compatible function
564        calling. Use `server_tools` to activate platform-managed tools such as
565        search that run on the server side before the response is returned.
566
567        Args:
568            input: Request body.
569            input.context: Key-value map used to resolve template variables in message content. Omit if messages contain no templates.
570            input.messages: Ordered list of conversation messages to send to the model.
571            input.opts: Model and sampling configuration for this request.
572
573        Returns:
574            The completed AI response, including the generated message, finish reason, and token usage.
575        """
576        return self._http.request(
577            "/api/v1/ai/chat/completions",
578            method="POST",
579            body=input,
580            response_type=AICompletionResult,
581        )
582
583    def stream(self, input: CompletionStreamInput) -> Iterator[CompletionStreamEvent]:
584        """
585        Stream a chat completion
586        Streams a chat completion over Server-Sent Events. Emits `message_delta`,
587        `message_complete`, `tool_call_*`, `tool_result`, and a terminal `done` (or
588        `error`) event. Same request shape as the non-streaming completion endpoint;
589        the app must have the `llm_calls` entitlement.
590
591        Args:
592            input: Request body.
593            input.context: Key-value map used to resolve template variables in message content. Omit if messages contain no templates.
594            input.messages: Ordered list of conversation messages to send to the model.
595            input.opts: Model and sampling configuration for this request.
596
597        Returns:
598            Server-Sent Events stream
599        """
600        yield from self._http.stream_sse_sync(
601            "/api/v1/ai/chat/completions/stream", method="POST", body=input
602        )
CompletionResource(http: archastro.platform.runtime.http_client.SyncHttpClient)
551    def __init__(self, http: SyncHttpClient):
552        self._http = http
def create( self, input: CompletionCreateInput) -> archastro.platform.types.ai.AICompletionResult:
554    def create(self, input: CompletionCreateInput) -> AICompletionResult:
555        """
556        Create a chat completion
557        Sends a list of messages to the configured AI provider and returns a single
558        completion. Use this endpoint when you want direct, low-level access to the
559        underlying model without any workflow or agent orchestration.
560        The authenticated app must have the `llm_calls` entitlement enabled on its
561        plan. Requests that exceed the plan quota are rejected with `402`. Token
562        usage is recorded against the authenticated app and organization.
563        Supply `tools` and `tool_choice` to enable OpenAI-compatible function
564        calling. Use `server_tools` to activate platform-managed tools such as
565        search that run on the server side before the response is returned.
566
567        Args:
568            input: Request body.
569            input.context: Key-value map used to resolve template variables in message content. Omit if messages contain no templates.
570            input.messages: Ordered list of conversation messages to send to the model.
571            input.opts: Model and sampling configuration for this request.
572
573        Returns:
574            The completed AI response, including the generated message, finish reason, and token usage.
575        """
576        return self._http.request(
577            "/api/v1/ai/chat/completions",
578            method="POST",
579            body=input,
580            response_type=AICompletionResult,
581        )

Create a chat completion Sends a list of messages to the configured AI provider and returns a single completion. Use this endpoint when you want direct, low-level access to the underlying model without any workflow or agent orchestration. The authenticated app must have the llm_calls entitlement enabled on its plan. Requests that exceed the plan quota are rejected with 402. Token usage is recorded against the authenticated app and organization. Supply tools and tool_choice to enable OpenAI-compatible function calling. Use server_tools to activate platform-managed tools such as search that run on the server side before the response is returned.

Arguments:
  • input: Request body.
  • input.context: Key-value map used to resolve template variables in message content. Omit if messages contain no templates.
  • input.messages: Ordered list of conversation messages to send to the model.
  • input.opts: Model and sampling configuration for this request.
Returns:

The completed AI response, including the generated message, finish reason, and token usage.

583    def stream(self, input: CompletionStreamInput) -> Iterator[CompletionStreamEvent]:
584        """
585        Stream a chat completion
586        Streams a chat completion over Server-Sent Events. Emits `message_delta`,
587        `message_complete`, `tool_call_*`, `tool_result`, and a terminal `done` (or
588        `error`) event. Same request shape as the non-streaming completion endpoint;
589        the app must have the `llm_calls` entitlement.
590
591        Args:
592            input: Request body.
593            input.context: Key-value map used to resolve template variables in message content. Omit if messages contain no templates.
594            input.messages: Ordered list of conversation messages to send to the model.
595            input.opts: Model and sampling configuration for this request.
596
597        Returns:
598            Server-Sent Events stream
599        """
600        yield from self._http.stream_sse_sync(
601            "/api/v1/ai/chat/completions/stream", method="POST", body=input
602        )

Stream a chat completion Streams a chat completion over Server-Sent Events. Emits message_delta, message_complete, tool_call_*, tool_result, and a terminal done (or error) event. Same request shape as the non-streaming completion endpoint; the app must have the llm_calls entitlement.

Arguments:
  • input: Request body.
  • input.context: Key-value map used to resolve template variables in message content. Omit if messages contain no templates.
  • input.messages: Ordered list of conversation messages to send to the model.
  • input.opts: Model and sampling configuration for this request.
Returns:

Server-Sent Events stream

class ChatResource:
605class ChatResource:
606    def __init__(self, http: SyncHttpClient):
607        self._http = http
608        self.completions = CompletionResource(http)
609
610    def models(self) -> ChatModelsResponse:
611        """
612        List available AI models
613        Returns the set of AI models that can be used with the chat completion and
614        workflow endpoints. The list reflects models currently enabled for the
615        platform and includes each model's identifier and whether it is the default.
616        Use the `model` field from any entry in `data` as the value for
617        `opts.model` when calling the completions or workflows endpoint.
618
619        Returns:
620            Successful response
621        """
622        return self._http.request("/api/v1/ai/chat/models", response_type=ChatModelsResponse)
606    def __init__(self, http: SyncHttpClient):
607        self._http = http
608        self.completions = CompletionResource(http)
completions
def models(self) -> ChatModelsResponse:
610    def models(self) -> ChatModelsResponse:
611        """
612        List available AI models
613        Returns the set of AI models that can be used with the chat completion and
614        workflow endpoints. The list reflects models currently enabled for the
615        platform and includes each model's identifier and whether it is the default.
616        Use the `model` field from any entry in `data` as the value for
617        `opts.model` when calling the completions or workflows endpoint.
618
619        Returns:
620            Successful response
621        """
622        return self._http.request("/api/v1/ai/chat/models", response_type=ChatModelsResponse)

List available AI models Returns the set of AI models that can be used with the chat completion and workflow endpoints. The list reflects models currently enabled for the platform and includes each model's identifier and whether it is the default. Use the model field from any entry in data as the value for opts.model when calling the completions or workflows endpoint.

Returns:

Successful response

class ImageResource:
625class ImageResource:
626    def __init__(self, http: SyncHttpClient):
627        self._http = http
628
629    def edits(self, input: ImageEditsInput) -> AIImageResult:
630        """
631        Edit an image with a text prompt
632        Applies a text-guided edit to one or more source images and returns the
633        resulting image. Pass the source images as base64-encoded objects in the
634        `images` array alongside a `prompt` describing the desired modification.
635        The underlying provider is selected by the `model` parameter. Omit `model`
636        to use the platform default. Size, quality, style, and format options are
637        forwarded to the provider as-is; unsupported combinations for a given model
638        return a 422 error with the provider's error message.
639        This endpoint requires authentication. The request is billed against the
640        workspace associated with the authenticated user.
641
642        Args:
643            input: Request body.
644            input.aspect_ratio: Desired aspect ratio of the output, e.g. `"1:1"` or `"16:9"`. Not supported by all models; omit to use the model's default.
645            input.background: Background treatment for the output. Accepted values and behavior are model-dependent.
646            input.height: Explicit output height in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
647            input.image_size: Output resolution tier for Gemini models, e.g. `"1K"`, `"2K"`, or `"4K"`. Ignored by non-Gemini models.
648            input.images: One or more source images to edit. Each image must be supplied as a base64-encoded object.
649            input.model: Model identifier to use for editing. Omit to use the platform default image model.
650            input.output_format: Desired MIME type or format for the returned image. Common values: `"png"`, `"jpeg"`, `"webp"`. Defaults to the model's native format.
651            input.prompt: Natural-language description of the edit to apply to the source image(s).
652            input.quality: Quality preset for the output image. Accepted values and behavior are model-dependent.
653            input.size: Output dimensions as a WxH string, e.g. `"1024x1024"`. Applies to OpenAI-compatible models. Omit to use the model's default.
654            input.style: Style preset applied to the edit. Accepted values and behavior are model-dependent.
655            input.width: Explicit output width in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
656
657        Returns:
658            The resulting edited image, including base64 data or a URL depending on the model.
659        """
660        return self._http.request(
661            "/api/v1/ai/image/edits",
662            method="POST",
663            body=input,
664            response_type=AIImageResult,
665        )
666
667    def generations(self, input: ImageGenerationsInput) -> AIImageResult:
668        """
669        Generate an image from a text prompt
670        Generates one or more images from a natural-language `prompt` using the
671        specified AI image model. The response contains the first generated image;
672        use `n` to request additional images (where supported by the model).
673        The underlying provider is selected by the `model` parameter. Omit `model`
674        to use the platform default. Size, quality, style, and format options are
675        forwarded to the provider as-is; unsupported combinations for a given model
676        return a 422 error with the provider's error message.
677        This endpoint requires authentication. The request is billed against the
678        workspace associated with the authenticated user.
679
680        Args:
681            input: Request body.
682            input.aspect_ratio: Desired aspect ratio of the output, e.g. `"1:1"` or `"16:9"`. Not supported by all models; omit to use the model's default.
683            input.background: Background treatment for the output. Accepted values and behavior are model-dependent.
684            input.height: Explicit output height in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
685            input.image_size: Output resolution tier for Gemini models, e.g. `"1K"`, `"2K"`, or `"4K"`. Ignored by non-Gemini models.
686            input.model: Model identifier to use for generation. Omit to use the platform default image model.
687            input.n: Number of images to generate. Defaults to `1`. Values greater than `1` are only supported by models that allow batch generation.
688            input.output_format: Desired MIME type or format for the returned image. Common values: `"png"`, `"jpeg"`, `"webp"`. Defaults to the model's native format.
689            input.prompt: Natural-language description of the image to generate.
690            input.quality: Quality preset for the output image. Accepted values and behavior are model-dependent.
691            input.size: Output dimensions as a WxH string, e.g. `"1024x1024"`. Applies to OpenAI-compatible models. Omit to use the model's default.
692            input.style: Style preset applied to the generated image. Accepted values and behavior are model-dependent.
693            input.width: Explicit output width in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
694
695        Returns:
696            The generated image, including base64 data or a URL depending on the model.
697        """
698        return self._http.request(
699            "/api/v1/ai/image/generations",
700            method="POST",
701            body=input,
702            response_type=AIImageResult,
703        )
704
705    def models(self) -> ImageModelsResponse:
706        """
707        List available image generation models
708        Returns the list of image generation models available on the platform.
709        Exactly one entry in the list carries `default: true`, indicating the model
710        used when no `model` parameter is supplied to the generation or editing
711        endpoints.
712        This endpoint requires authentication and reflects the models enabled for
713        the authenticated user's workspace.
714
715        Returns:
716            Successful response
717        """
718        return self._http.request("/api/v1/ai/image/models", response_type=ImageModelsResponse)
626    def __init__(self, http: SyncHttpClient):
627        self._http = http
def edits( self, input: ImageEditsInput) -> archastro.platform.types.ai.AIImageResult:
629    def edits(self, input: ImageEditsInput) -> AIImageResult:
630        """
631        Edit an image with a text prompt
632        Applies a text-guided edit to one or more source images and returns the
633        resulting image. Pass the source images as base64-encoded objects in the
634        `images` array alongside a `prompt` describing the desired modification.
635        The underlying provider is selected by the `model` parameter. Omit `model`
636        to use the platform default. Size, quality, style, and format options are
637        forwarded to the provider as-is; unsupported combinations for a given model
638        return a 422 error with the provider's error message.
639        This endpoint requires authentication. The request is billed against the
640        workspace associated with the authenticated user.
641
642        Args:
643            input: Request body.
644            input.aspect_ratio: Desired aspect ratio of the output, e.g. `"1:1"` or `"16:9"`. Not supported by all models; omit to use the model's default.
645            input.background: Background treatment for the output. Accepted values and behavior are model-dependent.
646            input.height: Explicit output height in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
647            input.image_size: Output resolution tier for Gemini models, e.g. `"1K"`, `"2K"`, or `"4K"`. Ignored by non-Gemini models.
648            input.images: One or more source images to edit. Each image must be supplied as a base64-encoded object.
649            input.model: Model identifier to use for editing. Omit to use the platform default image model.
650            input.output_format: Desired MIME type or format for the returned image. Common values: `"png"`, `"jpeg"`, `"webp"`. Defaults to the model's native format.
651            input.prompt: Natural-language description of the edit to apply to the source image(s).
652            input.quality: Quality preset for the output image. Accepted values and behavior are model-dependent.
653            input.size: Output dimensions as a WxH string, e.g. `"1024x1024"`. Applies to OpenAI-compatible models. Omit to use the model's default.
654            input.style: Style preset applied to the edit. Accepted values and behavior are model-dependent.
655            input.width: Explicit output width in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
656
657        Returns:
658            The resulting edited image, including base64 data or a URL depending on the model.
659        """
660        return self._http.request(
661            "/api/v1/ai/image/edits",
662            method="POST",
663            body=input,
664            response_type=AIImageResult,
665        )

Edit an image with a text prompt Applies a text-guided edit to one or more source images and returns the resulting image. Pass the source images as base64-encoded objects in the images array alongside a prompt describing the desired modification. The underlying provider is selected by the model parameter. Omit model to use the platform default. Size, quality, style, and format options are forwarded to the provider as-is; unsupported combinations for a given model return a 422 error with the provider's error message. This endpoint requires authentication. The request is billed against the workspace associated with the authenticated user.

Arguments:
  • input: Request body.
  • input.aspect_ratio: Desired aspect ratio of the output, e.g. "1:1" or "16:9". Not supported by all models; omit to use the model's default.
  • input.background: Background treatment for the output. Accepted values and behavior are model-dependent.
  • input.height: Explicit output height in pixels. Takes precedence over size when both are provided. Not supported by all models.
  • input.image_size: Output resolution tier for Gemini models, e.g. "1K", "2K", or "4K". Ignored by non-Gemini models.
  • input.images: One or more source images to edit. Each image must be supplied as a base64-encoded object.
  • input.model: Model identifier to use for editing. Omit to use the platform default image model.
  • input.output_format: Desired MIME type or format for the returned image. Common values: "png", "jpeg", "webp". Defaults to the model's native format.
  • input.prompt: Natural-language description of the edit to apply to the source image(s).
  • input.quality: Quality preset for the output image. Accepted values and behavior are model-dependent.
  • input.size: Output dimensions as a WxH string, e.g. "1024x1024". Applies to OpenAI-compatible models. Omit to use the model's default.
  • input.style: Style preset applied to the edit. Accepted values and behavior are model-dependent.
  • input.width: Explicit output width in pixels. Takes precedence over size when both are provided. Not supported by all models.
Returns:

The resulting edited image, including base64 data or a URL depending on the model.

def generations( self, input: ImageGenerationsInput) -> archastro.platform.types.ai.AIImageResult:
667    def generations(self, input: ImageGenerationsInput) -> AIImageResult:
668        """
669        Generate an image from a text prompt
670        Generates one or more images from a natural-language `prompt` using the
671        specified AI image model. The response contains the first generated image;
672        use `n` to request additional images (where supported by the model).
673        The underlying provider is selected by the `model` parameter. Omit `model`
674        to use the platform default. Size, quality, style, and format options are
675        forwarded to the provider as-is; unsupported combinations for a given model
676        return a 422 error with the provider's error message.
677        This endpoint requires authentication. The request is billed against the
678        workspace associated with the authenticated user.
679
680        Args:
681            input: Request body.
682            input.aspect_ratio: Desired aspect ratio of the output, e.g. `"1:1"` or `"16:9"`. Not supported by all models; omit to use the model's default.
683            input.background: Background treatment for the output. Accepted values and behavior are model-dependent.
684            input.height: Explicit output height in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
685            input.image_size: Output resolution tier for Gemini models, e.g. `"1K"`, `"2K"`, or `"4K"`. Ignored by non-Gemini models.
686            input.model: Model identifier to use for generation. Omit to use the platform default image model.
687            input.n: Number of images to generate. Defaults to `1`. Values greater than `1` are only supported by models that allow batch generation.
688            input.output_format: Desired MIME type or format for the returned image. Common values: `"png"`, `"jpeg"`, `"webp"`. Defaults to the model's native format.
689            input.prompt: Natural-language description of the image to generate.
690            input.quality: Quality preset for the output image. Accepted values and behavior are model-dependent.
691            input.size: Output dimensions as a WxH string, e.g. `"1024x1024"`. Applies to OpenAI-compatible models. Omit to use the model's default.
692            input.style: Style preset applied to the generated image. Accepted values and behavior are model-dependent.
693            input.width: Explicit output width in pixels. Takes precedence over `size` when both are provided. Not supported by all models.
694
695        Returns:
696            The generated image, including base64 data or a URL depending on the model.
697        """
698        return self._http.request(
699            "/api/v1/ai/image/generations",
700            method="POST",
701            body=input,
702            response_type=AIImageResult,
703        )

Generate an image from a text prompt Generates one or more images from a natural-language prompt using the specified AI image model. The response contains the first generated image; use n to request additional images (where supported by the model). The underlying provider is selected by the model parameter. Omit model to use the platform default. Size, quality, style, and format options are forwarded to the provider as-is; unsupported combinations for a given model return a 422 error with the provider's error message. This endpoint requires authentication. The request is billed against the workspace associated with the authenticated user.

Arguments:
  • input: Request body.
  • input.aspect_ratio: Desired aspect ratio of the output, e.g. "1:1" or "16:9". Not supported by all models; omit to use the model's default.
  • input.background: Background treatment for the output. Accepted values and behavior are model-dependent.
  • input.height: Explicit output height in pixels. Takes precedence over size when both are provided. Not supported by all models.
  • input.image_size: Output resolution tier for Gemini models, e.g. "1K", "2K", or "4K". Ignored by non-Gemini models.
  • input.model: Model identifier to use for generation. Omit to use the platform default image model.
  • input.n: Number of images to generate. Defaults to 1. Values greater than 1 are only supported by models that allow batch generation.
  • input.output_format: Desired MIME type or format for the returned image. Common values: "png", "jpeg", "webp". Defaults to the model's native format.
  • input.prompt: Natural-language description of the image to generate.
  • input.quality: Quality preset for the output image. Accepted values and behavior are model-dependent.
  • input.size: Output dimensions as a WxH string, e.g. "1024x1024". Applies to OpenAI-compatible models. Omit to use the model's default.
  • input.style: Style preset applied to the generated image. Accepted values and behavior are model-dependent.
  • input.width: Explicit output width in pixels. Takes precedence over size when both are provided. Not supported by all models.
Returns:

The generated image, including base64 data or a URL depending on the model.

def models(self) -> ImageModelsResponse:
705    def models(self) -> ImageModelsResponse:
706        """
707        List available image generation models
708        Returns the list of image generation models available on the platform.
709        Exactly one entry in the list carries `default: true`, indicating the model
710        used when no `model` parameter is supplied to the generation or editing
711        endpoints.
712        This endpoint requires authentication and reflects the models enabled for
713        the authenticated user's workspace.
714
715        Returns:
716            Successful response
717        """
718        return self._http.request("/api/v1/ai/image/models", response_type=ImageModelsResponse)

List available image generation models Returns the list of image generation models available on the platform. Exactly one entry in the list carries default: true, indicating the model used when no model parameter is supplied to the generation or editing endpoints. This endpoint requires authentication and reflects the models enabled for the authenticated user's workspace.

Returns:

Successful response

class AiResource:
721class AiResource:
722    def __init__(self, http: SyncHttpClient):
723        self._http = http
724        self.chat = ChatResource(http)
725        self.image = ImageResource(http)
722    def __init__(self, http: SyncHttpClient):
723        self._http = http
724        self.chat = ChatResource(http)
725        self.image = ImageResource(http)
chat
image