> ## 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.

# Python SDK Usage

> Endpoint-by-endpoint examples using the Python SDK.

## Setup

```python theme={null}
from phaseo import Phaseo

client = Phaseo(api_key="your-api-key")
```

## Chat completions

```python theme={null}
completion = client.generate_text(
    {
        "model": "openai/gpt-4o-mini",
        "messages": [{"role": "user", "content": "Hi!"}],
    }
)

for chunk in client.stream_chat(
    {
        "model": "openai/gpt-4o-mini",
        "messages": [{"role": "user", "content": "Stream a story"}],
    }
):
    if chunk.get("text"):
        print(chunk["text"], end="", flush=True)
```

## Responses

```python theme={null}
resp = client.generate_response(
    {
        "model": "openai/gpt-4.1",
        "input": [{"role": "user", "content": [{"type": "input_text", "text": "Summarise"}]}],
    }
)

for chunk in client.stream_responses(
    {
        "model": "openai/gpt-4.1",
        "input": [{"role": "user", "content": [{"type": "input_text", "text": "Stream it"}]}],
    }
):
    if chunk.get("text"):
        print(chunk["text"], end="", flush=True)
```

## Messages (Anthropic-compatible)

```python theme={null}
message = client.generate_message(
    {
        "model": "anthropic/claude-3-5-sonnet-latest",
        "messages": [{"role": "user", "content": "Hello from messages API"}],
        "max_tokens": 128,
    }
)

for chunk in client.stream_message(
    {
        "model": "anthropic/claude-3-5-sonnet-latest",
        "messages": [{"role": "user", "content": "Stream a short hello"}],
        "max_tokens": 128,
        "stream": True,
    }
):
    if chunk.get("text"):
        print(chunk["text"], end="", flush=True)
```

## Embeddings and moderations

```python theme={null}
embedding = client.generate_embedding(
    {"model": "openai/text-embedding-3-large", "input": "Sample text"}
)

moderation = client.generate_moderation(
    {"model": "openai/omni-moderation-latest", "input": "Text to check"}
)
```

## Models and health

```python theme={null}
models = client.get_models()
health = client.get_health()
```

## Control-plane helpers

```python theme={null}
providers = client.list_providers()
credits = client.get_credits({"team_id": "your-team-id"})
activity = client.get_activity({"team_id": "your-team-id", "days": 30})
```

## Images and audio

```python theme={null}
image = client.generate_image(
    {"model": "openai/gpt-image-1", "prompt": "A lighthouse at golden hour"}
)

transcription = client.generate_transcription(
    {"model": "openai/gpt-4o-transcribe", "audio_b64": "base64-audio"}
)

speech = client.generate_speech(
    {"model": "openai/gpt-4o-mini-tts", "input": "Hello world"}
)
```

## Batches

```python theme={null}
batch = client.create_batch(
    {
        "endpoint": "responses",
        "input_file_id": "file_123",
        "completion_window": "24h",
        "session_id": "agent-run-42",
    }
)

status = client.get_batch(batch["id"])
```

## Files, generations, and video jobs

```python theme={null}
uploaded = client.upload_file(
    purpose="batch",
    file="data:application/json;base64,eyJ0ZXN0Ijp0cnVlfQ==",
)

generation = client.get_generation("G-01ABC...")

job = client.generate_video(
    {"model": "openai/sora-2", "prompt": "A mountain sunrise"}
)
```

## Error handling

```python theme={null}
try:
    client.generate_text({"model": "invalid", "messages": []})
except Exception as exc:
    print(f"API error: {exc}")
```

## Configuration options

```python theme={null}
from phaseo import Phaseo

client = Phaseo(
    api_key="your-api-key",
    base_url="https://api.phaseo.app/v1",
    timeout=30.0,
)
```


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