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

# 建立回應

> OpenAI Responses API for stateful flows, reasoning-specific options, and newer OpenAI tooling patterns.



## OpenAPI

````yaml api-reference/openapi.json POST /v1/responses
openapi: 3.1.0
info:
  title: DGrid AI Gateway API
  description: >-
    A single, unified API to access 200+ leading AI models. OpenAI-, Claude-,
    and Gemini-compatible endpoints for chat, completions, embeddings, images,
    audio, and moderations.
  version: 1.0.0
  contact:
    name: DGrid AI
    url: https://dgrid.ai
servers:
  - url: https://api.dgrid.ai
    description: DGrid AI Gateway
security:
  - bearerAuth: []
paths:
  /v1/responses:
    post:
      tags:
        - Chat
      summary: Create response
      description: >-
        OpenAI Responses API for stateful flows, reasoning-specific options, and
        newer OpenAI tooling patterns.
      operationId: createResponse
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
              properties:
                model:
                  type: string
                  description: Target model ID.
                  example: openai/gpt-4o
                input:
                  description: Input text or structured input items.
                  oneOf:
                    - type: string
                    - type: array
                      items:
                        type: object
                stream:
                  type: boolean
                  default: false
                  description: Enable streaming.
            example:
              model: openai/gpt-4o
              input: Hello from DGrid.
      responses:
        '200':
          description: Response object.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: Response identifier.
                  object:
                    type: string
                    description: Always `response`.
                  created_at:
                    type: integer
                    description: Creation timestamp.
                  status:
                    type: string
                    description: Response lifecycle state.
                  model:
                    type: string
                    description: Model used for inference.
                  output:
                    type: array
                    description: Output items.
                    items:
                      type: object
                      properties:
                        type:
                          type: string
                          description: Typically `message`.
                        id:
                          type: string
                        status:
                          type: string
                        role:
                          type: string
                          description: Output role.
                        content:
                          type: array
                          description: Output content blocks.
                          items:
                            type: object
                            properties:
                              type:
                                type: string
                                description: '`output_text` for text payloads.'
                              text:
                                type: string
                                description: Output text.
                  usage:
                    $ref: '#/components/schemas/Usage'
        '400':
          $ref: '#/components/responses/BadRequest'
components:
  schemas:
    Usage:
      type: object
      description: Token usage breakdown.
      properties:
        prompt_tokens:
          type: integer
        completion_tokens:
          type: integer
        total_tokens:
          type: integer
        prompt_tokens_details:
          type: object
          properties:
            cached_tokens:
              type: integer
            text_tokens:
              type: integer
            audio_tokens:
              type: integer
            image_tokens:
              type: integer
        completion_tokens_details:
          type: object
          properties:
            text_tokens:
              type: integer
            audio_tokens:
              type: integer
            reasoning_tokens:
              type: integer
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            param:
              type: string
            code:
              type: string
  responses:
    BadRequest:
      description: Invalid request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your DGrid API key. All endpoints use `Authorization: Bearer
        <DGRID_API_KEY>`.

````