## Base URL

All API requests are made to:

```
https://api.modelstack.cc
```

## Supported API Formats

ModelStack supports **multiple API formats** so you can use your preferred SDK without changes:

- **OpenAI format** - Compatible with OpenAI SDK and most AI tools
- **Anthropic format** - Native Claude API format with advanced features

Just change the base URL and API key - no other code changes needed.

## Available Endpoints

### OpenAI-Compatible Endpoints

| Method | Endpoint               | Description                              |
| ------ | ---------------------- | ---------------------------------------- |
| `POST` | `/v1/chat/completions` | Create a chat completion (OpenAI format) |
| `GET`  | `/v1/models`           | List available models                    |

### Anthropic-Compatible Endpoints

| Method | Endpoint                    | Description                         |
| ------ | --------------------------- | ----------------------------------- |
| `POST` | `/v1/messages`              | Create a message (Anthropic format) |
| `POST` | `/v1/messages/count_tokens` | Count tokens for a message          |

## Authentication

All requests require an API key passed via the `Authorization` header:

```
Authorization: Bearer your_api_key
```

API keys are created and managed from your [dashboard](https://modelstack.cc/dashboard).

## Request Format

All requests use JSON. Set the `Content-Type` header:

```
Content-Type: application/json
```

## Response Format

Responses follow the OpenAI response format:

```json
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1699000000,
  "model": "claude-sonnet-4-6",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 15,
    "total_tokens": 25
  }
}
```

## Streaming

ModelStack supports Server-Sent Events (SSE) streaming. Set `"stream": true` in your request body to receive incremental responses.

## Rate Limits

When you exceed your current rate limit, requests return a `429 Too Many Requests` error. Implement exponential backoff and check your dashboard for account details.
