[Integrations](https://spiral.ai/integrations) › [opencode](https://spiral.ai/integrations/opencode) › [GPT-4.1 mini](https://spiral.ai/integrations/opencode/gpt-4-1-mini)

# How to Use GPT-4.1 mini in opencode

GPT-4.1 mini suits document extraction, focused code changes, and tasks with explicit output rules. Its 1,047,576-token context window supports large reference sets, with responses capped at 32,768 tokens.

|  |  |
| --- | --- |
| Model | GPT-4.1 mini |
| Available through | OpenAI |
| Category | LLM |
| Price | Up to $0.008539 per run at the default inputs. $0.52 per 1M input tokens, $0.13 per 1M cached input tokens, $2.08 per 1M output tokens. |
| Returns | text, json |
| Runs | In the background |
| Setup | About 2 minutes, no API key |

## Prompts to try with GPT-4.1 mini in opencode

- Use GPT-4.1 mini to inspect the failing test and relevant project files. Fix the underlying bug, keep edits within the affected behavior, and report the tests run and their results.
- Use GPT-4.1 mini to review the current diff for violations of our documented API contract. Return a table with file, location, evidence, and suggested correction.
- Use GPT-4.1 mini to extract configuration requirements from this project's documentation. Return structured JSON with each requirement, its source path, and whether the implementation satisfies it.
- Use GPT-4.1 mini to add tests for the parser's documented edge cases. Follow existing test conventions and identify any behavior the documentation leaves ambiguous.
- Use GPT-4.1 mini to compare the implementation with the migration guide. List required changes with supporting references, then prepare the smallest patch for the first confirmed incompatibility.

## How to set up GPT-4.1 mini in opencode

Pick the way that suits you. Each takes about two minutes.

### Use Spiral's MCP server

1. **Add the server**: Leave out `--global` to add Spiral to the current project only. No header and no client ID or secret: opencode registers itself with Spiral.

```bash
opencode mcp add spiral --global --url https://api.spiral.ai/mcp
```

2. **Sign in**: Your browser opens. Sign in to Spiral, pick the organization and click Authorize, then return to the terminal. No API key. Inside opencode, `/mcps` starts the same sign-in.

```bash
opencode mcp auth spiral
```

3. **Check it**: Spiral shows as connected.

```bash
opencode mcp list
```

### Use the Spiral skill

1. **Send opencode this message**: Your agent reads Spiral's skill and sets itself up.

```
set up https://spiral.ai/SKILL.md
```

2. **Sign in or paste a key**: Approve Spiral in the browser, or give the agent a key from the console.

### Use the Spiral CLI

1. **Install and sign in**: Installs the Spiral CLI, signs you in and adds its skill to your coding agents.

```bash
npx -y spiral-cli@latest init
```

### Call the Spiral API

1. **Create an API key**: In the console, under API keys.

2. **Run GPT-4.1 mini**: One request; the result comes back by polling or a webhook.

```bash
curl https://api.spiral.ai/v1/runs \
  -H "Authorization: Bearer $SPIRAL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "provider": "openai",
    "model": "openai/gpt-4.1-mini",
    "input": {
      "messages": [
        {
          "role": "system"
        }
      ]
    }
  }'
```

Then paste one of the prompts above: opencode finds GPT-4.1 mini on Spiral, shows the price and runs it.

Setup guide in the docs: https://spiral.ai/docs/quickstarts/opencode

## GPT-4.1 mini tools and prices

- [GPT-4.1 Mini](https://spiral.ai/tools/openai/openai/gpt-4.1-mini) (OpenAI): Up to $0.008539 per run at the default inputs. $0.52 per 1M input tokens, $0.13 per 1M cached input tokens, $2.08 per 1M output tokens.

## Settings you can ask for

| Setting | Allowed values | Default | Description |
| --- | --- | --- | --- |
| seed |  | — |  |
| stop |  | — |  |
| tools |  | — |  |
| top_p | 0 to 1 | — |  |
| logprobs |  | — |  |
| max_tokens | 16 to … | — | The most output tokens to generate. |

## What can you do with GPT-4.1 mini in opencode?

Turn project code and documentation into focused patches, tests, and structured findings with GPT-4.1 mini. Define the scope and acceptance criteria so its instruction following serves a concrete engineering task.

### Extract obligations from policy text

Use GPT-4.1 mini to turn supplied policies into a table of obligations, responsible roles, deadlines, and supporting passages. Mark missing details explicitly.

### Draft answers from a support policy

Give GPT-4.1 mini the customer's question and the applicable policy. Request a short reply supported by the policy, with a clarification question when essential details are missing.

### Make focused code changes

Ask GPT-4.1 mini to fix a bounded bug using the relevant code and failing test. Specify the intended behavior and require a patch with validation results.

### Classify incoming requests

Use GPT-4.1 mini to assign requests to defined categories. Provide labeled examples and an explicit outcome for ambiguous requests.

### Build evidence-backed research briefs

Have GPT-4.1 mini summarize supplied research excerpts with source IDs attached to each finding. Review smaller sets first when complete coverage matters.

### Convert notes into structured records

Ask GPT-4.1 mini to extract decisions, owners, and deadlines from meeting transcripts. Use a defined structure and preserve uncertainty when a detail was never stated.

### Compare document revisions

Supply GPT-4.1 mini with two versions of a policy or specification. Request a change table that pairs each finding with passages from both versions.

### Prepare tool requests from natural language

Use GPT-4.1 mini to translate a user's request into arguments for a defined function. Require missing information to be identified before an action is requested.

## Overview

- [OpenAI](https://spiral.ai/providers/openai)
- [All opencode guides](https://spiral.ai/integrations/opencode)

## GPT-4.1 mini in other agents

- [Amp](https://spiral.ai/integrations/amp/gpt-4-1-mini)
- [ChatGPT](https://spiral.ai/integrations/chatgpt/gpt-4-1-mini)
- [Claude](https://spiral.ai/integrations/claude-desktop/gpt-4-1-mini)
- [Claude Code](https://spiral.ai/integrations/claude-code/gpt-4-1-mini)
- [Cline](https://spiral.ai/integrations/cline/gpt-4-1-mini)
- [Codex](https://spiral.ai/integrations/codex/gpt-4-1-mini)
- [Cursor](https://spiral.ai/integrations/cursor/gpt-4-1-mini)
- [Devin](https://spiral.ai/integrations/devin/gpt-4-1-mini)
- [dots](https://spiral.ai/integrations/dots/gpt-4-1-mini)
- [Factory Droid](https://spiral.ai/integrations/factory-droid/gpt-4-1-mini)
- [Gemini](https://spiral.ai/integrations/gemini/gpt-4-1-mini)
- [Gemini CLI](https://spiral.ai/integrations/gemini-cli/gpt-4-1-mini)
- [Google Antigravity](https://spiral.ai/integrations/antigravity/gpt-4-1-mini)
- [goose](https://spiral.ai/integrations/goose/gpt-4-1-mini)
- [Grok](https://spiral.ai/integrations/grok/gpt-4-1-mini)
- [Grok Build](https://spiral.ai/integrations/grok-build/gpt-4-1-mini)
- [Hermes](https://spiral.ai/integrations/hermes/gpt-4-1-mini)
- [Instinct](https://spiral.ai/integrations/instinct/gpt-4-1-mini)
- [Manus](https://spiral.ai/integrations/manus/gpt-4-1-mini)
- [Muse](https://spiral.ai/integrations/muse/gpt-4-1-mini)
- [Muse Code](https://spiral.ai/integrations/muse-code/gpt-4-1-mini)
- [n8n](https://spiral.ai/integrations/n8n/gpt-4-1-mini)
- [Notion](https://spiral.ai/integrations/notion/gpt-4-1-mini)
- [OpenClaw](https://spiral.ai/integrations/openclaw/gpt-4-1-mini)
- [Perplexity](https://spiral.ai/integrations/perplexity/gpt-4-1-mini)
- [Raycast](https://spiral.ai/integrations/raycast/gpt-4-1-mini)
- [VS Code](https://spiral.ai/integrations/vscode/gpt-4-1-mini)
- [Windsurf](https://spiral.ai/integrations/windsurf/gpt-4-1-mini)
- [Zapier](https://spiral.ai/integrations/zapier/gpt-4-1-mini)

## More opencode guides

- [GPT-4.1](https://spiral.ai/integrations/opencode/gpt-4-1)
- [GPT-4o](https://spiral.ai/integrations/opencode/gpt-4o)
- [GPT-3.5 Turbo 0613](https://spiral.ai/integrations/opencode/gpt-3-5-turbo-0613)
- [GPT-4o 2024-08-06](https://spiral.ai/integrations/opencode/gpt-4o-2024-08-06)
- [GPT Terra Latest](https://spiral.ai/integrations/opencode/gpt-terra-latest)
- [GPT-4o 2024-11-20](https://spiral.ai/integrations/opencode/gpt-4o-2024-11-20)

## Questions about GPT-4.1 mini in opencode

**Can opencode use GPT-4.1 mini?**

Yes. Add Spiral to opencode as an MCP server, and opencode can find and run GPT-4.1 mini like any built-in tool.

**How much does GPT-4.1 mini cost in opencode?**

Up to $0.008539 per run at the default inputs. $0.52 per 1M input tokens, $0.13 per 1M cached input tokens, $2.08 per 1M output tokens. You pay from your Spiral balance as you go, with no subscription, and a failed run is not charged. Your opencode plan is separate.

**Do I need an OpenAI account to use GPT-4.1 mini in opencode?**

No. Spiral runs GPT-4.1 mini on its own OpenAI account. You sign in to Spiral once and never paste a key.

**How long does it take to set up GPT-4.1 mini in opencode?**

About two minutes: add the server, then sign in, then check it.

**Does opencode wait while GPT-4.1 mini runs?**

GPT-4.1 mini runs in the background. opencode starts the run, checks on it and gives you the text, json when it's ready.

**How much material can GPT-4.1 mini handle?**

OpenAI lists a 1,047,576-token context window. For exhaustive extraction, divide large collections into sections and check coverage, since retrieval performance can decline as more items must be found.

**How long can a GPT-4.1 mini response be?**

The model's maximum output is 32,768 tokens. For a long report, request an outline first, then generate sections with explicit length targets.

**Where does GPT-4.1 mini need extra checking?**

Tasks that require finding every relevant item across a large reference set need coverage checks. Extract evidence in smaller sections before asking for a combined conclusion.

**How should I prompt GPT-4.1 mini?**

State the task, permitted evidence, output format, and behavior when information is missing. Make each requirement explicit because GPT-4.1 models follow instructions literally.

**Can GPT-4.1 mini produce reliable structured data?**

GPT-4.1 mini supports Structured Outputs, which can enforce a supported JSON schema. Check the extracted values against the source because correct structure does not guarantee correct content.

