# Messages (Anthropic)

Source: https://staging-docs.aiand.com/api/messages/

```http
POST /v1/messages
```

Accepts requests in the [Anthropic Messages API](https://docs.anthropic.com/en/api/messages) format. Requests are translated to the internal OpenAI-compatible format, processed, and the response is translated back to the Anthropic format before returning.

This lets you use the Anthropic SDK with ai& without changing your code.

<Aside type="note">
  This is a compatibility adapter. For the full set of request parameters, use [Chat Completions](/api/chat-completions/) directly.
</Aside>

## Usage

<Tabs>
  <TabItem label="Python">
    ```python
    from anthropic import Anthropic

    client = Anthropic(
        api_key="sk-your-api-key",
        base_url="https://api.aiand.com/v1",
    )

    message = client.messages.create(
        model="openai/gpt-oss-120b",
        max_tokens=1024,
        messages=[{"role": "user", "content": "Hello!"}],
    )

    print(message.content[0].text)
    ```
  </TabItem>
  <TabItem label="JavaScript">
    ```javascript
    import Anthropic from "@anthropic-ai/sdk";

    const client = new Anthropic({
      apiKey: "sk-your-api-key",
      baseURL: "https://api.aiand.com/v1",
    });

    const message = await client.messages.create({
      model: "openai/gpt-oss-120b",
      max_tokens: 1024,
      messages: [{ role: "user", content: "Hello!" }],
    });

    console.log(message.content[0].text);
    ```
  </TabItem>
</Tabs>

## How it works

1. Your request arrives in Anthropic Messages format
2. ai& translates it to OpenAI format and runs inference
3. The response is translated back to Anthropic format

Streaming is supported. Authentication uses the same `Authorization: Bearer` header as all other endpoints.

## Supported parameters

Standard Anthropic Messages API parameters are accepted. Parameters with no equivalent in the underlying model are silently ignored.

## Image input

Image content blocks are supported on vision-capable models. All three Anthropic source types work — `base64`, `url`, and `file` (referencing a `file_id` from [`POST /v1/files`](/api/files/)). See [Anthropic's content blocks docs](https://docs.anthropic.com/en/api/messages#content-blocks) for the wire format. Requests against models without the `vision` capability are rejected with `400 invalid_request_error` before inference.
