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

# Responses API

> Create a model response with the OpenAI Responses format

Create a model response from text or message input.

## Create Response

`POST /responses`

Create a text response using OpenAI's response format.

### Request Body

<ParamField body="model" type="string" required>
  The model to use for response (e.g., "gpt-4o")
</ParamField>

<ParamField body="input" type="string | array" required>
  The input text or array of messages to generate responses for
</ParamField>

<ParamField body="instructions" type="string">
  System instructions for the model
</ParamField>

<ParamField body="max_output_tokens" type="integer">
  Maximum number of output tokens to generate
</ParamField>

<ParamField body="temperature" type="number">
  Temperature for randomness (default: 1.0)
</ParamField>

<ParamField body="top_p" type="number">
  Nucleus sampling parameter (default: 1.0)
</ParamField>

<ParamField body="stream" type="boolean">
  Whether to stream back partial progress (default: false)
</ParamField>

<ParamField body="tools" type="array">
  Array of tools available to the model
</ParamField>

<ParamField body="tool_choice" type="string | object">
  Tool choice preference ("auto", "none", or specific tool object)
</ParamField>

<ParamField body="web_search" type="boolean">
  Enable web search capabilities (default: false)
</ParamField>

<ParamField body="reasoning" type="object">
  Reasoning configuration with effort level and summary options
</ParamField>

<ParamField body="metadata" type="object">
  Additional metadata as key-value pairs
</ParamField>

### Response

Returns a response object with the generated text.

### Example

<CodeGroup>
  ```javascript Node.js theme={null}
  const response = await fetch('https://api.electronhub.ai/v1/responses', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      model: 'gpt-4o',
      input: 'Write a short story about a robot:',
      instructions: 'Write in a creative and engaging style',
      max_output_tokens: 500,
      temperature: 0.7
    })
  });

  const data = await response.json();
  console.log(data);
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.electronhub.ai/v1/responses',
      headers={
          'Authorization': 'Bearer YOUR_API_KEY',
          'Content-Type': 'application/json'
      },
      json={
          'model': 'gpt-4o',
          'input': 'Write a short story about a robot:',
          'instructions': 'Write in a creative and engaging style',
          'max_output_tokens': 500,
          'temperature': 0.7
      }
  )

  print(response.json())
  ```

  ```bash cURL theme={null}
  curl -X POST "https://api.electronhub.ai/v1/responses" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-4o",
      "input": "Write a short story about a robot:",
      "instructions": "Write in a creative and engaging style",
      "max_output_tokens": 500,
      "temperature": 0.7
    }'
  ```
</CodeGroup>


## OpenAPI

````yaml POST /responses
openapi: 3.0.1
info:
  title: Electron Hub API
  description: >-
    Unified API platform integrating 200+ AI models for chat, image generation,
    speech-to-text, embeddings, and more.
  version: 1.0.0
  contact:
    name: Electron Hub Support
    email: support@electronhub.ai
    url: https://discord.com/invite/electronhub
  license:
    name: MIT
servers:
  - url: https://api.electronhub.ai/v1
    description: Production API v1
security:
  - bearerAuth: []
paths:
  /responses:
    post:
      summary: Create Response (OpenAI)
      description: Create a response using OpenAI's new response format
      operationId: createResponse
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResponseRequest'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseOutput'
components:
  schemas:
    ResponseRequest:
      type: object
      required:
        - model
        - input
      properties:
        model:
          type: string
          example: gpt-4o
        input:
          oneOf:
            - type: string
            - type: array
              items:
                $ref: '#/components/schemas/ResponseMessage'
        instructions:
          type: string
          description: System instructions
        max_output_tokens:
          type: integer
          description: Maximum output tokens
        temperature:
          type: number
          default: 1
        top_p:
          type: number
          default: 1
        stream:
          type: boolean
          default: false
        tools:
          type: array
          items:
            $ref: '#/components/schemas/ResponseTool'
        tool_choice:
          oneOf:
            - type: string
              enum:
                - auto
                - none
            - type: object
          default: auto
        web_search:
          type: boolean
          default: false
        reasoning:
          $ref: '#/components/schemas/ReasoningConfig'
        metadata:
          type: object
          additionalProperties:
            type: string
    ResponseOutput:
      type: object
      required:
        - id
        - object
        - created_at
        - status
        - model
        - output
      properties:
        id:
          type: string
        object:
          type: string
          enum:
            - response
        created_at:
          type: integer
        status:
          type: string
          enum:
            - in_progress
            - completed
            - incomplete
            - errored
        model:
          type: string
        output:
          type: array
          items:
            $ref: '#/components/schemas/ResponseOutputItem'
        usage:
          $ref: '#/components/schemas/ResponseUsage'
    ResponseMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
            - system
        content:
          oneOf:
            - type: string
            - type: array
              items:
                $ref: '#/components/schemas/ResponseContentPart'
    ResponseTool:
      oneOf:
        - $ref: '#/components/schemas/FunctionTool'
        - $ref: '#/components/schemas/WebSearchTool'
    ReasoningConfig:
      type: object
      properties:
        effort:
          type: string
          enum:
            - low
            - medium
            - high
        summary:
          type: boolean
    ResponseOutputItem:
      type: object
      required:
        - id
        - type
        - status
      properties:
        id:
          type: string
        type:
          type: string
          enum:
            - message
            - tool_call
            - tool_result
            - reasoning
        status:
          type: string
          enum:
            - in_progress
            - completed
            - incomplete
            - errored
        role:
          type: string
          enum:
            - assistant
        content:
          type: array
          items:
            $ref: '#/components/schemas/OutputTextContentPart'
    ResponseUsage:
      type: object
      required:
        - input_tokens
        - output_tokens
        - total_tokens
      properties:
        input_tokens:
          type: integer
        input_tokens_details:
          type: object
        output_tokens:
          type: integer
        output_tokens_details:
          type: object
        total_tokens:
          type: integer
    ResponseContentPart:
      oneOf:
        - $ref: '#/components/schemas/InputTextContentPart'
        - $ref: '#/components/schemas/InputImageContentPart'
        - $ref: '#/components/schemas/OutputTextContentPart'
    FunctionTool:
      type: object
      required:
        - type
        - function
      properties:
        type:
          type: string
          enum:
            - function
        function:
          $ref: '#/components/schemas/FunctionDefinition'
    WebSearchTool:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - web_search
        web_search:
          type: object
    OutputTextContentPart:
      type: object
      required:
        - type
        - text
      properties:
        type:
          type: string
          enum:
            - output_text
        text:
          type: string
        annotations:
          type: array
          items: {}
    InputTextContentPart:
      type: object
      required:
        - type
        - text
      properties:
        type:
          type: string
          enum:
            - input_text
        text:
          type: string
    InputImageContentPart:
      type: object
      required:
        - type
        - image_url
      properties:
        type:
          type: string
          enum:
            - input_image
        image_url:
          type: string
          format: uri
    FunctionDefinition:
      type: object
      required:
        - name
      properties:
        name:
          type: string
        description:
          type: string
        parameters:
          type: object
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Enter your API key (starts with 'ek-')

````