vertex-ai error: max_tokens: Field required #7867

Closed
opened 2026-02-16 18:08:31 -05:00 by yindo · 3 comments
Owner

Originally created by @benjaminbauer on GitHub (Jan 28, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

I am trying to access a Claude model hosted on vertex via portkey in opencode. This worked (still works when downgrading) w/o problems in 1.1.36, but fails with vertex-ai error: max_tokens: Field required in 1.1.39.

{
    "$schema": "https://opencode.ai/config.json",
    "provider": {
        "portkey": {
            "npm": "@ai-sdk/openai-compatible",
            "name": "Portkey",
            "options": {
                "baseURL": "https://api.portkey.ai/v1",
                "apiKey": "{env:PORTKEY_API_KEY}",
            },
            "models": {
                "@vertex-ai/anthropic.claude-sonnet-4-5@20250929": {
                    "name": "Claude Sonnet 4.5 GCP",
                    "cost": {
                        "input": 3.00,
                        "output": 15.00,
                        "cache_write": 3.75,
                        "cache_read": 0.30
                    },
                    "limit": {
                        "context": 1000000,
                        "output": 64000
                    }
                },
...

Plugins

No response

OpenCode version

1.1.39

Steps to reproduce

  1. use the above config
  2. start opencode
  3. prompt anything

Screenshot and/or share link

No response

Operating System

Linux

Terminal

Alacritty

Originally created by @benjaminbauer on GitHub (Jan 28, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description I am trying to access a Claude model hosted on vertex via portkey in opencode. This worked (still works when downgrading) w/o problems in 1.1.36, but fails with `vertex-ai error: max_tokens: Field required` in 1.1.39. ``` { "$schema": "https://opencode.ai/config.json", "provider": { "portkey": { "npm": "@ai-sdk/openai-compatible", "name": "Portkey", "options": { "baseURL": "https://api.portkey.ai/v1", "apiKey": "{env:PORTKEY_API_KEY}", }, "models": { "@vertex-ai/anthropic.claude-sonnet-4-5@20250929": { "name": "Claude Sonnet 4.5 GCP", "cost": { "input": 3.00, "output": 15.00, "cache_write": 3.75, "cache_read": 0.30 }, "limit": { "context": 1000000, "output": 64000 } }, ... ``` ### Plugins _No response_ ### OpenCode version 1.1.39 ### Steps to reproduce 1. use the above config 2. start opencode 3. prompt anything ### Screenshot and/or share link _No response_ ### Operating System Linux ### Terminal Alacritty
yindo added the bug label 2026-02-16 18:08:31 -05:00
yindo closed this issue 2026-02-16 18:08:31 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 28, 2026):

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

  • #9565: Incorrect model IDs for Vertex Anthropic - About Vertex Anthropic model ID format issues
  • #7514: Bug: Shared state between google-vertex and google-vertex-anthropic providers - Vertex provider compatibility issues
  • #4282: Vertex AI: BadRequestError 'instructions: Extra inputs are not permitted' when running agents - Related Vertex AI compatibility issues

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

@github-actions[bot] commented on GitHub (Jan 28, 2026): This issue might be a duplicate of existing issues. Please check: - #9565: Incorrect model IDs for Vertex Anthropic - About Vertex Anthropic model ID format issues - #7514: Bug: Shared state between google-vertex and google-vertex-anthropic providers - Vertex provider compatibility issues - #4282: Vertex AI: BadRequestError 'instructions: Extra inputs are not permitted' when running agents - Related Vertex AI compatibility issues Feel free to ignore if none of these address your specific case.
Author
Owner

@benjaminbauer commented on GitHub (Jan 29, 2026):

workaround/narrowing down the cause - this works:

        "portkey-anthropic": {
            "npm": "@ai-sdk/anthropic",
            "name": "Portkey Anthropic (Vertex)",
            "options": {
                "baseURL": "https://api.portkey.ai/v1",
                "apiKey": "dummy", // Anthropic SDK sends this as x-api-key, but Portkey ignores it
                "headers": {
                    "x-portkey-api-key": "{env:PORTKEY_API_KEY}"
                }
            },
            "models": {
                "@vertex-ai/anthropic.claude-sonnet-4-5@20250929": {
                    "name": "Claude Sonnet 4.5 GCP (Anthropic SDK)",
                    "cost": {
                        "input": 3.00,
                        "output": 15.00,
                        "cache_write": 3.75,
                        "cache_read": 0.30
                    },
                    "limit": {
                        "context": 1000000,
                        "output": 64000
                    }
                },
@benjaminbauer commented on GitHub (Jan 29, 2026): workaround/narrowing down the cause - this works: ``` "portkey-anthropic": { "npm": "@ai-sdk/anthropic", "name": "Portkey Anthropic (Vertex)", "options": { "baseURL": "https://api.portkey.ai/v1", "apiKey": "dummy", // Anthropic SDK sends this as x-api-key, but Portkey ignores it "headers": { "x-portkey-api-key": "{env:PORTKEY_API_KEY}" } }, "models": { "@vertex-ai/anthropic.claude-sonnet-4-5@20250929": { "name": "Claude Sonnet 4.5 GCP (Anthropic SDK)", "cost": { "input": 3.00, "output": 15.00, "cache_write": 3.75, "cache_read": 0.30 }, "limit": { "context": 1000000, "output": 64000 } }, ```
Author
Owner

@rekram1-node commented on GitHub (Jan 29, 2026):

This should be fixed on latest, accidentally commented out line for max tokens, will add tests to catch in future

@rekram1-node commented on GitHub (Jan 29, 2026): This should be fixed on latest, accidentally commented out line for max tokens, will add tests to catch in future
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7867