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

# OpenAI Responses

> Use Prism through the OpenAI Responses API wire format.

Prism exposes a stateless OpenAI Responses-compatible endpoint. Use it with
OpenAI SDK clients that call `client.responses.create()`.

## Create a response

```http theme={"theme":{"light":"github-light","dark":"github-dark"}}
POST https://api.prisminference.com/v1/responses
```

<CodeGroup>
  ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import OpenAI from "openai";

  const client = new OpenAI({
    apiKey: process.env.PRISM_API_KEY,
    baseURL: "https://api.prisminference.com/v1",
  });

  const response = await client.responses.create({
    model: "prism/deepseek-v4.1-flash",
    instructions: "You are a senior TypeScript engineer.",
    input: "Write a bounded concurrency helper.",
    store: false,
  });

  console.log(response.output_text);
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import os
  from openai import OpenAI

  client = OpenAI(
      api_key=os.environ["PRISM_API_KEY"],
      base_url="https://api.prisminference.com/v1",
  )

  response = client.responses.create(
      model="prism/deepseek-v4.1-flash",
      instructions="You are a senior Python engineer.",
      input="Write a bounded concurrency helper.",
      store=False,
  )

  print(response.output_text)
  ```

  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl --fail-with-body "https://api.prisminference.com/v1/responses" \
    -H "Authorization: Bearer $PRISM_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "prism/deepseek-v4.1-flash",
      "instructions": "You are a senior TypeScript engineer.",
      "input": "Write a bounded concurrency helper.",
      "store": false
    }'
  ```
</CodeGroup>

Assistant text is available in `output_text` and in the `output` message item.
Function calls are returned as `function_call` output items. Free-form custom
tool calls are returned as `custom_tool_call` output items.

## Body parameters

| Field                 | Type              | Required | Description                                                      |
| --------------------- | ----------------- | -------- | ---------------------------------------------------------------- |
| `model`               | string            | Yes      | A supported [Prism model ID](/models).                           |
| `input`               | string or item\[] | Yes      | Text, images, messages, and prior function or custom tool items. |
| `instructions`        | string            | No       | System or developer instructions.                                |
| `stream`              | boolean           | No       | Return Responses API Server-Sent Events.                         |
| `max_output_tokens`   | integer           | No       | Maximum generated tokens, including reasoning tokens.            |
| `tools`               | tool\[]           | No       | Function, custom, and namespace tools available to the model.    |
| `tool_choice`         | string or object  | No       | Control whether and which supported tool is called.              |
| `parallel_tool_calls` | boolean           | No       | Allow independent function calls in one turn.                    |
| `text.format`         | object            | No       | Request text, JSON object, or JSON Schema output.                |
| `reasoning.effort`    | string            | No       | `none`, `low`, `medium`, or `high`. On at `high` when unset.     |
| `temperature`         | number            | No       | Sampling temperature from 0 to 2.                                |
| `top_p`               | number            | No       | Nucleus sampling probability from 0 to 1.                        |
| `store`               | boolean           | No       | `true` is unsupported; Prism does not persist response content.  |

Reasoning is on by default and appears as a `reasoning` output item before the
message. Send `reasoning: { "effort": "none" }` to skip it and receive answer
text as the first output. See
[Chat Completions reasoning](/api-reference/chat-completions#reasoning) for the
effort levels.

## Image input

For `prism/deepseek-v4.1-flash`, include an `input_image` part in a user
message. `image_url` accepts a base64 data URL:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "model": "prism/deepseek-v4.1-flash",
  "input": [
    {
      "role": "user",
      "content": [
        { "type": "input_text", "text": "What is in this image?" },
        {
          "type": "input_image",
          "image_url": "data:image/png;base64,iVBORw0KGgo...",
          "detail": "auto"
        }
      ]
    }
  ]
}
```

JPEG, PNG, GIF, and WebP are supported. Remote URLs and OpenAI file IDs are not
accepted, so send image bytes through `image_url`. `prism/deepseek-v4-flash` is
text-only, and the complete request must fit within the 4 MiB request limit.

## Continue a tool loop

Return prior output items explicitly in the next request:

```typescript theme={"theme":{"light":"github-light","dark":"github-dark"}}
const call = response.output.find((item) => item.type === "function_call");

if (call?.type === "function_call") {
  const result = await runFunction(call.name, JSON.parse(call.arguments));

  const final = await client.responses.create({
    model: "prism/deepseek-v4.1-flash",
    input: [
      { role: "user", content: "What is the weather in San Francisco?" },
      call,
      {
        type: "function_call_output",
        call_id: call.call_id,
        output: JSON.stringify(result),
      },
    ],
    tools,
    store: false,
  });

  console.log(final.output_text);
}
```

## Use a custom tool

Custom tools accept free-form string input instead of JSON arguments. Prism
supports unconstrained text and `lark` or `regex` grammar declarations:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "type": "custom",
  "name": "apply_patch",
  "description": "Apply a patch to files.",
  "format": {
    "type": "grammar",
    "syntax": "lark",
    "definition": "start: patch"
  }
}
```

Prism presents the custom tool to the provider as a function with one string
field named `input`. Provider calls are converted back to
`custom_tool_call` items:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "type": "custom_tool_call",
  "call_id": "call_123",
  "name": "apply_patch",
  "input": "*** Begin Patch\n*** End Patch"
}
```

Return the result in the next request as a `custom_tool_call_output` item with
the same `call_id`. Keep the tool declaration in each stateless request.

<Warning>
  Grammar definitions are included as model instructions but are not enforced
  during provider decoding. Validate custom-tool input before executing it.
</Warning>

## Use namespace tools

Namespaces group related function or custom tools:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "type": "namespace",
  "name": "mcp__node_repl",
  "description": "Node REPL tools.",
  "tools": [
    {
      "type": "function",
      "name": "execute",
      "description": "Execute JavaScript.",
      "parameters": {
        "type": "object",
        "properties": {
          "code": { "type": "string" }
        },
        "required": ["code"]
      }
    }
  ]
}
```

Prism flattens each namespace member into a provider function. Returned
`function_call` items restore the member name and include its namespace:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "type": "function_call",
  "call_id": "call_456",
  "name": "execute",
  "namespace": "mcp__node_repl",
  "arguments": "{\"code\":\"console.log('ready')\"}"
}
```

Round-trip the `namespace` field with the function call in later requests.

## Stream a response

```typescript theme={"theme":{"light":"github-light","dark":"github-dark"}}
const stream = await client.responses.create({
  model: "prism/deepseek-v4.1-flash",
  input: "Explain optimistic locking.",
  stream: true,
  store: false,
});

for await (const event of stream) {
  if (event.type === "response.output_text.delta") {
    process.stdout.write(event.delta);
  }
}
```

Streams use typed Responses events, including `response.created`,
`response.output_item.added`, `response.output_text.delta`,
`response.output_item.done`, and `response.completed`.

## Stateless compatibility

Prism applies zero data retention and does not implement stored Responses
resources. Keep the conversation in your application and resend the required
input items on each request.

Prism accepts `client_metadata`, `service_tier`, and Codex reasoning stream
options for client compatibility. These fields do not change provider routing
or decoding behavior.

The following OpenAI features are not supported:

* `previous_response_id`
* `store: true`
* `background: true`
* other Responses tool types such as web search, file search, computer use,
  shell, local shell, and native apply patch
* response retrieval, cancellation, deletion, and input-item subresources

Unsupported fields return an OpenAI-compatible `400` error rather than being
silently ignored.
