---
title: Generate text
description: Generate text with SubQ Savant on Chat Completions or the Responses API.
---

> Status: Preview

SubQ Savant (`subq-savant-1.4`) generates text over up to 4M tokens of
context, and reasons before it answers. Call it with the OpenAI SDK, with the
base URL set to `https://api.subq.ai/v1`, on either endpoint below.

## Choose an endpoint

Use Chat Completions if you already have a Chat Completions client or build the
message list yourself. Use Responses for multi-turn work, where SubQ keeps the
history for you.

|                     | Chat Completions                                      | Responses API                                                                 |
| ------------------- | ----------------------------------------------------- | ----------------------------------------------------------------------------- |
| Conversation state  | You send the full `messages[]` each request           | Server stores history; continue with `previous_response_id` or `conversation` |
| System prompt       | `system` role in messages                             | `instructions` (per turn, not inherited)                                      |
| Built-in web search | Not available                                         | `tools: [{ "type": "web_search_preview" }]`                                   |
| Function calling    | Nested shape (`{"type":"function","function":{...}}`) | Flattened shape (`{"type":"function","name":...}`)                            |
| Structured outputs  | `response_format`                                     | `text.format` (flattened shape)                                               |
| File input          | `file` parts (`file_data` or `file_id`)               | `input_file` parts (`file_id` only)                                           |
| Reasoning effort    | Top-level `reasoning_effort`                          | Nested `reasoning.effort`                                                     |
| Output cap          | `max_tokens`                                          | `max_output_tokens`                                                           |
| Stream terminator   | `data: [DONE]`                                        | `response.completed` event                                                    |

## Send a request

The same question on each endpoint. On Chat Completions:

```bash title="cURL"
curl --request POST \
  --url https://api.subq.ai/v1/chat/completions \
  --header "Authorization: Bearer $SUBQ_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "subq-savant-1.4",
  "messages": [
    {
      "role": "user",
      "content": "A vendor contract says: Either party may terminate this Agreement for convenience upon ninety (90) days prior written notice. How much notice do we need to give to cancel? Answer in one sentence."
    }
  ]
}
'
```

```ts title="TypeScript"
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.SUBQ_API_KEY,
  baseURL: "https://api.subq.ai/v1",
});

const completion = await client.chat.completions.create({
  model: "subq-savant-1.4",
  messages: [
    {
      role: "user",
      content:
        "A vendor contract says: Either party may terminate this Agreement for convenience upon ninety (90) days prior written notice. How much notice do we need to give to cancel? Answer in one sentence.",
    },
  ],
});

console.log(completion.choices[0].message.content);
```

```py title="Python"
import os

from openai import OpenAI

client = OpenAI(
    api_key=os.environ["SUBQ_API_KEY"],
    base_url="https://api.subq.ai/v1",
)

completion = client.chat.completions.create(
    model="subq-savant-1.4",
    messages=[
        {
            "role": "user",
            "content": (
                "A vendor contract says: Either party may terminate this "
                "Agreement for convenience upon ninety (90) days prior written "
                "notice. How much notice do we need to give to cancel? Answer "
                "in one sentence."
            ),
        }
    ],
)

print(completion.choices[0].message.content)
```

The answer is in `choices[0].message.content`:

```text
You need to give 90 days' written notice.
```

On Responses:

```bash title="cURL"
curl --request POST \
  --url https://api.subq.ai/v1/responses \
  --header "Authorization: Bearer $SUBQ_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "subq-savant-1.4",
  "input": "A vendor contract says: Either party may terminate this Agreement for convenience upon ninety (90) days prior written notice. How much notice do we need to give to cancel? Answer in one sentence."
}
'
```

```ts title="TypeScript"
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.SUBQ_API_KEY,
  baseURL: "https://api.subq.ai/v1",
});

const response = await client.responses.create({
  model: "subq-savant-1.4",
  input: "A vendor contract says: Either party may terminate this Agreement for convenience upon ninety (90) days prior written notice. How much notice do we need to give to cancel? Answer in one sentence."
});

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

```py title="Python"
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["SUBQ_API_KEY"],
    base_url="https://api.subq.ai/v1",
)

response = client.responses.create(
    model="subq-savant-1.4",
    input="A vendor contract says: Either party may terminate this Agreement for convenience upon ninety (90) days prior written notice. How much notice do we need to give to cancel? Answer in one sentence.",
)

print(response.output_text)
```

The answer is in `output_text`. The OpenAI SDKs build it from the `message`
items and skip the `reasoning` item that usually comes first, so don't read
`output[0]`. With tools, take the last `message` instead. See
[Extracting the assistant text](/endpoints/responses-api/#extracting-the-assistant-text).

## Control reasoning and length

- **Reasoning effort:** `low`, `high` (the default), or `max`. Reasoning can't
  be turned off. Reasoning tokens are billed as output tokens. See
  [Reasoning effort](/endpoints/chat-completions-api/#reasoning-effort).
- **Output cap:** reasoning and the answer share one allowance, so a low cap
  can end before any visible answer. See
  [Token limits](/endpoints/chat-completions-api/#token-limits).
- **Reasoning text** comes back apart from the answer. Parse only the answer.
  See [Reasoning output](/endpoints/chat-completions-api/#reasoning-output).

## Continue a conversation

- **Chat Completions:** append the assistant's reply and the next user message
  to `messages`, and send the whole list again.
- **Responses:** send only the new `input` with the last response's `id` as
  `previous_response_id`. Resend `instructions` each turn. See
  [Multi-turn conversations](/endpoints/responses-api/#multi-turn-conversations).

## Next steps

- [Sending files](/using-the-api/file-inputs/): ask about PDFs and other
  documents.
- [Structured outputs](/using-the-api/structured-outputs/): get JSON that
  matches your schema.
- [Function calling](/using-the-api/function-calling/): let the model call
  your code.
- [Use Savant in a coding agent](/cookbook/coding-agents/): set up OpenCode,
  VS Code, or another OpenAI-compatible agent.
