Skip to content

Anthropic API compatibility issue: unsupported n parameter in text generation requests #146

@saarnilauri

Description

@saarnilauri

Description

Description

When using the WordPress AI Experiments plugin with only an Anthropic API key configured, the Title generation experiment fails due to an incompatible parameter being sent to the Anthropic API.

Step-by-step reproduction instructions

Steps to Reproduce

  1. Install and activate the WordPress AI Experiments plugin
  2. Configure only the Anthropic API key (no OpenAI key)
  3. Attempt to use the Title generation experiment
  4. Observe the API request failure. This can be seen in browser inspector network. The returned value:
{
    "code": "prompt_builder_error",
    "message": "Bad Request (400) - n: Input should be less than or equal to 1",
    "data": {
        "exception_class": "WordPress\\AiClient\\Providers\\Http\\Exception\\ClientException"
    }
}

Screenshots, screen recording, code snippet

No response

Environment info

  • WP core 6.9.0
  • WordPress AI Experiments plugin (commit 663daab8d5a7d88a07318d73733bd1be6cb5ceb9 (HEAD -> develop, origin/develop, origin/HEAD)

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except AI Experiments plugin.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

Labels

[Type] BugAn existing feature does not function as intended

Type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions