# Create a response
URL: https://docs.munito.ai/api/createResponse

POST /responses

Create a response with the OpenAI Responses API. Send a string or a list of items in `input`. Set the system prompt with `instructions`.

- Continue a conversation with `previous_response_id`. The server restores its history from responses created with `store: true`.
- Set `stream: true` to receive response events.
- Set `background: true` to generate a response asynchronously, then poll or attach later. A background response is stored.
- Use function `tools` or `text.format` with `json_schema` for structured output.

A response is not stored by default, unlike OpenAI. Send `store: true` to keep it for 30 days. A `max_output_tokens` above the output maximum of the model uses that maximum.

```json
{
  "operationId": "createResponse",
  "parameters": [
    {
      "name": "munito-service-tier",
      "in": "header",
      "description": "priority, standard or flex. The response names the tier that is billed; see x-ratelimit-over-limit. See [Service tiers](https://docs.munito.ai/service-tiers).",
      "schema": {
        "type": "string",
        "enum": [
          "priority",
          "standard",
          "flex"
        ],
        "default": "standard"
      }
    },
    {
      "name": "munito-affinity",
      "in": "header",
      "description": "An opaque token. Send it back with the next request of the conversation, so that the prompt cache can serve it. Without it, the API uses `prompt_cache_key`, `x-session-affinity` or `user`, or `metadata.user_id` on the Messages API, for the same purpose.",
      "schema": {
        "type": "string"
      }
    },
    {
      "name": "munito-overflow",
      "in": "header",
      "description": "off, model, class or any: what may serve a chat request that its own capacity refuses. The response names the step that served it. Off by default. The request keeps its region, and you pay the price of the model that you asked for. Flex, background and free-tier requests do not overflow.",
      "schema": {
        "type": "string",
        "enum": [
          "off",
          "model",
          "class",
          "any"
        ],
        "default": "off"
      }
    },
    {
      "name": "munito-prompt-cache-isolation-key",
      "in": "header",
      "description": "A secret string of up to 256 characters. Requests with different keys never share the prompt cache. The body field prompt_cache_isolation_key does the same. See [Prompt caching](https://docs.munito.ai/features/prompt-caching#isolation).",
      "schema": {
        "type": "string",
        "maxLength": 256
      }
    }
  ],
  "summary": "Create a response",
  "tags": [
    "Responses"
  ],
  "description": "Create a response with the OpenAI Responses API. Send a string or a list of items in `input`. Set the system prompt with `instructions`.\n\n- Continue a conversation with `previous_response_id`. The server restores its history from responses created with `store: true`.\n- Set `stream: true` to receive response events.\n- Set `background: true` to generate a response asynchronously, then poll or attach later. A background response is stored.\n- Use function `tools` or `text.format` with `json_schema` for structured output.\n\nA response is not stored by default, unlike OpenAI. Send `store: true` to keep it for 30 days. A `max_output_tokens` above the output maximum of the model uses that maximum.",
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "required": [
            "model",
            "input"
          ],
          "properties": {
            "model": {
              "type": "string",
              "description": "Model id from GET /models, e.g. `qwen/qwen3.8-27b`.",
              "example": "qwen/qwen3.8-27b"
            },
            "input": {
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "array",
                  "items": {
                    "type": "object"
                  },
                  "description": "Input items: messages, function calls and function-call outputs."
                }
              ],
              "description": "The input: a plain string, or an array of input items (messages, function-call outputs)."
            },
            "instructions": {
              "type": "string",
              "description": "System instructions for this response."
            },
            "previous_response_id": {
              "type": "string",
              "description": "Continue from an earlier response. The server replays that conversation state."
            },
            "store": {
              "type": "boolean",
              "description": "Keep the response for 30 days for later retrieval and for `previous_response_id`.",
              "default": false
            },
            "stream": {
              "type": "boolean",
              "description": "Stream semantic events back as server-sent events.",
              "default": false
            },
            "background": {
              "type": "boolean",
              "description": "Generate server-side and return immediately; poll or attach later. A background response is stored, so `store: false` with `background: true` answers 400.",
              "default": false
            },
            "max_output_tokens": {
              "type": "integer",
              "description": "Maximum output tokens to generate, capped at the model's output maximum."
            },
            "temperature": {
              "type": "number",
              "description": "Sampling temperature (0–2)."
            },
            "tools": {
              "type": "array",
              "description": "OpenAI-style function tools the model may call. A namespace tool groups function tools. The API accepts a hosted web search tool, and the model answers without a search.",
              "items": {
                "type": "object"
              }
            },
            "prompt_cache_isolation_key": {
              "type": "string",
              "maxLength": 256,
              "description": "A secret key. Requests with different keys never share the prompt cache. See [Prompt caching](https://docs.munito.ai/features/prompt-caching#isolation)."
            }
          }
        },
        "example": {
          "model": "qwen/qwen3.8-27b",
          "input": "Summarize the EU AI Act in one paragraph."
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "The response object: the same shape that the final response.completed stream event carries.",
      "headers": {
        "x-request-id": {
          "description": "The id that Munito makes for each request. Quote it to support. OpenAI sends the same header.",
          "schema": {
            "type": "string"
          }
        },
        "munito-region": {
          "description": "The jurisdiction that served the request.",
          "schema": {
            "type": "string"
          }
        },
        "munito-service-tier": {
          "description": "priority, standard or flex. The response names the tier that is billed; see x-ratelimit-over-limit.",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-over-limit": {
          "description": "yes when the request exceeded a rate limit and ran on spare capacity: a free seat of its own tier, or the flex band for background work and OCR. Fireworks sends the same header.",
          "schema": {
            "type": "string"
          }
        },
        "munito-affinity": {
          "description": "An opaque token. Send it back with the next request of the conversation, so that the prompt cache can serve it. Without it, the API uses `prompt_cache_key`, `x-session-affinity` or `user`, or `metadata.user_id` on the Messages API, for the same purpose.",
          "schema": {
            "type": "string"
          }
        },
        "munito-overflow": {
          "description": "off, model, class or any: what may serve a chat request that its own capacity refuses. The response names the step that served it.",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-limit-requests": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-remaining-requests": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-reset-requests": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-limit-tokens": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-remaining-tokens": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-reset-tokens": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-limit-input-tokens": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-remaining-input-tokens": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-reset-input-tokens": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-limit-output-tokens": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-remaining-output-tokens": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-reset-output-tokens": {
          "description": "",
          "schema": {
            "type": "string"
          }
        }
      },
      "content": {
        "application/json": {
          "example": {
            "id": "resp_9f41c2d7b3a8",
            "object": "response",
            "status": "completed",
            "model": "qwen/qwen3.8-27b",
            "output": [
              {
                "type": "message",
                "id": "msg_5b1e88a04c21",
                "role": "assistant",
                "status": "completed",
                "content": [
                  {
                    "type": "output_text",
                    "text": "The EU AI Act is the first comprehensive AI law: a risk-based framework that bans a narrow set of unacceptable uses, imposes strict obligations on high-risk systems, adds transparency duties for general-purpose models, and phases in enforcement with fines of up to 7% of global turnover."
                  }
                ]
              }
            ],
            "usage": {
              "input_tokens": 12,
              "output_tokens": 42,
              "total_tokens": 54
            },
            "previous_response_id": null,
            "store": true
          }
        }
      }
    },
    "401": {
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "object",
                "required": [
                  "message",
                  "type",
                  "param",
                  "code"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "param": {
                    "type": "string",
                    "nullable": true
                  },
                  "code": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      },
      "headers": {
        "x-request-id": {
          "description": "The id that Munito makes for each request. Quote it to support. OpenAI sends the same header.",
          "schema": {
            "type": "string"
          }
        },
        "retry-after": {
          "description": "Seconds to wait before a retry.",
          "schema": {
            "type": "string"
          }
        },
        "www-authenticate": {
          "description": "The scheme that a 401 resource accepts.",
          "schema": {
            "type": "string"
          }
        },
        "allow": {
          "description": "The methods that a 405 resource allows.",
          "schema": {
            "type": "string"
          }
        }
      },
      "description": "Credentials are missing or invalid. Public model discovery also returns this error for invalid credentials."
    },
    "403": {
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "object",
                "required": [
                  "message",
                  "type",
                  "param",
                  "code"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "param": {
                    "type": "string",
                    "nullable": true
                  },
                  "code": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      },
      "headers": {
        "x-request-id": {
          "description": "The id that Munito makes for each request. Quote it to support. OpenAI sends the same header.",
          "schema": {
            "type": "string"
          }
        },
        "retry-after": {
          "description": "Seconds to wait before a retry.",
          "schema": {
            "type": "string"
          }
        },
        "www-authenticate": {
          "description": "The scheme that a 401 resource accepts.",
          "schema": {
            "type": "string"
          }
        },
        "allow": {
          "description": "The methods that a 405 resource allows.",
          "schema": {
            "type": "string"
          }
        }
      },
      "description": "The account or key does not permit this request."
    },
    "421": {
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "object",
                "required": [
                  "message",
                  "type",
                  "param",
                  "code"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "param": {
                    "type": "string",
                    "nullable": true
                  },
                  "code": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      },
      "headers": {
        "x-request-id": {
          "description": "The id that Munito makes for each request. Quote it to support. OpenAI sends the same header.",
          "schema": {
            "type": "string"
          }
        },
        "retry-after": {
          "description": "Seconds to wait before a retry.",
          "schema": {
            "type": "string"
          }
        },
        "www-authenticate": {
          "description": "The scheme that a 401 resource accepts.",
          "schema": {
            "type": "string"
          }
        },
        "allow": {
          "description": "The methods that a 405 resource allows.",
          "schema": {
            "type": "string"
          }
        }
      },
      "description": "The requested region does not permit this request on this endpoint. Read the error before a retry."
    },
    "429": {
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "object",
                "required": [
                  "message",
                  "type",
                  "param",
                  "code"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "param": {
                    "type": "string",
                    "nullable": true
                  },
                  "code": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      },
      "headers": {
        "x-request-id": {
          "description": "The id that Munito makes for each request. Quote it to support. OpenAI sends the same header.",
          "schema": {
            "type": "string"
          }
        },
        "retry-after": {
          "description": "Seconds to wait before a retry.",
          "schema": {
            "type": "string"
          }
        },
        "www-authenticate": {
          "description": "The scheme that a 401 resource accepts.",
          "schema": {
            "type": "string"
          }
        },
        "allow": {
          "description": "The methods that a 405 resource allows.",
          "schema": {
            "type": "string"
          }
        }
      },
      "description": "A request, token, page, or spend limit refuses the request. See [Errors](https://docs.munito.ai/errors) before a retry."
    },
    "500": {
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "object",
                "required": [
                  "message",
                  "type",
                  "param",
                  "code"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "param": {
                    "type": "string",
                    "nullable": true
                  },
                  "code": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      },
      "headers": {
        "x-request-id": {
          "description": "The id that Munito makes for each request. Quote it to support. OpenAI sends the same header.",
          "schema": {
            "type": "string"
          }
        },
        "retry-after": {
          "description": "Seconds to wait before a retry.",
          "schema": {
            "type": "string"
          }
        },
        "www-authenticate": {
          "description": "The scheme that a 401 resource accepts.",
          "schema": {
            "type": "string"
          }
        },
        "allow": {
          "description": "The methods that a 405 resource allows.",
          "schema": {
            "type": "string"
          }
        }
      },
      "description": "An unexpected error prevents a response."
    },
    "503": {
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "object",
                "required": [
                  "message",
                  "type",
                  "param",
                  "code"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "param": {
                    "type": "string",
                    "nullable": true
                  },
                  "code": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      },
      "headers": {
        "x-request-id": {
          "description": "The id that Munito makes for each request. Quote it to support. OpenAI sends the same header.",
          "schema": {
            "type": "string"
          }
        },
        "retry-after": {
          "description": "Seconds to wait before a retry.",
          "schema": {
            "type": "string"
          }
        },
        "www-authenticate": {
          "description": "The scheme that a 401 resource accepts.",
          "schema": {
            "type": "string"
          }
        },
        "allow": {
          "description": "The methods that a 405 resource allows.",
          "schema": {
            "type": "string"
          }
        }
      },
      "description": "The service cannot complete the request now. Follow Retry-After when present."
    },
    "default": {
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "object",
                "required": [
                  "message",
                  "type",
                  "param",
                  "code"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "param": {
                    "type": "string",
                    "nullable": true
                  },
                  "code": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      },
      "headers": {
        "x-request-id": {
          "description": "The id that Munito makes for each request. Quote it to support. OpenAI sends the same header.",
          "schema": {
            "type": "string"
          }
        },
        "retry-after": {
          "description": "Seconds to wait before a retry.",
          "schema": {
            "type": "string"
          }
        },
        "www-authenticate": {
          "description": "The scheme that a 401 resource accepts.",
          "schema": {
            "type": "string"
          }
        },
        "allow": {
          "description": "The methods that a 405 resource allows.",
          "schema": {
            "type": "string"
          }
        }
      },
      "description": "An HTTP error before a response stream starts. See [Errors](https://docs.munito.ai/errors) for status codes and retry rules."
    }
  }
}
```

# Shared API schemas
{
  "securitySchemes": {
    "BearerAuth": {
      "type": "http",
      "scheme": "bearer",
      "description": "Your Munito API key."
    },
    "ApiKeyAuth": {
      "type": "apiKey",
      "in": "header",
      "name": "x-api-key",
      "description": "Your Munito API key."
    }
  }
}