OpenAI provider fails: gpt-5-nano missing from models.dev registry causes ProviderModelNotFoundError #4021

Open
opened 2026-02-16 17:42:20 -05:00 by yindo · 3 comments
Owner

Originally created by @fl-sean03 on GitHub (Dec 30, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

When using the OpenCode SDK with OpenAI provider, sessions fail because the internal title agent tries to use gpt-5-nano, which is not in OpenCode's model registry (models.dev), causing ProviderModelNotFoundError.

Irony: gpt-5-nano actually exists and works when called directly via OpenAI API, but OpenCode's internal model lookup fails.

Steps to Reproduce

import { createOpencode } from '@opencode-ai/sdk';

const { client, server } = await createOpencode({ port: 4096 });

// Set up OpenAI auth
await client.auth.set({
  path: { id: 'openai' },
  body: { type: 'api', key: process.env.OPENAI_API_KEY },
});

// Create session and send prompt
const session = await client.session.create({ query: { directory: '/tmp/test' } });
await client.session.prompt({
  path: { id: session.data.id },
  query: { directory: '/tmp/test' },
  body: {
    model: { providerID: 'openai', modelID: 'gpt-5.2-2025-12-11' },
    parts: [{ type: 'text', text: 'Say hello' }],
  },
});
// Session is cancelled immediately

Logs

INFO  service=session.prompt sessionID=ses_xxx cancel
INFO  service=llm providerID=openai modelID=gpt-5-nano sessionID=ses_xxx small=true agent=title stream
ERROR service=acp-command reason=ProviderModelNotFoundError Unhandled rejection
ERROR service=default e=ProviderModelNotFoundError rejection

Verification that gpt-5-nano exists

// Direct OpenAI API call works fine:
const response = await fetch('https://api.openai.com/v1/chat/completions', {
  method: 'POST',
  headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    model: 'gpt-5-nano',
    messages: [{ role: 'user', content: 'Hi' }],
    max_completion_tokens: 5
  })
});
// ✅ Works - returns response from gpt-5-nano-2025-08-07

Root Cause

  1. OpenCode's internal title agent hardcodes gpt-5-nano as the small model for OpenAI
  2. OpenCode's model registry (from models.dev/api.json) doesn't include gpt-5-nano
  3. This causes ProviderModelNotFoundError even though the model exists at OpenAI

Workaround

Using Anthropic provider works correctly - no issues with internal agents.

Suggested Fix

Either:

  1. Add gpt-5-nano to the models.dev registry
  2. Make the title/small model configurable in opencode.json
  3. Skip model validation for internal agents if the provider supports the model

Environment

  • OpenCode SDK: @opencode-ai/sdk (latest)
  • OpenCode version: 1.0.218
  • Node.js: v22.21.1
  • OS: Linux (WSL2)

Related Issues

  • #916 - ProviderModelNotFoundError (models.dev sync)
  • #5421 - max_tokens vs max_completion_tokens for GPT 5.x
Originally created by @fl-sean03 on GitHub (Dec 30, 2025). Originally assigned to: @rekram1-node on GitHub. ## Description When using the OpenCode SDK with OpenAI provider, sessions fail because the internal `title` agent tries to use `gpt-5-nano`, which is not in OpenCode's model registry (models.dev), causing `ProviderModelNotFoundError`. **Irony:** `gpt-5-nano` actually exists and works when called directly via OpenAI API, but OpenCode's internal model lookup fails. ## Steps to Reproduce ```typescript import { createOpencode } from '@opencode-ai/sdk'; const { client, server } = await createOpencode({ port: 4096 }); // Set up OpenAI auth await client.auth.set({ path: { id: 'openai' }, body: { type: 'api', key: process.env.OPENAI_API_KEY }, }); // Create session and send prompt const session = await client.session.create({ query: { directory: '/tmp/test' } }); await client.session.prompt({ path: { id: session.data.id }, query: { directory: '/tmp/test' }, body: { model: { providerID: 'openai', modelID: 'gpt-5.2-2025-12-11' }, parts: [{ type: 'text', text: 'Say hello' }], }, }); // Session is cancelled immediately ``` ## Logs ``` INFO service=session.prompt sessionID=ses_xxx cancel INFO service=llm providerID=openai modelID=gpt-5-nano sessionID=ses_xxx small=true agent=title stream ERROR service=acp-command reason=ProviderModelNotFoundError Unhandled rejection ERROR service=default e=ProviderModelNotFoundError rejection ``` ## Verification that gpt-5-nano exists ```typescript // Direct OpenAI API call works fine: const response = await fetch('https://api.openai.com/v1/chat/completions', { method: 'POST', headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ model: 'gpt-5-nano', messages: [{ role: 'user', content: 'Hi' }], max_completion_tokens: 5 }) }); // ✅ Works - returns response from gpt-5-nano-2025-08-07 ``` ## Root Cause 1. OpenCode's internal `title` agent hardcodes `gpt-5-nano` as the small model for OpenAI 2. OpenCode's model registry (from `models.dev/api.json`) doesn't include `gpt-5-nano` 3. This causes `ProviderModelNotFoundError` even though the model exists at OpenAI ## Workaround Using Anthropic provider works correctly - no issues with internal agents. ## Suggested Fix Either: 1. Add `gpt-5-nano` to the models.dev registry 2. Make the title/small model configurable in `opencode.json` 3. Skip model validation for internal agents if the provider supports the model ## Environment - OpenCode SDK: `@opencode-ai/sdk` (latest) - OpenCode version: 1.0.218 - Node.js: v22.21.1 - OS: Linux (WSL2) ## Related Issues - #916 - ProviderModelNotFoundError (models.dev sync) - #5421 - max_tokens vs max_completion_tokens for GPT 5.x
Author
Owner

@github-actions[bot] commented on GitHub (Dec 30, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #916: ProviderModelNotFoundError - Similar issue with model registry sync problems
  • #5164: Session name is not computed - Related to internal agents (title agent) failing when models are missing
  • #5421: @ai-sdk/openai-compatible max_tokens error for GPT 5.x - Related to internal model configuration and API compatibility issues

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Dec 30, 2025): This issue might be a duplicate of existing issues. Please check: - #916: ProviderModelNotFoundError - Similar issue with model registry sync problems - #5164: Session name is not computed - Related to internal agents (title agent) failing when models are missing - #5421: @ai-sdk/openai-compatible max_tokens error for GPT 5.x - Related to internal model configuration and API compatibility issues Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Dec 30, 2025):

It's definitely in the model list...

https://models.dev/?search=gpt-5-nano

@rekram1-node commented on GitHub (Dec 30, 2025): It's definitely in the model list... https://models.dev/?search=gpt-5-nano
Author
Owner

@rekram1-node commented on GitHub (Dec 30, 2025):

model: { providerID: 'openai', modelID: 'gpt-5.2-2025-12-11' },

This isn't even nano?

@rekram1-node commented on GitHub (Dec 30, 2025): > model: { providerID: 'openai', modelID: 'gpt-5.2-2025-12-11' }, This isn't even nano?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4021