Last active
December 18, 2024 08:49
-
-
Save constantm/57df69c4ad265605732fe2a864024662 to your computer and use it in GitHub Desktop.
Anthropic Claude OpenAPI Specification (with PDF beta headers)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openapi: 3.0.3 | |
info: | |
title: Anthropics Messages API | |
version: 1.0.0 | |
servers: | |
- url: https://api.anthropic.com | |
paths: | |
/v1/messages: | |
post: | |
summary: Send messages and receive a response from the Anthropic model | |
description: This endpoint sends one or more messages to the Anthropic model and returns the model's response. Refer to the Anthropics Messages API documentation for more details. | |
operationId: sendMessage | |
tags: | |
- Messages | |
parameters: | |
- name: anthropic-version | |
in: header | |
required: true | |
schema: | |
type: string | |
example: "2023-06-01" | |
description: Specifies the version of the Anthropic API to use. | |
requestBody: | |
required: true | |
content: | |
application/json: | |
schema: | |
type: object | |
required: | |
- model | |
- messages | |
properties: | |
model: | |
type: string | |
description: The identifier of the model to send messages to. | |
example: "claude-3-5-sonnet-20241022" | |
max_tokens: | |
type: integer | |
description: The maximum number of tokens to generate in the response. | |
example: 1024 | |
messages: | |
type: array | |
description: A list of messages in the conversation so far. | |
items: | |
type: object | |
required: | |
- role | |
- content | |
properties: | |
role: | |
type: string | |
description: The role of the entity sending the message, typically "user" or "assistant". | |
example: "user" | |
content: | |
type: array | |
description: The content of the message. Each element can be text or a document. | |
items: | |
type: object | |
oneOf: | |
- type: object | |
description: A document content block. | |
required: | |
- type | |
- source | |
properties: | |
type: | |
type: string | |
description: Indicates this content block is a document. | |
example: "document" | |
source: | |
type: object | |
description: Source information for the document. | |
required: | |
- type | |
- media_type | |
- data | |
properties: | |
type: | |
type: string | |
description: The encoding type of the document data. | |
example: "base64" | |
media_type: | |
type: string | |
description: The MIME type of the document. | |
example: "application/pdf" | |
data: | |
type: string | |
description: Base64-encoded document data. | |
example: "$PDF_BASE64" | |
cache_control: | |
type: object | |
description: Cache control settings for the document. | |
properties: | |
type: | |
type: string | |
description: The cache control strategy. | |
example: "ephemeral" | |
- type: object | |
description: A text content block. | |
required: | |
- type | |
- text | |
properties: | |
type: | |
type: string | |
description: Indicates this content block is text. | |
example: "text" | |
text: | |
type: string | |
description: The text content of the message. | |
example: "Which model has the highest human preference win rates across each use-case?" | |
responses: | |
'200': | |
description: Successful response | |
content: | |
application/json: | |
schema: | |
type: object | |
properties: | |
content: | |
type: array | |
description: The assistant's response message content blocks. | |
items: | |
type: object | |
properties: | |
text: | |
type: string | |
description: The text of the assistant's response. | |
type: | |
type: string | |
description: The type of the content block. | |
id: | |
type: string | |
description: The unique identifier of the message. | |
model: | |
type: string | |
description: The model that produced the response. | |
role: | |
type: string | |
description: The role of the message author, typically "assistant". | |
stop_reason: | |
type: string | |
description: The reason the model stopped producing tokens. | |
stop_sequence: | |
type: string | |
nullable: true | |
description: The stop sequence that caused the model to stop, if any. | |
type: | |
type: string | |
description: The type of the returned object, typically "message". | |
usage: | |
type: object | |
description: Information about token usage. | |
properties: | |
input_tokens: | |
type: integer | |
description: The number of input tokens consumed. | |
output_tokens: | |
type: integer | |
description: The number of output tokens produced. | |
example: | |
content: | |
- text: "Hi! My name is Claude." | |
type: "text" | |
id: "msg_013Zva2CMHLNnXjNJJKqJ2EF" | |
model: "claude-3-5-sonnet-20241022" | |
role: "assistant" | |
stop_reason: "end_turn" | |
stop_sequence: null | |
type: "message" | |
usage: | |
input_tokens: 2095 | |
output_tokens: 503 | |
'400': | |
description: Bad request - invalid input or parameters. | |
'401': | |
description: Unauthorized - invalid or missing API key. | |
'500': | |
description: Internal server error. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like Anthropic still hasn't managed to get an OpenAPI schema up and running, so here's a schema built from their docs.