BazaarLinkBazaarLink
साइन इन
दस्तावेज़API संदर्भSDK संदर्भएजेंटिक उपयोगAI स्किल्स

API संदर्भ

BazaarLink API का अवलोकन

BazaarLink मॉडल और प्रदाताओं के बीच एक समान, OpenAI-संगत अनुरोध और प्रतिक्रिया प्रारूप देता है। एक बार एकीकरण करके आप ऐप को दोबारा लिखे बिना मॉडल बदल सकते हैं।

OpenAPI विनिर्देश

पूरा BazaarLink API OpenAPI विनिर्देश में दर्ज है और YAML तथा JSON प्रारूप में उपलब्ध है:

API देखने या क्लाइंट लाइब्रेरी बनाने के लिए इन विनिर्देशों को Swagger UI, Postman या किसी OpenAPI-संगत कोड जनरेटर के साथ उपयोग करें।

अनुरोध

चैट कम्प्लीशन अनुरोध प्रारूप

चैट कम्प्लीशन का अनुरोध बॉडी इस एंडपॉइंट पर भेजा जाता है:

POST/api/v1/chat/completions

समर्थित फ़ील्ड की पूरी सूची के लिए देखें पैरामीटर

अनुरोध स्कीमा
// Definitions of subtypes are below
type Request = {
  // Required by BazaarLink Chat Completions
  model: string;                    // Use a provider-qualified catalog ID
  messages: Message[];             // Must contain at least one message

  // Generation
  stream?: boolean;
  temperature?: number;            // Range: [0, 2]
  max_tokens?: number;             // Positive integer
  max_completion_tokens?: number;  // Alias mapped to max_tokens upstream
  n?: number;
  seed?: number;
  stop?: string | string[];

  // Sampling
  top_p?: number;
  top_k?: number;
  frequency_penalty?: number;      // Range: [-2, 2]
  presence_penalty?: number;       // Range: [-2, 2]
  repetition_penalty?: number;     // Range: (0, 2]
  min_p?: number;                  // Range: [0, 1]
  top_a?: number;                  // Range: [0, 1]

  // Token probabilities
  logit_bias?: Record<number, number>;
  logprobs?: boolean;
  top_logprobs?: number;

  // Stable end-user identifier for abuse prevention
  user?: string;

  // Tool calling
  tools?: Tool[];
  tool_choice?: ToolChoice;
  parallel_tool_calls?: boolean;

  // Structured output
  response_format?: ResponseFormat;
  structured_outputs?: boolean;

  // Plugin configuration — forwarded to upstreams that support plugins.
  plugins?: Plugin[];

  // Multimodal and image-generation options
  modalities?: Array<"text" | "image">;
  image_config?: Record<string, unknown>;
  input_audio?: InputAudio;

  // Provider-specific reasoning controls
  reasoning_effort?: "low" | "medium" | "high";
  reasoning?: ReasoningConfig;
  thinking?: ThinkingConfig;
  enable_thinking?: boolean;

  // BazaarLink message transforms and fallback routing
  transforms?: Array<"middle-out">;
  models?: string[];             // Fallback list — this drives waterfall routing, not route
  route?: "fallback";            // Passthrough only; forwarded as-is, no local effect
  provider?: ProviderPreferences;
};

// Message types
type Message =
  | SystemMessage
  | UserMessage
  | AssistantMessage
  | ToolMessage;

type SystemMessage = {
  role: "system";
  content: string | ContentPart[];
  name?: string;
};

type UserMessage = {
  role: "user";
  content: string | ContentPart[];
  name?: string;
};

type AssistantMessage = {
  role: "assistant";
  content?: string | ContentPart[] | null;
  name?: string;
  tool_calls?: ToolCall[];
};

type ToolMessage = {
  role: "tool";
  content: string;
  tool_call_id: string;
  name?: string;
};

// Multimodal content parts
type ContentPart =
  | TextContentPart
  | ImageContentPart
  | FileContentPart
  | AudioContentPart
  | VideoContentPart;

type TextContentPart = {
  type: "text";
  text: string;
};

type ImageContentPart = {
  type: "image_url";
  image_url: {
    url: string;                    // Remote URL or base64 data URI
    detail?: string;
  };
};

type FileContentPart = {
  type: "file";
  file: {
    filename?: string;
    file_data: string;              // Base64 data URI
  };
};

type AudioContentPart = {
  type: "input_audio";
  input_audio: InputAudio;
};

type InputAudio = {
  data: string;                     // Raw base64 without a data URI prefix
  format: string;                   // For example "wav" or "mp3"
};

type VideoContentPart = {
  type: "video_url";
  video_url: {
    url: string;                    // Remote URL or base64 data URI
  };
};

// Tool calling subtypes
type FunctionDescription = {
  name: string;
  description?: string;
  parameters: object;               // JSON Schema object
};

type Tool = {
  type: "function";
  function: FunctionDescription;
};

type ToolChoice =
  | "none"
  | "auto"
  | "required"
  | {
      type: "function";
      function: {
        name: string;
      };
    };

type ToolCall = {
  id: string;
  type: "function";
  function: {
    name: string;
    arguments: string;
  };
};

// Structured output
type ResponseFormat =
  | {
      type: "json_object";
    }
  | {
      type: "json_schema";
      json_schema: {
        name: string;
        strict?: boolean;
        schema: object;
      };
    };

// Upstream plugin configuration
type Plugin = {
  id: string;
  enabled?: boolean;
  [key: string]: unknown;
};

// Reasoning controls vary by model family
type ReasoningConfig = {
  effort?: "low" | "medium" | "high";
  max_tokens?: number;
  exclude?: boolean;
};

type ThinkingConfig = {
  type?: "enabled" | "disabled";
  budget_tokens?: number;
};

// Provider routing preferences
type ProviderPreferences = {
  order?: string[];
  only?: string[];
  ignore?: string[];
  allow_fallbacks?: boolean;
  sort?:
    | "price"
    | "latency"
    | "throughput"
    | {
        by: string;
        partition?: string;
      };
  require_parameters?: boolean;
  data_collection?: "allow" | "deny";
  quantizations?: string[];
  max_price?: Record<string, number>;
};

संरचित आउटपुट

मॉडल को स्कीमा से मेल खाते हुए वैध JSON वापस करने के लिए बाध्य करें। विश्वसनीय अनुप्रयोगों के निर्माण के लिए यह आवश्यक है जो मॉडल आउटपुट को प्रोग्रामेटिक रूप से पार्स करता है।

  • json_objectमूल JSON मोड; मॉडल वैध JSON लौटाता है।
  • json_schemaसख्त स्कीमा मोड; आउटपुट दिए गए JSON Schema से मेल खाना चाहिए।

प्लगइन्स

BazaarLink plugins ऐरे को चुने गए अपस्ट्रीम रूट पर भेजता है। उपलब्धता मॉडल और प्रदाता पर निर्भर करती है; :online मॉडल वेरिएंट web प्लगइन भी सक्षम करता है।

JSON
{
  "model": "openai/gpt-4.1",
  "messages": [
    { "role": "user", "content": "What happened today?" }
  ],
  "plugins": [
    { "id": "web" }
  ]
}

वैकल्पिक शीर्षलेख

उपयोग ट्रैकिंग, डैशबोर्ड दृश्यता और सूक्ष्म विश्लेषण सक्षम करने के लिए अनुरोध हेडर में अपने एप्लिकेशन की पहचान करें।

TypeScript
await fetch("https://bazaarlink.ai/api/v1/chat/completions", {
  method: "POST",
  headers: {
    "Authorization": "Bearer <BAZAARLINK_API_KEY>",
    "Content-Type": "application/json",
    "HTTP-Referer": "https://your-app.example",
    "X-Title": "Your App"
  },
  body: JSON.stringify({
    model: "openai/gpt-4.1",
    messages: [{ role: "user", content: "Hello!" }]
  })
});

असिस्टेंट प्रीफ़िल

संगत मॉडल रूट पर आगे का उत्तर माँगने के लिए messages ऐरे के अंत में एक अधूरा assistant संदेश जोड़ें।

यह कैसे काम करता है
BazaarLink अंतिम assistant संदेश को सुरक्षित रखकर आगे भेजता है। उत्तर जारी रखने का व्यवहार चुने गए अपस्ट्रीम मॉडल और प्रदाता द्वारा लागू होता है, इसलिए हर रूट पर इसकी गारंटी नहीं है।
TypeScript
const response = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-4.6",
  messages: [
    { role: "user", content: "What is the meaning of life?" },
    // Intentional partial response; compatible routes continue from here.
    { role: "assistant", content: "My best answer is" }
  ]
});

प्रतिक्रियाएँ

BazaarLink अलग-अलग मॉडल और प्रदाताओं की कम्प्लीशन प्रतिक्रियाओं को एक समान OpenAI-संगत प्रारूप में सामान्यीकृत करता है।

कम्प्लीशन प्रतिक्रिया प्रारूप

choices हमेशा एक ऐरे होता है। स्ट्रीमिंग में delta और गैर-स्ट्रीमिंग में message मिलता है; उपलब्ध होने पर उपयोग और लागत का विवरण भी लौटता है।

प्रतिक्रिया स्कीमा
type Response = {
  id: string;
  object: "chat.completion" | "chat.completion.chunk";
  created: number;
  model: string;
  choices: Array<NonStreamingChoice | StreamingChoice>;
  usage?: {
    prompt_tokens: number;
    completion_tokens: number;
    total_tokens: number;
    cost?: number;
    prompt_tokens_details?: {
      cached_tokens: number;
      cache_write_tokens?: number;
      audio_tokens?: number;
    };
    completion_tokens_details?: {
      reasoning_tokens?: number;
      image_tokens?: number;
    };
  };
};

type NonStreamingChoice = {
  index: number;
  finish_reason: string | null;
  native_finish_reason: string | null;
  message: {
    role: "assistant";
    content: string | null;
    tool_calls?: ToolCall[];
  };
};

type StreamingChoice = {
  index: number;
  finish_reason: string | null;
  native_finish_reason: string | null;
  delta: {
    role?: string;
    content?: string | null;
    tool_calls?: ToolCall[];
  };
};

समाप्ति कारण

finish_reason को stop, length, tool_calls, content_filter और error जैसे मानों में सामान्यीकृत किया जाता है; native_finish_reason मूल प्रदाता मान रखता है।

JSON
{
  "finish_reason": "stop",
  "native_finish_reason": "stop"
}

लागत और आँकड़े पूछना

जेनरेशन आईडी (chat/completions प्रतिक्रिया आईडी या स्ट्रीमिंग x-bz-gen-id हेडर से) द्वारा एकल पूर्णता के लिए विस्तृत आंकड़े प्राप्त करें।

TypeScript
const generation = await fetch(
  "https://bazaarlink.ai/api/v1/generation?id=<GENERATION_ID>",
  {
    headers: {
      Authorization: "Bearer <BAZAARLINK_API_KEY>"
    }
  }
).then((response) => response.json());

चैट कम्प्लीशन

प्राथमिक समापन बिंदु। OpenAI Chat Completions API के साथ संगत।

POST/api/v1/chat/completions

अनुरोध बॉडी

modelआवश्यक
string
मॉडल आईडी, उदा. "openai/gpt-4o" या "anthropic/claude-3.5-sonnet"
messagesआवश्यक
Message[]
भूमिका और सामग्री के साथ संदेश वस्तुओं की सरणी
stream
boolean
यदि सत्य है, तो सर्वर-भेजे गए इवेंट स्ट्रीम लौटाता है। डिफ़ॉल्ट: ग़लत
temperature
number
सैंपलिंग तापमान 0-2। उच्चतर = अधिक यादृच्छिक. डिफ़ॉल्ट: 1
max_tokens
integer
उत्पन्न करने के लिए टोकन की अधिकतम संख्या max_tokens के लिए
max_completion_tokens
integer
Alias (OpenAI ओ-सीरीज़ संगत)। दोनों स्वीकृत हैं; जो भी प्रदान किया जाता है वह प्रभावी होता है
top_p
number
न्यूक्लियस नमूना संभाव्यता द्रव्यमान। डिफ़ॉल्ट: 1
top_k
integer
टोकन विकल्पों को शीर्ष-K तक सीमित करें। 0 = अक्षम (सभी पर विचार करें)। डिफ़ॉल्ट: 0
frequency_penalty
number
बार-बार टोकन को दंडित करें। रेंज: [-2, 2]। डिफ़ॉल्ट: 0
presence_penalty
number
उपस्थिति के आधार पर टोकन को दंडित करें। रेंज: [-2, 2]। डिफ़ॉल्ट: 0
repetition_penalty
number
इनपुट से टोकन पुनरावृत्ति को कम करें। रेंज: (0, 2]। डिफ़ॉल्ट: 1
min_p
number
शीर्ष टोकन के सापेक्ष न्यूनतम संभावना। रेंज: [0, 1]। डिफ़ॉल्ट: 0
top_a
number
डायनामिक टॉप-पी उच्चतम-संभावना टोकन पर आधारित है। रेंज: [0, 1]। डिफ़ॉल्ट: 0
seed
integer
पूर्णांक बीज। सभी मॉडलों के लिए गारंटी नहीं है
n
integer
उत्पन्न होने वाली पूर्णताओं की संख्या। डिफ़ॉल्ट: 1 नियतात्मक नमूने के लिए
user
string
निगरानी और दुरुपयोग का पता लगाने के लिए अंतिम-उपयोगकर्ता पहचानकर्ता। बिलिंग पर कोई प्रभाव नहीं पड़ता. केवल OpenAI-पारिवारिक मॉडल - नीचे नोट देखें।
stop
string | string[]
स्टॉप अनुक्रम - सामना होने पर पीढ़ी रुक जाती है
logit_bias
object
मैप टोकन आईडी को पूर्वाग्रह मानों के लिए [-100, 100] नमूनाकरण से पहले जोड़ा गया। केवल OpenAI-पारिवारिक मॉडल - नीचे नोट देखें।
logprobs
boolean
प्रत्येक आउटपुट टोकन की लॉग संभावनाएँ लौटाएँ। केवल OpenAI-पारिवारिक मॉडल - नीचे नोट देखें।
top_logprobs
integer
प्रति स्थिति पर लौटने के लिए सबसे संभावित टोकन की संख्या (लॉगप्रॉब्स की आवश्यकता है: सत्य)। रेंज: 0-20. केवल OpenAI-पारिवारिक मॉडल - नीचे नोट देखें।
tools
Tool[]
उन टूल (फ़ंक्शन) की सूची जिन्हें मॉडल कॉल कर सकता है
tool_choice
string | object
कंट्रोल्स टूल का उपयोग: "ऑटो", "कोई नहीं", या विशिष्ट टूल
parallel_tool_calls
boolean
उपकरण उपलब्ध कराए जाने पर समानांतर फ़ंक्शन कॉलिंग सक्षम करें। डिफ़ॉल्ट: सत्य. केवल OpenAI-पारिवारिक मॉडल - नीचे नोट देखें।
response_format
object
Force संरचित JSON आउटपुट। संरचित आउटपुट अनुभाग देखें
structured_outputs
boolean
इसका समर्थन करने वाले प्रदाताओं पर सख्त JSON-स्कीमा-अनुरूप आउटपुट का अनुरोध करें। ज्यों का त्यों पार कर लिया
reasoning
object
प्रदाता-विशिष्ट reasoning/thinking कॉन्फ़िगरेशन। ज्यों का त्यों पार कर लिया
reasoning_effort
string
OpenAI ओ-सीरीज़ शैली तर्क प्रयास: "कम", "मध्यम", या "उच्च"। ज्यों का त्यों पार कर लिया
transforms
string[]
Message लागू करने के लिए रूपांतरित होता है, उदा. ["मध्य-बाहर"]। ≤8k-संदर्भ मॉडल पर स्वत: लागू करना छोड़ें
models
string[]
फ़ॉलबैक मॉडल सूची - प्राथमिक विफल होने पर BazaarLink प्रत्येक को क्रम में आज़माता है
route
string
उन्नत रूटिंग संगतता फ़ील्ड — अधिकांश उपयोगकर्ताओं को इसकी आवश्यकता नहीं। फ़ॉलबैक हेतु "models" उपयोग करें।
provider
object
उन्नत रूटिंग वरीयताएँ — अधिकांश उपयोगकर्ताओं को इनकी आवश्यकता नहीं।
उपयोगकर्ता, लॉगप्रोब्स, टॉप_लॉगप्रोब्स, लॉगिट_बियास और पैरेलल_टूल_कॉल केवल OpenAI-फ़ैमिली मॉडल तक पहुंचते हैं
जब भी हल किए गए मॉडल को OpenAI के स्वयं के रूप में पहचाना नहीं जाता है, तो ये पांच पैरामीटर अपस्ट्रीम अनुरोध से हटा दिए जाते हैं - उन्हें anthropic/claude-*, google/gemini-*, या किसी अन्य गैर-OpenAI लक्ष्य पर भेजकर पैरामीटर के साथ 200 लौटाता है चुपचाप अनदेखा कर दिया गया, कोई त्रुटि नहीं। यदि आप इनमें से कोई एक सेट कर रहे हैं और प्रभाव दिखाई नहीं दे रहा है, तो जांचें कि लक्ष्य मॉडल OpenAI है या नहीं।

अनुरोध स्कीमा (TypeScript)

// Definitions of subtypes are below
type Request = {
  // Required by BazaarLink Chat Completions
  model: string;                    // Use a provider-qualified catalog ID
  messages: Message[];             // Must contain at least one message

  // Generation
  stream?: boolean;
  temperature?: number;            // Range: [0, 2]
  max_tokens?: number;             // Positive integer
  max_completion_tokens?: number;  // Alias mapped to max_tokens upstream
  n?: number;
  seed?: number;
  stop?: string | string[];

  // Sampling
  top_p?: number;
  top_k?: number;
  frequency_penalty?: number;      // Range: [-2, 2]
  presence_penalty?: number;       // Range: [-2, 2]
  repetition_penalty?: number;     // Range: (0, 2]
  min_p?: number;                  // Range: [0, 1]
  top_a?: number;                  // Range: [0, 1]

  // Token probabilities
  logit_bias?: Record<number, number>;
  logprobs?: boolean;
  top_logprobs?: number;

  // Stable end-user identifier for abuse prevention
  user?: string;

  // Tool calling
  tools?: Tool[];
  tool_choice?: ToolChoice;
  parallel_tool_calls?: boolean;

  // Structured output
  response_format?: ResponseFormat;
  structured_outputs?: boolean;

  // Plugin configuration — forwarded to upstreams that support plugins.
  plugins?: Plugin[];

  // Multimodal and image-generation options
  modalities?: Array<"text" | "image">;
  image_config?: Record<string, unknown>;
  input_audio?: InputAudio;

  // Provider-specific reasoning controls
  reasoning_effort?: "low" | "medium" | "high";
  reasoning?: ReasoningConfig;
  thinking?: ThinkingConfig;
  enable_thinking?: boolean;

  // BazaarLink message transforms and fallback routing
  transforms?: Array<"middle-out">;
  models?: string[];             // Fallback list — this drives waterfall routing, not route
  route?: "fallback";            // Passthrough only; forwarded as-is, no local effect
  provider?: ProviderPreferences;
};

// Message types
type Message =
  | SystemMessage
  | UserMessage
  | AssistantMessage
  | ToolMessage;

type SystemMessage = {
  role: "system";
  content: string | ContentPart[];
  name?: string;
};

type UserMessage = {
  role: "user";
  content: string | ContentPart[];
  name?: string;
};

type AssistantMessage = {
  role: "assistant";
  content?: string | ContentPart[] | null;
  name?: string;
  tool_calls?: ToolCall[];
};

type ToolMessage = {
  role: "tool";
  content: string;
  tool_call_id: string;
  name?: string;
};

// Multimodal content parts
type ContentPart =
  | TextContentPart
  | ImageContentPart
  | FileContentPart
  | AudioContentPart
  | VideoContentPart;

type TextContentPart = {
  type: "text";
  text: string;
};

type ImageContentPart = {
  type: "image_url";
  image_url: {
    url: string;                    // Remote URL or base64 data URI
    detail?: string;
  };
};

type FileContentPart = {
  type: "file";
  file: {
    filename?: string;
    file_data: string;              // Base64 data URI
  };
};

type AudioContentPart = {
  type: "input_audio";
  input_audio: InputAudio;
};

type InputAudio = {
  data: string;                     // Raw base64 without a data URI prefix
  format: string;                   // For example "wav" or "mp3"
};

type VideoContentPart = {
  type: "video_url";
  video_url: {
    url: string;                    // Remote URL or base64 data URI
  };
};

// Tool calling subtypes
type FunctionDescription = {
  name: string;
  description?: string;
  parameters: object;               // JSON Schema object
};

type Tool = {
  type: "function";
  function: FunctionDescription;
};

type ToolChoice =
  | "none"
  | "auto"
  | "required"
  | {
      type: "function";
      function: {
        name: string;
      };
    };

type ToolCall = {
  id: string;
  type: "function";
  function: {
    name: string;
    arguments: string;
  };
};

// Structured output
type ResponseFormat =
  | {
      type: "json_object";
    }
  | {
      type: "json_schema";
      json_schema: {
        name: string;
        strict?: boolean;
        schema: object;
      };
    };

// Upstream plugin configuration
type Plugin = {
  id: string;
  enabled?: boolean;
  [key: string]: unknown;
};

// Reasoning controls vary by model family
type ReasoningConfig = {
  effort?: "low" | "medium" | "high";
  max_tokens?: number;
  exclude?: boolean;
};

type ThinkingConfig = {
  type?: "enabled" | "disabled";
  budget_tokens?: number;
};

// Provider routing preferences
type ProviderPreferences = {
  order?: string[];
  only?: string[];
  ignore?: string[];
  allow_fallbacks?: boolean;
  sort?:
    | "price"
    | "latency"
    | "throughput"
    | {
        by: string;
        partition?: string;
      };
  require_parameters?: boolean;
  data_collection?: "allow" | "deny";
  quantizations?: string[];
  max_price?: Record<string, number>;
};

उदाहरण अनुरोध

curl https://bazaarlink.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4.1",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Explain quantum computing in one paragraph."}
    ],
    "temperature": 0.7,
    "max_tokens": 512
  }'

प्रतिक्रिया

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1740000000,
  "model": "openai/gpt-4.1",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Quantum computing leverages quantum mechanics..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 28,
    "completion_tokens": 74,
    "total_tokens": 102,
    "cost": 0.0006480,
    "prompt_tokens_details": {
      "cached_tokens": 0
    },
    "completion_tokens_details": {
      "reasoning_tokens": 0
    }
  }
}

प्रतिक्रिया स्कीमा (TypeScript)

BazaarLink बिल्कुल दो फ़ील्ड को सामान्य करता है - मॉडल और एक प्रदाता फ़ील्ड को हटाना - और बाकी अपस्ट्रीम प्रतिक्रिया को वैसे ही आगे बढ़ाता है। नेटिव_फिनिश_रीज़न, सिस्टम_फ़िंगरप्रिंट और रीज़निंग जैसे फ़ील्ड केवल तभी मौजूद होते हैं जब विशिष्ट अपस्ट्रीम प्रदाता उन्हें भरता है; प्रत्येक मॉडल में उनकी उपस्थिति पर भरोसा न करें। उपयोग.लागत अपवाद है - यह हमेशा BazaarLink की अपनी settled/billed राशि होती है, अपस्ट्रीम से रिले किया गया मान नहीं।

type Response = {
  id: string;
  object: "chat.completion" | "chat.completion.chunk";
  created: number;                 // Unix timestamp
  model: string;
  choices: (NonStreamingChoice | StreamingChoice)[];
  usage?: ResponseUsage;
  cost?: number;                   // Total cost in USD
};

type NonStreamingChoice = {
  index: number;
  finish_reason: "stop" | "length" | "tool_calls" | "content_filter" | null;
  native_finish_reason: string | null;  // Provider's original finish reason
  message: {
    role: "assistant";
    content: string | null;
    tool_calls?: ToolCall[];
  };
};

type StreamingChoice = {
  index: number;
  finish_reason: string | null;
  native_finish_reason: string | null;  // Provider's original finish reason
  delta: {
    role?: string;
    content?: string | null;
    tool_calls?: ToolCall[];
  };
};

type ResponseUsage = {
  prompt_tokens: number;
  completion_tokens: number;
  total_tokens: number;
  cost: number;                      // Total cost for this request in USD
  prompt_tokens_details?: {
    cached_tokens: number;           // Tokens served from prompt cache (reduced cost)
    cache_write_tokens?: number;     // Tokens written to cache in this request
    audio_tokens?: number;
  };
  completion_tokens_details?: {
    reasoning_tokens?: number;       // Thinking/reasoning tokens (e.g. o3, Qwen3, DeepSeek R1)
    image_tokens?: number;
  };
};

type ToolCall = {
  id: string;
  type: "function";
  function: { name: string; arguments: string };
};

Image जनरेशन

Generate images from text prompts using models like DALL·E and GPT-4o. Use the `modalities` parameter to request image output from the chat completions endpoint. इमेज एडिटिंग (मौजूदा इमेज को संशोधित करना) POST /v1/images/edits का उपयोग करती है —— OpenAI images.edit संगत, आपकी स्रोत इमेज के साथ multipart/form-data। एडिट-सक्षम मॉडल की modality text+image->image होती है (जैसे qwen/qwen-image-edit); शुद्ध-जनरेशन मॉडल text->image होते हैं —— प्रत्येक मॉडल की modality GET /v1/models में जाँचें।

Response format

/api/v1/images/generations डिफ़ॉल्ट रूप से OpenAI-संगत सिंक JSON लौटाता है (2026-07-25 से) — client.images.generate() बिना किसी रैपर के काम करता है। stream: true भेजकर SSE इवेंट स्ट्रीम चुनें, जो लंबे जनरेशन समय वाले मॉडलों की प्रगति देता है।

A. /v1/chat/completions (नेटिव, अनुशंसित)

POST/api/v1/chat/completions

The canonical streaming path. Recommended for any new integration.

curl -N https://bazaarlink.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $BL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5.4-image-2",
    "messages": [{"role":"user","content":"a red cat on a sofa"}],
    "modalities": ["image","text"],
    "stream": true
  }'

इमेज-टू-इमेज: content ऐरे में एक image_url पार्ट शामिल करें। डेटा URI या https इमेज URL सपोर्टेड हैं (http:// अस्वीकृत होता है), अधिकतम 8 इमेज, ~10MB प्रति डेटा URI। इमेज वाले संदेश में एक टेक्स्ट पार्ट (संपादन निर्देश) भी होना चाहिए। कुछ मॉडल अतिरिक्त रूप से image_config सपोर्ट करते हैं (जैसे {"strength": 0.7}, 0–1 — कम मान स्रोत इमेज के करीब रहता है), जो अपस्ट्रीम को ज्यों-का-त्यों भेजा जाता है।

curl -N https://bazaarlink.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $BL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5.4-image-2",
    "messages": [{"role":"user","content":[
      {"type":"image_url","image_url":{"url":"data:image/png;base64,..."}},
      {"type":"text","text":"change the background to a night city"}
    ]}],
    "modalities": ["image"],
    "stream": true
  }'

इमेज एडिट (OpenAI-संगत)

POST/api/v1/images/edits

OpenAI SDK का client.images.edit() सीधे काम करता है (multipart अपलोड, सिंक JSON रिस्पॉन्स जो data: [{ url }] लौटाता है)। इमेज-टू-इमेज जैसी ही सीमाएँ: अधिकतम 8 इमेज, 10MB प्रत्येक; mask और response_format=b64_json अभी सपोर्टेड नहीं हैं।

curl https://bazaarlink.ai/api/v1/images/edits \
  -H "Authorization: Bearer $BL_API_KEY" \
  -F model="openai/gpt-5.4-image-2" \
  -F image=@cat.png \
  -F prompt="change the background to a night city"

B. /v1/images/generations (DALL·E-संगत)

POST/api/v1/images/generations

OpenAI DALL-E request shape. Sync JSON ({ created, data: [{ url }] }) is the default and works with client.images.generate() out of the box; pass stream: true to get the SSE event stream documented below instead.

curl https://bazaarlink.ai/api/v1/images/generations \
  -H "Authorization: Bearer $BL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-image-2",
    "prompt": "a red cat on a sofa",
    "size": "1024x1024"
  }'
modelआवश्यक
string
मॉडल ID, जैसे google/gemini-2.5-flash-image
promptआवश्यक
string
टेक्स्ट प्रॉम्प्ट
size
string
आउटपुट आकार (स्वतः मैप)
n
integer
इमेज की संख्या (डिफ़ॉल्ट 1)
# Streaming variant — progressive delivery for long generations
curl -N https://bazaarlink.ai/api/v1/images/generations \
  -H "Authorization: Bearer $BL_API_KEY" \
  -H "Accept: text/event-stream" \
  -H "Content-Type: application/json" \
  -d '{"model":"openai/gpt-5.4-image-2","prompt":"a red cat on a sofa","stream":true}'

SSE event protocol

Both endpoints emit the same event types:

event: heartbeat        # every 60 s, keeps Cloudflare happy
data: {}

event: image            # upstream URL, fastest path
data: {"index": 0, "url": "https://upstream/a.png"}

event: image-cached     # bazaarlink Redis-backed proxy URL (1 hr TTL)
data: {"index": 0, "url": "https://bazaarlink.ai/api/v1/images/proxy/<token>"}

event: usage            # final cost / token count
data: {"promptTokens": 12, "completionTokens": 7080, "cost": 0.226, "durationMs": 163400, "imageCount": 1}

event: done
data: {}

समर्थित इमेज मॉडल

Model IDModalityi2i (edits)

वीडियो जनरेशन

असिंक्रोनस तीन-चरणीय प्रक्रिया (submit → poll → content)। वीडियो बनने में 30 सेकंड से 5 मिनट लगते हैं, जो chat-completions के सिंक्रोनस अनुरोध/उत्तर मॉडल में फिट नहीं होता — इसलिए BazaarLink वीडियो को अलग /api/v1/videos पथ पर job-id पैटर्न से उपलब्ध कराता है: submit से vjob_* ID मिलता है → status poll करें → पूरा होने पर bytes प्राप्त करें। वीडियो मॉडल को /chat/completions या /images/generations से कॉल करने पर 400 (code: wrong_endpoint_for_video) मिलेगा। बिलिंग completed होने पर वास्तविक usage.cost के अनुसार होती है।

वीडियो टास्क प्रकार

एक ही एंडपॉइंट कई टास्क को कवर करता है। कौन-सा टास्क चलेगा यह इस पर निर्भर करता है कि आप कौन-से फ़ील्ड भेजते हैं —— एक ही मॉडल image-to-video, keyframes और continuation कर सकता है। हर मॉडल हर टास्क को सपोर्ट नहीं करता; असमर्थित अनुरोध 400 लौटाता है।

टेक्स्ट-टू-वीडियो
prompt
केवल टेक्स्ट प्रॉम्प्ट से जनरेट करें — कोई इनपुट मीडिया नहीं।
इमेज-टू-वीडियो
frame_images: [ first frame ]
आपकी इमेज ही दृश्य है: यह पहला फ़्रेम बनकर एनिमेट होती है और मूल के प्रति निष्ठावान रहती है। जैसे, एक बिल्ली की फ़ोटो → वही बिल्ली उसी दृश्य में सिर घुमाती है।
कीफ़्रेम (पहला + अंतिम)
frame_images: [ first, last ]
एक शुरुआती और एक अंतिम इमेज दें; मॉडल बीच की गति को इंटरपोलेट करता है।
निरंतरता
input_video
एक मौजूदा क्लिप को बढ़ाएं। अनुरोधित duration स्रोत वीडियो की लंबाई से अधिक होना चाहिए।
रेफ़रेंस-टू-वीडियो
input_references: [ images ]
आपकी इमेज रेफ़रेंस हैं, फ़्रेम नहीं: मॉडल विषय/स्टाइल बनाए रखता है और बिल्कुल नया दृश्य जनरेट करता है। जैसे, एक बिल्ली की फ़ोटो + "जंगल में नाचते हुए" → एक नया वीडियो जिसमें बिल्ली का रूप बरकरार रहता है पर दृश्य और गति नई होती है (1–9 रेफ़रेंस)। इमेज-टू-वीडियो से अंतर: i2v सटीक तस्वीर के प्रति निष्ठावान रहता है; r2v विषय को नए फ़ुटेज में फिर से ढालता है।
वीडियो एडिटिंग
input_video + prompt
एक मौजूदा वीडियो संपादित करें — दृश्य, स्टाइल या गति बदलें। इनपुट-वीडियो सेकंड + आउटपुट सेकंड पर बिलिंग।

1. जॉब सबमिट करें (तुरंत vjob_xxx लौटाता है)

POST/api/v1/videos
modelआवश्यक
string
मॉडल ID, जैसे alibaba/wan2.7-t2v
promptआवश्यक
string
टेक्स्ट प्रॉम्प्ट
duration
integer
सेकंड में अवधि (मॉडल पर निर्भर)
resolution
string
रिज़ॉल्यूशन: 480p / 720p / 1080p आदि
generate_audio
boolean
ऑडियो ट्रैक बनाएं (true/false)
frame_images
array
पहला/अंतिम फ़्रेम इमेज (image-to-video, keyframes)। ऑब्जेक्ट { type: "image_url", image_url: { url }, frame_type: "first_frame" | "last_frame" } या सादा URL स्ट्रिंग।
input_references
array
reference-to-video के लिए रेफ़रेंस इमेज —— विषय/स्टाइल मार्गदर्शन, सटीक फ़्रेम नहीं।
input_video
string|object
continuation और वीडियो एडिटिंग के लिए स्रोत वीडियो URL। अपस्ट्रीम द्वारा सार्वजनिक रूप से फ़ेच करने योग्य होना चाहिए।
aspect_ratio
string
आस्पेक्ट रेशियो, जैसे 16:9 या 9:16। जब कोई इनपुट इमेज रेशियो तय करती है तो इसे अनदेखा किया जाता है।
watermark
boolean
वॉटरमार्क जोड़ें। डिफ़ॉल्ट false।
callback_url
string
जॉब के अंतिम स्थिति पर पहुँचने पर कॉल होने वाला webhook URL — केवल HTTPS, SSRF जाँच सहित। v1 में कोई हस्ताक्षर नहीं; इसे संकेत मानें और GET /videos/{id} से पुष्टि करें।
curl https://bazaarlink.ai/api/v1/videos \
  -H "Authorization: Bearer $BL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "alibaba/wan2.7-t2v",
    "prompt": "a bird flying over mountains",
    "duration": 3,
    "resolution": "720p",
    "generate_audio": false
  }'
# → 202 { "id": "vjob_xxx", "status": "pending" }
Note
Submit पर सबसे खराब स्थिति × अवधि × multiplier के अनुसार राशि रोकी जाती है; completed पर अपस्ट्रीम के usage.cost से अंतर का समायोजन होता है।

2. स्थिति poll करें

GET/api/v1/videos/{id}
curl -H "Authorization: Bearer $BL_API_KEY" \
  https://bazaarlink.ai/api/v1/videos/vjob_xxx
Note
हर GET के बीच ≥ 8 सेकंड का अंतर होने पर ही अपस्ट्रीम को वास्तविक कॉल जाती है (rate limit से बचाव)।
Note
यदि status=failed हो, तो पूरी reserve राशि उपयोगकर्ता को वापस कर दी जाती है।

3. वीडियो कंटेंट प्राप्त करें (MP4)

GET/api/v1/videos/{id}/content
curl -H "Authorization: Bearer $BL_API_KEY" \
  -o output.mp4 \
  https://bazaarlink.ai/api/v1/videos/vjob_xxx/content

जानने योग्य बातें

  • अनुमत रिज़ॉल्यूशन प्रत्येक मॉडल के लिए अलग होते हैं —— असमर्थित मान 400 लौटाता है और समर्थित मानों की सूची देता है।
  • इनपुट इमेज/वीडियो सार्वजनिक URL से पहुँच योग्य होने चाहिए। हॉटलिंक-सुरक्षित होस्ट (जैसे कुछ wikis) विफल हो जाते हैं।
  • इनपुट मीडिया अपस्ट्रीम कंटेंट मॉडरेशन से गुज़रता है और कभी-कभी अस्वीकृत हो सकता है।
  • continuation के लिए, अनुरोधित duration स्रोत वीडियो लंबाई से अधिक होना चाहिए।
  • आउटपुट आस्पेक्ट रेशियो इनपुट इमेज का अनुसरण करता है —— वर्गाकार इमेज वर्गाकार वीडियो देती है।
  • वीडियो एडिटिंग की बिलिंग इनपुट वीडियो के सेकंड और जनरेट किए गए आउटपुट के सेकंड पर होती है।
  • input_video (एडिटिंग / continuation) एक सार्वजनिक URL होना चाहिए। यहाँ जनरेट किए गए वीडियो आपकी API key के पीछे सर्व होते हैं, इसलिए अपस्ट्रीम उन्हें फ़ेच नहीं कर सकता —— अपने स्रोत वीडियो को सार्वजनिक रूप से पहुँच योग्य URL पर होस्ट करें।
  • Webhook payload पर कोई हस्ताक्षर नहीं है — कार्रवाई से पहले GET /videos/{id} से स्थिति/राशि की पुष्टि करें, और ध्यान दें कि वहाँ unsigned_urls निरपेक्ष हैं (poll प्रतिक्रिया के सापेक्ष पथ से भिन्न)।

समर्थित वीडियो मॉडल

Model IDModalityTasks
bytedance/seedance-2.0text+image+audio+video->videot2v, i2v
bytedance/seedance-2.0-fasttext+image+audio+video->videot2v, i2v
google/veo-3.1text+image->videot2v, i2v
openai/sora-2-protext+image->videot2v, i2v
bytedance/seedance-1-5-protext+image->videot2v, i2v
alibaba/wan2.6-r2v-flashtext+image+video->videor2v
alibaba/wan2.5-i2v-previewtext+image->videoi2v
alibaba/wan2.7-i2vtext+image+video->videoi2v, kf2v, continuation
alibaba/wan2.6-t2vtext->videot2v
alibaba/wan2.5-t2v-previewtext->videot2v
alibaba/wan2.2-t2v-plustext->videot2v
alibaba/wan2.7-r2vtext+image+video->videor2v
alibaba/wan2.7-t2vtext->videot2v
alibaba/happyhorse-1.0text+image->videot2v, i2v
alibaba/happyhorse-1.1text->videot2v
alibaba/wan2.2-i2v-plustext+image->videoi2v
alibaba/wan2.1-t2v-plustext->videot2v
alibaba/wan2.2-i2v-flashtext+image->videoi2v
alibaba/wan2.6-r2vtext+image+video->videor2v
alibaba/wan2.7-videoedittext+image+video->videovideoedit
alibaba/wan2.1-t2v-turbotext->videot2v
alibaba/wan2.6-i2v-flashtext+image->videoi2v
alibaba/wan2.6-i2vtext+image->videoi2v

वीडियो इनपुट

वीडियो इनपुट सपोर्ट करने वाले मॉडल को वीडियो फ़ाइलें भेजें ताकि विश्लेषण, कैप्शन या दृश्यों और घटनाओं से जुड़े सवालों के जवाब पाए जा सकें। सीधे URL या base64 data URI से काम करता है — सार्वजनिक रूप से उपलब्ध वीडियो के लिए URL अधिक कुशल है; स्थानीय फ़ाइलों या निजी वीडियो के लिए base64।

समर्थित प्रारूप

MP4 (H.264)MPEGMOVWebM
response = client.chat.completions.create(
    model="google/gemini-2.5-flash",
    messages=[{
        "role": "user",
        "content": [
            {
                "type": "video_url",
                "video_url": {"url": "https://example.com/video.mp4"},
            },
            {"type": "text", "text": "What is happening in this video?"},
        ],
    }],
)

पूरा API संदर्भ →

PDF इनपुट

PDF को नेटिव रूप से सपोर्ट करने वाले मॉडल (जैसे Claude, Gemini) को संदेशों में सीधे PDF दस्तावेज़ भेजें। BazaarLink फ़ाइल को सीधे मॉडल को भेजता है — सामान्य input tokens की तरह बिल होता है, कोई अतिरिक्त शुल्क या प्रोसेसिंग चरण नहीं।

समर्थित प्रारूप

  • PDF दस्तावेज़ (पाठ, चित्र, तालिकाएँ, स्कैन किए गए)
  • Base64-एन्कोडेड डेटा URL (`data:application/pdf;base64,...`)
  • बहु-पृष्ठ दस्तावेज़ केवल
  • पासवर्ड-मुक्त पीडीएफ
import base64

with open("document.pdf", "rb") as f:
    pdf_data = base64.b64encode(f.read()).decode()

response = client.chat.completions.create(
    model="anthropic/claude-sonnet-4.6",
    messages=[{
        "role": "user",
        "content": [
            {
                "type": "file",
                "file": {
                    "filename": "document.pdf",
                    "file_data": f"data:application/pdf;base64,{pdf_data}",
                },
            },
            {"type": "text", "text": "Summarize this document."},
        ],
    }],
)

Responses API

An OpenAI प्रतिक्रियाएँ API-स्टेटलेस मल्टी-टर्न वार्तालाप, टूल कॉलिंग और मल्टीमॉडल इनपुट के लिए संगत समापन बिंदु। एजेंटों और फ्रेमवर्क के लिए आदर्श जो client.responses.create() के साथ OpenAI Python SDK ≥ 1.x का उपयोग करते हैं।

POST/api/v1/responses
Note
Chat Completions के समान प्रमाणीकरण और मॉडल रूटिंग को स्वीकार करता है।

अनुरोध बॉडी

modelआवश्यक
string
मॉडल आईडी, उदा. "openai/gpt-4o" या "anthropic/claude-3.5-sonnet"
inputआवश्यक
string | Item[]
User इनपुट - एक सादा स्ट्रिंग (एकल संदेश) या मल्टी-टर्न / मल्टीमॉडल वार्तालापों के लिए इनपुट आइटम की एक सरणी।
instructions
string
सिस्टम-स्तरीय निर्देश, सिस्टम संदेश के समतुल्य। प्रत्येक अनुरोध पर पुनः भेजा जाना चाहिए।
stream
boolean
यदि सत्य है, तो प्रतिक्रियाएँ API SSE स्ट्रीम इवेंट लौटाता है। इवेंट प्रकार: प्रतिक्रिया.निर्मित, प्रतिक्रिया.आउटपुट_टेक्स्ट.डेल्टा, प्रतिक्रिया.पूर्ण।
max_output_tokens
integer
उत्पन्न करने के लिए आउटपुट टोकन की अधिकतम संख्या (ओ-श्रृंखला मॉडल के लिए तर्क टोकन शामिल हैं)।
temperature
number
सैंपलिंग तापमान 0-2। उच्चतर = अधिक यादृच्छिक. डिफ़ॉल्ट: 1
top_p
number
न्यूक्लियस नमूना संभाव्यता द्रव्यमान। डिफ़ॉल्ट: 1
tools
Tool[]
टूल (फ़ंक्शन) परिभाषाएँ — Chat Completions जैसा ही JSON Schema प्रारूप (फ़्लैट Responses रूप और नेस्टेड रूप दोनों स्वीकार्य)। OpenAI के अपने अंतर्निहित होस्टेड टूल (web_search_preview, file_search, computer_use_preview) समर्थित नहीं हैं; वेब सर्च plugins: [{id:"web"}] से उपलब्ध है — केवल कुछ मॉडल रूट पर समर्थित।
tool_choice
string | object
कंट्रोल्स टूल का उपयोग: "ऑटो", "कोई नहीं", या विशिष्ट टूल
parallel_tool_calls
boolean
उपकरण उपलब्ध कराए जाने पर समानांतर फ़ंक्शन कॉलिंग सक्षम करें। डिफ़ॉल्ट: सत्य. केवल OpenAI-पारिवारिक मॉडल - नीचे नोट देखें।
response_format
object
Force संरचित JSON आउटपुट। संरचित आउटपुट अनुभाग देखें
models
string[]
फ़ॉलबैक मॉडल सूची - प्राथमिक विफल होने पर BazaarLink प्रत्येक को क्रम में आज़माता है
transforms
string[]
Message लागू करने के लिए रूपांतरित होता है, उदा. ["मध्य-बाहर"]। ≤8k-संदर्भ मॉडल पर स्वत: लागू करना छोड़ें
previous_response_id
string
यह एंडपॉइंट स्टेटलेस है — गैर-null मान भेजने पर तुरंत 400 (invalid_prompt) लौटता है, यह कभी स्वीकार होकर अनदेखा नहीं होता। इसके बजाय स्टेटलेस मोड का उपयोग करें: input सरणी में पूरा बातचीत इतिहास भेजें।
provider
object
उन्नत रूटिंग वरीयताएँ — अधिकांश उपयोगकर्ताओं को इनकी आवश्यकता नहीं।

अनुरोध स्कीमा (TypeScript)

type ResponsesRequest = {
  model: string;                    // "provider/model-name"
  input: string | InputItem[];      // string or multi-turn array

  // Optional
  instructions?: string;            // System-level message
  stream?: boolean;                 // Default: false
  max_output_tokens?: number;
  temperature?: number;             // Range: [0, 2], default: 0.7
  top_p?: number;
  tools?: Tool[];
  tool_choice?: "auto" | "none" | "required" | object;
  parallel_tool_calls?: boolean;    // Default: true
  previous_response_id?: string;    // Not supported — use full input array
  provider?: ProviderPreferences;   // Same as Chat Completions
};

type InputItem =
  | { type?: "message"; role: "user" | "assistant" | "system" | "developer"; content: string | ContentBlock[] }
  | { type: "function_call_output"; call_id: string; output: string }   // tool result
  | { type: "function_call"; call_id: string; name: string; arguments: string };

type ContentBlock =
  | { type: "input_text"; text: string }
  | { type: "input_image"; image_url: string; detail?: "auto" | "low" | "high" };

उदाहरण अनुरोध

curl https://bazaarlink.ai/api/v1/responses \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "instructions": "You are a helpful assistant.",
    "input": "What is the capital of Taiwan?"
  }'

प्रतिक्रिया प्रारूप

// Non-streaming response object
type ResponsesResponse = {
  id: string;             // "resp_..."
  object: "response";
  created_at: number;
  completed_at: number;
  status: "completed" | "failed" | "incomplete";
  model: string;
  output: OutputItem[];
  usage: {
    input_tokens: number;   // equivalent to prompt_tokens
    output_tokens: number;  // equivalent to completion_tokens
    total_tokens: number;
    cost?: number;          // actual cost in credits
  } | null;
  error: null | { code: string; message: string };
};

type OutputItem =
  | {
      type: "message";
      id: string;
      role: "assistant";
      status: "completed";
      content: Array<{ type: "output_text"; text: string; annotations: [] }>;
    }
  | { type: "function_call"; id: string; call_id: string; name: string; arguments: string; status: "completed" };

Chat Completions से माइग्रेट हो रहा है

संदेशों को इनपुट (स्ट्रिंग या ऐरे) से बदलें, सिस्टम-रोल संदेश के बजाय निर्देशों का उपयोग करें, और विकल्पों[0].message.content के बजाय आउटपुट[0].content[0].text पढ़ें।

# Chat Completions (before)
response = client.chat.completions.create(
    model="openai/gpt-4o-mini",
    messages=[
        {"role": "system", "content": "You are helpful."},
        {"role": "user",   "content": "Hello"},
    ]
)
text = response.choices[0].message.content

# Responses API (after)
response = client.responses.create(
    model="openai/gpt-4o-mini",
    instructions="You are helpful.",
    input="Hello"
)
text = response.output[0].content[0].text

सीमाएँ

  • previous_response_id या store: true को 400 (त्रुटि कोड invalid_prompt) के साथ अस्वीकार किया जाता है — स्वीकार होकर अनदेखा नहीं होता। हमेशा स्टेटलेस मोड का उपयोग करें: input सरणी में पूरा बातचीत इतिहास भेजें।
  • OpenAI के अपने अंतर्निहित होस्टेड टूल (web_search_preview, file_search, computer_use_preview) समर्थित नहीं हैं। वेब सर्च plugins: [{id:"web"}] से उपलब्ध है — केवल कुछ मॉडल रूट पर समर्थित।
  • background: true स्वीकार किया जाता है लेकिन अनदेखा कर दिया जाता है — हर अनुरोध पूरा होने तक सिंक्रोनस रूप से चलता है।

Messages (Anthropic)

Anthropic-संगत संदेश API Claude SDK के लिए। ठीक वैसे ही उपयोग करें जैसे आप Anthropic के API के साथ करेंगे - बस आधार URL और ऑथ हेडर बदलें।

POST/api/v1/messages
Note
बियरर टोकन या एक्स-एपीआई-कुंजी हेडर स्वीकार करता है (Anthropic SDK संगतता)। अधिकतम बॉडी आकार: 10 एमबी.

अनुरोध बॉडी

modelआवश्यक
string
मॉडल आईडी, उदा. "openai/gpt-4o" या "anthropic/claude-3.5-sonnet"
max_tokensआवश्यक
integer
उत्पन्न करने के लिए टोकन की अधिकतम संख्या (सकारात्मक पूर्णांक)।
messagesआवश्यक
Message[]
बातचीत संदेशों की सरणी (गैर-रिक्त)।
system
string
वैकल्पिक सिस्टम प्रॉम्प्ट।
stream
boolean
यदि सत्य है, तो सर्वर-भेजे गए इवेंट स्ट्रीम लौटाता है। डिफ़ॉल्ट: ग़लत
temperature
number
सैंपलिंग तापमान 0-2। उच्चतर = अधिक यादृच्छिक. डिफ़ॉल्ट: 1
top_p
number
न्यूक्लियस नमूना संभाव्यता द्रव्यमान। डिफ़ॉल्ट: 1
top_k
integer
टोकन विकल्पों को शीर्ष-K तक सीमित करें। 0 = अक्षम (सभी पर विचार करें)। डिफ़ॉल्ट: 0
stop_sequences
string[]
कस्टम स्टॉप अनुक्रम स्ट्रिंग।
tools
Tool[]
उन टूल (फ़ंक्शन) की सूची जिन्हें मॉडल कॉल कर सकता है
tool_choice
string | object
कंट्रोल्स टूल का उपयोग: "ऑटो", "कोई नहीं", या विशिष्ट टूल

उदाहरण अनुरोध

from anthropic import Anthropic

client = Anthropic(
    base_url="https://bazaarlink.ai/api/v1",
    api_key="sk-bl-YOUR_KEY"
)

response = client.messages.create(
    model="anthropic/claude-opus-4",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}]
)
print(response.content[0].text)

प्रतिक्रिया

{
  "id": "msg_...",
  "type": "message",
  "role": "assistant",
  "model": "anthropic/claude-opus-4",
  "content": [
    { "type": "text", "text": "Hello! How can I help you today?" }
  ],
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 10,
    "output_tokens": 12,
    "cache_read_input_tokens": 0,
    "cache_creation_input_tokens": 0,
    "bz_cost": 0.00042
  }
}

त्रुटियाँ: 400 (सत्यापन), 402 (अपर्याप्त क्रेडिट), 429 (दर सीमा), 502 (अपस्ट्रीम त्रुटि / गुम कुंजी), 503 (सर्वर पुनरारंभ)।

मॉडल

मूल्य निर्धारण और क्षमता की जानकारी के साथ सभी उपलब्ध मॉडलों की सूची बनाएं। इस समापन बिंदु के लिए किसी प्रमाणीकरण की आवश्यकता नहीं है।

GET/api/v1/models
# Text models (default)
curl https://bazaarlink.ai/api/v1/models

# Complete catalog
curl "https://bazaarlink.ai/api/v1/models?output_modalities=all"

प्रतिक्रिया

{
  "data": [
    {
      "id": "openai/gpt-4.1",
      "name": "GPT 4.1",
      "context_length": 1047576,
      "modality": "text+image+file->text",
      "pricing": {
        "prompt": "2.00",
        "completion": "8.00"
      }
    }
  ]
}
// /v1/models — Response Schema
type ModelsResponse = {
  data: Model[];
};

type Model = {
  id: string;                    // Model ID (e.g. "openai/gpt-4.1")
  name: string;                  // Human-readable name
  context_length: number | null; // Max context window in tokens
  modality: string | null;       // e.g. "text->text", "text+image->text"
  architecture?: {
    input_modalities?: string[];
    output_modalities?: Array<
      "text" | "image" | "embeddings" | "audio" |
      "video" | "rerank" | "speech" | "transcription"
    >;
  };
  pricing: {
    prompt: string;              // Input price per 1M tokens (USD)
    completion: string;          // Output price per 1M tokens (USD)
  };
  description?: string | null;   // Model description
  top_provider?: {
    max_completion_tokens?: number;
  };
  supported_parameters?: string[]; // e.g. ["tools", "response_format", "reasoning"]
  pricing_tiers?: {               // Present only for models with input-length tiers
    above_prompt_tokens: number;  // Ascending; strict "greater than" threshold
    prompt: string;                // USD per token, override tier
    completion: string;            // USD per token, override tier
  }[];
};

इनपुट-लंबाई स्तरित मूल्य निर्धारण

कुछ मॉडल संकेत के टोकन सीमा से अधिक हो जाने पर एक अलग मूल्य तालिका में बदल जाते हैं - पूरी तालिका बदल जाती है, न कि केवल सीमा से ऊपर के टोकन। सीमाएं सख्त हैं: बिल्कुल एन टोकन वाला एक प्रॉम्प्ट अभी भी एन के नीचे के स्तर पर बिल करता है; उच्चतर स्तर तभी लागू होता है जब इनपुट टोकन एन से अधिक हों।

pricing_tiers मूल्य निर्धारण का एक सहोदर है, जो केवल तभी मौजूद होता है जब किसी मॉडल के आधार मूल्य से अधिक स्तर ओवरराइड हो जाते हैं। प्रविष्टियाँ उपरोक्त_प्रोम्प्ट_टोकन के अनुसार आरोही क्रम में क्रमबद्ध की जाती हैं; prompt/completion प्रति टोकन USD हैं (pricing.prompt/pricing.completion के समान इकाई)। मूल्य निर्धारण.प्रॉम्प्ट और मूल्य निर्धारण.समापन हमेशा आधार (निम्नतम) स्तर बने रहते हैं।

अधिकांश मॉडलों में कोई स्तर नहीं है - उनके लिए, मूल्य निर्धारण_स्तर कुंजी प्रतिक्रिया से अनुपस्थित है।

{
  "id": "openai/gpt-4.1",
  "name": "GPT 4.1",
  "pricing": {
    "prompt": "2.00",
    "completion": "8.00"
  },
  "pricing_tiers": [
    {
      "above_prompt_tokens": 128000,
      "prompt": "4.00",
      "completion": "16.00"
    }
  ]
}

उपलब्ध मॉडल (254)

ये वे मॉडल हैं जो वर्तमान में BazaarLink पर उपलब्ध हैं, जो हमारे डेटाबेस से गतिशील रूप से लोड किए गए हैं:

OpenAI
openai/gpt-5.3-codex400K ctx · $1.75/$14.00text+image+file->text
openai/gpt-5.4-nano400K ctx · $0.20/$1.25text+image+file->text
openai/gpt-3.5-turbo-instruct4K ctx · $1.50/$2.00text->text
openai/text-embedding-ada-0028K ctx · $0.10/$0.00text->embeddings
openai/gpt-5.1400K ctx · $1.25/$10.00text+image+file->text
openai/gpt-5.6-luna-pro1050K ctx · $0.20/$1.20text+image+file->text
openai/gpt-4.11048K ctx · $2.00/$8.00text+image+file->text
openai/gpt-5.2-chat128K ctx · $1.75/$14.00text+image+file->text
openai/gpt-5.6-terra-pro1050K ctx · $2.00/$12.00text+image+file->text
openai/gpt-4o128K ctx · $2.50/$10.00text+image+file->text
openai/gpt-5.2-codex400K ctx · $1.75/$14.00text+image->text
openai/gpt-5.51050K ctx · $5.00/$30.00text+image+file->text
openai/gpt-3.5-turbo-06134K ctx · $1.00/$2.00text->text
openai/text-embedding-3-small8K ctx · $0.02/$0.00text->embeddings
openai/gpt-5.6-terra1050K ctx · $2.00/$12.00text+image+file->text
openai/gpt-5.1-codex400K ctx · $1.25/$10.00text+image->text
openai/gpt-oss-20b131K ctx · $0.03/$0.13text->text
openai/gpt-oss-safeguard-20b131K ctx · $0.07/$0.30text->text
openai/gpt-4-turbo-preview128K ctx · $10.00/$30.00text->text
openai/gpt-5.2400K ctx · $1.75/$14.00text+image+file->text
openai/gpt-5.1-chat128K ctx · $1.25/$10.00text+image+file->text
openai/gpt-4.1-nano1048K ctx · $0.10/$0.40text+image+file->text
openai/o3200K ctx · $2.00/$8.00text+image+file->text
openai/gpt-5.4-mini400K ctx · $0.75/$4.50text+image+file->text
openai/gpt-4.1-mini1048K ctx · $0.40/$1.60text+image+file->text
openai/gpt-5.2-pro400K ctx · $21.00/$168.00text+image+file->text
openai/o4-mini-high200K ctx · $1.10/$4.40text+image+file->text
openai/gpt-5-codex400K ctx · $1.25/$10.00text+image->text
openai/gpt-3.5-turbo-16k16K ctx · $3.00/$4.00text->text
openai/gpt-4o-mini128K ctx · $0.15/$0.60text+image+file->text
openai/gpt-5.3-chat128K ctx · $1.75/$14.00text+image+file->text
openai/gpt-4o-2024-05-13128K ctx · $5.00/$15.00text+image+file->text
openai/gpt-oss-120b131K ctx · $0.15/$0.60text->text
openai/gpt-4-turbo128K ctx · $10.00/$30.00text+image->text
openai/o3-mini200K ctx · $1.10/$4.40text+file->text
openai/gpt-5.4-pro1050K ctx · $30.00/$180.00text+image+file->text
openai/text-embedding-3-large8K ctx · $0.13/$0.00text->embeddings
openai/gpt-5.41050K ctx · $2.50/$15.00text+image+file->text
openai/gpt-5-nano400K ctx · $0.05/$0.40text+image+file->text
openai/gpt-5.1-codex-max400K ctx · $1.25/$10.00text+image->text
openai/o1200K ctx · $15.00/$60.00text+image+file->text
openai/gpt-5.1-codex-mini400K ctx · $0.25/$2.00text+image->text
openai/gpt-4o-2024-08-06128K ctx · $2.50/$10.00text+image+file->text
openai/gpt-4o-mini-2024-07-18128K ctx · $0.15/$0.60text+image+file->text
openai/gpt-5400K ctx · $1.25/$10.00text+image+file->text
openai/gpt-5.6-sol-pro1050K ctx · $5.00/$30.00text+image+file->text
openai/o3-pro200K ctx · $20.00/$80.00text+image+file->text
openai/gpt-3.5-turbo16K ctx · $0.50/$1.50text->text
openai/gpt-4o-2024-11-20128K ctx · $2.50/$10.00text+image+file->text
openai/o3-mini-high200K ctx · $1.10/$4.40text+file->text
openai/gpt-5-pro400K ctx · $15.00/$120.00text+image+file->text
openai/sora-2-pro · $0.00/$0.00text+image->video
openai/gpt-48K ctx · $30.00/$60.00text->text
openai/o4-mini200K ctx · $1.10/$4.40text+image+file->text
openai/gpt-5.6-luna1050K ctx · $0.20/$1.20text+image+file->text
openai/gpt-5.6-sol1050K ctx · $5.00/$30.00text+image+file->text
openai/gpt-5.4-image-2272K ctx · $8.00/$15.00text+image+file->text+image
openai/gpt-5-mini400K ctx · $0.25/$2.00text+image+file->text
openai/o1-pro200K ctx · $150.00/$600.00text+image+file->text
openai/gpt-image-1400K ctx · $10.00/$10.00text+image->image
openai/gpt-image-2400K ctx · $8.00/$8.00text+image->image
openai/gpt-image-1-mini400K ctx · $2.50/$2.50text+image->image
Qwen
qwen/qwen3.7-plus1000K ctx · $0.32/$1.28text+image->text
qwen/qwen3.7-max1000K ctx · $1.48/$4.42text->text
qwen/qwen3.5-plus-02-151000K ctx · $0.26/$1.56text+image+video->text
qwen/qwen3-coder-flash1000K ctx · $0.20/$0.97text->text
qwen/qwen-2.5-coder-32b-instruct33K ctx · $0.66/$1.00text->text
qwen/qwen-plus1000K ctx · $0.26/$0.78text->text
qwen/qwen3-coder-plus1000K ctx · $0.65/$3.25text->text
qwen/qwen-2.5-72b-instruct33K ctx · $0.36/$0.40text->text
qwen/qwen3.6-27b262K ctx · $0.29/$2.40text+image+video->text
qwen/qwen3.6-35b-a3b262K ctx · $0.14/$1.00text+image+video->text
qwen/qwen3-vl-30b-a3b-instruct262K ctx · $0.15/$0.60text+image->text
qwen/qwen3-30b-a3b-thinking-250782K ctx · $0.20/$2.40text->text
qwen/qwen3-32b131K ctx · $0.08/$0.28text->text
qwen/qwen3-vl-8b-thinking131K ctx · $0.18/$2.10text+image->text
qwen/qwen3.5-flash-02-231000K ctx · $0.07/$0.26text+image+video->text
qwen/qwen3-vl-235b-a22b-instruct262K ctx · $0.21/$1.90text+image->text
qwen/qwen3.5-27b262K ctx · $0.20/$1.56text+image+video->text
qwen/qwen3-235b-a22b131K ctx · $0.46/$1.82text->text
qwen/qwen3.5-9b262K ctx · $0.10/$0.15text+image+video->text
qwen/qwen3-30b-a3b131K ctx · $0.13/$0.52text->text
qwen/qwen3-8b131K ctx · $0.12/$0.46text->text
qwen/qwen3-vl-8b-instruct262K ctx · $0.12/$0.46text+image->text
qwen/qwen3-max-thinking262K ctx · $0.78/$3.90text->text
qwen/qwen3.5-122b-a10b262K ctx · $0.26/$2.08text+image+video->text
qwen/qwen3-vl-32b-instruct131K ctx · $0.10/$0.42text+image->text
qwen/qwen3-vl-30b-a3b-thinking262K ctx · $0.20/$2.40text+image->text
qwen/qwen2.5-vl-72b-instruct128K ctx · $0.80/$1.00text+image->text
qwen/qwen3-235b-a22b-thinking-2507262K ctx · $0.23/$2.30text->text
qwen/qwen3-coder262K ctx · $0.30/$1.00text->text
qwen/qwen3.5-35b-a3b262K ctx · $0.14/$1.00text+image+video->text
qwen/qwen3-coder-next262K ctx · $0.12/$0.80text->text
qwen/qwen3-max262K ctx · $0.78/$3.90text->text
qwen/qwen-plus-2025-07-281000K ctx · $0.26/$0.78text->text
qwen/qwen3-next-80b-a3b-thinking262K ctx · $0.15/$1.20text->text
qwen/qwen3-14b131K ctx · $0.23/$0.91text->text
qwen/qwen-plus-2025-07-28:thinking1000K ctx · $0.40/$1.20text->text
qwen/qwen3.6-plus1000K ctx · $0.33/$1.95text+image+video->text
qwen/qwen3.5-397b-a17b262K ctx · $0.39/$2.34text+image+video->text
qwen/qwen3-coder-30b-a3b-instruct262K ctx · $0.07/$0.27text->text
qwen/qwen3-embedding-8b33K ctx · $0.01/$0.00text->embeddings
qwen/qwen3-235b-a22b-2507262K ctx · $0.09/$0.55text->text
qwen/qwen3.5-plus-202604201000K ctx · $0.30/$1.80text+image+video->text
qwen/qwen-2.5-7b-instruct33K ctx · $0.10/$0.20text->text
qwen/qwen3-30b-a3b-instruct-2507262K ctx · $0.05/$0.19text->text
qwen/qwen3-vl-235b-a22b-thinking131K ctx · $0.40/$4.00text+image->text
qwen/qwen3-embedding-4b33K ctx · $0.02/$0.00text->embeddings
qwen/qwen3-next-80b-a3b-instruct262K ctx · $0.10/$1.10text->text
qwen/qwen-image-edit-maxtext+image->image
qwen/qwen-image-edit-plustext+image->image
qwen/qwen-image-plustext->image
qwen/qwen-image-maxtext->image
qwen/qwen-image-edittext+image->image
qwen/qwen-image-2.0text->image
qwen/qwen-image-2.0-protext->image
qwen/qwen-imagetext->image
Alibaba
alibaba/wan2.6-r2v-flash · $0.00/$0.00text+image+video->video
alibaba/wan2.5-i2i-previewtext+image->image
alibaba/z-image-turbotext->image
alibaba/wan2.1-t2i-plustext->image
alibaba/wan2.1-t2i-turbotext->image
alibaba/wan2.2-t2i-plustext->image
alibaba/wan2.6-imagetext->image
alibaba/wan2.5-i2v-preview · $0.00/$0.00text+image->video
alibaba/wan2.7-i2v · $0.00/$0.00text+image+video->video
alibaba/wan2.6-t2v · $0.00/$0.00text->video
alibaba/wan2.5-t2v-preview · $0.00/$0.00text->video
alibaba/wan2.2-t2v-plus · $0.00/$0.00text->video
alibaba/wan2.7-r2v · $0.00/$0.00text+image+video->video
alibaba/wan2.7-t2v · $0.00/$0.00text->video
alibaba/happyhorse-1.0 · $0.00/$0.00text+image->video
alibaba/happyhorse-1.1 · $0.00/$0.00text->video
alibaba/wan2.2-i2v-plus · $0.00/$0.00text+image->video
alibaba/wan2.1-t2v-plus · $0.00/$0.00text->video
alibaba/wan2.5-t2i-previewtext->image
alibaba/wan2.2-t2i-flashtext->image
alibaba/wan2.2-i2v-flash · $0.00/$0.00text+image->video
alibaba/wan2.6-r2v · $0.00/$0.00text+image+video->video
alibaba/wan2.7-videoedit · $0.00/$0.00text+image+video->video
alibaba/wan2.1-t2v-turbo · $0.00/$0.00text->video
alibaba/wan2.6-i2v-flash · $0.00/$0.00text+image->video
alibaba/wan2.6-i2v · $0.00/$0.00text+image->video
alibaba/wan2.6-t2itext->image
alibaba/wan2.7-imagetext->image
alibaba/wan2.7-image-protext->image
Google
google/gemini-2.5-flash-lite1049K ctx · $0.10/$0.40text+image+file+audio+video->text
google/gemini-3.1-pro-preview1049K ctx · $2.00/$12.00text+image+file+audio+video->text
google/gemini-3.1-flash-lite-preview1049K ctx · $0.25/$1.50text+image+file+audio+video->text
google/gemini-embedding-2-preview8K ctx · $0.20/$0.00text+image+file+audio+video->embeddings
google/gemma-3-4b-it131K ctx · $0.05/$0.10text+image->text
google/gemini-2.5-pro-preview1049K ctx · $1.25/$10.00text+image+file+audio->text
google/gemma-3n-e4b-it33K ctx · $0.06/$0.12text->text
google/gemini-3.1-flash-image-preview66K ctx · $0.50/$3.00text+image->text+image
google/gemma-3-12b-it131K ctx · $0.05/$0.15text+image->text
google/gemini-3.1-flash-image131K ctx · $0.50/$3.00text+image->text+image
google/gemini-3-flash-preview1049K ctx · $0.50/$3.00text+image+file+audio+video->text
google/gemini-2.5-flash1049K ctx · $0.30/$2.50text+image+file+audio+video->text
google/gemma-2-27b-it8K ctx · $0.65/$0.65text->text
google/gemini-2.5-pro1049K ctx · $1.25/$10.00text+image+file+audio+video->text
google/gemma-4-31b-it262K ctx · $0.10/$0.34text+image+video->text
google/gemini-embedding-00120K ctx · $0.15/$0.00text->embeddings
google/gemini-2.5-pro-preview-05-061049K ctx · $1.25/$10.00text+image+file+audio+video->text
google/gemini-3.5-flash-lite1049K ctx · $0.30/$2.50text+image+file+audio+video->text
google/gemini-2.5-flash-image33K ctx · $0.30/$2.50text+image->text+image
google/gemma-3-27b-it262K ctx · $0.08/$0.45text+image->text
google/veo-3.1 · $0.00/$0.00text+image->video
google/gemini-3-pro-image131K ctx · $2.00/$12.00text+image->text+image
google/gemini-3.1-pro-preview-customtools1049K ctx · $2.00/$12.00text+image+file+audio+video->text
google/gemma-4-26b-a4b-it262K ctx · $0.07/$0.34text+image+video->text
google/gemini-3.6-flash1049K ctx · $1.50/$7.50text+image+file+audio+video->text
google/gemini-3.5-flash1049K ctx · $1.50/$9.00text+image+file+audio+video->text
Anthropic
anthropic/claude-opus-4.61000K ctx · $5.00/$25.00text+image+file->text
anthropic/claude-sonnet-4.61000K ctx · $3.00/$15.00text+image+file->text
anthropic/claude-sonnet-41000K ctx · $3.00/$15.00text+image+file->text
anthropic/claude-sonnet-51000K ctx · $2.00/$10.00text+image+file->text
anthropic/claude-haiku-4.5200K ctx · $1.00/$5.00text+image+file->text
anthropic/claude-sonnet-4.51000K ctx · $3.00/$15.00text+image+file->text
anthropic/claude-opus-4.71000K ctx · $5.00/$25.00text+image+file->text
anthropic/claude-fable-51000K ctx · $10.00/$50.00text+image+file->text
anthropic/claude-opus-4.81000K ctx · $5.00/$25.00text+image+file->text
anthropic/claude-3-haiku200K ctx · $0.25/$1.25text+image->text
anthropic/claude-opus-4.5200K ctx · $5.00/$25.00text+image+file->text
anthropic/claude-opus-4200K ctx · $15.00/$75.00text+image+file->text
anthropic/claude-opus-4.1200K ctx · $15.00/$75.00text+image+file->text
anthropic/claude-opus-51000K ctx · $5.00/$25.00text+image+file->text
Zhipu AI
z-ai/glm-5205K ctx · $1.00/$3.20text->text
z-ai/glm-5.1205K ctx · $1.40/$4.40text->text
z-ai/glm-5v-turbo203K ctx · $1.20/$4.00text+image+video->text
z-ai/glm-4.7205K ctx · $0.40/$1.75text->text
z-ai/glm-5.21049K ctx · $1.40/$4.40text->text
z-ai/glm-5-turbo203K ctx · $1.20/$4.00text->text
z-ai/glm-4.5v66K ctx · $0.60/$1.80text+image->text
z-ai/glm-4.6v131K ctx · $0.30/$0.90text+image+video->text
z-ai/glm-4.6205K ctx · $0.50/$2.00text->text
z-ai/glm-4.7-flash203K ctx · $0.06/$0.40text->text
z-ai/glm-4.5-air131K ctx · $0.13/$0.85text->text
z-ai/glm-4.5131K ctx · $0.60/$2.20text->text
DeepSeek
deepseek/deepseek-v3.2164K ctx · $0.28/$0.42text->text
deepseek/deepseek-v4-pro1049K ctx · $2.40/$4.80text->text
deepseek/deepseek-v4-flash1049K ctx · $0.20/$0.40text->text
deepseek/deepseek-chat-v3-0324164K ctx · $0.27/$1.12text->text
deepseek/deepseek-r1164K ctx · $0.70/$2.50text->text
deepseek/deepseek-v3.1-terminus164K ctx · $0.27/$1.00text->text
deepseek/deepseek-r1-0528164K ctx · $0.50/$2.15text->text
deepseek/deepseek-r1-distill-llama-70b8K ctx · $0.80/$0.80text->text
deepseek/deepseek-chat-v3.1164K ctx · $0.25/$0.95text->text
deepseek/deepseek-chat164K ctx · $0.40/$1.30text->text
deepseek/deepseek-v3.2-exp164K ctx · $0.27/$0.41text->text
Moonshot AI
moonshotai/kimi-k31049K ctx · $3.00/$15.00text+image->text
moonshotai/kimi-k2.5262K ctx · $0.60/$3.00text+image->text
moonshotai/kimi-k2.7-code262K ctx · $0.95/$4.00text+image->text
moonshotai/kimi-k2.6262K ctx · $0.95/$4.00text+image->text
moonshotai/kimi-k2131K ctx · $0.57/$2.30text->text
moonshotai/kimi-k2-0905262K ctx · $0.60/$2.50text->text
moonshotai/kimi-k2-thinking262K ctx · $0.60/$2.50text->text
Perplexity
perplexity/sonar-pro200K ctx · $3.00/$15.00text+image->text
perplexity/sonar-pro-search200K ctx · $3.00/$15.00text+image->text
perplexity/sonar127K ctx · $1.00/$1.00text+image->text
perplexity/sonar-reasoning-pro128K ctx · $2.00/$8.00text+image->text
perplexity/sonar-deep-research128K ctx · $2.00/$8.00text->text
xAI
x-ai/grok-4.31000K ctx · $1.25/$2.50text+image+file->text
x-ai/grok-build-0.1256K ctx · $1.00/$2.00text+image+file->text
x-ai/grok-4.202000K ctx · $1.25/$2.50text+image+file->text
x-ai/grok-4.20-multi-agent2000K ctx · $1.25/$2.50text+image+file->text
x-ai/grok-4.5500K ctx · $2.00/$6.00text+image+file->text
MiniMax
minimax/minimax-m2.5205K ctx · $0.30/$1.20text->text
minimax/minimax-m31049K ctx · $0.30/$1.20text+image+video->text
minimax/minimax-m2.7205K ctx · $0.30/$1.20text->text
minimax/minimax-m2.1205K ctx · $0.30/$1.20text->text
Tencent
tencent/kinfra-text-embedding-4b · $0.08/$0.00
tencent/hy3 · $0.13/$0.53
tencent/hy-mt2-plus · $0.10/$0.40
tencent/kinfra-text-embedding-0.6b · $0.07/$0.00
bytedance-seed
bytedance-seed/seed-1.6262K ctx · $0.25/$2.00text+image+video->text
bytedance-seed/seed-2.0-mini262K ctx · $0.10/$0.40text+image+video->text
bytedance-seed/seed-2.0-lite262K ctx · $0.25/$2.00text+image+video->text
bytedance-seed/seed-1.6-flash262K ctx · $0.07/$0.30text+image+video->text
Nous
nousresearch/hermes-3-llama-3.1-70b131K ctx · $0.70/$0.70text->text
nousresearch/hermes-4-70b131K ctx · $0.13/$0.40text->text
nousresearch/hermes-4-405b131K ctx · $1.00/$3.00text->text
nousresearch/hermes-3-llama-3.1-405b131K ctx · $1.00/$1.00text->text
ByteDance
bytedance/seedance-2.0 · $0.00/$0.00text+image+audio+video->video
bytedance/seedance-2.0-fast · $0.00/$0.00text+image+audio+video->video
bytedance/seedance-1-5-pro · $0.00/$0.00text+image->video
Mistral
mistralai/mistral-large128K ctx · $2.00/$6.00text+file->text
mistralai/mixtral-8x22b-instruct66K ctx · $2.00/$6.00text+file->text
xiaomi
xiaomi/mimo-v2.51050K ctx · $0.14/$0.28text+image+audio+video->text
xiaomi/mimo-v2.5-pro1050K ctx · $0.43/$0.87text->text
NVIDIA
nvidia/nemotron-3-nano-30b-a3b262K ctx · $0.05/$0.20text->text
nvidia/nemotron-3-super-120b-a12b1000K ctx · $0.30/$0.90text->text
ibm-granite
ibm-granite/granite-4.0-h-micro131K ctx · $0.02/$0.11text->text
Meta
meta-llama/llama-3.2-1b-instruct60K ctx · $0.03/$0.20text->text
Tongyi-MAI
Tongyi-MAI/Z-Image-Turbotext->image

पर सभी मॉडल ब्राउज़ करें मॉडल पेज.

Streaming

सेट stream: true सर्वर-भेजे गए इवेंट (SSE) स्ट्रीम प्राप्त करने के लिए। प्रत्येक घटना में प्रतिक्रिया का एक हिस्सा होता है।

from openai import OpenAI

client = OpenAI(
    base_url="https://bazaarlink.ai/api/v1",
    api_key="sk-bl-YOUR_API_KEY",
)

stream = client.chat.completions.create(
    model="anthropic/claude-sonnet-4.6",
    messages=[{"role": "user", "content": "Count to 10 slowly."}],
    stream=True,
)

for chunk in stream:
    content = chunk.choices[0].delta.content
    if content:
        print(content, end="", flush=True)

SSE प्रारूप स्ट्रीमिंग में

data: {"id":"chatcmpl-abc","choices":[{"delta":{"content":"Hello"},"index":0}]}

data: {"id":"chatcmpl-abc","choices":[{"delta":{"content":" world"},"index":0}]}

data: {"id":"chatcmpl-abc","choices":[{"delta":{},"finish_reason":"stop","index":0}],"usage":{"prompt_tokens":10,"completion_tokens":4,"total_tokens":14}}

data: [DONE]
Usage
स्ट्रीमिंग करते समय, उपयोग डेटा को [DONE] संदेश से पहले अंतिम खंड में, एक खाली डेल्टा और फिनिश_कारण: "स्टॉप" के साथ एक विकल्प सरणी के साथ लौटाया जाता है।

Keep-alive और अंतिम चंक

स्ट्रीम में keep-alive के रूप में SSE कमेंट लाइनें (कोलन से शुरू होने वाली) या हार्टबीट इवेंट हो सकते हैं — रॉ स्ट्रीम को JSON.parse करने के बजाय गैर-data: लाइनों को छोड़ दें। अंतिम data चंक data: [DONE] से पहले usage (टोकन गणना और लागत) लेकर आता है। सफल रिस्पॉन्स में X-Request-Id हेडर होता है — समस्या रिपोर्ट करते समय इसे शामिल करें।

: keepalive          <- SSE comment line — ignore, do NOT JSON.parse

data: {"id":"chatcmpl-abc","choices":[{"delta":{"content":"Hi"},"index":0}]}

data: {"id":"chatcmpl-abc","choices":[{"delta":{},"finish_reason":"stop","index":0}],"usage":{...}}

data: [DONE]

स्ट्रीम रद्दीकरण

क्लाइंट कनेक्शन बंद करके स्ट्रीमिंग रिक्वेस्ट रद्द की जा सकती है — जैसे AbortController.abort() कॉल करना या stream ऑब्जेक्ट बंद करना। रद्दीकरण मिलते ही BazaarLink आगे के चंक भेजना बंद कर देता है और प्रोवाइडर को भेजी जा रही रिक्वेस्ट रद्द कर देता है।

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://bazaarlink.ai/api/v1",
  apiKey: "sk-bl-YOUR_API_KEY",
});

const controller = new AbortController();

const stream = await client.chat.completions.create(
  {
    model: "anthropic/claude-sonnet-4.6",
    messages: [{ role: "user", content: "Write a long story." }],
    stream: true,
  },
  { signal: controller.signal }
);

for await (const chunk of stream) {
  const content = chunk.choices[0]?.delta?.content;
  if (content) process.stdout.write(content);
}

// e.g. on a "Stop" button click:
controller.abort();
बीच में रुकी स्ट्रीम के लिए कोई शुल्क नहीं
अगर अंतिम usage चंक आने से पहले ही स्ट्रीम खत्म हो जाए — क्लाइंट-साइड रद्दीकरण सहित — तो उस रिक्वेस्ट के लिए कोई भरोसेमंद टोकन-गणना नहीं होती, इसलिए BazaarLink पूरा आरक्षित अमाउंट वापस कर देता है। रद्द करने से पहले आपके क्लाइंट तक पहुँच चुकी सामग्री के लिए कोई शुल्क नहीं लिया जाता।
प्रोवाइडर पर तुरंत रुकने की गारंटी नहीं
कनेक्शन बंद करने से BazaarLink तुरंत आगे के टोकन भेजना और उनका शुल्क लेना बंद कर देता है, लेकिन कनेक्शन टूटते ही अपस्ट्रीम प्रोवाइडर अपने सर्वर पर जनरेशन रोकता है या नहीं, यह उस प्रोवाइडर पर निर्भर करता है — कुछ डिस्कनेक्ट के बाद भी थोड़ी देर तक प्रोसेसिंग जारी रख सकते हैं।

मिड-स्ट्रीम त्रुटियाँ

त्रुटि फ़्रेम पर कोई विकल्प फ़ील्ड नहीं
यदि स्ट्रीमिंग शुरू होने के बाद कोई विफलता होती है (उदाहरण के लिए अपस्ट्रीम कनेक्शन बंद हो जाता है), तो आपको सामान्य {विकल्प:[...]} के बजाय एक SSE डेटा फ्रेम आकार का {त्रुटि: {संदेश, प्रकार, कोड}} मिलता है - बिना HTTP स्थिति परिवर्तन के, क्योंकि हेडर पहले ही भेजे जा चुके हैं। विकल्प[0].डेल्टा पढ़ने से पहले त्रुटि कुंजी की जांच करें, और केवल पहले से स्ट्रीम किए गए टोकन के लिए बिल करें (आंशिक बिलिंग लागू होती है)।
data: {"id":"chatcmpl-abc","choices":[{"delta":{"content":"The capital of "},"index":0}]}

data: {"error":{"message":"Upstream connection lost.","type":"upstream_error","code":502}}

data: [DONE]

Embeddings

Embeddings, अर्थ (semantic meaning) capture करने वाला numerical representation है — यह text को vectors (numbers की array) में बदल देता है, जिसे कई machine learning tasks में इस्तेमाल किया जा सकता है। BazaarLink एक unified, OpenAI Embeddings API-compatible endpoint देता है ताकि आप एक ही interface से कई providers के embedding models call कर सकें।

Embeddings क्या हैं?

Embeddings text को high-dimensional vectors में बदल देते हैं, जहाँ semantically similar text vector space में एक-दूसरे के करीब होते हैं — जैसे "cat" और "kitten" के embeddings मिलते-जुलते होंगे, लेकिन "cat" और "airplane" काफी दूर होंगे। इन vector representations से machines text के बीच के संबंध समझ पाती हैं, जो कई AI applications की नींव है।

आम Use Cases

Use केस
विवरण
RAG (पुनर्प्राप्ति-संवर्धित पीढ़ी)ऐसे systems बनाएं जो answer generate करने से पहले knowledge base से relevant context retrieve करें — embeddings LLM के context में शामिल करने के लिए सबसे relevant documents ढूंढते हैं।
सिमेंटिक खोजdocuments और queries को embeddings में बदलें, फिर vector similarity से सबसे relevant documents ढूंढें — यह सिर्फ keyword matching की बजाय meaning समझता है, इसलिए keyword search से बेहतर results देता है।
सिफारिश प्रणालीitems (products, articles, videos) और user preferences के embeddings बनाकर similar items recommend करें — common keywords न होने पर भी vector comparison semantically related items ढूंढ लेता है।
क्लस्टरिंग और वर्गीकरणembedding patterns analyze करके similar documents को group या classify करें — similar embeddings वाले documents आमतौर पर एक ही topic या category के होते हैं।
डुप्लिकेट डिटेक्शनembedding similarity compare करके duplicate या near-duplicate content ढूंढें — content paraphrase किया गया हो तब भी यह काम करता है।
असामान्यता का पता लगानाdataset के typical pattern से काफी अलग embeddings पहचान कर unusual या outlier content detect करें।
POST/api/v1/embeddings
Note
सभी अपस्ट्रीम प्रदाता एम्बेडिंग का समर्थन नहीं करते हैं। यदि आपका कॉन्फ़िगर किया गया प्रदाता अनुरोधित मॉडल का समर्थन नहीं करता है, तो BazaarLink स्वचालित रूप से अगले उपलब्ध प्रदाता को विफल कर देगा।

पैरामीटर्स

modelआवश्यक
string
उपयोग करने के लिए एम्बेडिंग मॉडल, उदा. "openai/text-embedding-3-small"। एम्बेड करने के लिए
inputआवश्यक
string | string[] | ContentItem[]
Text - एक एकल स्ट्रिंग, एक बैच कॉल के लिए स्ट्रिंग्स की एक सरणी, या (उन मॉडलों के लिए जो इसका समर्थन करते हैं) टेक्स्ट और इमेज_यूआरएल भागों को मिलाकर {content:[...]} आइटम की एक सरणी।
dimensions
integer
अनुरोधित आउटपुट वेक्टर आकार। केवल उन मॉडलों द्वारा सम्मानित किया जाता है जो परिवर्तनीय आयामों का समर्थन करते हैं (उदाहरण के लिए OpenAI टेक्स्ट-एम्बेडिंग-3 परिवार); अपस्ट्रीम प्रदाता को वैसे ही अग्रेषित किया गया और उन मॉडलों द्वारा अनदेखा कर दिया गया जो इसका समर्थन नहीं करते हैं।
encoding_format
string
अनुरोधित एम्बेडिंग एन्कोडिंग, उदा. "फ्लोट" या "बेस64"। अपस्ट्रीम प्रदाता को वैसे ही अग्रेषित किया जाता है - समर्थन मॉडल पर निर्भर करता है।
provider
object
प्रदाता रूटिंग प्राथमिकताएँ - ऑर्डर, अनुमति_फ़ॉलबैक, डेटा_कलेक्शन, और प्रदाता चयन में वर्णित अन्य फ़ील्ड।

बुनियादी अनुरोध

from openai import OpenAI

client = OpenAI(
    base_url="https://bazaarlink.ai/api/v1",
    api_key="sk-bl-YOUR_API_KEY",
)

response = client.embeddings.create(
    model="openai/text-embedding-3-small",
    input="The quick brown fox jumps over the lazy dog",
)

print(response.data[0].embedding)  # 1536-dimensional vector

बैच प्रोसेसिंग

एक ही अनुरोध में एकाधिक टेक्स्ट को एम्बेड करने के लिए स्ट्रिंग्स की एक सरणी भेजें - प्रति टेक्स्ट एक कॉल की तुलना में सस्ता और तेज़।

response = client.embeddings.create(
    model="openai/text-embedding-3-small",
    input=[
        "Machine learning is a subset of artificial intelligence",
        "Deep learning uses neural networks with multiple layers",
        "Natural language processing enables computers to understand text",
    ],
)

for i, item in enumerate(response.data):
    print(f"Embedding {i}: {len(item.embedding)} dimensions")

मल्टीमॉडल इनपुट (छवि + टेक्स्ट) छवि इनपुट समर्थन के साथ

मॉडल (आउटपुट_मोडालिटी में "एम्बेडिंग" और इनपुटमोडालिटी में "इमेज" शामिल है) {content:[{type:"text",...}, {type:"image_url",...}]} के आकार के इनपुट आइटम स्वीकार करते हैं, जिससे आप अकेले या टेक्स्ट के साथ संयुक्त रूप से एक छवि एम्बेड कर सकते हैं।

मॉडल-निर्भर
केवल कुछ एम्बेडिंग मॉडल छवि इनपुट स्वीकार करते हैं - image_url सामग्री भेजने से पहले मॉडल पृष्ठ पर मॉडल के समर्थित तौर-तरीकों की जांच करें। केवल-पाठ मॉडल इस आकृति को अस्वीकार कर देंगे।
import requests

response = requests.post(
    "https://bazaarlink.ai/api/v1/embeddings",
    headers={
        "Authorization": "Bearer sk-bl-YOUR_API_KEY",
        "Content-Type": "application/json",
    },
    json={
        "model": "google/gemini-embedding-2-preview",
        "input": [{
            "content": [
                {"type": "text", "text": "A scenic boardwalk through a green meadow"},
                {"type": "image_url", "image_url": {"url": "https://example.com/boardwalk.jpg"}},
            ]
        }],
        "encoding_format": "float",
    },
)

embedding = response.json()["data"][0]["embedding"]
print(f"Embedding dimension: {len(embedding)}")

प्रदाता रूटिंग

Control जो अपस्ट्रीम चैट पूर्णता के समान एम्बेडिंग अनुरोध को पूरा करता है - पूर्ण फ़ील्ड संदर्भ के लिए प्रदाता चयन देखें।

{
  "model": "openai/text-embedding-3-small",
  "input": "Your text here",
  "provider": {
    "order": ["openai"],
    "allow_fallbacks": true,
    "data_collection": "deny"
  }
}

एंबेडिंग मॉडल ढूँढना

कोई समर्पित एम्बेडिंग मॉडल-लिस्टिंग एंडपॉइंट नहीं है - GET /api/v1/models पर कॉल करें और उन प्रविष्टियों के लिए क्लाइंट-साइड फ़िल्टर करें जिनके आउटपुट_मोडैलिटी में "एम्बेडिंग" शामिल है, या मॉडल पृष्ठ ब्राउज़ करें।

सीमाएँ

  • कोई स्ट्रीमिंग नहीं - चैट पूर्णता के विपरीत, एम्बेडिंग हमेशा पूर्ण प्रतिक्रिया के रूप में लौटाई जाती है।
  • प्रत्येक मॉडल की अधिकतम इनपुट लंबाई होती है; उस सीमा से परे पाठ को काट दिया जाता है या अपस्ट्रीम में अस्वीकृत कर दिया जाता है।
  • Embeddings समान इनपुट के लिए नियतात्मक हैं - इसमें कोई तापमान या यादृच्छिकता शामिल नहीं है।

सर्वोत्तम अभ्यास

  • अपने speed/quality/लागत ट्रेडऑफ़ के लिए एक मॉडल चुनें - छोटे मॉडल (जैसे qwen/qwen3-embedding-4b) सस्ते और तेज़ हैं; बड़े वाले (उदाहरण के लिए openai/text-embedding-3-large) आम तौर पर उच्च निष्ठा के साथ एम्बेड होते हैं।
  • प्रति टेक्स्ट एक कॉल के बजाय एकाधिक टेक्स्ट को एक अनुरोध में बैचें - कम राउंड ट्रिप, कम ओवरहेड।
  • Cache परिणाम - एक ही इनपुट के लिए एम्बेडिंग कभी नहीं बदलती है, इसलिए उन्हें पुन: उत्पन्न करने के बजाय संग्रहीत करें।
  • कोसाइन समानता से तुलना करें, यूक्लिडियन दूरी से नहीं - यह स्केल-अपरिवर्तनीय है और उच्च-आयामी वैक्टर के लिए बेहतर काम करता है।
  • प्रत्येक मॉडल की संदर्भ लंबाई देखें - लंबे दस्तावेज़ों को एम्बेड करने से पहले टुकड़े-टुकड़े करने की आवश्यकता हो सकती है।

पैरामीटर्स

सैंपलिंग पैरामीटर टोकन निर्माण प्रक्रिया को आकार देते हैं। BazaarLink अपस्ट्रीम प्रदाता को समर्थित पैरामीटर पास करता है; असमर्थित मापदंडों को चुपचाप नजरअंदाज कर दिया जाता है।

सैंपलिंग पैरामीटर

प्योर पासथ्रू - कोई स्थानीय डिफ़ॉल्ट नहीं
ये अपस्ट्रीम प्रदाता को बिल्कुल वैसे ही अग्रेषित किए जाते हैं जैसे भेजा गया था - BazaarLink कभी भी डिफ़ॉल्ट को इंजेक्ट या लागू नहीं करता है। नीचे दिया गया "डिफ़ॉल्ट" किसी फ़ील्ड को छोड़े जाने पर प्रदाता के स्वयं के व्यवहार का वर्णन करता है, BazaarLink की गारंटी नहीं।
temperature
number
सैंपलिंग तापमान 0-2। उच्चतर = अधिक यादृच्छिक. डिफ़ॉल्ट: 1
top_p
number
न्यूक्लियस नमूना संभाव्यता द्रव्यमान। डिफ़ॉल्ट: 1
top_k
integer
टोकन विकल्पों को शीर्ष-K तक सीमित करें। 0 = अक्षम (सभी पर विचार करें)। डिफ़ॉल्ट: 0
frequency_penalty
number
बार-बार टोकन को दंडित करें। रेंज: [-2, 2]। डिफ़ॉल्ट: 0
presence_penalty
number
उपस्थिति के आधार पर टोकन को दंडित करें। रेंज: [-2, 2]। डिफ़ॉल्ट: 0
repetition_penalty
number
इनपुट से टोकन पुनरावृत्ति को कम करें। रेंज: (0, 2]। डिफ़ॉल्ट: 1
min_p
number
शीर्ष टोकन के सापेक्ष न्यूनतम संभावना। रेंज: [0, 1]। डिफ़ॉल्ट: 0
top_a
number
डायनामिक टॉप-पी उच्चतम-संभावना टोकन पर आधारित है। रेंज: [0, 1]। डिफ़ॉल्ट: 0
seed
integer
पूर्णांक बीज। सभी मॉडलों के लिए गारंटी नहीं है
max_tokens
integer
उत्पन्न करने के लिए टोकन की अधिकतम संख्या max_tokens के लिए
n
integer
उत्पन्न होने वाली पूर्णताओं की संख्या। डिफ़ॉल्ट: 1 नियतात्मक नमूने के लिए
logit_bias
object
मैप टोकन आईडी को पूर्वाग्रह मानों के लिए [-100, 100] नमूनाकरण से पहले जोड़ा गया। केवल OpenAI-पारिवारिक मॉडल - नीचे नोट देखें।
logprobs
boolean
प्रत्येक आउटपुट टोकन की लॉग संभावनाएँ लौटाएँ। केवल OpenAI-पारिवारिक मॉडल - नीचे नोट देखें।
top_logprobs
integer
प्रति स्थिति पर लौटने के लिए सबसे संभावित टोकन की संख्या (लॉगप्रॉब्स की आवश्यकता है: सत्य)। रेंज: 0-20. केवल OpenAI-पारिवारिक मॉडल - नीचे नोट देखें।
response_format
object
Force संरचित JSON आउटपुट। संरचित आउटपुट अनुभाग देखें
structured_outputs
boolean
इसका समर्थन करने वाले प्रदाताओं पर सख्त JSON-स्कीमा-अनुरूप आउटपुट का अनुरोध करें। ज्यों का त्यों पार कर लिया
reasoning
object
प्रदाता-विशिष्ट reasoning/thinking कॉन्फ़िगरेशन। ज्यों का त्यों पार कर लिया
reasoning_effort
string
OpenAI ओ-सीरीज़ शैली तर्क प्रयास: "कम", "मध्यम", या "उच्च"। ज्यों का त्यों पार कर लिया
stop
string | string[]
स्टॉप अनुक्रम - सामना होने पर पीढ़ी रुक जाती है
tools
Tool[]
उन टूल (फ़ंक्शन) की सूची जिन्हें मॉडल कॉल कर सकता है
tool_choice
string | object
कंट्रोल्स टूल का उपयोग: "ऑटो", "कोई नहीं", या विशिष्ट टूल
parallel_tool_calls
boolean
उपकरण उपलब्ध कराए जाने पर समानांतर फ़ंक्शन कॉलिंग सक्षम करें। डिफ़ॉल्ट: सत्य. केवल OpenAI-पारिवारिक मॉडल - नीचे नोट देखें।

BazaarLink-केवल पैरामीटर

transforms
string[]
Message लागू करने के लिए रूपांतरित होता है, उदा. ["मध्य-बाहर"]। ≤8k-संदर्भ मॉडल पर स्वत: लागू करना छोड़ें
models
string[]
फ़ॉलबैक मॉडल सूची - प्राथमिक विफल होने पर BazaarLink प्रत्येक को क्रम में आज़माता है
route
string
उन्नत रूटिंग संगतता फ़ील्ड — अधिकांश उपयोगकर्ताओं को इसकी आवश्यकता नहीं। फ़ॉलबैक हेतु "models" उपयोग करें।
provider
object
उन्नत रूटिंग वरीयताएँ — अधिकांश उपयोगकर्ताओं को इनकी आवश्यकता नहीं।

क्रेडिट

Query वर्तमान क्रेडिट शेष और आजीवन API उपयोग।

GET/api/v1/credits
Auth
को बियरर टोकन (मानक API कुंजी sk-bl-...) की आवश्यकता है।

उदाहरण अनुरोध

curl https://bazaarlink.ai/api/v1/credits \
  -H "Authorization: Bearer sk-bl-YOUR_KEY"

प्रतिक्रिया

{
  "data": {
    "total_credits": 100.00,
    "total_usage": 12.34
  }
}

त्रुटियाँ: 401 (missing/invalid कुंजी), 403 (निलंबित उपयोगकर्ता)।

जनरेशन विवरण

जेनरेशन आईडी (chat/completions प्रतिक्रिया आईडी या स्ट्रीमिंग x-bz-gen-id हेडर से) द्वारा एकल पूर्णता के लिए विस्तृत आंकड़े प्राप्त करें।

GET/api/v1/generation?id=<generation-id>
Auth
को बियरर टोकन (मानक API कुंजी) की आवश्यकता है। आवश्यक क्वेरी पैरामीटर: आईडी।

उदाहरण अनुरोध

curl "https://bazaarlink.ai/api/v1/generation?id=gen_abc123" \
  -H "Authorization: Bearer sk-bl-YOUR_KEY"

प्रतिक्रिया

{
  "data": {
    "id": "gen_xyz...",
    "model": "openai/gpt-4.1",
    "provider": "openai",
    "created_at": "2026-04-20T10:00:00.000Z",
    "app_name": "MyApp",
    "finish_reason": "stop",
    "status": 200,
    "duration_ms": 1234,
    "first_token_ms": 234,
    "throughput": 45.6,
    "usage": {
      "prompt_tokens": 100,
      "completion_tokens": 200,
      "total_tokens": 300,
      "prompt_tokens_details": { "cached_tokens": 50 },
      "completion_tokens_details": { "reasoning_tokens": 30 },
      "cost": 0.00123
    },
    "cost_breakdown": {
      "subtotal": 0.00123,
      "cache_discount": 0.00015,
      "total": 0.00108
    }
  }
}

त्रुटियाँ: 400 (गुम आईडी), 401 (auth), 404 (पीढ़ी नहीं मिली)।

API मुख्य जानकारी

Query वर्तमान API कुंजी की दर सीमा स्तर और एकत्रित उपयोग काउंटर (प्रतिक्रिया प्रारूप सामान्य उद्योग कुंजी-जानकारी API सम्मेलनों का पालन करता है)।

GET/api/v1/key
Auth
को बियरर टोकन (मानक API कुंजी) की आवश्यकता है।

प्रतिक्रिया

{
  "data": {
    "label": "Production Key",
    "limit": null,
    "limit_remaining": 100.00,
    "limit_reset": null,
    "expires_at": null,
    "is_free_tier": false,
    "is_management_key": false,
    "is_provisioning_key": false,
    "usage": 12.34,
    "usage_daily": 0.12,
    "usage_weekly": 0.45,
    "usage_monthly": 1.23,
    "requests": 1234,
    "requests_daily": 10,
    "requests_weekly": 50,
    "requests_monthly": 200,
    "rate_limit": { "requests": 600, "interval": "1m", "note": "Paid-tier rate limit." }
  }
}
Note
is_free_tier = सत्य जब क्रेडिट शेष <$10। विंडोज़ UTC में हैं: दैनिक = वर्तमान दिन, साप्ताहिक = सोम-रविवार, मासिक = 1-EOM। जब कुंजी में प्रति-कुंजी खर्च सीमा निर्धारित होती है (कुंजी creation/update पर सीमा पैरामीटर के माध्यम से), सीमा / सीमा_शेष / सीमा_रीसेट उस सीमा और मिलान अवधि के उपयोग को दर्शाती है; अन्यथा सीमा शून्य है और सीमा_शेष आपके खाते के क्रेडिट शेष में वापस आ जाती है। एक्सपायर_एट कुंजी का समाप्ति समय है (यदि कोई नहीं है तो शून्य)। is_management_key और is_provisioning_key एक ही अवधारणा के लिए उपनाम हैं - दोनों प्रबंधन कुंजी के लिए सही हैं।
BYOK
BazaarLink ब्रिंग-योर-ओन-की (BYOK) प्रोग्राम की पेशकश नहीं करता है, इसलिए यह एंडपॉइंट किसी भी byok_usage फ़ील्ड को वापस नहीं करता है।

त्रुटियाँ: 401 (auth), 404 (उपयोगकर्ता अनुपलब्ध - दुर्लभ)।

एजेंट पंजीकरण

एआई एजेंटों (बॉट्स, स्वायत्त सिस्टम) के लिए स्व-सेवा पंजीकरण। परीक्षण क्रेडिट और खाता अपग्रेड के लिए दावा टोकन के साथ एक API कुंजी लौटाता है।

POST/api/v1/agents/register
Rate Limit
किसी प्रमाणीकरण की आवश्यकता नहीं है, लेकिन आईपी-प्रति 24 घंटे में 1 पंजीकरण तक सीमित है।

अनुरोध बॉडी

nameआवश्यक
string
Agent नाम (गैर-रिक्त, छोटा, अधिकतम 100 वर्ण)।
description
string
वैकल्पिक एजेंट विवरण।
referral_code
string
वैकल्पिक रेफरल कोड।

उदाहरण अनुरोध

curl -X POST https://bazaarlink.ai/api/v1/agents/register \
  -H "content-type: application/json" \
  -d '{
    "name": "My Agent",
    "description": "Autonomous research bot"
  }'

प्रतिक्रिया

{
  "api_key": "sk-bl-xxxxx...",
  "credits": 0.10,
  "credits_usd": "$0.1000",
  "claim_token": "abc...xyz",
  "claim_expires": "2026-04-27T10:00:00.000Z",
  "upgrade_url": "https://bazaarlink.ai/claim?token=...",
  "referral_code": "aBcDeFgH",
  "free_model": "auto:free",
  "message": "Welcome to BazaarLink!...",
  "referral_message": "Share referral link:...",
  "base_url": "https://bazaarlink.ai/api/v1",
  "docs": "https://bazaarlink.ai/llms.txt"
}

त्रुटियाँ: 400 (अमान्य बॉडी / गुम नाम), 429 (दर सीमा - 1/IP/24h), 500 (आंतरिक)।

त्रुटि कोड

त्रुटि प्रतिक्रिया प्रारूप

मॉडल इन्फ़रेंस एंडपॉइंट OpenAI-संगत त्रुटि आवरण लौटाते हैं। type फ़ील्ड अलग हो सकता है या अनुपस्थित हो सकता है; संदेश को पार्स करने के बजाय प्रोग्राम लॉजिक में HTTP स्थिति और error.code का उपयोग करें।

{
  "error": {
    "message": "Insufficient credits. Please top up to continue.",
    "type": "invalid_request_error",
    "code": "insufficient_credits"
  }
}

HTTP स्थिति और त्रुटि.कोड

Before streaming, the HTTP status identifies the broad failure class. error.code is either that number or a stable string for a specific remedy. Prefer the string code when present, otherwise use the HTTP status.

कोड
नाम
विवरण
400खराब अनुरोधविकृत अनुरोध, खाली संदेश सरणी, या आवश्यक फ़ील्ड अनुपलब्ध
401अनधिकृतAPI कुंजी गुम, अमान्य या अक्षम है
402भुगतान आवश्यकअपर्याप्त खाता क्रेडिट, प्रति-कुंजी खर्च सीमा पूरी हो गई, या monthly/weekly बजट सीमा पार हो गई
403निषिद्धखाता निलंबित है या उसके पास अनुमति नहीं है
404नहीं मिलाRequested model, generation, key, or other resource does not exist
409संघर्षResource is not in the required state, such as an incomplete video job
410चला गयाRequested model has been retired and must be replaced
413पेलोड बहुत बड़ा हैअनुरोध का मुख्य भाग 10 एमबी से अधिक है; सामग्री का आकार कम करें या अनुरोध को विभाजित करें
416रेंज संतोषजनक नहीं हैRequested byte range is invalid for generated video content
429बहुत अधिक अनुरोधदर सीमा पार हो गई; पुनः प्रयास करने से पहले पुनः प्रयास-आफ्टर हेडर की जाँच करें
500सर्वर त्रुटिआंतरिक BazaarLink त्रुटि
502खराब गेटवेसभी अपस्ट्रीम प्रदाता विफल रहे; फेलओवर का प्रयास किया गया
503सेवा अनुपलब्धइस मॉडल के लिए कोई अपस्ट्रीम प्रदाता कॉन्फ़िगर नहीं किया गया है; व्यवस्थापक से संपर्क करें
504गेटवे टाइमआउटUpstream connection or stream stalled and timed out

मशीन-पठनीय बिलिंग कोड

A 402 can represent different controls. Use these stable codes to choose the correct action.

कोड
विवरण
budget_cap_reachedA weekly or monthly budget cap was reached; raise or reset the cap.
credit_limit_exceededA monthly-billing organization's credit line was exhausted; contact billing.
insufficient_creditsThe prepaid balance is insufficient; add credits.
spend_limit_exceededThe API key reached its daily, weekly, or monthly spend limit.

Stable error.code catalog

These string codes are emitted by public inference and media paths. Branch on the string code when present; the HTTP status remains the broad failure class.

मॉडल और समापन बिंदु
मॉडल लुकअप, जीवनचक्र, मूल्य निर्धारण, तौर-तरीके और समापन बिंदु संगतता त्रुटियाँ।
कोड
HTTP स्थिति
unknown_model400
invalid_model_id400
model_not_found404
model_retired410
model_endpoint_mismatch400
embedding_on_chat_endpoint400
model_not_priced400
invalid_modality_for_model400
अनुरोध और सुरक्षा
अमान्य पैरामीटर, संदर्भ, उपकरण, स्कीमा, और सामग्री-सुरक्षा अस्वीकरण।
कोड
HTTP स्थिति
missing_required_field400
unsupported_param400
max_tokens_invalid400
context_too_long400
tool_use_unsupported400
malformed_tool_messages400
invalid_response_format_schema400
invalid_tools_definition400
content_moderation403
content_filter403
unknown_4xx400
Image निर्माण और संपादन
Image इनपुट, मल्टीपार्ट संपादन, आउटपुट और छवि-पाइपलाइन त्रुटियाँ।
कोड
HTTP स्थिति
invalid_image_url400
input_images_not_supported400
invalid_content_type400
mask_not_supported400
unsupported_response_format400
missing_prompt400
missing_image400
too_many_images400
invalid_image_type400
image_too_large400
invalid_n400
pipeline_error502
no_images502
अपस्ट्रीम रूटिंग
Sanitized प्रदाता कनेक्टिविटी, प्रमाणीकरण, थ्रॉटलिंग और उपलब्धता त्रुटियाँ।
कोड
HTTP स्थिति
upstream_unreachable502
upstream_auth_failed502
upstream_rate_limited429
upstream_unavailable502/503

दर सीमा, बजट और आपातकालीन ब्रेक

These controls can reject an otherwise valid request and require different recovery actions.

नियंत्रण
HTTP स्थिति
कैसे करें इसकी पहचान
अनुरोध दर सीमा429न्यूमेरिक कोड 429; रिट्री-आफ्टर और एक्स-रेटलिमिट-* हेडर का उपयोग करें।
दर-सीमा जुर्माना ब्लॉक429न्यूमेरिक कोड 429 और एक अस्थायी प्रतिबंध संदेश; पुन:प्रयास-आफ्टर का उपयोग करें।
वैश्विक व्यय आपातकालीन ब्रेक503न्यूमेरिक कोड 503, वैश्विक खर्च-सीमा संदेश, और 30 या 300 सेकंड का पुनः प्रयास करें।
Scoped spend brake429Numeric code 429 and a spend circuit-breaker message naming the scope.
बिलिंग और बजट नियंत्रण402ऊपर सूचीबद्ध स्थिर बिलिंग स्ट्रिंग कोड का उपयोग करें।

Compatibility note: rate-limit and emergency-brake paths currently emit numeric error.code values. Use HTTP status, Retry-After, and the documented response message.

वीडियो और मीडिया संसाधन स्थिति

Video validation commonly returns numeric code 400. Missing jobs return 404, retired models 410, unfinished video content 409, and invalid video byte ranges 416.

पुनः प्रयास नीति

Retry only failures that may recover without changing the request. Honor Retry-After or use exponential backoff with jitter. Do not stack SDK and manual retries.

बैकऑफ़ के साथ पुनः प्रयास करें पुनः प्रयास करने से पहले
429, 502, 503, and 504. Check the original generation job before creating another after an ambiguous network failure.
Fix करें
400, 401, 402, 403, 404, 409, 410, 413, and 416. Fix the request, credentials, balance, permissions, resource state, or Range header first.

हैंडलिंग त्रुटियाँ

import random
import time
from openai import OpenAI, APIStatusError

client = OpenAI(
    base_url="https://bazaarlink.ai/api/v1",
    api_key="sk-bl-YOUR_API_KEY",
    max_retries=0,  # Avoid double retries; this example handles them.
)

RETRYABLE = {429, 502, 503, 504}

for attempt in range(5):
    try:
        response = client.chat.completions.create(
            model="openai/gpt-4.1",
            messages=[{"role": "user", "content": "Hello!"}],
        )
        break
    except APIStatusError as error:
        if error.status_code not in RETRYABLE or attempt == 4:
            raise
        retry_after = error.response.headers.get("Retry-After")
        delay = (
            float(retry_after)
            if retry_after
            else min(8, 0.5 * (2 ** attempt)) + random.uniform(0, 0.25)
        )
        time.sleep(delay)

स्ट्रीमिंग त्रुटि प्रारूप

त्रुटियां जो किसी भी टोकन को स्ट्रीम करने से पहले होती हैं, JSON बॉडी के साथ एक मानक HTTP त्रुटि प्रतिक्रिया लौटाती हैं।

After a stream starts, the HTTP response is already 200. Parse each SSE data frame and treat a top-level error or choices[0].finish_reason === "error" as a failed, incomplete response.

यदि स्ट्रीम बीच में विफल हो जाती है, तो BazaarLink एक अंतिम SSE इवेंट भेजता है जिसमें टॉप-लेवल error ऑब्जेक्ट होता है, उसके बाद data: [DONE] आता है। कुछ upstream से ज्यों-के-त्यों रिले किए गए चंक इसके बजाय choice पर त्रुटि रख सकते हैं (choices[0].finish_reason === "error") — दोनों को हैंडल करें।

// If the stream fails mid-flight, BazaarLink emits a final SSE event
// with a top-level "error" object, followed by data: [DONE]
data: {"error":{"message":"Upstream stream interrupted. The response is incomplete.","type":"upstream_error","code":502}}

data: [DONE]

// Chunks relayed verbatim from some upstreams may instead carry the error
// inline on the choice: choices[0].finish_reason === "error" with an
// "error" object ({ code, message }) on the choice — handle both shapes.
// Branch on error.code; error.type can vary by failure path.

संस्करणीकरण

BazaarLink एकल स्थिर API पथ को उजागर करता है, /api/v1 - प्रबंधित करने के लिए कोई दिनांक-पिन किए गए संस्करण या संस्करण हेडर नहीं हैं। API क्रमांकित रिलीज़ के बजाय लगातार विकसित होता है।

नॉन-ब्रेकिंग परिवर्तन

ये जहाज बिना किसी पूर्व सूचना के:

  • नए समापनबिंदु
  • कैटलॉग में नए मॉडल जोड़े गए
  • नए वैकल्पिक अनुरोध पैरामीटर
  • नए प्रतिक्रिया फ़ील्ड
  • वैकल्पिक गुणों के साथ नए स्कीमा
  • अतिरिक्त प्रतिक्रिया status/error कोड
ग्राहकों को रक्षात्मक रूप से लिखें
उन प्रतिक्रिया फ़ील्ड को अनदेखा करें जिन्हें आप नहीं पहचानते हैं, और एनम-जैसे फ़ील्ड में अज्ञात मानों पर असफल न हों - कैटलॉग और फीचर सेट बढ़ने पर नए जोड़े जाते हैं।

ब्रेकिंग परिवर्तन

ये दुर्लभ हैं, और कवर करते हैं:

  • किसी समापन बिंदु, पैरामीटर या प्रतिक्रिया फ़ील्ड को हटाना या उसका नाम बदलना
  • फ़ील्ड का प्रकार बदलना
  • एक वैकल्पिक पैरामीटर बनाना आवश्यक है

जब वे घटित होते हैं, तो संपूर्ण /api/v1 सतह के बजाय एक विशिष्ट समापन बिंदु पर एक ब्रेकिंग परिवर्तन लागू होता है - कोई एकल संस्करण बम्प नहीं है जो एक ही बार में प्रत्येक एकीकरण को तोड़ सकता है। हमने अभी तक ब्रेकिंग-चेंज टैग के साथ कोई औपचारिक चेंजलॉग प्रकाशित नहीं किया है (नीचे वर्तमान में बने रहना देखें); एकीकरण-महत्वपूर्ण किसी भी चीज़ के लिए, अप्रलेखित व्यवहार पर भरोसा करने से पहले समर्थन के माध्यम से संपर्क करें।

अवमूल्यन नीति

एक नियमित "ब्रेकिंग" घटना जिसकी आपको उम्मीद करनी चाहिए: व्यक्तिगत मॉडल सेवानिवृत्त हो जाते हैं क्योंकि अपस्ट्रीम प्रदाता उन्हें पदावनत कर देते हैं। GET /api/v1/models के माध्यम से मॉडल की वर्तमान स्थिति के बारे में पूछें।

GET https://bazaarlink.ai/api/v1/models
Authorization: Bearer sk-bl-YOUR_API_KEY

# A model within 30 days of its deprecation date shows in the catalog
# with an "EOL" badge on the Models page. After the effective date it's
# dropped from the catalog and calls return:
# 410 { "error": { "type": "model_not_available", "code": "model_retired" } }

वर्तमान में बने रहें

हमने अभी तक एक समर्पित API चेंजलॉग या RSS फ़ीड प्रकाशित नहीं किया है। अभी के लिए, इस पृष्ठ को सीधे जांचें, GET /api/v1/models के माध्यम से मॉडल की स्थिति देखें, या यदि आपको किसी महत्वपूर्ण एकीकरण के लिए अग्रिम सूचना की आवश्यकता है तो समर्थन से संपर्क करें।

Support
Support
Hi! How can we help you?
Send a message and we'll get back to you soon.