Skip to content

[bug] anthropic <> vertex proxies: unknown SSE event raises error #13914

Closed

Description

@audibleblink

Description

When a vertex proxy sends back a vertex_event SSE event, an uncaught exception makes its way up to OpenCode.

The true cause is with ai-sdk and the bug is filed.
The fix upstream on ai-sdk is to ignore the event so I'm assuming the exception can also be safely ignored.

The bug report's likely to go stale so logging this here in case we're able to add exception handling.


For streaming proxies that present the Anthropic API to clients, but use Vertex Anthropic upstream -- Vertex returns an additional SSE event called vertex_event that breaks @ai-sdk/anthropic with the following error:

AI_APICallError: Type validation failed: Value: {"type":"vertex_event","usage":{"input_tokens":9,"output_tokens":1,"cache_
creation_input_tokens":null,"cache_read_input_tokens":null,"web_search_requests":null,"cache_creation":{"ephemeral_5m_inpu
t_tokens":0,"ephemeral_1h_input_tokens":0},"tiers":{"0-to-200000":{"input_tokens":9,"output_tokens":1,"cache_creation_inpu
t_tokens":null,"cache_read_input_tokens":null,"web_search_requests":null,"cache_creation":{"ephemeral_5m_input_tokens":0,"
ephemeral_1h_input_tokens":0}}}}}.
Error message: [
  {
    "code": "invalid_union",
    "errors": [],
    "note": "No matching discriminator",
    "discriminator": "type",
    "path": [
      "type"
    ],
    "message": "Invalid input"
  }
]
    at AnthropicMessagesLanguageModel.doStream (file:///Users/xxxxxx/.cache/deno/npm/registry.npmjs.org/@ai-sdk/anthropic
/2.0.56/src/anthropic-messages-language-model.ts:1433:15)

Clients that use the official Anthropic SDK don't suffer from this. I found that Block's Goose handles this as well.

Plugins

None

OpenCode version

1.2.6

Steps to reproduce

import { createAnthropic } from "@ai-sdk/anthropic";
import { generateText, streamText } from "ai";

const apiKey: string | undefined = Deno.env.get("ANTHROPIC_API_KEY");
const baseURL: string = `${Deno.env.get("ANTHROPIC_BASE_URL")}/v1`;

const anthropic = createAnthropic({
  apiKey: apiKey,
  baseURL: baseURL,
  headers: { "anthropic_version": "vertex-2023-10-16" },
});

const { textStream } = streamText({
  model: anthropic("claude-sonnet-4-5"),
  prompt: "ping.",
});

for await (const part of textStream) {
  console.log(part);
}

// non-stream works just fine
const { text } = await generateText({
  model: anthropic("claude-sonnet-4-5"),
  prompt: "ping.",
});

console.log(text);
console.log(baseURL);

Screenshot and/or share link

No response

Operating System

macOS

Terminal

Ghostty

Activity

  1. github-actions commented on Feb 17, 2026

    @github-actions
    Contributor

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

    Highly likely duplicates:

    Related issues:

    Please check if this is indeed a duplicate before proceeding. Note that you mentioned filing this upstream in @ai-sdk/anthropic (#11309), so this may need exception handling in OpenCode for the extra vertex_event SSE event that Vertex returns.

  2. added a commit that references this issue on Feb 17, 2026
    7efca1c
  3. nehaaprasad commented on Feb 17, 2026

    @nehaaprasad

    hello @audibleblink
    please check out the PR!

  4. github-actions commented on Apr 19, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 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

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions