opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Custom OpenAI-compatible provider returns no text content

Open cgilly2fast opened this issue 1 month ago • 2 comments

Description

Summary

When using a custom provider with @ai-sdk/openai-compatible, API calls complete successfully but no text content is displayed. The API returns valid responses (verified via curl), but opencode shows empty responses with 0 tokens.

Dedalus API: https://docs.dedaluslabs.ai/api

Environment

  • opencode version: 1.0.134
  • OS: macOS (darwin arm64)

Config

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "dedalus-labs": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Dedalus Labs",
      "options": {
        "baseURL": "https://api.dedaluslabs.ai/v1"
      },
      "models": {
        "openai/gpt-5-mini": {
          "name": "GPT-5 Mini"
        },
        "google/gemini-2.5-flash": {
          "name": "Gemini 2.5 Flash"
        }
      }
    }
  }
}

Symptoms

  1. API calls complete (shows ~2s completion time in UI)
  2. No text content is displayed
  3. Session data shows finish: "stop" but no text parts
  4. Token counts show input: 0, output: 0
  5. No error is displayed

API Works Correctly

Direct curl test confirms the API returns valid streaming responses:

curl -s "https://api.dedaluslabs.ai/v1/chat/completions" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "openai/gpt-5-mini", "messages": [{"role": "user", "content": "Say hi"}], "stream": true}'

Returns valid SSE stream:

data: {"choices":[{"delta":{"content":"Hi"}}]}
data: {"choices":[{"delta":{},"finish_reason":"stop"}],"usage":{...}}
data: [DONE]

Likely Cause

The @ai-sdk/openai-compatible package may not be emitting text-start events before text-delta events. In processor.ts, text-delta handling requires currentText to be set (which happens in text-start):

case "text-delta":
  if (currentText) {  // <-- undefined without text-start
    currentText.text += value.text
    ...
  }
  break

Without a text-start event, all text-delta events are silently ignored.

Session Data

Stored message shows completion but no content:

{
  "finish": "stop",
  "tokens": {
    "input": 0,
    "output": 0,
    "reasoning": 0,
    "cache": { "read": 0, "write": 0 }
  }
}

No text parts are created - only step-start and step-finish parts exist.

OpenCode version

1.0.134

Steps to reproduce

  1. Add opencode.json
  2. add Dedalus api key ( "dedalus-labs", using opencode auth login > Other ) (if you dm me on x I will provide you one https://x.com/cgilly2fast)
  3. Pick a dedalus model
  4. Send "Hello"

Screenshot and/or share link

Image

Operating System

macOS 15.5 (24F74) (darwin arm64) M1 mac

Terminal

VSCode terminal

cgilly2fast avatar Dec 07 '25 19:12 cgilly2fast

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

  • #5187: Ollama with @ai-sdk/openai-compatible provider also reports empty/missing content - user messages arrive as empty arrays instead of actual text

Both issues use the @ai-sdk/openai-compatible provider and report content not being displayed despite successful API calls. The symptoms and likely root cause (missing text-start events before text-delta events) suggest these could be related issues.

Feel free to ignore if your case is specific to the Dedalus Labs provider.

github-actions[bot] avatar Dec 07 '25 19:12 github-actions[bot]

Hm every other provider i've seen emits them correctly, it seems like it'd be a bug on the provider side rather than the sdk no?

rekram1-node avatar Dec 08 '25 01:12 rekram1-node

I am not 100% sure thats the issue, I was trying help with beginning deductions

cgilly2fast avatar Dec 08 '25 02:12 cgilly2fast