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

# Eine Nachricht erstellen

> Anthropic-kompatibler Messages-Endpunkt unter `/v1/messages`.

`/v1/messages` akzeptiert Request-Payloads der Anthropic Messages API und gibt Antworten im Anthropic-Format zurück.

## Datenstrom

Setze `stream: true`, um Server-Sent Events im Anthropic-Format (`message_start`, `content_block_*`, `message_delta`, `message_stop`) zu erhalten.

## Hinweise

* Anthropic-Felder zur Tool-Nutzung werden unterstützt.
* `stream: true` funktioniert auch mit Tool-Schleifen. Bei vom Gateway verwalteten Servertools kann Phaseo den Upstream-Zug materialisieren, die Schleife fortsetzen und einen synthetischen Stream erneut ausgeben.
* Das native Format des Anthropic-Websuche-Tools wird auch direkt in `tools` akzeptiert, zum Beispiel `type: "web_search_20250305"`.
* Der Header `X-Phaseo-Strictness` steuert den Umgang mit nicht unterstützten Parametern.

## Servertools

`/v1/messages` unterstützt außerdem diese vom Gateway verwalteten Servertools:

* `gateway:datetime`
* `phaseo:web_search`
* `phaseo:web_fetch`
* `phaseo:advisor`
* `phaseo:image_generation`

Phaseo wandelt diese Tools für den Upstream-Anbieter in ein Anthropic-kompatibles Format um, führt sie serverseitig aus und setzt die Tool-Schleife fort.

## Native Websuche des Anbieters

Wenn ein kompatibles Anthropic-Modell-/Anbieter-Paar native Websuche unterstützt, kannst du die native Tool-Definition direkt übergeben:

```bash theme={null}
curl https://api.phaseo.app/v1/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-4",
    "max_tokens": 512,
    "messages": [
      { "role": "user", "content": "Find the latest Anthropic web search guidance." }
    ],
    "tools": [
      {
        "type": "web_search_20250305",
        "name": "web_search",
        "max_uses": 3,
        "allowed_domains": ["docs.anthropic.com"]
      }
    ],
    "tool_choice": { "type": "tool", "name": "web_search" }
  }'
```

Das Provider-Routing prüft vor der Ausführung weiterhin die Unterstützung von `web_search_options`.

### Beispiel für Datum und Uhrzeit

```bash theme={null}
curl https://api.phaseo.app/v1/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-4",
    "max_tokens": 512,
    "stream": false,
    "messages": [
      { "role": "user", "content": "What time is it in America/New_York right now?" }
    ],
    "tools": [
      {
        "type": "gateway:datetime",
        "parameters": { "timezone": "America/New_York" }
      }
    ],
    "tool_choice": { "type": "auto" }
  }'
```

Bei Verwendung geben die `usage.server_tool_use.*`-Zähler die Aufrufe der Servertools an.


## OpenAPI

````yaml de/openapi/v1/openapi.localized.yaml POST /messages
openapi: 3.0.3
info:
  title: Phaseo Gateway API
  description: >-
    Eine Gateway-API für den Zugriff auf verschiedene KI-Modelle über
    OpenAI-kompatible Endpunkte.
  version: 1.0.0
  contact:
    name: Phaseo
    url: https://phaseo.app
    email: danielbutler500@gmail.com
servers:
  - url: https://api.phaseo.app/v1
    description: Globales Routing
security:
  - BearerAuth: []
tags:
  - name: Gateway
    description: Core Phaseo Gateway operations.
paths:
  /messages:
    post:
      tags:
        - Gateway
      summary: Nachricht erstellen
      description: Erstellt eine Nachricht mit der Anthropic Messages API.
      operationId: createAnthropicMessage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnthropicMessagesRequest'
            examples:
              datetimeServerTool:
                summary: Built-in datetime server tool
                value:
                  model: anthropic/claude-sonnet-4
                  max_tokens: 512
                  stream: false
                  messages:
                    - role: user
                      content: What time is it in America/New_York right now?
                  tools:
                    - type: gateway:datetime
                      parameters:
                        timezone: America/New_York
                  tool_choice:
                    type: auto
      responses:
        '200':
          description: Nachrichtenantwort
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicMessagesResponse'
            text/event-stream:
              schema:
                type: string
      servers:
        - url: https://api.phaseo.app/v1
          description: Globales Routing
        - url: https://eu.api.phaseo.app/v1
          description: Regionales Anbieter-Routing für die EU (nur Text)
        - url: https://us.api.phaseo.app/v1
          description: Regionales Anbieter-Routing für die USA (nur Text)
components:
  schemas:
    AnthropicMessagesRequest:
      type: object
      required:
        - model
        - messages
        - max_tokens
      properties:
        model:
          type: string
        system:
          oneOf:
            - type: string
            - type: array
              items:
                type: object
                properties:
                  type:
                    type: string
                    enum:
                      - text
                  text:
                    type: string
                  cache_control:
                    $ref: '#/components/schemas/CacheControl'
        messages:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/AnthropicMessage'
        max_tokens:
          type: integer
          minimum: 1
        service_tier:
          type: string
          description: >-
            Wählt eine unterstützte Routing- oder Preisstufe auf kompatiblen
            Text-APIs.
          enum:
            - standard
            - default
            - fast
            - ultrafast
            - priority
            - flex
            - batch
        temperature:
          type: number
          minimum: 0
          maximum: 1
        top_p:
          type: number
          minimum: 0
          maximum: 1
        top_k:
          type: integer
          minimum: 1
        tools:
          type: array
          description: Anthropic-kompatible Tools und vom Gateway verwaltete Servertools.
          items:
            oneOf:
              - $ref: '#/components/schemas/AnthropicTool'
              - $ref: '#/components/schemas/GatewayDatetimeToolDefinition'
              - $ref: '#/components/schemas/GatewayWebSearchToolDefinition'
              - $ref: '#/components/schemas/GatewayWebFetchToolDefinition'
              - $ref: '#/components/schemas/SubagentToolDefinition'
              - $ref: '#/components/schemas/FusionToolDefinition'
              - $ref: '#/components/schemas/SearchModelsToolDefinition'
        tool_choice:
          description: >-
            Anthropic-Toolauswahl als Objekt oder Zeichenfolge. Namen von
            Gateway-verwalteten Servertools werden ebenfalls akzeptiert und vom
            Gateway umgeschrieben.
          oneOf:
            - type: object
            - type: string
        stream:
          type: boolean
        metadata:
          type: object
          additionalProperties: true
        session_id:
          type: string
          maxLength: 256
          description: >-
            Eindeutige Kennung, um zusammengehörige Anfragen (zum Beispiel eine
            Unterhaltung oder einen Agenten-Workflow) für die Beobachtbarkeit zu
            gruppieren.
        reasoning:
          $ref: '#/components/schemas/ReasoningConfig'
        stop_sequences:
          type: array
          items:
            type: string
        provider_options:
          $ref: '#/components/schemas/ProviderOptions'
        usage:
          type: boolean
        meta:
          type: boolean
        echo_upstream_request:
          type: boolean
        debug:
          $ref: '#/components/schemas/DebugOptions'
        provider:
          $ref: '#/components/schemas/ProviderRoutingOptions'
    AnthropicMessagesResponse:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
        role:
          type: string
          enum:
            - assistant
        model:
          type: string
        content:
          type: array
          items:
            $ref: '#/components/schemas/AnthropicContentBlock'
        stop_reason:
          type: string
        stop_sequence:
          type: string
        usage:
          $ref: '#/components/schemas/AnthropicUsage'
    CacheControl:
      type: object
      properties:
        type:
          type: string
        ttl:
          type: string
        scope:
          type: string
      additionalProperties: true
    AnthropicMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
        content:
          oneOf:
            - type: string
            - type: array
              items:
                $ref: '#/components/schemas/AnthropicContentBlock'
    AnthropicTool:
      type: object
      required:
        - name
      properties:
        name:
          type: string
        async:
          type: boolean
          description: >-
            Lässt unterstützte OpenAI-Modelle weiterarbeiten, während der
            Aufrufer dieses Tool ausführt. Wird beim Routing zu anderen
            Anbietern ignoriert.
        description:
          type: string
        input_schema:
          type: object
    GatewayDatetimeToolDefinition:
      type: object
      description: >-
        Vom Gateway verwaltetes Servertool. Das Gateway führt die Datums- und
        Uhrzeitabfrage aus und fügt das Ergebnis wieder in den
        Modell-Tool-Aufrufzyklus ein.
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - phaseo:datetime
            - gateway:datetime
        parameters:
          type: object
          properties:
            timezone:
              type: string
              description: IANA-Zeitzonenname (zum Beispiel Europe/London).
          additionalProperties: false
        timezone:
          type: string
          description: Veraltete Kurzform für die Standardzeitzone (IANA).
      additionalProperties: false
    GatewayWebSearchToolDefinition:
      type: object
      description: >-
        Vom Gateway verwaltetes Servertool. Das Gateway führt eine Websuche aus
        und fügt normalisierte Suchergebnisse wieder in den
        Modell-Tool-Aufrufzyklus ein.
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - phaseo:web_search
            - gateway:web_search
        parameters:
          type: object
          properties:
            engine:
              type: string
              enum:
                - auto
                - native
                - exa
                - firecrawl
                - parallel
                - perplexity
                - tinyfish
            max_results:
              type: integer
              minimum: 1
              maximum: 25
            language:
              type: string
            page:
              type: integer
              minimum: 0
              maximum: 10
            include_text:
              type: boolean
            include_highlights:
              type: boolean
          additionalProperties: false
        max_results:
          type: integer
          minimum: 1
          maximum: 25
        engine:
          type: string
          enum:
            - auto
            - native
            - exa
            - firecrawl
            - parallel
            - perplexity
            - tinyfish
        language:
          type: string
        page:
          type: integer
          minimum: 0
          maximum: 10
        include_text:
          type: boolean
        include_highlights:
          type: boolean
      additionalProperties: false
    GatewayWebFetchToolDefinition:
      type: object
      description: >-
        Vom Gateway verwaltetes Servertool. Das Gateway ruft eine HTTP(S)-Seite
        ab, kürzt sie auf eine begrenzte Textmenge und fügt das Ergebnis wieder
        in den Modell-Tool-Aufrufzyklus ein.
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - phaseo:web_fetch
            - gateway:web_fetch
        parameters:
          type: object
          properties:
            max_chars:
              type: integer
              minimum: 1
              maximum: 100000
          additionalProperties: false
        max_chars:
          type: integer
          minimum: 1
          maximum: 100000
      additionalProperties: false
    SubagentToolDefinition:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - phaseo:subagent
        parameters:
          type: object
          additionalProperties: true
    FusionToolDefinition:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - phaseo:fusion
        parameters:
          type: object
          required:
            - analysis_models
          properties:
            analysis_models:
              type: array
              minItems: 2
              maxItems: 8
              items:
                type: string
            model:
              type: string
          additionalProperties: true
    SearchModelsToolDefinition:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - phaseo:search_models
        parameters:
          type: object
          properties:
            max_results:
              type: integer
              minimum: 1
              maximum: 20
    ReasoningConfig:
      type: object
      properties:
        effort:
          type: string
          enum:
            - none
            - minimal
            - low
            - medium
            - high
            - xhigh
            - max
          default: medium
        mode:
          type: string
          enum:
            - standard
            - pro
        summary:
          type: string
          enum:
            - auto
            - concise
            - detailed
          default: auto
        enabled:
          type: boolean
        max_tokens:
          type: integer
          minimum: 0
    ProviderOptions:
      type: object
      description: Optionale anbieterspezifische Optionen.
      properties:
        openai:
          type: object
          properties:
            context_management:
              type: object
              description: Optionale OpenAI-Konfiguration für die Kontextverwaltung.
              properties:
                type:
                  type: string
                  enum:
                    - compaction
                compact_threshold:
                  type: number
              required:
                - type
            prompt_cache_retention:
              type: string
        anthropic:
          type: object
          properties:
            cache_control:
              $ref: '#/components/schemas/CacheControl'
        google:
          type: object
          properties:
            cache_control:
              $ref: '#/components/schemas/CacheControl'
            cached_content:
              type: string
            cache_ttl:
              type: string
    DebugOptions:
      type: object
      description: >-
        Gateway-Debug-Steuerungen. Diese Flags werden niemals an den Anbieter
        weitergeleitet.
      properties:
        enabled:
          type: boolean
        return_upstream_request:
          type: boolean
        return_upstream_response:
          type: boolean
        trace:
          type: boolean
        trace_level:
          type: string
          enum:
            - summary
            - full
    ProviderRoutingOptions:
      type: object
      description: Anbieterrouting-Präferenzen für die Auswahl durch das Gateway.
      properties:
        order:
          type: array
          items:
            type: string
        only:
          type: array
          items:
            type: string
        ignore:
          type: array
          items:
            type: string
        include_alpha:
          type: boolean
          description: >-
            Alpha-Anbieter in das Routing einbeziehen (standardmäßig
            deaktiviert).
        allow_fallbacks:
          type: boolean
          nullable: true
          description: Nach einem Fehler auf einen anderen geeigneten Anbieter ausweichen.
        require_parameters:
          type: boolean
          nullable: true
          description: >-
            Vor dem Routing die Unterstützung der angeforderten Parameter durch
            den Anbieter voraussetzen.
        required_execution_region:
          type: string
          nullable: true
          description: >-
            Das Routing auf Anbieter mit der angeforderten Ausführungsregion
            beschränken.
        required_data_region:
          type: string
          nullable: true
          description: >-
            Das Routing auf Anbieter mit der angeforderten Datenregion
            beschränken.
        require_zero_data_retention:
          type: boolean
          nullable: true
          description: >-
            Das Routing auf Anbieter beschränken, die keine Datenspeicherung
            unterstützen.
        data_collection:
          type: string
          nullable: true
          enum:
            - allow
            - deny
        zdr:
          type: boolean
          nullable: true
        enforce_distillable_text:
          type: boolean
          nullable: true
        quantizations:
          type: array
          nullable: true
          items:
            type: string
        sort:
          oneOf:
            - type: string
            - type: object
              additionalProperties: true
          description: >-
            Anbieter für diese Anfrage sortieren, zum Beispiel nach Preis,
            Latenz oder Durchsatz.
        max_price:
          type: object
          properties:
            prompt:
              oneOf:
                - type: number
                - type: string
            completion:
              oneOf:
                - type: number
                - type: string
            image:
              oneOf:
                - type: number
                - type: string
            audio:
              oneOf:
                - type: number
                - type: string
            request:
              oneOf:
                - type: number
                - type: string
        preferred_min_throughput:
          oneOf:
            - type: number
            - type: object
              additionalProperties:
                type: number
        preferred_max_latency:
          oneOf:
            - type: number
            - type: object
              additionalProperties:
                type: number
    AnthropicContentBlock:
      type: object
      properties:
        type:
          type: string
          enum:
            - text
            - image
            - tool_use
            - tool_result
        text:
          type: string
        cache_control:
          $ref: '#/components/schemas/CacheControl'
        source:
          type: object
          properties:
            type:
              type: string
            media_type:
              type: string
            data:
              type: string
            url:
              type: string
        id:
          type: string
        name:
          type: string
        input:
          type: object
        tool_use_id:
          type: string
        content:
          type: string
    AnthropicUsage:
      type: object
      properties:
        input_tokens:
          type: integer
        output_tokens:
          type: integer
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Authentifizierung mit Bearer-Token

````

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