> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gregapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Messages API

> Call Claude models using the Anthropic Messages API protocol.

GregAPI is compatible with the Anthropic Messages API and can be used directly with the official SDK or cURL.

Requests must carry the `anthropic-version` header:

```http theme={null}
Authorization: Bearer <TOKEN>
anthropic-version: 2023-06-01
Content-Type: application/json
```

## Request examples

### cURL

```bash theme={null}
curl -X POST "https://api.gregapi.com/v1/messages" \
  -H "Authorization: Bearer $TOKEN" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-4-6",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Hi, please introduce yourself in one sentence."}
    ]
  }'
```

### Python SDK

```bash theme={null}
pip install anthropic
```

```python theme={null}
import os
import anthropic

client = anthropic.Anthropic(
    api_key=os.environ["TOKEN"],
    base_url="https://api.gregapi.com",
)

message = client.messages.create(
    model="claude-opus-4-6",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hi, please introduce yourself in one sentence."}],
)
print(message)
```

### TypeScript SDK

```bash theme={null}
npm install @anthropic-ai/sdk
```

```typescript theme={null}
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: process.env.TOKEN!,
  baseURL: "https://api.gregapi.com",
});

const message = await client.messages.create({
  model: "claude-opus-4-6",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hi, please introduce yourself in one sentence." }],
});
console.log(message);
```

## Building approaches

| | Messages API | Claude Managed Agents |
| - | - | - |
| **What it is** | Call models directly and orchestrate conversations and tools yourself | A configurable agent form on managed infrastructure |
| **Better for** | Custom agent loops and fine-grained control over each call | Long-running, async-style tasks |

## Recommended development path

1. **Make your first call**: configure environment variables and send the first request with cURL or an SDK.
2. **Understand the Messages API**: learn the `messages` structure, multi-turn conversations, and `stop_reason`.
3. **Choose a model**: confirm available models via `GET /v1/models` or the console.
4. **Extend capabilities**: tool calling, vision, and structured output follow the official Anthropic documentation.

## Resources

* **GregAPI console**: create and manage API keys, and review usage and quotas.
* **GregAPI documentation**: platform capabilities and multi-product navigation.

Gateway behavior is subject to the GregAPI console; native Anthropic capabilities follow the official documentation.


## OpenAPI

````yaml openapi/llm-en.yaml POST /v1/messages
openapi: 3.0.3
info:
  title: GregAPI Large Language Models
  version: 1.0.0
  description: >-
    Large language model (LLM) endpoints behind the GregAPI unified gateway,
    covering general chat completion, multi-modal responses, and native
    message/generation protocols.
servers:
  - url: https://api.gregapi.com
security:
  - bearerAuth: []
paths:
  /v1/messages:
    post:
      summary: Messages API
      description: >-
        Call Claude models using the Anthropic Messages API protocol, directly
        via the official SDK or cURL.
      parameters:
        - name: anthropic-version
          in: header
          required: true
          schema:
            type: string
            example: '2023-06-01'
          description: Anthropic API version
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - max_tokens
                - messages
              properties:
                model:
                  type: string
                  description: Model name
                max_tokens:
                  type: integer
                  description: Maximum output tokens
                messages:
                  type: array
                  description: Conversation messages
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                        enum:
                          - user
                          - assistant
                      content:
                        type: string
            example:
              model: claude-opus-4-6
              max_tokens: 1024
              messages:
                - role: user
                  content: Hello, please introduce yourself in one sentence.
      responses:
        '200':
          description: Successful message response
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.