---
title: "Anthropic Messages API on a PopNow text model"
method: POST
path: "/v1/messages"
tags: ["OpenAI Compatible"]
---

# Anthropic Messages API on a PopNow text model

`POST /v1/messages`

## Request

- Base URL: `https://api.popnow.ai`
- URL: `https://api.popnow.ai/v1/messages`
- Auth: HTTP bearer

Accepts an Anthropic Messages request (`model`, `system`, `messages`
with text / image / tool_use / tool_result blocks, `max_tokens`,
`temperature`, `top_p`, `top_k`, `stop_sequences`, `tools`,
`tool_choice`, `stream`) and translates it to a chat completion
internally. `stop_sequences` becomes the model's `stop` field, and
`tool_choice.disable_parallel_tool_use: true` becomes
`parallel_tool_calls: false`; a model that does not declare the
target field rejects the request with `400` instead of ignoring it.
Non-streaming calls return an Anthropic `message` object. Streaming
calls emit `message_start`, `content_block_start`,
`content_block_delta`, `content_block_stop`, `message_delta` and
`message_stop` events. Errors use the Anthropic
`{type:"error",error:{type,message}}` shape.

Billing: chat models are priced per token in credits (1 credit = $0.001), listed per 1M input and output
tokens in `credits` on `GET /api/v1/models` and `GET /v1/models`. When the request is accepted, the most it
can cost is held from your balance, computed from the input and `max_tokens` (the model's maximum output when
you omit it, so set `max_tokens` to keep holds small). When the reply ends you are charged its actual usage in
fractional credits, with no per-request minimum, and the rest of the hold is released. A balance below the
hold, or a key spend limit that would be exceeded, returns `402` before anything is sent to the model. A request
that fails or that the model refuses is refunded in full. The `X-PopNow-Task-Id` response header names the task;
`GET /api/v1/jobs/recordInfo` shows the final charge in `cost` (USD) and `exactCredits`. Message text is not
kept after the charge settles. Requests are forwarded to the model as sent and each model's own usage policy applies.

## Headers

- `Idempotency-Key` string

## Request body

- AnthropicMessageRequest
  - `model` string, required
  - `system` union
    - string
    - object[]
  - `messages` object[], required
    - `role` 'user' | 'assistant', required
    - `content` union, required
      - string
      - object[]
  - `max_tokens` integer, required
  - `temperature` number
  - `top_p` number
  - `top_k` integer
  - `stop_sequences` string[]
  - `tools` object[]
  - `tool_choice` object: `disable_parallel_tool_use: true` is translated to `parallel_tool_calls: false`.
  - `stream` boolean

## Response `200`

One Anthropic `message` object, or an SSE stream when `stream` is true.

- AnthropicMessage
  - `id` string, required
  - `type` 'message', required
  - `role` 'assistant', required
  - `model` string, required
  - `content` object[], required
    - `type` 'text' | 'tool_use', required
    - `text` string
    - `id` string
    - `name` string
    - `input` object
  - `stop_reason` 'end_turn' | 'max_tokens' | 'tool_use', required
  - `stop_sequence` unknown
  - `usage` object, required
    - `input_tokens` integer
    - `output_tokens` integer

## Other responses

- `400`: Error in the Anthropic `{type:"error",error:{type,message}}` shape.
- `401`: Error in the Anthropic `{type:"error",error:{type,message}}` shape.
- `402`: Error in the Anthropic `{type:"error",error:{type,message}}` shape.
- `403`: Error in the Anthropic `{type:"error",error:{type,message}}` shape.
- `404`: Error in the Anthropic `{type:"error",error:{type,message}}` shape.
- `409`: Error in the Anthropic `{type:"error",error:{type,message}}` shape.
- `413`: Error in the Anthropic `{type:"error",error:{type,message}}` shape.
- `429`: Error in the Anthropic `{type:"error",error:{type,message}}` shape.
- `500`: Error in the Anthropic `{type:"error",error:{type,message}}` shape.
- `503`: Error in the Anthropic `{type:"error",error:{type,message}}` shape.

---

[API](https://skmtc.dev/popnow/apis/popnow-api.md) · [All operations](https://skmtc.dev/popnow/apis/popnow-api/llms.txt) · [OpenAPI document](https://skmtc.dev/popnow/apis/popnow-api/revisions/fede911a6e9b?raw)
