Content पर जाएं

Anthropic Message बनाएँ

client.messages.create(params)
POST/v1/messages

SandBase के Anthropic-compatible Messages endpoint के ज़रिए message बनाएँ। SandBase चुने गए provider के लिए model को map करता है और compatible request व response fields को बनाए रखता है।

Request headers

वैकल्पिक<string>x-api-key

SandBase API key। Authorization: Bearer भी स्वीकार है; दोनों मौजूद होने पर x-api-key को प्राथमिकता मिलती है।

वैकल्पिक<string>anthropic-version

upstream को भेजा जाने वाला Anthropic API version। न भेजने पर SandBase 2023-06-01 इस्तेमाल करता है।

डिफ़ॉल्ट: 2023-06-01T00:00:00.000Z

वैकल्पिक<string>anthropic-beta

comma से अलग किए गए beta feature identifiers, provider compatibility के अधीन।

Request body

MessageCreateParams
stringmodelज़रूरी

Anthropic-compatible model identifier।

object[]messagesज़रूरी

text या typed content blocks वाले user और assistant messages।

integermax_tokensज़रूरी

output tokens की अधिकतम संख्या।

वैकल्पिक<string | object[]>system

Top-level system instruction।

वैकल्पिक<number>temperature

0 से 1 तक sampling temperature।

डिफ़ॉल्ट: 1

वैकल्पिक<number>top_p

Nucleus sampling threshold।

वैकल्पिक<integer>top_k

sampling को top K tokens तक सीमित करें।

वैकल्पिक<string[]>stop_sequences

generation रोकने वाले custom sequences।

वैकल्पिक<boolean>stream

Anthropic-style Server-Sent Events लौटाएँ।

डिफ़ॉल्ट: false

वैकल्पिक<object>metadata

Request metadata, जिसमें वैकल्पिक user_id शामिल है।

वैकल्पिक<object[]>tools

model के लिए उपलब्ध tool definitions।

वैकल्पिक<object>tool_choice

tool चुनने के व्यवहार को नियंत्रित करता है।

वैकल्पिक<object>thinking

समर्थित models के लिए extended thinking configuration।

Authentication

x-api-key या Authorization: Bearer इस्तेमाल करें। दोनों दिए जाने पर x-api-key को प्राथमिकता मिलती है।

Transparent protocol

model mapping और configured provider compatibility rules को छोड़कर, SandBase compatible request fields, non-stream responses और SSE events को बिना protocol translation के आगे भेजता है।

Beta features

anthropic-beta मौजूद होने पर आगे भेजा जाता है। किसी candidate के compatibility rules असमर्थित beta fields हटा सकते हैं या उस candidate को छोड़ सकते हैं।

त्रुटियाँ

400

अमान्य request body या असमर्थित feature।

401

API key मौजूद नहीं है या अमान्य है।

402

संगठन की खर्च सीमा पूरी हो गई।

403

API Key की खर्च सीमा या संगठन permission विफलता।

404

Model नहीं मिला या उपलब्ध नहीं है।

413

provider ने request को बहुत बड़ा मानकर अस्वीकार कर दिया।

429

Provider की rate limit पार हो गई।

500

Prediction lifecycle या provider error।

502

उपयोगी content मिलने से पहले upstream stream समाप्त हो गया।

503

Routing विफल हुई या सभी provider candidates अनुपलब्ध थे।