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

# Create response

> JSON body with **`messages`**, a non-empty chat-style array, and optional **`model`**. The server builds the **Responses** `input` from stored history plus the last user turn, sets **`stream: true`**, and **streams** a compatible **Responses** request. Response is JSON or **`text/event-stream`**.

If the last user text is **`/new`**, same as completions: new session and minimal SSE **without** calling inference.

**CORS:** **OPTIONS** returns **204** with no body.



## OpenAPI

````yaml /api-reference/ageneral-chat-openapi.json post /v1/chat/responses
openapi: 3.1.0
info:
  title: Chat
  version: 1.0.0
  description: >-
    **Platform chat** for the Ageneral web app: session-backed conversations
    tied to a **project**, with inference using your **project access**. **Base
    URL:** `https://ageneral.ai`.


    **Not** the inference-only host at `models.ageneral.ai` — use
    **`https://models.ageneral.ai`** instead. That host uses **API keys** only —
    no **`Ageneral-Project-Id`** or session headers.


    **Authentication:** `Authorization: Bearer <session JWT>` from Ageneral
    sign-in.


    **Project scope:** Every route requires header **`Ageneral-Project-Id`**
    with a project you can access.


    **Session:** For **`POST /v1/chat/completions`** and **`POST
    /v1/chat/responses`**, send optional **`Ageneral-Session-Id`** to continue
    an existing session; responses echo the active session id in the
    **`Ageneral-Session-Id`** response header. Omit the header to start a new
    session.
  contact:
    name: Ageneral
    url: https://ageneral.ai
servers:
  - url: https://ageneral.ai
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Chat completions
    description: >-
      OpenAI Chat Completions–compatible body; server merges history and
      defaults model.
  - name: Responses
    description: >-
      Streaming responses compatible with OpenAI **Responses**; request uses
      `model` and `messages`.
  - name: Sessions
    description: List, update metadata, and load stored messages for platform chat.
paths:
  /v1/chat/responses:
    post:
      tags:
        - Responses
      summary: Create response
      description: >-
        JSON body with **`messages`**, a non-empty chat-style array, and
        optional **`model`**. The server builds the **Responses** `input` from
        stored history plus the last user turn, sets **`stream: true`**, and
        **streams** a compatible **Responses** request. Response is JSON or
        **`text/event-stream`**.


        If the last user text is **`/new`**, same as completions: new session
        and minimal SSE **without** calling inference.


        **CORS:** **OPTIONS** returns **204** with no body.
      operationId: platformChatResponses
      parameters:
        - $ref: '#/components/parameters/AgeneralProjectId'
        - $ref: '#/components/parameters/AgeneralSessionIdOptional'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PlatformChatResponsesRequest'
      responses:
        '200':
          description: Success. JSON or SSE stream.
          headers:
            Ageneral-Session-Id:
              description: Active platform chat session id after this request.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponsesResponse'
            text/event-stream:
              schema:
                type: string
        '400':
          description: >-
            Bad request — missing project header, invalid `messages`, or
            similar.
        '401':
          description: Missing or invalid session JWT.
        '402':
          description: Insufficient balance.
        '403':
          description: User cannot access this project.
        '404':
          description: Session id invalid for this user and project.
        '502':
          description: Inference request failed.
        '503':
          description: Billing, model access, or chat persistence not configured.
      security:
        - bearerAuth: []
components:
  parameters:
    AgeneralProjectId:
      name: Ageneral-Project-Id
      in: header
      required: true
      schema:
        type: string
      description: Project id. You must be a member with access.
    AgeneralSessionIdOptional:
      name: Ageneral-Session-Id
      in: header
      required: false
      schema:
        type: string
      description: >-
        Existing platform chat session to continue. Omit to create a new session
        on first non-`/new` turn.
  schemas:
    PlatformChatResponsesRequest:
      type: object
      required:
        - messages
      description: >-
        At least one chat-style message; last user text drives the turn.
        **`model`** is optional when a server default applies.
      properties:
        model:
          type: string
          example: openai/gpt-4o-mini
        messages:
          type: array
          minItems: 1
          items:
            type: object
            additionalProperties: true
      additionalProperties: true
    ResponsesResponse:
      type: object
      description: OpenAI-compatible Responses output when not streaming.
      additionalProperties: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Session JWT from Ageneral sign-in. Send as `Authorization: Bearer
        <token>`.

````