Skip to content

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

Closed as not planned

Description

@fl-sean03

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

Activity

  1. github-actions commented on Dec 31, 2025

    @github-actions
    Contributor

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

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

  2. rekram1-node commented on Dec 31, 2025

    @rekram1-node
    Contributor

    It's definitely in the model list...

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

  3. rekram1-node commented on Dec 31, 2025

    @rekram1-node
    Contributor
    model: { providerID: 'openai', modelID: 'gpt-5.2-2025-12-11' },
    

    This isn't even nano?

  4. thdxr commented on Mar 25, 2026

    @thdxr
    Member

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions