{
  "openapi": "3.1.0",
  "info": {
    "title": "Anthropic Messages API",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.cometapi.com"
    }
  ],
  "security": [
    {
      "apiKeyAuth": []
    }
  ],
  "paths": {
    "/v1/messages": {
      "post": {
        "summary": "Anthropic Messages",
        "operationId": "anthropic_messages",
        "description": "Send structured messages to Claude models using the Anthropic native API format. Supports text and multimodal inputs, multi-turn conversations, adaptive thinking, tool use, prompt caching, streaming, and web search. Use this endpoint when you need Claude-specific features like adaptive thinking or prompt caching that are not available through the OpenAI-compatible endpoint.",
        "parameters": [
          {
            "name": "anthropic-version",
            "in": "header",
            "required": false,
            "description": "The Anthropic API version to use. Defaults to `2023-06-01`.",
            "schema": {
              "type": "string",
              "default": "2023-06-01",
              "example": "2023-06-01"
            }
          },
          {
            "name": "anthropic-beta",
            "in": "header",
            "required": false,
            "description": "Comma-separated list of beta features to enable. Examples: `max-tokens-3-5-sonnet-2024-07-15`, `pdfs-2024-09-25`, `output-128k-2025-02-19`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "messages",
                  "max_tokens"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "description": "The Claude model to use. See the [Models page](/overview/models) for available Claude model IDs.",
                    "example": "claude-sonnet-5"
                  },
                  "messages": {
                    "type": "array",
                    "description": "The conversation messages. Must alternate between `user` and `assistant` roles. Each message's `content` can be a string or an array of content blocks (text, image, document, tool_use, tool_result). There is a limit of 100,000 messages per request.",
                    "items": {
                      "type": "object",
                      "required": [
                        "role",
                        "content"
                      ],
                      "properties": {
                        "role": {
                          "type": "string",
                          "description": "The role of the message author.",
                          "enum": [
                            "user",
                            "assistant"
                          ]
                        },
                        "content": {
                          "description": "The message content. Either a plain string or an array of content blocks for multimodal input.",
                          "oneOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "description": "The content block type.",
                                    "enum": [
                                      "text",
                                      "image",
                                      "document",
                                      "tool_use",
                                      "tool_result"
                                    ]
                                  },
                                  "text": {
                                    "type": "string",
                                    "description": "Text content (for `text` type blocks)."
                                  },
                                  "source": {
                                    "type": "object",
                                    "description": "Source data for `image` or `document` blocks.",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "base64",
                                          "url"
                                        ],
                                        "description": "Image source type: `url` for a public image URL, or `base64` for inline data."
                                      },
                                      "media_type": {
                                        "type": "string",
                                        "description": "Image MIME type for base64 sources, such as `image/jpeg` or `image/png`."
                                      },
                                      "data": {
                                        "type": "string",
                                        "description": "Base64-encoded image bytes when `type` is `base64`."
                                      },
                                      "url": {
                                        "type": "string",
                                        "description": "Public HTTPS image URL when `type` is `url`. The provider must be able to download it."
                                      }
                                    }
                                  },
                                  "cache_control": {
                                    "type": "object",
                                    "description": "Cache control for prompt caching. Set `{\"type\": \"ephemeral\"}` to cache this content block.",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "ephemeral"
                                        ],
                                        "description": "Cache control type. Use `ephemeral`."
                                      },
                                      "ttl": {
                                        "type": "string",
                                        "description": "Cache TTL. Options: `ephemeral_5m` (5 min), `ephemeral_1h` (1 hour)."
                                      }
                                    }
                                  }
                                }
                              }
                            }
                          ]
                        }
                      }
                    }
                  },
                  "max_tokens": {
                    "type": "integer",
                    "description": "The maximum number of tokens to generate. The model may stop before reaching this limit. When using `thinking`, the thinking tokens count towards this limit.",
                    "minimum": 1,
                    "example": 1024
                  },
                  "system": {
                    "description": "System prompt providing context and instructions to Claude. Can be a plain string or an array of content blocks (useful for prompt caching).",
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "text"
                              ],
                              "description": "Content block type, `text`."
                            },
                            "text": {
                              "type": "string",
                              "description": "System prompt text for this block."
                            },
                            "cache_control": {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "ephemeral"
                                  ],
                                  "description": "Cache control type. Use `ephemeral`."
                                }
                              },
                              "description": "Marks this system block as a prompt-cache breakpoint."
                            }
                          }
                        }
                      }
                    ]
                  },
                  "temperature": {
                    "type": "number",
                    "description": "Model-dependent sampling control. Many newer Claude models reject non-default `temperature` values on the Messages API. Omit this field unless you have verified that the selected model accepts it; if the model returns an unsupported or deprecated-parameter error, remove the field instead of substituting another sampling value.",
                    "minimum": 0,
                    "maximum": 1,
                    "default": 1,
                    "example": 1
                  },
                  "top_p": {
                    "type": "number",
                    "description": "Model-dependent nucleus sampling control. Many newer Claude models reject non-default `top_p` values on the Messages API. Omit this field unless you have verified support for the selected model. Do not set `temperature` and `top_p` together.",
                    "minimum": 0,
                    "maximum": 1,
                    "example": 1
                  },
                  "top_k": {
                    "type": "integer",
                    "description": "Model-dependent top-k sampling control. Many newer Claude models reject non-default `top_k` values on the Messages API. Omit this field unless you have verified support for the selected model.",
                    "minimum": 0,
                    "example": 0
                  },
                  "stream": {
                    "type": "boolean",
                    "description": "If `true`, stream the response incrementally using Server-Sent Events (SSE). Events include `message_start`, `content_block_start`, `content_block_delta`, `content_block_stop`, `message_delta`, and `message_stop`.",
                    "default": false
                  },
                  "stop_sequences": {
                    "type": "array",
                    "description": "Custom strings that cause the model to stop generating when encountered. The stop sequence is not included in the response.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "thinking": {
                    "type": "object",
                    "description": "Controls Claude thinking when the selected model supports a configurable thinking mode. For newer adaptive-thinking models, use `{\"type\":\"adaptive\"}` with `output_config.effort`, or omit `thinking` when adaptive thinking is already the model default. Manual `{\"type\":\"enabled\",\"budget_tokens\":...}` is supported only by older models and is rejected by newer Claude models.",
                    "properties": {
                      "type": {
                        "type": "string",
                        "description": "Thinking mode. `adaptive` lets the model decide when and how much to think. `disabled` turns thinking off only on models that support disabling it. `enabled` is the legacy manual-budget mode and is rejected by newer Claude models.",
                        "enum": [
                          "adaptive",
                          "disabled",
                          "enabled"
                        ]
                      },
                      "budget_tokens": {
                        "type": "integer",
                        "description": "Legacy manual-thinking token budget. Minimum: 1,024 when accepted. These tokens count toward `max_tokens`. Do not send this field to newer adaptive-thinking models that reject manual thinking budgets.",
                        "minimum": 1024
                      },
                      "display": {
                        "type": "string",
                        "description": "Controls visible thinking blocks on models that support display selection. `summarized` returns a readable thinking summary; `omitted` returns an empty thinking field with continuity metadata where applicable.",
                        "enum": [
                          "summarized",
                          "omitted"
                        ]
                      }
                    }
                  },
                  "tools": {
                    "type": "array",
                    "description": "Tools the model may use. Supports client-defined functions, web search (`web_search_20250305`), web fetch (`web_fetch_20250910`), code execution (`code_execution_20250522`), and more.",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "description": "Tool name. The model repeats it in `tool_use` blocks when it calls the tool."
                        },
                        "description": {
                          "type": "string",
                          "description": "A description of what the tool does."
                        },
                        "input_schema": {
                          "type": "object",
                          "description": "JSON Schema defining the tool's input parameters."
                        },
                        "type": {
                          "type": "string",
                          "description": "The tool type. Required for server tools (e.g., `web_search_20250305`, `web_fetch_20250910`, `code_execution_20250522`)."
                        },
                        "max_uses": {
                          "type": "integer",
                          "description": "Maximum number of times this tool can be used in a single request."
                        }
                      }
                    }
                  },
                  "tool_choice": {
                    "type": "object",
                    "description": "Controls how the model uses tools.",
                    "properties": {
                      "type": {
                        "type": "string",
                        "description": "The tool choice mode: `auto` (model decides), `any` (must use a tool), `tool` (must use a specific tool), or `none` (no tools).",
                        "enum": [
                          "auto",
                          "any",
                          "tool",
                          "none"
                        ]
                      },
                      "name": {
                        "type": "string",
                        "description": "The specific tool name to use. Required when `type` is `tool`."
                      },
                      "disable_parallel_tool_use": {
                        "type": "boolean",
                        "description": "If `true`, prevent the model from calling multiple tools in parallel."
                      }
                    }
                  },
                  "metadata": {
                    "type": "object",
                    "description": "Request metadata for tracking and analytics.",
                    "properties": {
                      "user_id": {
                        "type": "string",
                        "description": "An external identifier for the user making the request. Used for abuse detection."
                      }
                    }
                  },
                  "output_config": {
                    "type": "object",
                    "description": "Configuration for response effort and output format. Field support depends on the selected Claude model.",
                    "properties": {
                      "effort": {
                        "type": "string",
                        "description": "Controls how much effort Claude applies to the response. `high` is the default for newer effort-capable models. Use `low` or `medium` for lower latency and cost, `xhigh` for advanced coding or agentic work when supported, and `max` only for the hardest tasks with a large `max_tokens` value.",
                        "enum": [
                          "low",
                          "medium",
                          "high",
                          "xhigh",
                          "max"
                        ],
                        "example": "medium"
                      },
                      "format": {
                        "type": "object",
                        "description": "Structured output configuration. Use `{\"type\":\"json\",\"schema\":{...}}` to ask for JSON that matches your schema when the selected model supports structured output."
                      }
                    }
                  },
                  "service_tier": {
                    "type": "string",
                    "description": "The service tier to use. `auto` tries priority capacity first, `standard_only` uses only standard capacity.",
                    "enum": [
                      "auto",
                      "standard_only"
                    ]
                  }
                }
              },
              "examples": {
                "Default": {
                  "summary": "Basic message",
                  "value": {
                    "model": "claude-sonnet-5",
                    "max_tokens": 1024,
                    "system": "You are a helpful assistant.",
                    "messages": [
                      {
                        "role": "user",
                        "content": "Hello, world"
                      }
                    ]
                  }
                },
                "Image Input": {
                  "summary": "Image Input",
                  "value": {
                    "model": "claude-sonnet-5",
                    "max_tokens": 1024,
                    "messages": [
                      {
                        "role": "user",
                        "content": [
                          {
                            "type": "image",
                            "source": {
                              "type": "url",
                              "url": "https://picsum.photos/seed/comet/800/600.jpg"
                            }
                          },
                          {
                            "type": "text",
                            "text": "Describe this image in one sentence."
                          }
                        ]
                      }
                    ]
                  }
                },
                "Prompt Cache": {
                  "summary": "With prompt caching",
                  "value": {
                    "model": "claude-sonnet-5",
                    "max_tokens": 1024,
                    "system": [
                      {
                        "type": "text",
                        "text": "You are an expert code reviewer. Analyze code for correctness, performance, security, and maintainability. Follow SOLID principles and provide actionable suggestions. [Long system prompt content that exceeds 1024 tokens to enable caching...]",
                        "cache_control": {
                          "type": "ephemeral"
                        }
                      }
                    ],
                    "messages": [
                      {
                        "role": "user",
                        "content": "Please review this Python code:\n\ndef calculate_order_total(items):\n    total = 0\n    for item in items:\n        total += item['price'] * item['quantity']\n    return total"
                      }
                    ]
                  }
                },
                "Streaming": {
                  "summary": "Streaming response",
                  "value": {
                    "model": "claude-sonnet-5",
                    "max_tokens": 256,
                    "stream": true,
                    "messages": [
                      {
                        "role": "user",
                        "content": "Hello"
                      }
                    ]
                  }
                },
                "Web Fetch": {
                  "summary": "With web fetch tool",
                  "value": {
                    "model": "claude-sonnet-5",
                    "max_tokens": 1024,
                    "messages": [
                      {
                        "role": "user",
                        "content": "Please analyze the content at https://arxiv.org/abs/1512.03385"
                      }
                    ],
                    "tools": [
                      {
                        "type": "web_fetch_20250910",
                        "name": "web_fetch",
                        "max_uses": 5
                      }
                    ]
                  }
                },
                "Adaptive Thinking": {
                  "summary": "With adaptive thinking and effort",
                  "value": {
                    "model": "claude-sonnet-5",
                    "max_tokens": 4096,
                    "thinking": {
                      "type": "adaptive"
                    },
                    "output_config": {
                      "effort": "xhigh"
                    },
                    "messages": [
                      {
                        "role": "user",
                        "content": "Analyze the trade-offs between a monolithic architecture and microservices for a small engineering team."
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. When `stream` is `true`, the response is a stream of SSE events.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Unique identifier for this message (e.g., `msg_01XFDUDYJgAACzvnptvVoYEL`)."
                    },
                    "type": {
                      "type": "string",
                      "description": "Always `message`.",
                      "enum": [
                        "message"
                      ]
                    },
                    "role": {
                      "type": "string",
                      "description": "Always `assistant`.",
                      "enum": [
                        "assistant"
                      ]
                    },
                    "content": {
                      "type": "array",
                      "description": "The response content blocks. May include `text`, `thinking`, `tool_use`, and other block types.",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "description": "The content block type.",
                            "enum": [
                              "text",
                              "thinking",
                              "tool_use"
                            ]
                          },
                          "text": {
                            "type": "string",
                            "description": "The generated text (for `text` blocks)."
                          },
                          "thinking": {
                            "type": "string",
                            "description": "Thinking text or summary for `thinking` blocks when the selected model returns visible thinking content."
                          },
                          "signature": {
                            "type": "string",
                            "description": "Cryptographic signature for the thinking block."
                          },
                          "id": {
                            "type": "string",
                            "description": "Tool use ID (for `tool_use` blocks)."
                          },
                          "name": {
                            "type": "string",
                            "description": "Tool name (for `tool_use` blocks)."
                          },
                          "input": {
                            "type": "object",
                            "description": "Tool input arguments (for `tool_use` blocks)."
                          }
                        }
                      }
                    },
                    "model": {
                      "type": "string",
                      "description": "The specific model version that generated this response, such as `claude-sonnet-5`."
                    },
                    "stop_reason": {
                      "type": "string",
                      "description": "Why the model stopped generating. `refusal` can be returned as a successful HTTP response when the model declines a request.",
                      "enum": [
                        "end_turn",
                        "max_tokens",
                        "stop_sequence",
                        "tool_use",
                        "pause_turn",
                        "refusal"
                      ]
                    },
                    "stop_sequence": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "The stop sequence that caused the model to stop, if applicable."
                    },
                    "usage": {
                      "type": "object",
                      "description": "Token usage statistics.",
                      "properties": {
                        "input_tokens": {
                          "type": "integer",
                          "description": "Number of input tokens (prompt + conversation history)."
                        },
                        "output_tokens": {
                          "type": "integer",
                          "description": "Number of output tokens generated."
                        },
                        "cache_creation_input_tokens": {
                          "type": "integer",
                          "description": "Number of input tokens used to create the prompt cache."
                        },
                        "cache_read_input_tokens": {
                          "type": "integer",
                          "description": "Number of input tokens read from the prompt cache."
                        },
                        "cache_creation": {
                          "type": "object",
                          "description": "Detailed cache creation token breakdown by TTL tier.",
                          "properties": {
                            "ephemeral_5m_input_tokens": {
                              "type": "integer",
                              "description": "Tokens written to 5-minute ephemeral cache."
                            },
                            "ephemeral_1h_input_tokens": {
                              "type": "integer",
                              "description": "Tokens written to 1-hour ephemeral cache."
                            }
                          }
                        },
                        "output_tokens_details": {
                          "type": "object",
                          "description": "Detailed output token breakdown when returned by the selected model.",
                          "properties": {
                            "thinking_tokens": {
                              "type": "integer",
                              "description": "Number of output tokens used for model thinking when reported."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Python",
            "label": "Basic",
            "source": "import os\nimport anthropic\n\nclient = anthropic.Anthropic(\n    base_url=\"https://api.cometapi.com\",\n    api_key=os.environ[\"COMETAPI_KEY\"],\n)\n\nmessage = client.messages.create(\n    model=\"claude-sonnet-5\",\n    max_tokens=1024,\n    system=\"You are a helpful assistant.\",\n    messages=[\n        {\"role\": \"user\", \"content\": \"Hello, world\"}\n    ],\n)\n\nprint(message.content[0].text)\n"
          },
          {
            "lang": "Python",
            "label": "Prompt Cache",
            "source": "import os\nimport anthropic\n\nclient = anthropic.Anthropic(\n    base_url=\"https://api.cometapi.com\",\n    api_key=os.environ[\"COMETAPI_KEY\"],\n)\n\nmessage = client.messages.create(\n    model=\"claude-sonnet-5\",\n    max_tokens=1024,\n    system=[\n        {\n            \"type\": \"text\",\n            \"text\": \"You are an expert code reviewer. Analyze code, identify issues, \"\n                    \"and suggest improvements following SOLID principles...\",\n            \"cache_control\": {\"type\": \"ephemeral\"},\n        }\n    ],\n    messages=[\n        {\n            \"role\": \"user\",\n            \"content\": \"Please review this Python code:\\n\\n\"\n                       \"def calculate_order_total(items):\\n\"\n                       \"    total = 0\\n\"\n                       \"    for item in items:\\n\"\n                       \"        total += item['price'] * item['quantity']\\n\"\n                       \"    return total\",\n        }\n    ],\n)\n\nprint(message.content[0].text)\n"
          },
          {
            "lang": "Python",
            "label": "Adaptive thinking",
            "source": "import os\nimport anthropic\n\nclient = anthropic.Anthropic(\n    base_url=\"https://api.cometapi.com\",\n    api_key=os.environ[\"COMETAPI_KEY\"],\n)\n\nmessage = client.messages.create(\n    model=\"claude-sonnet-5\",\n    max_tokens=4096,\n    thinking={\"type\": \"adaptive\"},\n    output_config={\"effort\": \"xhigh\"},\n    messages=[\n        {\n            \"role\": \"user\",\n            \"content\": \"Analyze the trade-offs between a monolithic architecture and microservices for a small engineering team.\",\n        }\n    ],\n)\n\nfor block in message.content:\n    if block.type == \"text\":\n        print(block.text)\n"
          },
          {
            "lang": "Python",
            "label": "Effort control",
            "source": "import os\nimport anthropic\n\nclient = anthropic.Anthropic(\n    base_url=\"https://api.cometapi.com\",\n    api_key=os.environ[\"COMETAPI_KEY\"],\n)\n\nmessage = client.messages.create(\n    model=\"claude-sonnet-5\",\n    max_tokens=2048,\n    messages=[\n        {\n            \"role\": \"user\",\n            \"content\": \"Summarize the key risks in moving a billing service to microservices.\",\n        }\n    ],\n    output_config={\"effort\": \"low\"},\n)\n\nprint(message.content[0].text)\n"
          },
          {
            "lang": "Python",
            "label": "Streaming",
            "source": "import os\nimport anthropic\n\nclient = anthropic.Anthropic(\n    base_url=\"https://api.cometapi.com\",\n    api_key=os.environ[\"COMETAPI_KEY\"],\n)\n\nwith client.messages.stream(\n    model=\"claude-sonnet-5\",\n    max_tokens=256,\n    messages=[\n        {\"role\": \"user\", \"content\": \"Hello\"}\n    ],\n) as stream:\n    for text in stream.text_stream:\n        print(text, end=\"\")\n"
          },
          {
            "lang": "Python",
            "label": "Web Fetch",
            "source": "import os\nimport anthropic\n\nclient = anthropic.Anthropic(\n    base_url=\"https://api.cometapi.com\",\n    api_key=os.environ[\"COMETAPI_KEY\"],\n)\n\nmessage = client.messages.create(\n    model=\"claude-sonnet-5\",\n    max_tokens=1024,\n    messages=[\n        {\n            \"role\": \"user\",\n            \"content\": \"Please analyze the content at https://arxiv.org/abs/1512.03385\",\n        }\n    ],\n    tools=[\n        {\n            \"type\": \"web_fetch_20250910\",\n            \"name\": \"web_fetch\",\n            \"max_uses\": 5,\n        }\n    ],\n)\n\nprint(message.content)\n"
          },
          {
            "lang": "Python",
            "label": "Image Input",
            "source": "import os\nimport anthropic\n\nclient = anthropic.Anthropic(\n    base_url=\"https://api.cometapi.com\",\n    api_key=os.environ[\"COMETAPI_KEY\"],\n)\n\nmessage = client.messages.create(\n    model=\"claude-sonnet-5\",\n    max_tokens=1024,\n    messages=[\n        {\n            \"role\": \"user\",\n            \"content\": [\n                {\n                    \"type\": \"image\",\n                    \"source\": {\n                        \"type\": \"url\",\n                        \"url\": \"https://picsum.photos/seed/comet/800/600.jpg\",\n                    },\n                },\n                {\"type\": \"text\", \"text\": \"Describe this image in one sentence.\"},\n            ],\n        }\n    ],\n)\n\nprint(message.content[0].text)\n"
          },
          {
            "lang": "JavaScript",
            "label": "Basic",
            "source": "import Anthropic from \"@anthropic-ai/sdk\";\n\nconst client = new Anthropic({\n    apiKey: process.env.COMETAPI_KEY,\n    baseURL: \"https://api.cometapi.com\",\n});\n\nconst message = await client.messages.create({\n    model: \"claude-sonnet-5\",\n    max_tokens: 1024,\n    system: \"You are a helpful assistant.\",\n    messages: [\n        { role: \"user\", content: \"Hello, world\" },\n    ],\n});\n\nconsole.log(message.content[0].text);\n"
          },
          {
            "lang": "JavaScript",
            "label": "Adaptive thinking",
            "source": "import Anthropic from \"@anthropic-ai/sdk\";\n\nconst client = new Anthropic({\n    apiKey: process.env.COMETAPI_KEY,\n    baseURL: \"https://api.cometapi.com\",\n});\n\nconst message = await client.messages.create({\n    model: \"claude-sonnet-5\",\n    max_tokens: 4096,\n    thinking: { type: \"adaptive\" },\n    output_config: { effort: \"xhigh\" },\n    messages: [\n        {\n            role: \"user\",\n            content: \"Analyze the trade-offs between a monolithic architecture and microservices for a small engineering team.\",\n        },\n    ],\n});\n\nfor (const block of message.content) {\n    if (block.type === \"text\") {\n        console.log(block.text);\n    }\n}\n"
          },
          {
            "lang": "JavaScript",
            "label": "Effort control",
            "source": "import Anthropic from \"@anthropic-ai/sdk\";\n\nconst client = new Anthropic({\n    apiKey: process.env.COMETAPI_KEY,\n    baseURL: \"https://api.cometapi.com\",\n});\n\nconst message = await client.messages.create({\n    model: \"claude-sonnet-5\",\n    max_tokens: 2048,\n    messages: [\n        {\n            role: \"user\",\n            content: \"Summarize the key risks in moving a billing service to microservices.\",\n        },\n    ],\n    output_config: { effort: \"low\" },\n});\n\nconsole.log(message.content[0].text);\n"
          },
          {
            "lang": "JavaScript",
            "label": "Streaming",
            "source": "import Anthropic from \"@anthropic-ai/sdk\";\n\nconst client = new Anthropic({\n    apiKey: process.env.COMETAPI_KEY,\n    baseURL: \"https://api.cometapi.com\",\n});\n\nconst stream = await client.messages.create({\n    model: \"claude-sonnet-5\",\n    max_tokens: 256,\n    messages: [\n        { role: \"user\", content: \"Hello\" },\n    ],\n    stream: true,\n});\n\nfor await (const event of stream) {\n    if (event.type === \"content_block_delta\" && event.delta.type === \"text_delta\") {\n        process.stdout.write(event.delta.text);\n    }\n}\n"
          },
          {
            "lang": "JavaScript",
            "label": "Web Fetch",
            "source": "import Anthropic from \"@anthropic-ai/sdk\";\n\nconst client = new Anthropic({\n    apiKey: process.env.COMETAPI_KEY,\n    baseURL: \"https://api.cometapi.com\",\n});\n\nconst message = await client.messages.create({\n    model: \"claude-sonnet-5\",\n    max_tokens: 1024,\n    messages: [\n        {\n            role: \"user\",\n            content: \"Please analyze the content at https://arxiv.org/abs/1512.03385\",\n        },\n    ],\n    tools: [\n        {\n            type: \"web_fetch_20250910\",\n            name: \"web_fetch\",\n            max_uses: 5,\n        },\n    ],\n});\n\nconsole.log(message.content);\n"
          },
          {
            "lang": "JavaScript",
            "label": "Image Input",
            "source": "import Anthropic from \"@anthropic-ai/sdk\";\n\nconst client = new Anthropic({\n    apiKey: process.env.COMETAPI_KEY,\n    baseURL: \"https://api.cometapi.com\",\n});\n\nconst message = await client.messages.create({\n    model: \"claude-sonnet-5\",\n    max_tokens: 1024,\n    messages: [\n        {\n            role: \"user\",\n            content: [\n                {\n                    type: \"image\",\n                    source: { type: \"url\", url: \"https://picsum.photos/seed/comet/800/600.jpg\" },\n                },\n                { type: \"text\", text: \"Describe this image in one sentence.\" },\n            ],\n        },\n    ],\n});\n\nconsole.log(message.content[0].text);\n"
          },
          {
            "lang": "JavaScript",
            "label": "Prompt Cache",
            "source": "import Anthropic from \"@anthropic-ai/sdk\";\n\nconst client = new Anthropic({\n    apiKey: process.env.COMETAPI_KEY,\n    baseURL: \"https://api.cometapi.com\",\n});\n\nconst message = await client.messages.create({\n    model: \"claude-sonnet-5\",\n    max_tokens: 1024,\n    system: [\n        {\n            type: \"text\",\n            text: \"You are an expert code reviewer. Analyze code, identify issues, and suggest improvements following SOLID principles...\",\n            cache_control: { type: \"ephemeral\" },\n        },\n    ],\n    messages: [\n        {\n            role: \"user\",\n            content: \"Please review this Python code:\\n\\ndef calculate_order_total(items):\\n    total = 0\\n    for item in items:\\n        total += item['price'] * item['quantity']\\n    return total\",\n        },\n    ],\n});\n\nconsole.log(message.content[0].text);\n"
          },
          {
            "lang": "Shell",
            "label": "Basic",
            "source": "curl https://api.cometapi.com/v1/messages \\\n  -H \"Content-Type: application/json\" \\\n  -H \"x-api-key: $COMETAPI_KEY\" \\\n  -H \"anthropic-version: 2023-06-01\" \\\n  -d '{\n    \"model\": \"claude-sonnet-5\",\n    \"max_tokens\": 1024,\n    \"system\": \"You are a helpful assistant.\",\n    \"messages\": [\n      {\"role\": \"user\", \"content\": \"Hello, world\"}\n    ]\n  }'\n"
          },
          {
            "lang": "Shell",
            "label": "Adaptive thinking",
            "source": "curl https://api.cometapi.com/v1/messages \\\n  -H \"Content-Type: application/json\" \\\n  -H \"x-api-key: $COMETAPI_KEY\" \\\n  -H \"anthropic-version: 2023-06-01\" \\\n  -d '{\n    \"model\": \"claude-sonnet-5\",\n    \"max_tokens\": 4096,\n    \"thinking\": {\"type\": \"adaptive\"},\n    \"output_config\": {\"effort\": \"xhigh\"},\n    \"messages\": [\n      {\"role\": \"user\", \"content\": \"Analyze the trade-offs between a monolithic architecture and microservices for a small engineering team.\"}\n    ]\n  }'\n"
          },
          {
            "lang": "Shell",
            "label": "Effort control",
            "source": "curl https://api.cometapi.com/v1/messages \\\n  -H \"Content-Type: application/json\" \\\n  -H \"x-api-key: $COMETAPI_KEY\" \\\n  -H \"anthropic-version: 2023-06-01\" \\\n  -d '{\n    \"model\": \"claude-sonnet-5\",\n    \"max_tokens\": 2048,\n    \"messages\": [\n      {\"role\": \"user\", \"content\": \"Summarize the key risks in moving a billing service to microservices.\"}\n    ],\n    \"output_config\": {\"effort\": \"low\"}\n  }'\n"
          },
          {
            "lang": "Shell",
            "label": "Streaming",
            "source": "curl https://api.cometapi.com/v1/messages \\\n  -H \"Content-Type: application/json\" \\\n  -H \"x-api-key: $COMETAPI_KEY\" \\\n  -H \"anthropic-version: 2023-06-01\" \\\n  -d '{\n    \"model\": \"claude-sonnet-5\",\n    \"max_tokens\": 256,\n    \"stream\": true,\n    \"messages\": [\n      {\"role\": \"user\", \"content\": \"Hello\"}\n    ]\n  }'\n"
          },
          {
            "lang": "Shell",
            "label": "Prompt Cache",
            "source": "curl https://api.cometapi.com/v1/messages \\\n  -H \"Content-Type: application/json\" \\\n  -H \"x-api-key: $COMETAPI_KEY\" \\\n  -H \"anthropic-version: 2023-06-01\" \\\n  -d '{\n    \"model\": \"claude-sonnet-5\",\n    \"max_tokens\": 1024,\n    \"system\": [\n      {\n        \"type\": \"text\",\n        \"text\": \"You are an expert code reviewer...\",\n        \"cache_control\": {\"type\": \"ephemeral\"}\n      }\n    ],\n    \"messages\": [\n      {\"role\": \"user\", \"content\": \"Please review this code...\"}\n    ]\n  }'\n"
          },
          {
            "lang": "Shell",
            "label": "Web Fetch",
            "source": "curl https://api.cometapi.com/v1/messages \\\n  -H \"Content-Type: application/json\" \\\n  -H \"x-api-key: $COMETAPI_KEY\" \\\n  -H \"anthropic-version: 2023-06-01\" \\\n  -d '{\n    \"model\": \"claude-sonnet-5\",\n    \"max_tokens\": 1024,\n    \"messages\": [\n      {\"role\": \"user\", \"content\": \"Please analyze the content at https://arxiv.org/abs/1512.03385\"}\n    ],\n    \"tools\": [\n      {\"type\": \"web_fetch_20250910\", \"name\": \"web_fetch\", \"max_uses\": 5}\n    ]\n  }'\n"
          },
          {
            "lang": "Shell",
            "label": "Image Input",
            "source": "curl https://api.cometapi.com/v1/messages \\\n  -H \"Content-Type: application/json\" \\\n  -H \"x-api-key: $COMETAPI_KEY\" \\\n  -H \"anthropic-version: 2023-06-01\" \\\n  -d '{\n    \"model\": \"claude-sonnet-5\",\n    \"max_tokens\": 1024,\n    \"messages\": [\n      {\n        \"role\": \"user\",\n        \"content\": [\n          {\"type\": \"image\", \"source\": {\"type\": \"url\", \"url\": \"https://picsum.photos/seed/comet/800/600.jpg\"}},\n          {\"type\": \"text\", \"text\": \"Describe this image in one sentence.\"}\n        ]\n      }\n    ]\n  }'\n"
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Your CometAPI key passed via the `x-api-key` header. `Authorization: Bearer $COMETAPI_KEY` is also supported."
      }
    }
  }
}