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

# Responses API

> Use the Responses API to create and stream model responses.

The Responses API is an alternative to the Chat Completions API with a different request shape — it takes an `input` string instead of a `messages` array.

## Create a response

> [tab] Python
>
> ```python theme={null}
> from meshapi import MeshAPI, ResponsesParams
>
> client = MeshAPI(base_url="https://api.meshapi.ai", token="rsk_...")
>
> resp = client.responses.create(
>     ResponsesParams(
>         model="openai/gpt-4o-mini",
>         input="Reply with exactly the word: ok",
>         max_output_tokens=16,
>     )
> )
> print(resp.id)
> print(resp.model)
> ```

> [tab] Node.js
>
> ```javascript theme={null}
> const resp = await client.responses.create({
>   model: "openai/gpt-4o-mini",
>   input: "Reply with exactly the word: ok",
>   max_output_tokens: 16,
> });
> console.log(resp.id);
> console.log(resp.status);
> ```

> [tab] Go
>
> ```go theme={null}
> maxTokens := 16
> model := "openai/gpt-4o-mini"
> resp, err := client.Responses.Create(ctx, meshapi.ResponsesParams{
>     Model:           &model,
>     Input:           "Reply with exactly the word: ok",
>     MaxOutputTokens: &maxTokens,
> })
> if err != nil {
>     log.Fatal(err)
> }
> if resp.ID != nil {
>     fmt.Println("id:", *resp.ID)
> }
> if resp.Status != nil {
>     fmt.Println("status:", *resp.Status)
> }
> ```

## Stream a response

> [tab] Python
>
> ```python theme={null}
> from meshapi import MeshAPIError
>
> try:
>     events = list(
>         client.responses.stream(
>             ResponsesParams(
>                 model="openai/gpt-4o-mini",
>                 input="Count from 1 to 3.",
>                 max_output_tokens=32,
>             )
>         )
>     )
>     print(f"received {len(events)} events")
> except MeshAPIError as e:
>     if e.status == 501:
>         print("Streaming not supported for this model")
>     else:
>         raise
> ```

> [tab] Node.js
>
> ```javascript theme={null}
> let events = 0;
> for await (const _event of client.responses.create({
>   model: "openai/gpt-4o-mini",
>   input: "Count from 1 to 3.",
>   max_output_tokens: 20,
>   stream: true,
> })) {
>   events++;
> }
> console.log(`received ${events} events`);
> ```

> [tab] Go
>
> ```go theme={null}
> maxTokens := 32
> model := "openai/gpt-4o-mini"
> eventCh, errCh := client.Responses.Stream(ctx, meshapi.ResponsesParams{
>     Model:           &model,
>     Input:           "Count from 1 to 3.",
>     MaxOutputTokens: &maxTokens,
> })
>
> count := 0
> for range eventCh {
>     count++
> }
> if err := <-errCh; err != nil {
>     log.Fatal(err)
> }
> fmt.Printf("received %d events\n", count)
> ```

## Parameters

| Parameter | Description |
| - | - |
| `model` | Model ID |
| `input` | The input text prompt |
| `max_output_tokens` | Maximum tokens in the response |

## Retrieve background responses

Use `list` and `get` for persisted/background response jobs. A response returned from a synchronous `create` call is not guaranteed to be retrievable later by ID.

The SDKs expose both as `client.responses.list()` and `client.responses.get(id)` in Python
and Node.js, and `client.Responses.List` and `client.Responses.Get` in Go.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.