Repository: promptfoo/promptfoo
Issue: Can't use Claude Models on Google Vertex (with images)
Root cause: Interface Contract Mismatch

```yaml
  - id: "vertex:claude-3-5-sonnet-v2@20241022"
    label: vertex-claude-3-5-sonnet-v2@20241022-0-temp
    config:
      region: us-east5
      publisher: anthropic
      temperature: 0
```


```js
function makePromptVertexClaude(file, imageBase64) {
  const promptText = fs.readFileSync(
    path.join(__dirname, file),
    'utf-8'
  );

  return [
    {
      role: "user",
      content: [
        {
          type: "text",
          text: promptText
        },
        {
          type: "image",
          source: {
            type: "base64",
            media_type: "image/jpeg",
            data: imageBase64
          }
        }
      ]
    }
  ];
}
```

Return:

```
"message":"messages: Field required"
```

API call error: {"config":{"url":"https://us-east5-aiplatform.googleapis.com/v1/projects/ricardo-xxxxx/locations/us-east5/publishers/anthropic/models/claude-3-5-sonnet-v2:predict","method":"POST","headers":{"Content-Type":"application/json","x-goog-user-project":"ricardo-xxxxx","Authorization":"<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.","User-Agent":"google-api-nodejs-client/9.15.1","x-goog-api-client":"gl-node/22.13.0"},"data":{"instances":[{"role":"system","content":[{"type":"text","text":"Follow the instructions...

The problem is that it's passing data: "instances": [{role... instead of "instances": {"messages": [{role...

Hi Ricardo, could you please see if 0.105.0 fixes this?  It will send in
the correct format and I tested with claude 3.5 sonnet via vertex today,
although I have not personally tested the images component.

On Mon, Feb 24, 2025 at 5:44 PM Ricardo Fritsche ***@***.***>
wrote:

> API call error: {"config":{"url":"
> https://us-east5-aiplatform.googleapis.com/v1/projects/ricardo-xxxxx/locations/us-east5/publishers/anthropic/models/claude-3-5-sonnet-v2:predict","method":"POST","headers":{"Content-Type":"application/json","x-goog-user-project":"ricardo-xxxxx","Authorization":"<
> - See errorRedactor option in gaxios for
> configuration>.","User-Agent":"google-api-nodejs-client/9.15.1","x-goog-api-client":"gl-node/22.13.0"},"data":{"instances":[{"role":"system","content":[{"type":"text","text":"Follow
> the instructions...
>
> The problem is that it's passing data: "instances": [{role... instead of
> "instances": {"messages": [{role...
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/promptfoo/promptfoo/issues/3191#issuecomment-2680152838>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AACLYJVIJM2F2QKFPJIZ2HT2RPDG3AVCNFSM6AAAAABXWZ7HBOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOBQGE2TEOBTHA>
> .
> You are receiving this because you are subscribed to this thread.Message
> ID: ***@***.***>
> [image: ricardovf]*ricardovf* left a comment (promptfoo/promptfoo#3191)
> <https://github.com/promptfoo/promptfoo/issues/3191#issuecomment-2680152838>
>
> API call error: {"config":{"url":"
> https://us-east5-aiplatform.googleapis.com/v1/projects/ricardo-xxxxx/locations/us-east5/publishers/anthropic/models/claude-3-5-sonnet-v2:predict","method":"POST","headers":{"Content-Type":"application/json","x-goog-user-project":"ricardo-xxxxx","Authorization":"<
> - See errorRedactor option in gaxios for
> configuration>.","User-Agent":"google-api-nodejs-client/9.15.1","x-goog-api-client":"gl-node/22.13.0"},"data":{"instances":[{"role":"system","content":[{"type":"text","text":"Follow
> the instructions...
>
> The problem is that it's passing data: "instances": [{role... instead of
> "instances": {"messages": [{role...
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/promptfoo/promptfoo/issues/3191#issuecomment-2680152838>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AACLYJVIJM2F2QKFPJIZ2HT2RPDG3AVCNFSM6AAAAABXWZ7HBOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOBQGE2TEOBTHA>
> .
> You are receiving this because you are subscribed to this thread.Message
> ID: ***@***.***>
>


It worked, thanks!