Skip to content

Perplexity Agent provider fails with unknown field "store" on /v1/responses #32108

Closed as not planned

Description

@asakura42

Description

The built-in perplexity-agent provider is currently failing on Opencode 1.17.4.

Any request to a Perplexity Agent model fails with:

AI_APICallError: invalid request body: json: unknown field "store"

I verified that the Perplexity Agent /v1/responses endpoint works if OpenAI-specific fields are omitted, but fails when fields such as store, temperature, include, or tool_choice are present.

The built-in provider appears to use the OpenAI AI SDK adapter:

provider: perplexity-agent
api.package: @ai-sdk/openai
api.url: https://api.perplexity.ai/v1

That adapter sends OpenAI Responses API fields that Perplexity Agent API now rejects.

I have now local workaround only: a custom plugin that strips unsupported fields from requests to https://api.perplexity.ai/v1/responses makes the provider work again, but this should be fixed upstream:

const unsupportedFields = ["store", "temperature", "include", "tool_choice"]

function sanitizeBody(body: unknown) {
  if (typeof body !== "string") return body

  try {
    const json = JSON.parse(body)
    for (const field of unsupportedFields) delete json[field]
    return JSON.stringify(json)
  } catch {
    return body
  }
}

export default async () => {
  const fetchKey = Symbol.for("opencode.perplexityAgentSanitizeFetch")
  const global = globalThis as typeof globalThis & { [fetchKey]?: true }

  if (!global[fetchKey]) {
    const originalFetch = globalThis.fetch.bind(globalThis)
    globalThis.fetch = async (input, init) => {
      const url = typeof input === "string" || input instanceof URL ? input.toString() : input.url
      if (!url.startsWith("https://api.perplexity.ai/v1/responses")) {
        return originalFetch(input, init)
      }

      if (init?.body) {
        return originalFetch(input, { ...init, body: sanitizeBody(init.body) as BodyInit })
      }

      if (input instanceof Request) {
        const body = sanitizeBody(await input.clone().text())
        return originalFetch(new Request(input, { body: body as BodyInit }), init)
      }

      return originalFetch(input, init)
    }
    global[fetchKey] = true
  }

  return {}
}

Plugins

None relevant. I also reproduced this with plugins disabled / without my local workaround.

OpenCode version

1.17.4

Steps to reproduce

  1. Configure/authenticate the built-in perplexity-agent provider.
  2. Run:
opencode run "Reply with exactly: ok" \
  --model "perplexity-agent/anthropic/claude-opus-4-6" \
  --print-logs \
  --log-level DEBUG
  1. Observe the failure:
    AI_APICallError: invalid request body: json: unknown field "store"
    Additional direct API check:
    This succeeds:
curl -sS -X POST "https://api.perplexity.ai/v1/responses" \
  -H "Authorization: Bearer $PERPLEXITY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-opus-4-6",
    "input": [
      {
        "role": "user",
        "content": [
          {
            "type": "input_text",
            "text": "Reply exactly: ok"
          }
        ]
      }
    ],
    "stream": false,
    "max_output_tokens": 16
  }'

This fails:

curl -sS -X POST "https://api.perplexity.ai/v1/responses" \
  -H "Authorization: Bearer $PERPLEXITY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-opus-4-6",
    "input": [
      {
        "role": "user",
        "content": [
          {
            "type": "input_text",
            "text": "Reply exactly: ok"
          }
        ]
      }
    ],
    "stream": false,
    "max_output_tokens": 16,
    "store": false
  }'

Response:

{
  "error": {
    "message": "invalid request body: json: unknown field \"store\"",
    "type": "invalid_request",
    "code": 400,
    "param": "store"
  }
}

I also observed the same class of error for:
temperature
include
tool_choice

Expected behavior: perplexity-agent should not send OpenAI-specific Responses fields that Perplexity Agent API rejects.

Screenshot and/or share link

N/A

Operating System

Arch

Terminal

Konsole

Activity

  1. samuelsennev commented on Jun 13, 2026

    @samuelsennev

    Same here...

  2. added a commit that references this issue on Jul 9, 2026
    609fe28
  3. github-actions commented on Aug 13, 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

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions