> ## Documentation Index
> Fetch the complete documentation index at: https://phaseo.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Phaseo Gateway base URL: https://api.phaseo.app/v1. Send `Authorization: Bearer $PHASEO_API_KEY` with every request.
> Model IDs look like `provider/model`, for example `openai/gpt-6-astra`. Do not guess IDs: list them with `GET /v1/models` or check https://phaseo.app/models. `phaseo/free` routes to an available free model and needs no wallet balance.
> For new text integrations prefer `POST /v1/responses`. `POST /v1/chat/completions` (OpenAI format) and `POST /v1/messages` (Anthropic format) suit existing code.
> The full API contract is https://phaseo.app/docs/openapi/v1/openapi.yaml. Official SDKs: `@phaseo/sdk` (TypeScript) and `phaseo` (Python), plus Go, C#, PHP, Ruby and Rust.
> Search these docs over MCP at https://phaseo.app/docs/mcp, and install Phaseo skills with `npx skills add https://phaseo.app/docs`. If a page is wrong or out of date, report it with the MCP `submit_feedback` tool.
> Manage Phaseo accounts with the `phaseo` CLI (`npm install -g @phaseo/cli`, then `phaseo login` or `phaseo login --device-code`), the `/v1` Management API or the MCP server at `https://mcp.phaseo.app/mcp?access=manage`. Do not send users to the dashboard for account tasks. A person is still needed for sign-up, approving a sign-in, paying the first top-up on the checkout link that `phaseo credits add` returns when no card is saved, confirming each saved-card top-up from the emailed link, and account security (password, MFA, passkeys). Create API keys with `phaseo keys create --name <name> --json`; never guess one. Credit top-ups need `phaseo login --scopes billing:write` first. Task map: https://phaseo.app/docs/v1/developers/manage-from-an-agent.md.

# Image Generation

> Let models create images through A Phaseo server tool.

Use `phaseo:image_generation` when the model should be able to create an image while it is answering. Phaseo exposes a managed tool to the model, executes the image request server-side, and feeds the image result back into the model loop.

## Request

```bash theme={null}
curl https://api.phaseo.app/v1/responses \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5-nano",
    "input": "Design a wide product concept image for a compact desktop synthesizer.",
    "tools": [
      {
        "type": "phaseo:image_generation",
        "parameters": {
          "model": "openai/gpt-image-2",
          "quality": "high",
          "aspect_ratio": "16:9",
          "output_format": "png"
        }
      }
    ]
  }'
```

## Parameters

| Parameter | Type | Description |
| - | - | - |
| `model` | string | Optional image-capable model ID. Defaults to `openai/gpt-image-2` when neither the tool nor tool call provides a model. |
| `quality` | string | Optional provider quality hint, such as `low`, `medium`, or `high`. |
| `size` | string | Optional image size hint. |
| `aspect_ratio` | string | Optional aspect ratio, such as `1:1`, `16:9`, or `9:16`. |
| `background` | string | Optional background mode hint. |
| `output_format` | string | Optional output format, such as `png`, `jpeg`, or `webp`. |
| `output_compression` | integer | Optional provider compression hint. |
| `moderation` | string | Optional provider moderation hint. |

The model supplies the final `prompt` when it calls the tool. Tool-level parameters provide defaults and constraints for that call.

The tool call may also send `description` instead of `prompt`. Phaseo treats `description` as a prompt alias for compatibility with model-generated image descriptions.

## Tool Result

The result is returned to the model as JSON:

```json theme={null}
{
  "status": "ok",
  "model": "openai/gpt-image-2",
  "imageUrl": "https://...",
  "mime_type": "image/png"
}
```

Some providers return base64 image data instead:

```json theme={null}
{
  "status": "ok",
  "model": "openai/gpt-image-2",
  "b64_json": "...",
  "mime_type": "image/png"
}
```

## Usage And Pricing

Image generation usage is included in the parent response usage when the image model reports token usage. Phaseo also records:

```json theme={null}
{
  "usage": {
    "server_tool_use": {
      "image_generation_requests": 1
    }
  }
}
```

Pricing cards can bill this with the `server_tool_image_generation_requests` meter. The underlying image model usage can still be billed through its normal model pricing.

## Related

* [Server Tools](https://phaseo.app/docs/v1/guides/server-tools/index.md)
* [Tool Calling](https://phaseo.app/docs/v1/guides/tool-calling.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.