BazaarLinkBazaarLink
ログイン
ドキュメントAPIリファレンスSDKリファレンスエージェント利用AIスキル

API リファレンス

BazaarLink API の概要

BazaarLink は、モデルやプロバイダーをまたいで統一された OpenAI 互換のリクエスト/レスポンス形式を提供します。一度統合すれば、アプリを書き直さずにモデルを切り替えられます。

顧客指定のルーティング項目は無視されます
provider(オブジェクト全体)、transforms、route、トップレベルの service_tier、preset は上流へ送信する前に削除され、上流や料金ティアを選べません。Chat Completions と Responses の各エンドポイントでは、models 配列をローカルなフォールバックリストとしてサポートします。各モデルは BazaarLink が独自にルーティングしてその顧客価格を適用し、リストは上流へ転送しません。お客様が指定した :nitro、:floor、:exacto は無視されます。:eco は BazaarLink の経済ティアとして維持され、内部で BazaarLink の :floor に対応します。:free は独立したカタログモデルバリアントです。
ウェブ検索の追加料金
plugins、:online、または web_search_options によるウェブ検索の動作は維持されますが、上流の追加料金が発生する場合があります。料金はリクエストで使用したキー、つまり BazaarLink のプラットフォームキーまたはお客様の BYOK キーに請求されます。

OpenAPI 仕様

BazaarLink API 全体は OpenAPI 仕様で文書化され、YAML と JSON 形式で利用できます:

Swagger UI、Postman、または OpenAPI 対応のコードジェネレーターに読み込み、API の確認やクライアントライブラリの生成に利用できます。

リクエスト

チャット補完のリクエスト形式

チャット補完のリクエスト本文は、次のエンドポイントに送信します:

POST/v1/chat/completions

対応フィールドの完全な一覧は パラメータ。

リクエストスキーマ
// Definitions of subtypes are below
type Request = {
  // Required by BazaarLink Chat Completions
  model: string;                    // Use an id or alias from GET /v1/models
  messages: Message[];             // Must contain at least one message

  // Generation
  stream?: boolean;
  temperature?: number;
  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;
  presence_penalty?: number;
  repetition_penalty?: number;
  min_p?: number;
  top_a?: number;
  // Sampling values are forwarded without range validation; models may clamp or ignore them.

  // 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";
  include_reasoning?: boolean;
  reasoning?: ReasoningConfig;
  thinking?: ThinkingConfig;
  enable_thinking?: boolean;

};

// 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;
};

構造化出力

モデルにスキーマに一致する有効なJSONを返させます。モデル出力をプログラムで解析する信頼性の高いアプリケーション構築に不可欠です。

  • json_object — 基本 JSON モード。モデルは有効な JSON を返します。
  • json_schema — 厳密なスキーマモード。出力は指定した JSON Schema に一致する必要があります。

プラグイン

BazaarLink は plugins 配列を選択した上流ルートへ転送します。利用可否はモデルとプロバイダーに依存し、:online モデルでは web プラグインも有効になります。

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

オプションヘッダー

リクエストヘッダーでアプリケーションを識別して、使用量追跡、ダッシュボード表示、詳細な分析を有効にします。

TypeScript
await fetch("https://api.bazaarlink.ai/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-4o",
    messages: [{ role: "user", content: "Hello!" }]
  })
});

アシスタントプリフィル

メッセージ配列の最後に未完成の 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;
  message: {
    role: "assistant";
    content: string | null;
    tool_calls?: ToolCall[];
    reasoning?: string;                                      // thinking text: when the request asked for it, or by default for the models listed in the reasoning docs section
    reasoning_details?: Array<{ type: string; text?: string }>;
  };
};

type StreamingChoice = {
  index: number;
  finish_reason: string | null;
  delta: {
    role?: string;
    content?: string | null;
    tool_calls?: ToolCall[];
    reasoning?: string;
    reasoning_details?: Array<{ type: string; text?: string }>;
  };
};

終了理由

finish_reasonはstop、length、tool_calls、content_filter、errorなどBazaarLinkの標準化値を使用します。

JSON
{
  "finish_reason": "stop"
}

コストと統計の照会

レスポンスのidまたはx-request-idヘッダーの不透明なBazaarLinkリクエストIDでGET /v1/generationを呼び出します。非ストリーミングではx-generation-idにも同じIDが返ります。統計は完了後数秒かかる場合があり、404は短時間再試行してください。

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

エージェント登録

有効化すると、エージェントは無課金または x402 決済の登録入口からアカウントを作成できます。

POSThttps://api.bazaarlink.ai/api/v1/agents/register

無課金登録は name、任意の description、任意の referral_code を受け付けます。201 応答には API キー、クレジット、7 日間の claim token と有効期限、アップグレード URL、紹介コード、free_model auto:free、ベース URL、ドキュメントリンクが含まれます。既存の無料モデル機構を使います。無料ウェブ検索には認証済みメールが必要なため、無課金エージェントは利用できません。

POSThttps://api.bazaarlink.ai/api/v1/agents/register/x402

有料登録の最初の応答は HTTP 402 の要件で、scheme exact、network eip155:196、asset USD-T0、payTo を含みます。X-PAYMENT ヘッダー付きで再送すると、同じ登録フィールドに payment { txHash, network, amountUsd } が加わった 201 を受け取ります。有料エージェントは通常の有料アカウント規則に従い、既存アカウントは /api/x402/topup でチャージできます。

人間は 7 日間の token 有効期間中に /claim から無課金エージェントを引き継げます。登録は IP ごとに 24 時間で 1 回、さらにクラウドプロバイダー上限があります。拒否された場合は Retry-After 付き 429 です。

POSThttps://api.bazaarlink.ai/api/x402/topup

チャットコンプリーション

主要エンドポイント。OpenAI Chat Completions APIと互換。

POST/v1/chat/completions

リクエストボディ

model必須
string
GET /v1/modelsに掲載されたidまたはaliasを使用します(例: "claude-sonnet-4.6"、"anthropic/claude-sonnet-4.6")。
messages必須
Message[]
roleとcontentを持つメッセージオブジェクトの配列
stream
boolean
trueの場合、Server-Sent Eventsストリームを返す。デフォルト:false
temperature
number
サンプリング値は範囲検証なしで転送されます。モデルが対応範囲外の値を制限または無視する場合があります。
max_tokens
integer
生成する最大トークン数
max_completion_tokens
integer
max_tokensのエイリアス(OpenAI oシリーズ互換)。両方受け付けられ、指定されたほうが有効
top_p
number
Nucleusサンプリングの確率質量。デフォルト:1
top_k
integer
サンプリング値は範囲検証なしで転送されます。モデルが対応範囲外の値を制限または無視する場合があります。
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
最高確率トークンに基づく動的top-P。範囲:[0, 1]。デフォルト:0
seed
integer
決定論的サンプリング用の整数シード。すべてのモデルで保証されるわけではない
n
integer
生成するコンプリーション数。デフォルト:1
user
string
モニタリングと不正検出用のエンドユーザー識別子。課金には影響なし。OpenAI系モデルのみ対応 — 下記の注記を参照。
stop
string | string[]
停止シーケンス — 検出時に生成が停止
logit_bias
object
サンプリング前に追加されるトークンIDからバイアス値[-100, 100]へのマップ。OpenAI系モデルのみ対応 — 下記の注記を参照。
logprobs
boolean
各出力トークンのログ確率を返す。OpenAI系モデルのみ対応 — 下記の注記を参照。
top_logprobs
integer
位置ごとに返す最も可能性の高いトークン数(logprobs: trueが必要)。範囲:0〜20。OpenAI系モデルのみ対応 — 下記の注記を参照。
tools
Tool[]
モデルが呼び出せるツール(関数)のリスト
tool_choice
string | object
ツール使用の制御:"auto"、"none"、または特定のツール
parallel_tool_calls
boolean
ツール提供時の並列ファンクションコールを有効化。デフォルト:true。OpenAI系モデルのみ対応 — 下記の注記を参照。
response_format
object
構造化JSON出力を強制。構造化出力セクションを参照
structured_outputs
boolean
対応プロバイダーで厳密なJSONスキーマ準拠の出力をリクエスト。そのまま転送
reasoning
object
プロバイダー固有のreasoning/thinking設定。そのまま転送
reasoning_effort
string
OpenAI oシリーズ形式のreasoning強度:"low"、"medium"、または"high"。そのまま転送
include_reasoning
boolean
true にすると message.reasoning(ストリーミングでは delta.reasoning)に思考内容を返し、false にすると、デフォルトで思考するモデルの思考をオフにします(推論のセクション参照)。そのため思考は課金されません。reasoning_effort、reasoning、thinking のいずれも送らない場合、デフォルトで思考して返すのはそれらのモデルだけで、ほかのモデルは求めたときだけ返します
user、logprobs、top_logprobs、logit_bias、parallel_tool_callsはOpenAI系モデルにのみ届きます
解決されたモデルがOpenAI自身のものと認識されない場合、この5つのパラメータはアップストリームリクエストから除去されます — anthropic/claude-*、google/gemini-*、その他のOpenAI以外のターゲットに送信すると、エラーではなくパラメータが黙って無視された200が返されます。これらのいずれかを設定していて効果が現れない場合は、対象モデルがOpenAIのものかどうかを確認してください。

リクエストスキーマ(TypeScript)

// Definitions of subtypes are below
type Request = {
  // Required by BazaarLink Chat Completions
  model: string;                    // Use an id or alias from GET /v1/models
  messages: Message[];             // Must contain at least one message

  // Generation
  stream?: boolean;
  temperature?: number;
  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;
  presence_penalty?: number;
  repetition_penalty?: number;
  min_p?: number;
  top_a?: number;
  // Sampling values are forwarded without range validation; models may clamp or ignore them.

  // 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";
  include_reasoning?: boolean;
  reasoning?: ReasoningConfig;
  thinking?: ThinkingConfig;
  enable_thinking?: boolean;

};

// 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;
};

リクエスト例

curl https://api.bazaarlink.ai/v1/chat/completions \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o",
    "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": "85e6f35c71a31f19-SJC",
  "object": "chat.completion",
  "created": 1740000000,
  "model": "openai/gpt-4o",
  "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は標準化されたレスポンスを返し、上流固有のフィールドを削除します。usage.costはこのリクエストでお客様に請求された米ドル額です。

100秒を超える長いリクエストには、stream:true の使用を推奨します。非ストリーミングリクエストは、約12秒後(デフォルト値で、デプロイ設定により変更可能)にまず200を返し、keepalive の空白の送信を開始します。その後にエラーが発生した場合は、200 + error JSON として返されます。keepalive は JSON 本文の前に置かれる空白で、標準の JSON パーサーはこれを無視します。

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

type NonStreamingChoice = {
  index: number;
  finish_reason: "stop" | "length" | "tool_calls" | "content_filter" | null;
  message: {
    role: "assistant";
    content: string | null;
    tool_calls?: ToolCall[];
    reasoning?: string;                                      // thinking text: when the request asked for it, or by default for the models listed in the reasoning docs section
    reasoning_details?: Array<{ type: string; text?: string }>;
  };
};

type StreamingChoice = {
  index: number;
  finish_reason: string | null;
  delta: {
    role?: string;
    content?: string | null;
    tool_calls?: ToolCall[];
    reasoning?: string;
    reasoning_details?: Array<{ type: string; text?: string }>;
  };
};

type ResponseUsage = {
  prompt_tokens: number;
  completion_tokens: number;
  total_tokens: number;
  cost: number;                      // USD amount charged to the customer for this request
  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 };
};

画像生成

DALL·EやGPT-4oなどのモデルを使用してテキストプロンプトから画像を生成。チャットコンプリーションエンドポイントの`modalities`パラメータを使用して画像出力をリクエスト。 画像編集(既存の画像を修正)は POST /v1/images/edits を使用します —— OpenAI images.edit 互換で、multipart/form-data でソース画像を送信します。編集対応モデルは modality が text+image->image です(例: qwen/qwen-image-3)。純粋な生成モデルは text->image です —— 各モデルの modality は GET /v1/models で確認してください。

Response format

/v1/images/generations はデフォルトで OpenAI 互換の同期 JSON を返します(2026-07-25 以降)——client.images.generate() はラッパーなしで動作します。stream: true を渡すと SSE イベントストリームに切り替わり、生成時間の長いモデルで進捗を受け取れます。

20 秒を超える非ストリーミングリクエストは、まず HTTP 200 を返し(その後は空白文字で接続を維持します)、後から発生した失敗は「200+エラー本文」で返ります。最上位の `error` オブジェクトを確認してください(`"object": "error"` と `"http_status"` も付与します)。クライアントの読み取りタイムアウトが長い場合(OpenAI SDK の既定は 10 分)は、`X-BazaarLink-Sync-Wait: 90`(整数秒、1〜90、既定 20)を送ると、その時間内の失敗で実際のステータスコードを受け取れます。Python SDK は `default_headers={"X-BazaarLink-Sync-Wait": "90"}`、Node SDK は `defaultHeaders: { "X-BazaarLink-Sync-Wait": "90" }` を使います。Windows では JSON を UTF-8 ファイルに保存し `curl --data-binary @body.json` で送信してください。コンソールで `-d` の後に入力した日本語は UTF-8 ではなく、直ちに 400 `invalid_utf8` で拒否されます。

A. /v1/chat/completions(ネイティブ、推奨)

POST/v1/chat/completions

The canonical streaming path. Recommended for any new integration.

curl -N https://api.bazaarlink.ai/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
  }'

画像から画像(image-to-image):content 配列に image_url パートを含めます。データURIまたは https 画像URL(http:// は拒否されます)をサポートし、最大8枚、データURIあたり約10MBです。画像を含むメッセージには text パート(編集指示)も必要です。一部のモデルは image_config(例:{"strength": 0.7}、0〜1 — 低いほど元画像に近い)を追加でサポートし、そのままアップストリームに渡されます。

curl -N https://api.bazaarlink.ai/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/v1/images/edits

OpenAI SDK の client.images.edit() がそのまま動作します(multipart アップロード、data: [{ url }] を返す同期JSONレスポンス)。制限は image-to-image と同じ:最大8枚、各10MB。mask と response_format=b64_json は未対応です。

curl https://api.bazaarlink.ai/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/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://api.bazaarlink.ai/v1/images/generations \
  -H "Authorization: Bearer $BL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-image-1",
    "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://api.bazaarlink.ai/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

SSEコメント行や未知またはpingイベントを無視し、文書化されたimage、usage、doneイベントを処理してください。

: keep-alive

event: image
data: {"index": 0, "url": "https://api.bazaarlink.ai/v1/images/proxy/<token>"}

event: image-cached     # bazaarlink Redis-backed proxy URL (1 hr TTL)
data: {"index": 0, "url": "https://api.bazaarlink.ai/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)

動画生成

非同期の 3 ステップフロー(submit → poll → content)。動画生成には 30 秒〜5 分かかり、chat-completions の同期リクエスト/レスポンス方式には適合しません — そのため BazaarLink は動画を専用の /v1/videos パスに分離し、job-id パターンを採用しています:submit で vjob_* ID を取得 → ステータスを poll → 完了後に bytes を fetch。video model を /chat/completions や /images/generations 経由で呼び出すと 400(code: wrong_endpoint_for_video)が返ります。費用は completed 時に実際の usage.cost で精算されます。

動画タスクの種類

1 つのエンドポイントで複数のタスクを扱います。実際にどのタスクが実行されるかは送信するフィールドで決まります —— 同一モデルで画像から動画、キーフレーム、継続生成が可能です。すべてのモデルがすべてのタスクに対応するわけではなく、非対応の場合は 400 を返します。

テキストから動画
prompt
テキストプロンプトだけから生成します。入力メディアは不要です。
画像から動画
frame_images: [ 先頭フレーム ]
画像そのものが映像になります。先頭フレームとしてアニメーション化され、元画像に忠実です。例:猫の写真 → 同じ猫が同じシーンで首を振る。
キーフレーム(先頭+末尾)
frame_images: [ 先頭, 末尾 ]
開始画像と終了画像を与えると、モデルがその間の動きを補間します。
継続生成
input_video
既存のクリップを延長します。指定する duration はソース動画の長さより大きくする必要があります。
参照から動画
input_references: [ 画像 ]
画像はフレームではなく「参照」です。モデルは被写体/スタイルを保ちつつ、まったく新しいシーンを生成します。例:猫の写真 +「森の中で踊る」→ 猫の見た目は保たれるがシーンと動きは新しい映像(参照は 1〜9 枚)。画像から動画との違い:i2v は元画像そのものに忠実、r2v は被写体を新しい映像に作り直します。
動画編集
input_video + prompt
既存の動画を編集します——シーン、スタイル、動きを変更。入力動画の秒数 + 出力秒数で課金されます。

1. ジョブを送信(即座に vjob_xxx を返す)

POST/v1/videos
model必須
string
モデル ID。例:bytedance/seedance-2.0
prompt必須
string
テキストプロンプト
duration
integer
秒数(モデルの制限による)
resolution
string
解像度:480p / 720p / 1080p など
generate_audio
boolean
音声トラックを生成するか(true/false)
frame_images
array
先頭/末尾フレーム画像(画像から動画、キーフレーム)。オブジェクト { type: "image_url", image_url: { url }, frame_type: "first_frame" | "last_frame" } または純粋な URL 文字列。
input_references
array
参照から動画で使う参照画像 —— 被写体/スタイルの誘導であり、厳密なフレームではありません。
input_video
string|object
継続生成と動画編集のソース動画 URL。アップストリームから公開でアクセス可能である必要があります。
aspect_ratio
string
アスペクト比。例:16:9 または 9:16。入力画像が比率を決める場合は無視されます。
watermark
boolean
ウォーターマークを追加します。デフォルトは false。
callback_url
string
ジョブが終了状態に達したときに呼び出される webhook URL——HTTPS のみ、SSRF チェックあり。v1 に署名はなく、ヒントとして扱い GET /videos/{id} で確認してください。
curl https://api.bazaarlink.ai/v1/videos \
  -H "Authorization: Bearer $BL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "bytedance/seedance-2.0",
    "prompt": "a bird flying over mountains",
    "duration": 3,
    "resolution": "720p",
    "generate_audio": false
  }'
# → 202 { "id": "vjob_xxx", "status": "pending" }
Note
送信時に最悪ケースの見積もりでクレジットを確保します。ジョブ完了後、usage.costはこのリクエストでお客様に請求された米ドル額です。

2. ステータスをポーリング

GET/v1/videos/{id}
curl -H "Authorization: Bearer $BL_API_KEY" \
  https://api.bazaarlink.ai/v1/videos/vjob_xxx
Note
各 GET は 8 秒以上の間隔を空けないと実際にアップストリームへ到達しません(レートリミット回避)
Note
status=failed の場合、reserve 金額は全額ユーザーに返金されます。

3. 動画コンテンツを取得 (MP4)

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

知っておくべきこと

  • 許可される解像度はモデルごとに異なります —— 非対応の値を送ると、対応値を列挙した 400 が返ります。
  • 入力の画像/動画は公開 URL からアクセス可能である必要があります。ホットリンク保護されたホスト(一部の wiki など)は失敗します。
  • 入力メディアはアップストリームのコンテンツモデレーションを通過し、まれに拒否されることがあります。
  • 継続生成では、指定する duration がソース動画長を超える必要があります。
  • 出力アスペクト比は入力画像に従います —— 正方形の画像は正方形の動画になります。
  • 動画編集は入力動画の秒数と生成された出力の秒数で課金されます。
  • 編集/継続生成の input_video は公開 URL である必要があります。ここで生成した動画は API キーの背後で配信されるためアップストリームが取得できません —— ソース動画は公開アクセス可能な URL にホストしてください。
  • Webhook には署名がありません——実行前に GET /videos/{id} でステータスと金額を確認してください。そこでの unsigned_urls は絶対 URL です(ポーリング応答の相対パスとは異なります)。

対応する動画モデル

Model IDModalityTasks
minimax/hailuo-3-maxtext+image->videot2v, i2v
google/veo-3.1text+image->videot2v, i2v
bytedance/seedance-2.5text+image+audio+video->video—
x-ai/grok-imagine-video-1.5-litetext+image->videot2v, i2v
bytedance/seedance-2.0text+image+audio+video->videot2v, i2v
bytedance/seedance-1-5-protext+image->videot2v, i2v
bytedance/seedance-2.0-fasttext+image+audio+video->videot2v, i2v

音声合成

/v1/models?output_modalities=speech のモデル ID でテキストを音声に変換します。モデルページの100万文字あたりの価格で課金されます。音声全体をバッファしてからバイナリで返し、分割ストリーミングには対応していません。provider、transforms、route、service_tier、preset などのルーティング制御フィールドは無視されます。

POST/v1/audio/speech
curl https://api.bazaarlink.ai/v1/audio/speech \
  -H "$BAZAARLINK_AUTH_HEADER" \
  -H "Content-Type: application/json" \
  -d '{"model":"<speech-model-id>","input":"Hello","voice":"alloy","response_format":"mp3"}' \
  --output speech.mp3

# Voice settings (elevenlabs/* models; the X-Voice-Settings response header says applied or ignored)
curl -D - https://api.bazaarlink.ai/v1/audio/speech \
  -H "$BAZAARLINK_AUTH_HEADER" \
  -H "Content-Type: application/json" \
  -d '{"model":"elevenlabs/eleven-v4","input":"Hello","voice":"george","stability":0.4,"similarity_boost":0.8,"style":0.2,"use_speaker_boost":true,"language_code":"en","audio_effects":{"distance":0.3}}' \
  --output speech.mp3

音声文字起こし

multipart/form-data の model と file、または JSON の model と input_audio:{data,format}(生の base64)を送信します。形式: wav, mp3, mp4, m4a, ogg, flac, webm, aac。音声は最大 25 MiB、本文は base64 のため 50 MiB。audio.transcription_max_seconds_by_model でモデル別の上限を設定し、未設定なら audio.transcription_max_seconds、次に既定の 60 秒を使います。超過した音声は処理前に 413 audio_too_long で拒否され、課金されません。response_format は json、verbose_json のみ。timestamp_granularities の word、segment は verbose_json が必要です。stream は未対応(400 unsupported_parameter)、サイズ超過は 413 audio_too_large。provider は無視されます。データベース料金で usage.seconds または入出力 token に課金し、分単価は秒単価の 60 倍。usage.cost は USD の請求額です。

POST/v1/audio/transcriptions
curl https://api.bazaarlink.ai/v1/audio/transcriptions \
  -H "$BAZAARLINK_AUTH_HEADER" \
  -F model="<transcription-model-id>" \
  -F file=@audio.wav \
  -F response_format=json

curl https://api.bazaarlink.ai/v1/audio/transcriptions \
  -H "$BAZAARLINK_AUTH_HEADER" \
  -H "Content-Type: application/json" \
  -d '{"model":"<transcription-model-id>","input_audio":{"data":"<raw-base64-audio>","format":"wav"},"response_format":"verbose_json","timestamp_granularities":["word","segment"]}'

文書の再ランキング

query と documents で関連性順の index と relevance_score を取得します。課金単位は search で、モデルページの単価と usage.search_units に基づき、文書数では課金しません。ストリーミング(stream)は非対応です。

POST/v1/rerank
curl https://api.bazaarlink.ai/v1/rerank \
  -H "$BAZAARLINK_AUTH_HEADER" \
  -H "Content-Type: application/json" \
  -d '{"model":"your-rerank-model-id","query":"capital of France","documents":["Paris is the capital of France.","Berlin is in Germany."],"top_n":1}'
POST/v1/chat/completions

/v1/chat/completions に audio または input_audio を渡し、音声対応モデルを選びます。報告された文字と音声のトークン合計に、設定された入力・出力単価を一律適用します。

curl https://api.bazaarlink.ai/v1/chat/completions \
  -H "$BAZAARLINK_AUTH_HEADER" \
  -H "Content-Type: application/json" \
  -d '{"model":"<audio-chat-model-id>","messages":[{"role":"user","content":"Say hi."}],"stream":true,"modalities":["text","audio"],"audio":{"voice":"alloy","format":"pcm16"},"max_tokens":32}'

音声合成(TTS)ガイド

POST /v1/audio/speech は OpenAI-compatible です。JSON を送ると音声ファイルのバイナリが返ります。ElevenLabs 系列には elevenlabs/eleven-v4、eleven-v4-turbo、eleven-v3、eleven-v3-conversational、eleven-multilingual-v2、eleven-flash-v2.5、eleven-flash-v2、eleven-turbo-v2.5、eleven-turbo-v2 があります。最新一覧は GET /v1/models?output_modalities=speech を参照してください。 GET /v1/models は既定ではテキストモデルのみを返すため、?output_modalities=speech(または all)を付けて一覧を取得してください。

POST/v1/audio/speech

パラメーター

パラメーター型必須説明
modelstringはい音声モデル ID。例: elevenlabs/eleven-flash-v2.5。
inputstringはい合成するテキスト。1 リクエストあたり最大 4,096 文字(elevenlabs/eleven-v4 と eleven-v4-turbo は 10,000 文字)。それより長い場合は複数のリクエストに分けてください。
voicestringはい使用する声。形式はモデルにより異なります。以下の声の規則を参照してください。
response_formatstringいいえmp3(既定)または pcm。opus・aac・flac・wav は API では受け付けますが、現在 ElevenLabs モデルでは 400 で拒否されます。
speednumberいいえ話速は 0.25~4.0。モデルによっては適用されません。
instructionsstringいいえ声のスタイル指定。モデルによっては適用されません。
stabilitynumberいいえ声の安定性(0〜1、既定 0.5)。低いほど感情豊か、高いほど平坦になります。当社の直接音声ルートで処理される elevenlabs/* モデルで有効です。レスポンスヘッダー X-Voice-Settings が applied(適用)か ignored(未適用)を示します。
similarity_boostnumberいいえ元の声との類似度(0〜1、既定 0.75)。Eleven v3 では使われません。
stylenumberいいえスタイルの強調度(0〜1、既定 0)。0 より大きいと遅延が増えます。Eleven v4 では使われません。
use_speaker_boostbooleanいいえ元の話者との類似度を高めます(既定 true)。わずかに遅延が増えます。
clone_strengthnumberいいえクローン強度(0〜1、通常は 0 を推奨)。Eleven v4 向けに学習したご自身のプロフェッショナルクローン音声(voice_…)にのみ有効です。
language_codestringいいえ読み上げ言語を指定する 2 文字の小文字の言語コード(ISO 639-1。例:ar、ja、en)。multilingual-v2 モデルでは使われません。
audio_effectsobjectいいえ任意のオーディオエフェクトのオブジェクト:filter_preset_id(フィルター。例 phone、old_radio)、environment_id(残響空間。例 small_room、hall)、background_noise_id(背景音。例 cafe)、distance(距離 0〜1)、send_level(残響量 0〜1)、pan(左右位置 −1〜1)。ID は小文字・数字・アンダースコアのみ。追加料金はありません。残響または pan が 0 以外だとステレオ出力になり、pcm 出力とは併用できません。

上の 7 つの音声設定はすべて任意で、指定しなければ何も変わりません。範囲外の値は 400 を返し、送信も課金もされません。レスポンスヘッダー X-Voice-Settings は設定が使われたかを示します:applied=適用、ignored=予備ルートが応答したため設定は使われませんでした(音声は通常どおり生成されます)、ヘッダーなし=音声設定を送っていません。例:stability を 0 にすると抑揚が大きく、1 にするとより均一に読み上げます。

声の規則

ElevenLabs モデル(elevenlabs/…)には次の音声名(大文字小文字不問)を指定できます: george, sarah, adam, alice, bella, bill, brian, callum, charlie, chris, daniel, eric, harry, jessica, laura, liam, lily, matilda, river, roger, will。ElevenLabs モデルでは voice を省略できます(既定は george)。それ以外の値は 400 invalid_voice になります。自分のカスタムボイス(voice_…)は下の「カスタムボイス」セクションを参照してください。

alloy、echo、nova などの OpenAI-style の声名は、それらを列挙するモデルでのみ使えます。モデルページを確認してください。

カスタムボイス(クローン)は段階的に公開中です。下の「カスタムボイス」セクション(POST /v1/voices)をご覧ください。アカウントで有効になるまでは、上の 21 個のプリセット名か公開ボイス ID をお使いください。

ElevenLabs モデルに alloy を送ると失敗します
ElevenLabs モデルに voice ID でも対応する音声名でもない値(例: alloy、Rachel)を渡すと 400 invalid_voice を返し、メッセージに使える名前が表示されます。失敗したリクエストは課金されません。

組み込み音声一覧

voice には下表の音声名(小文字)を指定できます。各音声に短い試聴クリップがあり、GET /api/v1/audio/voices で全一覧(性別・年齢層・アクセント・スタイル・試聴 URL)を取得できます。

?lang=(en、zh-TW、zh-CN。既定は Accept-Language)は description の言語だけを決めます。試聴 URL は変わりません:preview_urls.en(preview_url と同じ)が英語、preview_urls.zh(preview_url_zh と同じ)が中国語のクリップです。

音声説明試聴
georgeMale, middle-aged, British accent. Mature and steady, suited to narration and storytelling.
sarahFemale, young adult, American accent. Professional and clear, suited to broadcast-style reading.
adamMale, middle-aged, American accent. Everyday and approachable, suited to short social videos.
aliceFemale, middle-aged, British accent. Professional and informative, suited to explainers and teaching.
bellaFemale, middle-aged, American accent. Professional and informative, suited to explainers and teaching.
billMale, senior, American accent. Crisp and direct, suited to advertising voice-overs.
brianMale, middle-aged, American accent. Polished and refined, suited to social and brand content.
callumMale, middle-aged, American accent. Expressive, suited to characters and animation.
charlieMale, young adult, Australian accent. Energetic and lively, suited to conversation.
chrisMale, middle-aged, American accent. Relaxed and casual, suited to conversation.
danielMale, middle-aged, British accent. Formal and measured, suited to news-style and educational reading.
ericMale, middle-aged, American accent. Polished and warm, suited to conversation.
harryMale, young adult, American accent. Rough and gritty, suited to character voices.
jessicaFemale, young adult, American accent. Bright and cute, suited to conversation.
lauraFemale, young adult, American accent. Playful with attitude, suited to social content.
liamMale, young adult, American accent. Confident and upbeat, suited to social content.
lilyFemale, middle-aged, British accent. Confident and clear, suited to explainers and teaching.
matildaFemale, middle-aged, American accent. Upbeat and friendly, suited to explainers and teaching.
riverNeutral voice, middle-aged, American accent. Calm and even, suited to conversation.
rogerMale, middle-aged, American accent. Polished and confident, suited to conversation.
willMale, young adult, American accent. Laid-back and easygoing, suited to conversation.

感情・動作タグ(audio tags)

input の中に角括弧でタグを直接書きます。例: [laughs]、[whispers]、[excited]、[sighs]、[crying]、[curious]、[softly]。タグは入力どおりモデルに渡され、続く言葉の演じ方を決めます。本文が日本語でもタグは英語のままにしてください。

curl https://api.bazaarlink.ai/v1/audio/speech \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"elevenlabs/eleven-v3","input":"[laughs] That was actually funny. [whispers] Do not tell anyone.","voice":"george","response_format":"mp3"}' \
  --output audio-tags.mp3

elevenlabs/eleven-v3 と elevenlabs/eleven-v4 系列が対応しています。ほかの音声モデルはタグを解釈せず、括弧の中を読み上げることがあるため、まず短い文で試してください。

タグも input の文字数に含まれ、ほかのテキストと同じように課金されます。

出力形式

response_format を省略すると mp3(Content-Type は audio/mpeg)になります。pcm(audio/pcm、生の 16-bit PCM)も使えます。API は opus、aac、flac、wav も受け付けますが、ElevenLabs モデルは現在 400 で拒否します。保存時はレスポンスの Content-Type ヘッダーに従ってください。

料金

音声合成は入力文字数で課金されます。文字単価は /models のモデルページと GET /v1/models の pricing.character にあります。モデルページでは 100 万文字単位で表示されます。

例

curl https://api.bazaarlink.ai/v1/audio/speech \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"elevenlabs/eleven-flash-v2.5","input":"Hello from BazaarLink.","voice":"george","response_format":"mp3"}' \
  --output speech.mp3

よくあるエラー

状態原因と対処
400不正なリクエスト: model、input、voice の欠落、input が 4,096 文字超、speed が 0.25~4.0 の範囲外、未対応の response_format、Unknown voice、unknown_model(/models で ID を確認)。
401API キーがないか無効です。Authorization: Bearer で BazaarLink キーを送ってください。
402残高不足です。チャージして再試行してください。
403管理キーはモデルを呼び出せないか、アカウントが停止中です。通常の API キーを使ってください。
429レート制限です。Retry-After ヘッダーに従って再試行してください。
502モデルサービスが一時的に利用できないか音声転送が中断されました。再試行してください。失敗したリクエストは課金されません。

全パラメーター一覧: 音声合成

音声文字起こしガイド

POST /v1/audio/transcriptions は OpenAI-compatible です。multipart/form-data で音声をアップロードするか JSON で base64 の input_audio を送るとテキストが返ります。モデルには elevenlabs/scribe-v2 と elevenlabs/scribe-v2-medical があります。最新一覧は GET /v1/models?output_modalities=transcription を参照してください。 GET /v1/models は既定ではテキストモデルのみを返すため、?output_modalities=transcription(または all)を付けて一覧を取得してください。

POST/v1/audio/transcriptions

パラメーター

パラメーター型必須説明
modelstringはい文字起こしモデル ID。例: elevenlabs/scribe-v2。
filefileはい音声ファイル(multipart)。wav、mp3、mp4、m4a、ogg、flac、webm、aac に対応し、最大 25 MiB。JSON では input_audio: {data: base64, format} を送れます。
response_formatstringいいえjson(既定)は {text}、verbose_json は言語、長さ、segments/words も返します。
languagestringいいえen や zh などの任意の言語ヒント。省略すると自動判定します。
promptstringいいえ名前や用語の認識を助ける任意の文脈テキスト。モデルによっては適用されません。
timestamp_granularities[]string[]いいえword または segment、あるいは両方。response_format=verbose_json の場合のみ適用されます。 単語単位のタイムスタンプは現在返されません(segments は返されます)。

出力形式

response_format は json または verbose_json のみです(text、srt、vtt は未対応)。stream は未対応です。音声の長さはモデル別に制限され、既定は 60 秒です。超過すると処理前に 413 audio_too_long が返り、課金されません。長い録音は分割してください。

料金

文字起こしは音声の秒数で課金されます。秒単価は /models のモデルページと GET /v1/models の pricing.second にあります。分単価はその 60 倍です。応答の usage は課金秒数、usage.cost は請求額を示します。

例

curl https://api.bazaarlink.ai/v1/audio/transcriptions \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY" \
  -F model="elevenlabs/scribe-v2" \
  -F file=@audio.mp3 \
  -F response_format=verbose_json \
  -F "timestamp_granularities[]=word"

よくあるエラー

状態原因と対処
400不正なリクエスト: model または file の欠落、空の音声、json/verbose_json 以外の response_format、stream=true(unsupported_parameter)、word/segment 以外の timestamp_granularities。
401API キーがないか無効です。
402残高不足です。チャージして再試行してください。
413audio_too_large: デコード後の音声が 25 MiB を超えています。audio_too_long: モデル別の長さ制限(既定 60 秒)を超える音声は処理前に拒否され、課金されません。圧縮または分割してください。
429レート制限です。Retry-After に従って再試行してください。
502モデルサービスが一時的に利用できないか、音声転送が中断されました。再試行してください。失敗したリクエストは課金されません。

全パラメーター一覧: 音声文字起こし

カスタムボイス(ボイスクローン)

カスタムボイス(ボイスクローン)
申請制です。カスタムボイスはアカウントごとに開放します。ご利用にはカスタマーサポートへお問い合わせください。アカウントで有効になるまで、/v1/voices へのリクエストはすべて 403 voice_cloning_not_enabled を返します(機能が全体で無効のときは 404 not_found)。このページの上限と料金は初期値で、変更される場合があります。

使用する権利のある声の短い録音をアップロードすると、当社の voice id(voice_…)が返ります。この id を POST /v1/audio/speech の voice に指定してください。声を使えるのは作成した本人だけです。

エンドポイント

POST/v1/voices

ボイスを作成(multipart/form-data)

GET/v1/voices

自分のボイスを一覧(limit は 1〜100、after に voice id を渡すと次のページ)

GET/v1/voices/{id}

自分のボイスを 1 件取得

DELETE/v1/voices/{id}

ボイスを削除(即時に反映)

POST/v1/voices/report

ボイスを通報(API キー不要)

ボイスの作成:フィールド

フィールド型必須説明
namestringはいボイス名、1〜60 文字。
filesfile[]はいその声の録音ファイル 1〜5 個(mp3, wav, m4a, ogg, flac, webm)。
consentbooleanはいtrue が必須:この声を複製して使用する権利があることを確認します(「同意」を参照)。
consent_statement_versionstringはい確認した同意文のバージョン。現在は "v1"。
descriptionstringいいえ任意、200 文字まで。
remove_background_noisebooleanいいえ任意の真偽値、既定は false。クローン前にサンプルの背景ノイズを除去します。

リクエストは同期です。201 が返ればボイスはすぐ使えます。Idempotency-Key ヘッダ(一意の任意文字列)を付け、再試行時は同じ値を使ってください。再試行で 2 つ目のボイスが作成されたり課金されたりすることはありません。

レスポンス

201。id(voice_…)、object("voice")、name、description、status("ready")、created_at(Unix 秒)、usage.cost_usd(課金された作成料金)を含みます。ボイスの作り方に関するそれ以外の情報は外部に出ません。

GET /v1/voices は自分のボイスだけを返します:{ "object": "list", "data": [ … ], "has_more": false }。他人の voice id は、存在しない id と同じく 404 voice_not_found を返します。

GET /v1/voices/{id} は 1 件のボイスを返します(上と同じフィールド、usage なし)。

DELETE /v1/voices/{id} は { "id": "voice_…", "object": "voice", "deleted": true } を返し、即時に反映されます。そのボイスを使う音声リクエストはすぐに失敗します。削除は無料で、作成料金は返金されません。

上限(初期値)

  • 1 人あたり最大 3 ボイス。
  • 1 ボイスにつき音声ファイル 1〜5 個、1 ファイル 10 MB まで、合計 25 MB まで。形式:mp3, wav, m4a, ogg, flac, webm。クリアな音声が合計 30 秒〜5 分あると最適です。
  • 1 日(UTC)あたり最大 3 回まで作成できます。
  • メールアドレスが確認済みで、残高が US$5 以上のアカウントが必要です。
  • 著名人を模した名前や説明、公式・スタッフの声のように聞こえる名前や説明は拒否されます(invalid_voice_name)。
  • 録音はボイスの作成にのみ使い、当社では保存しません。ボイス名、所有者、同意記録、タイムスタンプのみを保持します。

料金

ボイスの作成には 1 回限りの料金がかかります(初期値 US$1.00)。実際の課金額は usage.cost_usd に返り、ボイスが正常に作成されたときだけ課金されます。音声合成でカスタムボイスを使う料金は、そのモデルの他の声と同じ 1 文字あたりの料金です。削除は無料です。

同意

作成のたびに consent=true と consent_statement_version="v1" を送る必要があります。同意文が更新されると 400 consent_version_mismatch が返るので、新しいバージョンで再度確認してください。

確認していただく同意文の草案(正式な文面は確認中で、変更される場合があります):

I confirm that I own the voice in these recordings or have the written permission of the person whose voice it is, that this person is an adult and has agreed to have their voice cloned and synthesized, and that I will not use the voice to impersonate a real person, to deceive, to harass, or for political persuasion, fraud or any unlawful purpose. I understand the voice can be removed and my account suspended if I break these rules.

カスタムボイスを使う

voice id を POST /v1/audio/speech (voice=voice_…) の voice に指定し、elevenlabs/* ファミリーの音声モデルと組み合わせます。入力上限、形式、1 文字あたりの料金はモデルのものです。存在しない、削除・停止された、または他人の voice id は 400 invalid_voice を返します。カスタムボイスは他のモデルでは使えません。

例

curl https://api.bazaarlink.ai/v1/voices \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -F name="My narrator" \
  -F description="Warm and calm" \
  -F consent=true \
  -F consent_statement_version=v1 \
  -F files=@sample-1.mp3 \
  -F files=@sample-2.wav

curl "https://api.bazaarlink.ai/v1/voices?limit=20" \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY"

curl -X DELETE https://api.bazaarlink.ai/v1/voices/voice_0123456789abcdef01234567 \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY"

curl https://api.bazaarlink.ai/v1/audio/speech \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"elevenlabs/eleven-flash-v2.5","input":"Hello, this is my own voice.","voice":"voice_0123456789abcdef01234567","response_format":"mp3"}' \
  --output my-voice.mp3

ボイスを通報

許可なく自分や他人を模したボイスを見つけたら通報してください:POST /v1/voices/report(API キー不要)。JSON ボディに voice_id(voice_…)または sample_url、reason(impersonation、fraud、harassment、minor、political、other)、任意で details と contact(メールアドレス)を指定します。常に 202 を返します。通報は審査し、規約違反のボイスは削除します。アカウントが停止されることもあります。

curl https://api.bazaarlink.ai/v1/voices/report \
  -H "Content-Type: application/json" \
  -d '{"voice_id":"voice_0123456789abcdef01234567","reason":"impersonation","details":"...","contact":"me@example.com"}'

責任ある利用

著名人、有名人、政治家、または同意していない人の声を複製しないでください。クローンした声で本人と話していると誤解させること、欺く・嫌がらせをする・政治的に説得する・詐欺を行うことは禁止です。

エラー

ステータスコード意味
400bad_requestリクエストの形式が不正:multipart/form-data ではない、音声ファイルがない、description が長すぎる、または limit が 1〜100 の範囲外。
400consent_requiredconsent=true がありません。
400consent_version_mismatch同意文のバージョンが古くなっています。現在のバージョンで再度確認してください。
400invalid_voice_name名前が空、60 文字を超えている、または使用できません。
400too_many_files音声ファイルが 5 個を超えています。
401invalid_api_keyAPI キーがない、または無効です。
402insufficient_balance残高不足(作成料金または最低残高)。
403email_unverified先にメールアドレスを確認してください。
403voice_cloning_not_enabledお使いのアカウントではカスタムボイスがまだ有効ではありません。カスタマーサポートへお問い合わせください。
403voice_cloning_disabled現在このサービスではカスタムボイスは有効ではありません。
404voice_not_foundそのボイスはありません(またはあなたのものではありません)。
404not_found見つかりません。機能がアカウントで有効になるまでの /v1/voices へのすべてのリクエストを含みます。
405method_not_allowedこのパスではそのメソッドは使えません。
409duplicate_request同じ Idempotency-Key がまだ処理中です。しばらくしてから再試行してください。
413file_too_largeファイルが 10 MB を超えている、または合計が 25 MB を超えています。
415unsupported_file_type対応していない音声形式です。mp3, wav, m4a, ogg, flac, webm を使用してください。
422voice_rejected音声プロバイダーの確認でサンプルが受け入れられませんでした(例:著名な声や内蔵の声、既知の AI 合成音声)。ボイスは保存されず、課金もされません。ご自身の声の鮮明な録音、または使用する権利のある声を使ってください。
429voice_create_rate_limited1 日の作成上限に達しました。明日(UTC)もう一度お試しください。
429voice_limit_reachedカスタムボイスの上限数に達しました。
502upstream_failedボイスを作成できませんでした。課金はされていません。新しい Idempotency-Key で再試行してください。
503voice_capacity_fullカスタムボイスの枠が一時的にいっぱいです。課金はされていません。後でもう一度お試しください。
504upstream_timeoutボイスサービスが時間内に応答しませんでした。課金はされていません。同じ Idempotency-Key で再試行してください。

データAPI

近日公開 — 3つのBazaarLinkエンドポイントで公開ソーシャル・コマースデータを取得できます。このサービスはデフォルトで無効です。有効になるまでリクエストはservice_pausedを返します。

ソーシャルデータのリクエストを送信

POST/v1/data/social

リクエストパラメータ

コード型必須意味
platformstringはいカタログにあるプラットフォームID(twitterやinstagramなど)。
actionstringはいそのプラットフォームが対応するアクション。利用可能な組み合わせはカタログを参照してください。
paramsobjectいいえアクション固有の入力。カタログのrequired_paramsとoptional_paramsを使用してください。
modesync | asyncいいえ任意。asyncを指定するとポーリングするジョブが返ります。非同期専用のアクションは省略してもジョブを返します。

レスポンス形式

HTTP 200 · data.social · id · object · platform · action · count · results · usage.cost

{
  "id": "req_example",
  "object": "data.social",
  "platform": "twitter",
  "action": "search",
  "count": 1,
  "results": [
    {
      "id": "post_example",
      "url": "https://x.com/someone/status/post_example",
      "text": "Example post",
      "like_count": 120,
      "reply_count": 8,
      "retweet_count": 14,
      "view_count": 5400,
      "posted_at": "2026-10-07T00:48:38+00:00",
      "author_username": "someone",
      "author_name": "Someone",
      "platform": "twitter"
    }
  ],
  "usage": {
    "cost": 0.0048
  }
}

非同期ジョブ

非同期専用のアクション、またはmode asyncを指定すると、HTTP 202と不透明なジョブIDが返ります。GET /v1/data/jobs/{id}をポーリングしてください。HTTP 202は処理中、HTTP 200は完了したdata.socialレスポンスを示します。ジョブは15分後に期限切れになります(HTTP 410 job_expired)。存在しないジョブや別アカウントが所有するジョブはHTTP 404 not_foundを返します。完了したジョブは最初に正常取得した時点で1回だけ課金されます。

{
  "platform": "instagram",
  "action": "discover",
  "params": {
    "keyword": "coffee"
  },
  "mode": "async"
}

HTTP 202

{
  "id": "job_example",
  "object": "data.job",
  "status": "pending",
  "platform": "instagram",
  "action": "discover"
}

非同期ジョブをポーリング

GET/v1/data/jobs/{id}

HTTP 202 pending → HTTP 200 data.social · HTTP 410 job_expired · HTTP 404 not_found

{
  "id": "job_example",
  "object": "data.social",
  "platform": "instagram",
  "action": "discover",
  "count": 1,
  "results": [
    {
      "id": "post_example",
      "url": "https://www.instagram.com/p/example/",
      "text": "Example result",
      "platform": "instagram"
    }
  ],
  "usage": {
    "cost": 0.0096
  }
}

利用可能なアクションと料金を一覧表示

GET/v1/data/catalog

object · product · platforms · actions · required_params · optional_params · max_limit · async · price_usd

{
  "object": "data.catalog",
  "product": "BazaarLink Data API",
  "platforms": [
    {
      "platform": "twitter",
      "actions": [
        {
          "action": "search",
          "label": "Keyword search",
          "required_params": [
            "keyword"
          ],
          "optional_params": [
            "sort"
          ],
          "max_limit": 200,
          "async": false,
          "price_usd": 0.0048
        }
      ]
    },
    {
      "platform": "instagram",
      "actions": [
        {
          "action": "discover",
          "label": "Discover",
          "required_params": [
            "keyword"
          ],
          "optional_params": [],
          "max_limit": null,
          "async": true,
          "price_usd": 0.0096
        }
      ]
    }
  ]
}

料金

料金はプラットフォームとアクションごとの段階制です。GET /v1/data/catalogで有効な各アクションの顧客向け料金を確認できます。成功した呼び出しは1回だけ課金され、失敗した呼び出しと結果が0件の呼び出しは無料です。Data APIとウェブ検索は1日分の無料枠を共有します。

エラーコード

{"error":{"code":"<code>","message":"<fixed message>"}}

コードHTTP意味
unauthorized401API keyがないか、無効です。
forbidden403リクエストは許可されていません。
invalid_request400リクエスト本文が無効です。
invalid_params400アクションパラメータが拒否されました。
unsupported_capability400プラットフォームまたはアクションを利用できません。
insufficient_credits402クレジットが不足しています。
budget_cap_reached402 or policy statusアカウントの利用上限に達しました。
body_too_large413リクエスト本文がサイズ上限を超えています。
free_quota_exhausted4321日の無料枠を使い切りました。
rate_limited429レート制限に達しました。Retry-Afterに従ってください。
data_unavailable503データサービスは一時的に利用できません。
timeout504リクエストがタイムアウトしました。
bad_upstream_response502データサービスが無効なレスポンスを返しました。
job_expired410ジョブは15分後に期限切れになりました。
not_found404ジョブが存在しないか、別のアカウントに属しています。
job_failed503非同期ジョブに失敗しました。
service_paused503サービスはまだ有効化されていないか、一時停止中です。

例

curl

curl https://api.bazaarlink.ai/v1/data/social \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"platform":"twitter","action":"search","params":{"keyword":"BazaarLink","limit":5}}'

Python (requests)

import os
import requests

response = requests.post(
    "https://api.bazaarlink.ai/v1/data/social",
    headers={"Authorization": f"Bearer {os.environ['BAZAARLINK_API_KEY']}"},
    json={"platform": "twitter", "action": "search", "params": {"keyword": "BazaarLink", "limit": 5}},
    timeout=30,
)
response.raise_for_status()
print(response.json())

JavaScript (fetch)

const response = await fetch("https://api.bazaarlink.ai/v1/data/social", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BAZAARLINK_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ platform: "twitter", action: "search", params: { keyword: "BazaarLink", limit: 5 } }),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());

Submit a decisions request

Evaluate a state against named questions with a decisions-output model. This alpha endpoint returns non-streaming JSON. Find available model ids with GET /v1/models?output_modalities=decisions; use this endpoint for Clef instead of chat/completions. Input tokens are billed at the selected model's customer price. Sufficient credits are required. Set BAZAARLINK_API_KEY to your API key; the sample builds its complete Authorization header in BAZAARLINK_AUTH_HEADER.

View the decisions API reference

export BAZAARLINK_AUTH_HEADER="Authorization: $(printf '%s %s' 'Bearer' "$BAZAARLINK_API_KEY")"

curl https://api.bazaarlink.ai/v1/alpha/decisions \
  -H "$BAZAARLINK_AUTH_HEADER" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "cloudflare/clef-flash",
    "state": "The support agent issued a full refund.",
    "questions": {
      "refunded": {
        "type": "noul",
        "instructions": "Was a refund issued?"
      }
    }
  }'

動画入力

動画入力に対応するモデルに動画ファイルを送信し、分析、キャプション生成、シーンやイベントに関する質問への回答をさせます。直接URLまたはbase64データURIが使えます — URLは公開アクセス可能な動画に効率的、base64はローカルファイルや非公開動画向けです。

対応フォーマット

MP4 (H.264)MPEGMOVWebM
response = client.chat.completions.create(
    model="google/gemini-3.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,...`)
  • 複数ページドキュメント
  • パスワードなしPDFのみ
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

ステートレスなマルチターン会話、ツールコール、マルチモーダル入力に対応するOpenAI Responses API互換エンドポイント。OpenAI Python SDK ≥ 1.xのclient.responses.create()を使用するエージェントやフレームワークに最適。

POST/v1/responses
Note
Chat Completionsと同じ認証とモデルルーティングを使用。

リクエストボディ

model必須
string
GET /v1/modelsに掲載されたidまたはaliasを使用します(例: "claude-sonnet-4.6"、"anthropic/claude-sonnet-4.6")。
input必須
string | Item[]
ユーザー入力 — プレーンな文字列(単一メッセージ)またはマルチターン/マルチモーダル会話用の入力アイテムの配列。
instructions
string
システムレベルの指示、システムメッセージに相当。リクエストごとに再送信が必要。
stream
boolean
trueの場合、Responses API SSEストリームイベントを返す。イベントタイプ:response.created、response.output_text.delta、response.completed。
max_output_tokens
integer
生成する最大出力トークン数(oシリーズモデルの推論トークンを含む)。
temperature
number
サンプリング値は範囲検証なしで転送されます。モデルが対応範囲外の値を制限または無視する場合があります。
top_p
number
Nucleusサンプリングの確率質量。デフォルト:1
tools
Tool[]
ツール(関数)定義 — Chat Completions と同じ JSON Schema 形式(フラットな Responses 形式とネスト形式の両方を受け付けます)。OpenAI 独自の組み込み型ホスト済みツール(web_search_preview、file_search、computer_use_preview)は非対応です。Web 検索は plugins: [{id:"web"}] で利用できます——一部のモデルルートのみ対応。
tool_choice
string | object
ツール使用の制御:"auto"、"none"、または特定のツール
parallel_tool_calls
boolean
ツール提供時の並列ファンクションコールを有効化。デフォルト:true。OpenAI系モデルのみ対応 — 下記の注記を参照。
response_format
object
構造化JSON出力を強制。構造化出力セクションを参照
previous_response_id
string
このエンドポイントはステートレスです——非 null の値を渡すと即座に 400(invalid_prompt)を返します。受け付けられて無視されることはありません。代わりにステートレスモードを使用してください:input 配列に完全な会話履歴を渡します。

リクエストスキーマ(TypeScript)

type ResponsesRequest = {
  model: string;                    // Listed id or alias from GET /v1/models
  input: string | InputItem[];      // string or multi-turn array

  // Optional
  instructions?: string;            // System-level message
  stream?: boolean;                 // Default: false
  max_output_tokens?: number;
  temperature?: number;
  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
};

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://api.bazaarlink.ai/v1/responses \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5.4-mini",
    "instructions": "You are a helpful assistant.",
    "input": "What is the capital of Taiwan?"
  }'

レスポンス形式

BazaarLinkは標準化されたレスポンスを返し、アップストリーム固有のフィールドを削除します。レスポンス内の不透明なBazaarLinkリクエストIDはx-request-idと一致します。GET /v1/generationで使用してください。非ストリーミングのレスポンスでは、同じIDがx-generation-idにも返されます。usage.costはお客様に請求されたUSD金額です。統計は完了後数秒かかる場合があるため、404は短時間再試行してください。

// Non-streaming response object
type ResponsesResponse = {
  id: string;             // Opaque BazaarLink request id; format may change
  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;          // USD amount charged to the customer for this request
  } | 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からの移行

messagesをinput(文字列または配列)に置き換え、システムロールメッセージの代わりにinstructionsを使用し、choices[0].message.contentの代わりにoutput[0].content[0].textを読み取ります。

# Chat Completions (before)
response = client.chat.completions.create(
    model="openai/gpt-5.4-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-5.4-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)は非対応です。Web 検索は plugins: [{id:"web"}] で利用できます——一部のモデルルートのみ対応。
  • background: true は受け付けられますが無視されます——すべてのリクエストは完了まで同期的に実行されます。

Messages(Anthropic 互換)

Claude SDK向けのAnthropic互換Messages APIです。SDKの接続先をBazaarLinkにし、BazaarLink APIキーを使用してください。レスポンスのフィールドと課金メタデータは、以下に記載するBazaarLinkの仕様に従います。

POST/v1/messages
Note
Bearer token または x-api-key header をサポート(Anthropic SDK 互換)。最大ボディサイズ:10 MB。

リクエストボディ

model必須
string
GET /v1/modelsに掲載されたidまたはaliasを使用します(例: "claude-sonnet-4.6"、"anthropic/claude-sonnet-4.6")。
max_tokens必須
integer
生成する最大トークン数(正の整数)。
messages必須
Message[]
会話メッセージの配列(空不可)。
system
string
任意の system prompt。
stream
boolean
trueの場合、Server-Sent Eventsストリームを返す。デフォルト:false
temperature
number
サンプリング値は範囲検証なしで転送されます。モデルが対応範囲外の値を制限または無視する場合があります。
top_p
number
Nucleusサンプリングの確率質量。デフォルト:1
top_k
integer
サンプリング値は範囲検証なしで転送されます。モデルが対応範囲外の値を制限または無視する場合があります。
stop_sequences
string[]
カスタム停止シーケンス文字列の配列。
tools
Tool[]
モデルが呼び出せるツール(関数)のリスト
tool_choice
string | object
ツール使用の制御:"auto"、"none"、または特定のツール

リクエスト例

from anthropic import Anthropic

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

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

レスポンス

BazaarLinkは標準化されたレスポンスを返し、アップストリーム固有のフィールドを削除します。レスポンス内の不透明なBazaarLinkリクエストIDはx-request-idと一致します。GET /v1/generationで使用してください。非ストリーミングのレスポンスでは、同じIDがx-generation-idにも返されます。usage.costとusage.bz_costには、お客様に請求された同じUSD金額が入ります。統計は完了後数秒かかる場合があるため、404は短時間再試行してください。

{
  "id": "85e6f35c71a31f19-SJC",
  "type": "message",
  "role": "assistant",
  "model": "anthropic/claude-opus-4.6",
  "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,
    "cost": 0.00042,
    "bz_cost": 0.00042
  }
}

エラーエンベロープは失敗の種類によって異なります。HTTPステータスと、存在する場合はerror.typeで分岐してください。error.codeは文字列、数値のHTTPステータス、または省略される場合があります。対処方法はエラーのセクションを参照してください。

モデル

料金と機能情報を含む、利用可能な全モデルの一覧を取得。 このエンドポイントには認証は不要です。

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

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

レスポンス

{
  "data": [
    {
      "id": "openai/gpt-4o",
      "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-4o")
  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)
    input_cache_read?: string;   // Cache read price per token (USD); only when the model publishes one
    input_cache_write?: string;  // Cache write price per token (USD); only when the model publishes one
    image_output?: string;       // Image output price per token (USD); only token-billed image models (display only)
  };
  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
    input_cache_read?: string;     // USD per token, only when the tier overrides it
    input_cache_write?: string;    // USD per token, only when the tier overrides it
  }[];
};

入力長に応じた段階制価格

一部のモデルは、プロンプトが token 閾値を超えると価格表全体が切り替わります(閾値を超えた分だけではありません)。閾値は厳密な不等式です:入力 token 数がちょうど N の場合は N 以下の階層が適用され、N を超えた場合にのみ上位の階層が適用されます。

pricing_tiers は pricing と同階層のフィールドで、基本価格を超える上書き階層があるモデルにのみ存在します。項目は above_prompt_tokens の昇順で並び、prompt/completion は token あたりの USD 価格です(pricing.prompt/pricing.completion と同じ単位)。pricing.prompt と pricing.completion は常に基本(最低)階層です。

ほとんどのモデルには階層がありません — その場合、レスポンスに pricing_tiers キー自体が存在しません。

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

利用可能なモデル (171)

BazaarLinkで現在利用可能なモデルです。データベースから動的に読み込まれます:

Qwen
qwen/qwen3.8-max1000K ctx · $1.65/$4.95text+image+video->text
qwen/qwen3.7-plus1000K ctx · $0.32/$1.28text+image->text
qwen/qwen3.7-max1000K ctx · $1.65/$4.95text->text
qwen/qwen3.7-flash1000K ctx · $0.03/$0.13text+image+video->text
qwen/qwen3.5-35b-a3b262K ctx · $0.31/$1.25text+image+video->text
qwen/qwen3.5-27b262K ctx · $0.26/$2.60text+image+video->text
qwen/qwen3-next-80b-a3b-instruct262K ctx · $0.14/$0.57text->text
qwen/qwen3.5-397b-a17b262K ctx · $0.55/$3.50text+image+video->text
qwen/qwen3.6-plus1000K ctx · $0.33/$1.95text+image+video->text
qwen/qwen3-coder-flash1000K ctx · $0.20/$0.97text->text
qwen/qwen3.5-122b-a10b262K ctx · $0.40/$3.20text+image+video->text
qwen/qwen3-vl-235b-a22b-instruct262K ctx · $0.20/$0.88text+image->text
qwen/qwen3.8-27b1000K ctx · $0.50/$3.00text+image+video->text
qwen/qwen3.8-2.4t-a95b1049K ctx · $2.00/$6.00text->text
qwen/qwen3-embedding-8b33K ctx · $0.01/$0.00text->embeddings
qwen/qwen3-embedding-0.6b33K ctx · $0.01/$0.00text->embeddings
qwen/qwen3-embedding-4b33K ctx · $0.02/$0.00text->embeddings
qwen/qwen3.5-flash-02-231000K ctx · $0.07/$0.26text+image+video->text
qwen/qwen3-coder-30b-a3b-instruct262K ctx · $0.07/$0.28text->text
qwen/qwen3.6-35b-a3b262K ctx · $0.15/$1.00text+image+video->text
qwen/qwen3-coder-next262K ctx · $0.12/$0.80text->text
qwen/qwen3-vl-30b-a3b-instruct262K ctx · $0.15/$0.60text+image->text
qwen/qwen3.5-plus-02-151000K ctx · $0.26/$1.56text+image+video->text
qwen/qwen3.6-27b262K ctx · $0.29/$2.40text+image+video->text
qwen/qwen3.5-plus-202604201000K ctx · $0.30/$1.80text+image+video->text
qwen/qwen3-coder262K ctx · $0.30/$1.00text->text
qwen/qwen-2.5-72b-instruct33K ctx · $0.36/$0.40text->text
qwen/qwen-image-3 · $0.00/$0.00text+image->image
qwen/qwen-image-3-pro · $0.00/$0.00text+image->image
Google
google/gemini-4-argon1049K ctx · $2.00/$10.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-3.1-pro-preview1049K ctx · $2.00/$12.00text+image+file+audio+video->text
google/gemma-3-4b-it131K ctx · $0.05/$0.10text+image->text
google/gemini-3.1-flash-lite1049K ctx · $0.25/$1.50text+image+file+audio+video->text
google/gemini-3.5-flash-lite1049K ctx · $0.30/$2.50text+image+file+audio+video->text
google/gemini-3-flash-preview1049K ctx · $0.50/$3.00text+image+file+audio+video->text
google/gemini-3.7-flash1049K ctx · $0.75/$3.75text+image+file+audio+video->text
google/gemini-3.8-flash1049K ctx · $0.75/$3.75text+image+file+audio+video->text
google/gemini-3.6-flash1049K ctx · $0.75/$3.75text+image+file+audio+video->text
google/gemini-3.5-flash1049K ctx · $1.50/$9.00text+image+file+audio+video->text
google/text-embedding-0052K ctx · $0.03/$0.00text->embeddings
google/text-multilingual-embedding-0022K ctx · $0.03/$0.00text->embeddings
google/gemini-embedding-00120K ctx · $0.15/$0.00text->embeddings
google/gemma-4-26b-a4b-it262K ctx · $0.09/$0.34text+image+video->text
google/gemma-4-31b-it262K ctx · $0.09/$0.34text+image+video->text
google/gemini-2.5-flash-image33K ctx · $0.30/$2.50text+image->text+image
google/gemini-3.1-flash-image-preview66K ctx · $0.50/$3.00text+image->text+image
google/gemini-3.1-flash-image131K ctx · $0.50/$3.00text+image->text+image
google/gemini-3-pro-image131K ctx · $2.00/$12.00text+image->text+image
google/veo-3.1 · $0.00/$0.00text+image->video
google/gemini-embedding-2-preview8K ctx · $0.20/$0.00text+image+file+audio+video->embeddings
google/gemini-nano-banana-2.166K ctx · $1.50/$7.50text+image->text+image
OpenAI
openai/gpt-5.3-codex400K ctx · $1.75/$14.00text->text
openai/gpt-6-luna1050K ctx · $0.10/$0.50text+image+file->text
openai/gpt-5.6-luna1050K ctx · $0.20/$1.20text+image+file->text
openai/gpt-5.4-mini400K ctx · $0.75/$4.50text+image+file->text
openai/gpt-6.1-sol1050K ctx · $2.00/$10.00text+image+file->text
openai/gpt-6-sol1050K ctx · $2.00/$10.00text+image+file->text
openai/gpt-5.41050K ctx · $2.50/$15.00text+image+file->text
openai/gpt-5.51050K ctx · $5.00/$30.00text+image+file->text
openai/gpt-6-astra1050K ctx · $10.00/$50.00text+image+file->text
openai/gpt-5.6-terra1050K ctx · $2.00/$12.00text+image+file->text
openai/text-embedding-3-small8K ctx · $0.02/$0.00text->embeddings
openai/gpt-oss-safeguard-20b128K ctx · $0.07/$0.30text->text
openai/gpt-oss-120b131K ctx · $0.15/$0.60text->text
openai/text-embedding-ada-0028K ctx · $0.10/$0.00text->embeddings
openai/text-embedding-3-large · $0.13/$0.00text->embeddings
openai/gpt-5.6-sol1050K ctx · $4.00/$20.00text+image+file->text
openai/gpt-oss-20b131K ctx · $0.03/$0.13text->text
openai/gpt-4o128K ctx · $2.50/$10.00text+image+file->text
openai/gpt-image-1-mini400K ctx · $2.50/$2.50text+image->image
openai/gpt-5.4-image-2272K ctx · $8.00/$15.00text+image+file->text+image
openai/gpt-image-2.5-flare400K ctx · $8.00/$8.00text+image->image
openai/gpt-image-2.5-sunburst400K ctx · $8.00/$8.00text+image->image
openai/gpt-image-1400K ctx · $10.00/$10.00text+image->image
Anthropic
anthropic/claude-sonnet-4.61000K ctx · $3.00/$15.00text+image+file->text
anthropic/claude-opus-4.61000K ctx · $5.00/$25.00text+image+file->text
anthropic/claude-haiku-5.51000K ctx · $0.10/$0.50text+image+file->text
anthropic/claude-haiku-4.5200K ctx · $1.00/$5.00text+image+file->text
anthropic/claude-sonnet-51000K ctx · $2.00/$10.00text+image+file->text
anthropic/claude-sonnet-5.51000K ctx · $2.00/$10.00text+image+file->text
anthropic/claude-sonnet-4.51000K ctx · $3.00/$15.00text+image+file->text
anthropic/claude-opus-5.51000K ctx · $4.00/$20.00text+image+file->text
anthropic/claude-opus-4.81000K ctx · $5.00/$25.00text+image+file->text
anthropic/claude-opus-4.71000K ctx · $5.00/$25.00text+image+file->text
anthropic/claude-opus-51000K ctx · $5.00/$25.00text+image+file->text
anthropic/claude-opus-4.5200K ctx · $5.00/$25.00text+image+file->text
anthropic/claude-fable-5.11000K ctx · $10.00/$50.00text+image+file->text
anthropic/claude-fable-51000K ctx · $10.00/$50.00text+image+file->text
anthropic/claude-opus-4.1200K ctx · $15.00/$75.00text+image+file->text
DeepSeek
deepseek/deepseek-v4.1-flash-10171049K ctx · $0.21/$0.85text+image->text
deepseek/deepseek-v4-flash1049K ctx · $0.14/$0.28text->text
deepseek/deepseek-v4-pro1049K ctx · $1.65/$3.30text->text
deepseek/deepseek-v4.1-flash1049K ctx · $0.21/$0.85text+image->text
deepseek/deepseek-chat-v3.1164K ctx · $0.21/$0.79text->text
deepseek/deepseek-chat164K ctx · $0.26/$0.38text->text
deepseek/deepseek-r164K ctx · $0.50/$2.15text->text
deepseek/deepseek-v4-pro-08131049K ctx · $0.89/$2.67text->text
deepseek/deepseek-v4-flash-07311000K ctx · $0.44/$1.32text->text
deepseek/deepseek-r1-0528164K ctx · $0.50/$2.15text->text
deepseek/deepseek-v4-flash-0731free1049K ctx · $0.20/$0.40text->text
elevenlabs
elevenlabs/eleven-v4-turbo · $0.00/$0.00text->speech
elevenlabs/eleven-multilingual-v2 · $0.00/$0.00text->speech
elevenlabs/eleven-v4 · $0.00/$0.00text->speech
elevenlabs/eleven-turbo-v2.5 · $0.00/$0.00text->speech
elevenlabs/eleven-flash-v2 · $0.00/$0.00text->speech
elevenlabs/eleven-v3-conversational · $0.00/$0.00text->speech
elevenlabs/eleven-flash-v2.5 · $0.00/$0.00text->speech
elevenlabs/eleven-v3 · $0.00/$0.00text->speech
elevenlabs/eleven-turbo-v2 · $0.00/$0.00text->speech
elevenlabs/scribe-v2 · $0.00/$0.00audio->transcription
elevenlabs/scribe-v2-medical · $0.00/$0.00audio->transcription
Zhipu AI
z-ai/glm-5v-turbo203K ctx · $1.20/$4.00text+image+video->text
z-ai/glm-5.3-flash1049K ctx · $0.15/$0.50text+image+video->text
z-ai/glm-4.6205K ctx · $0.60/$2.20text->text
z-ai/glm-5.3-flashx1049K ctx · $0.37/$1.25text+image+video->text
z-ai/glm-5.31049K ctx · $1.13/$4.40text->text
z-ai/glm-4.7-flash200K ctx · $0.06/$0.40text->text
z-ai/glm-4.5-air131K ctx · $0.13/$0.85text->text
z-ai/glm-4.6v131K ctx · $0.30/$0.90text+image+video->text
z-ai/glm-4.5v66K ctx · $0.60/$1.80text+image->text
z-ai/glm-4.5131K ctx · $0.60/$2.20text->text
voyage
voyage/voyage-4-lite32K ctx · $0.02/$0.00text->embeddings
voyage/voyage-3.5-lite32K ctx · $0.02/$0.00text->embeddings
voyage/voyage-3.532K ctx · $0.06/$0.00text->embeddings
voyage/voyage-432K ctx · $0.06/$0.00text->embeddings
voyage/voyage-4-large32K ctx · $0.12/$0.00text->embeddings
voyage/voyage-law-216K ctx · $0.12/$0.00text->embeddings
voyage/voyage-finance-232K ctx · $0.12/$0.00text->embeddings
voyage/voyage-code-216K ctx · $0.12/$0.00text->embeddings
voyage/voyage-3-large32K ctx · $0.18/$0.00text->embeddings
voyage/voyage-code-332K ctx · $0.18/$0.00text->embeddings
xAI
x-ai/grok-build-0.1256K ctx · $1.00/$2.00text+image+file->text
x-ai/grok-4.31000K ctx · $1.25/$2.50text+image+file->text
x-ai/grok-4.6500K ctx · $2.00/$6.00text+image+file->text
x-ai/grok-4.5500K ctx · $2.00/$6.00text+image+file->text
x-ai/grok-4.7500K ctx · $2.00/$6.00text+image->text
x-ai/grok-4.202000K ctx · $1.25/$2.50text+image+file->text
x-ai/grok-imagine-video-1.5-lite · $0.00/$0.00text+image->video
x-ai/grok-imagine-image-2.0 · $0.00/$0.00text+image->image
bytedance-seed
bytedance-seed/seed-1.6-flash262K ctx · $0.07/$0.30text+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.6262K ctx · $0.25/$2.00text+image+video->text
ByteDance
bytedance/seedance-2.5 · $0.00/$0.00text+image+audio+video->video
bytedance/seedance-2.0 · $0.00/$0.00text+image+audio+video->video
bytedance/seedance-1-5-pro · $0.00/$0.00text+image->video
bytedance/seedance-2.0-fast · $0.00/$0.00text+image+audio+video->video
Moonshot AI
moonshotai/kimi-k31049K ctx · $2.83/$14.13text+image+video->text
moonshotai/kimi-k3.1-pro1049K ctx · $2.00/$10.00text+image+video->text
moonshotai/kimi-k2-0905262K ctx · $0.60/$2.50text->text
Cohere
cohere/rerank-v3.54K ctx · $0.00/$0.00text->rerank
cohere/rerank-4-pro33K ctx · $0.00/$0.00text->rerank
cohere/rerank-4-fast33K ctx · $0.00/$0.00text->rerank
MiniMax
minimax/minimax-m31049K ctx · $0.30/$1.20text+image+video->text
minimax/hailuo-3-max · $0.00/$0.00text+image->video
xiaomi
xiaomi/mimo-v2.6-flash1049K ctx · $0.14/$0.28text+image+video+audio->text
xiaomi/mimo-v2.6-pro1049K ctx · $0.43/$0.87text+image+video+audio->text
reflection
reflection/beam-free1049K ctx · $0.00/$0.00text->text
reflection/beam1049K ctx · $0.00/$0.00text->text
Perplexity
perplexity/pplx-embed-v1-0.6b32K ctx · $0.00/$0.00text->embeddings
perplexity/pplx-embed-v1-4b32K ctx · $0.03/$0.00text->embeddings
Mistral
mistralai/mistral-embed-23128K ctx · $0.10/$0.00text->embeddings
mistralai/codestral-embed-25058K ctx · $0.15/$0.00text->embeddings
cloudflare
cloudflare/clef-flash25K ctx · $0.09/$0.00text+image->decisions
cloudflare/clef66K ctx · $0.24/$0.00text+image->decisions
NVIDIA
nvidia/nemotron-3.5-lightning-free1000K ctx · $0.00/$0.00text->text
stealth
stealth/glyph-cluster256K ctx · $0.00/$0.00text->text
Meta
meta/muse-wonder1049K ctx · $4.00/$20.00text+image+file->text
amazon
amazon/titan-embed-text-v28K ctx · $0.02/$0.00text->embeddings
typesafe-ai
typesafe-ai/jev32K ctx · $0.04/$0.00text->decisions

すべてのモデルは モデルページで閲覧できます。

構造化評価(Jev)

Jev は JSON 状態を名前付きの質問で評価し、boolean、choice、score の型付き回答を返します。明確な基準をプログラムで扱える評価結果にしたい場合に使用します。

評価・判定専用
Jev はチャットには対応していません。Jev のリクエストは POST /v1/evaluations に送信してください。POST /v1/chat/completions に送ると HTTP 400 が返ります。
POST/v1/evaluations

BazaarLink API キーを使って次のエンドポイントを呼び出します。完全な URL: https://api.bazaarlink.ai/v1/evaluations。

フィールドの説明

model
string
省略可能です。省略すると typesafe-ai/jev が既定値になります。他のモデル ID では HTTP 400 と model_not_available が返ります。
state
string | object | array
必須です。評価対象の状態として JSON の文字列、オブジェクト、または配列を指定します。シリアライズ後の state と questions の合計が 32,000 tokens を超えると context_length_exceeded が返ります。
questions
record<string, Question>
必須です。名前付き質問を 1 つ以上含むオブジェクトを指定します。各質問名は応答 answers オブジェクトのキーになります。
type
boolean | choice | score
各質問で必須です。boolean、choice、score のいずれかを指定します。
instructions
string | object | array
各質問で必須です。判断内容を説明する JSON 文字列、オブジェクト、または配列を指定します。
criteria
object | array
type によって異なります。boolean では省略可能で、指定する場合はキーが true または false のオブジェクトです。choice は空でないオブジェクト、score は順序を保った 2 項目以上の配列が必須です。

回答の型

  • boolean — criteria は省略できます。指定する場合、キーには true と false のみ指定できます。回答には数値の probability が含まれます。
  • choice — criteria は、選択肢名と JSON 形式の判定基準を対応付ける空でないオブジェクトです。回答には文字列の choice が含まれ、probabilities のキーは選択肢名です。
  • score — criteria は2件以上の順序付き配列です。score は数値で、criteria 配列の順序に従ったインデックス 0..N-1 の期待値です。probabilities のキーは、そのインデックスを文字列にしたものです。

リクエスト例

curl --fail-with-body https://api.bazaarlink.ai/v1/evaluations \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "typesafe-ai/jev",
  "state": "The support agent issued a full refund and apologised for the delay.",
  "questions": {
    "refunded": {
      "type": "boolean",
      "instructions": "Was a refund issued?"
    },
    "tone": {
      "type": "choice",
      "instructions": "Tone of the agent?",
      "criteria": {
        "apologetic": "The agent apologises",
        "neutral": "No emotional language",
        "hostile": "The agent is rude"
      }
    },
    "quality": {
      "type": "score",
      "instructions": "How complete was the resolution?",
      "criteria": [
        "poor",
        "partial",
        "complete"
      ]
    }
  }
}'

成功時の応答例

サンプルレスポンスには id、object、model、answers、usage、rounding、warnings が含まれます。answers のキーは質問名です。usage には input_tokens、output_tokens、total_tokens が含まれ、rounding には probabilityDecimals と scoreDecimals が示されます。warnings は配列で、この例では空です。answers 内では、choice の probabilities は選択肢名をキーにし、score の probabilities は criteria のインデックスを文字列にした値をキーにします。

{
  "id": "eval-a3d350e5-2705-4a9b-be7c-838fa4e4eb2b",
  "object": "evaluation",
  "model": "typesafe-ai/jev",
  "answers": {
    "refunded": {
      "type": "boolean",
      "probability": 0.99
    },
    "tone": {
      "type": "choice",
      "choice": "apologetic",
      "probabilities": {
        "apologetic": 1,
        "neutral": 0,
        "hostile": 0
      }
    },
    "quality": {
      "type": "score",
      "score": 1.98,
      "probabilities": {
        "0": 0,
        "1": 0.02,
        "2": 0.98
      }
    }
  },
  "usage": {
    "input_tokens": 394,
    "output_tokens": 74,
    "total_tokens": 468
  },
  "rounding": {
    "probabilityDecimals": 2,
    "scoreDecimals": 2
  },
  "warnings": []
}

チャット形式のエンドポイントでのエラー応答

Jev をチャット形式のエンドポイントに送信すると HTTP 400 が返ります。下記のフィールドと値はハンドラーの形状に一致します。message はプレースホルダーで、実際の文面はサーバーから返されます。

{
  "error": {
    "message": "<server-generated message>",
    "type": "invalid_request_error",
    "code": 400
  }
}

ストリーミング

設定: stream: true でServer-Sent Events(SSE)ストリームを受信します。各イベントにはレスポンスのチャンクが含まれます。

from openai import OpenAI

client = OpenAI(
    base_url="https://api.bazaarlink.ai/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":"85e6f35c71a31f19-SJC","choices":[{"delta":{"content":"Hello"},"index":0}]}

data: {"id":"85e6f35c71a31f19-SJC","choices":[{"delta":{"content":" world"},"index":0}]}

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

data: [DONE]
ストリーミングでの使用量
ストリーミング時、使用量データは[DONE]メッセージの前の最終チャンクに、空のdeltaとfinish_reason: "stop"を持つchoices配列とともに返されます。

Keep-alive と最終チャンク

ストリームにはSSEコメント行や未知またはpingのkeep-aliveイベントが含まれる場合があります。これらを無視してdataフレームを解析してください。最後のdataフレームにはdata: [DONE]の前にusageが含まれる場合があります。

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

data: {"id":"85e6f35c71a31f19-SJC","choices":[{"delta":{"content":"Hi"},"index":0}]}

data: {"id":"85e6f35c71a31f19-SJC","choices":[{"delta":{},"finish_reason":"stop","index":0}],"usage":{...}}

data: [DONE]

ストリームのキャンセル

クライアント接続を閉じることでストリーミングリクエストをキャンセルできます — 例えば AbortController.abort() を呼ぶ、または stream オブジェクトを閉じるなど。BazaarLink はキャンセルを受け取り次第、以降のチャンク転送を停止し、プロバイダーへのアウトバウンドリクエストを中止します。

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.bazaarlink.ai/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 は以降のトークンの転送と課金を直ちに停止しますが、接続が切れた瞬間にアップストリームのプロバイダーが自社サーバー上で生成を停止するかどうかはそのプロバイダー次第です — 切断後もしばらく処理を続けるプロバイダーもあります。

ストリーム途中でのエラー

エラーフレームには choices フィールドがありません
ストリーミング開始後に失敗が発生した場合(例:アップストリーム接続の切断)、通常の {choices:[...]} ではなく {error:{message,type,code}} 形式の SSE データフレームが返されます — ヘッダーはすでに送信済みのため、HTTP ステータスの変化はありません。choices[0].delta を読む前に error キーの有無を確認してください。課金はそれまでにストリーミングされたトークン分のみです(部分課金が適用されます)。
data: {"id":"85e6f35c71a31f19-SJC","choices":[{"delta":{"content":"The capital of "},"index":0}]}

data: {"error":{"message":"The request could not be completed.","type":"upstream_error","code":502}}

data: [DONE]

エンベディング

エンベディング(Embeddings)は意味を捉えた数値表現で、テキストをベクトル(数値の配列)に変換し、さまざまな機械学習タスクに利用できます。BazaarLinkはOpenAI Embeddings API互換の統一エンドポイントを提供し、単一のインターフェースで複数プロバイダーのエンベディングモデルを呼び出せます。

Embeddingのレスポンスでは、x-request-idと一致する不透明なBazaarLinkリクエストIDが使われます。GET /v1/generationで使用してください。非ストリーミングのレスポンスでは、同じIDがx-generation-idにも返されます。usage.costはこのリクエストでお客様に請求されたUSD金額です。統計は完了後数秒かかる場合があるため、404は短時間再試行してください。

エンベディングとは?

エンベディングはテキストを高次元ベクトルに変換し、意味的に近いテキストはベクトル空間上でも近い距離に位置します——例えば「猫」と「子猫」のエンベディングは似ていますが、「猫」と「飛行機」は大きく離れています。このベクトル表現により、機械はテキスト間の関係を理解できるようになり、多くのAIアプリケーションの基盤となっています。

一般的なユースケース

ユースケース
説明
RAG(検索拡張生成)回答を生成する前にナレッジベースから関連コンテキストを検索するシステムを構築——エンベディングはLLMのコンテキストに含めるべき最も関連性の高いドキュメントを見つけます。
セマンティック検索ドキュメントとクエリをエンベディングに変換し、ベクトル類似度で最も関連性の高いドキュメントを見つけます——キーワード一致だけでなく意味を理解するため、キーワード検索より優れた結果が得られます。
レコメンデーションシステム商品、記事、動画などのアイテムとユーザーの好みのエンベディングを生成し、類似アイテムを推薦——共通のキーワードがなくても、ベクトル比較で意味的に関連するアイテムを見つけられます。
クラスタリングと分類エンベディングのパターンを分析して、類似したドキュメントをグループ化または分類——エンベディングが似ているドキュメントは通常、同じトピックやカテゴリに属します。
重複検出エンベディングの類似度を比較して重複または近似重複コンテンツを検出——言い換えられたコンテンツでも検出できます。
異常検知データセットの典型的なパターンから大きく外れたエンベディングを特定し、異常や外れ値のコンテンツを検出します。
POST/v1/embeddings
Note
上流の接続先が要求された埋め込みモデルに対応していない場合、リクエストは別の利用可能な接続先を試すことがあります。対応する接続先がない場合はエラーが返されます。

パラメータ

model必須
string
使用するエンベディングモデル。例:"openai/text-embedding-3-small"。
input必須
string | string[] | ContentItem[]
エンベディング対象のテキスト — 単一の文字列、1回のバッチ呼び出し用の文字列配列、または(対応モデルの場合)text パートと image_url パートを混在させた {content:[...]} 形式の配列。
dimensions
integer
リクエストする出力ベクトルの次元数。可変次元をサポートするモデル(例:OpenAI text-embedding-3 系)でのみ有効です。アップストリームプロバイダーにそのまま転送され、対応していないモデルでは無視されます。
encoding_format
string
リクエストするエンベディングのエンコード形式。例:"float" または "base64"。アップストリームプロバイダーにそのまま転送されます — 対応状況はモデルによって異なります。
provider
object
Unsupported. The entire object is ignored and removed before forwarding; it cannot select an upstream or price tier.

基本リクエスト

from openai import OpenAI

client = OpenAI(
    base_url="https://api.bazaarlink.ai/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

バッチ処理

文字列の配列を送信すると、1回のリクエストで複数のテキストをまとめてエンベディングできます — テキストごとに呼び出すより安く速くなります。

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")

マルチモーダル入力(画像+テキスト)

画像入力に対応したモデル(output_modalities に "embeddings"、inputModalities に "image" を含む)は、{content:[{type:"text",...}, {type:"image_url",...}]} 形式の入力アイテムを受け付け、画像単体、またはテキストと組み合わせてエンベディングできます。

モデル依存
画像入力を受け付けるのは一部のエンベディングモデルのみです。image_url コンテンツを送信する前に、Models ページでそのモデルの対応モダリティを確認してください。テキスト専用モデルはこの形式を拒否します。
import requests

response = requests.post(
    "https://api.bazaarlink.ai/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)}")

エンベディングモデルの探し方

エンベディング専用のモデル一覧エンドポイントはありません。GET /v1/models を呼び出し、output_modalities に "embeddings" を含むエントリをクライアント側でフィルタするか、Models ページを参照してください。

制限事項

  • ストリーミング非対応 — チャット補完と異なり、エンベディングは常に完全なレスポンスとして返されます。
  • 各モデルには最大入力長があります。それを超えるテキストはアップストリーム側で切り詰められるか拒否されます。
  • 同一の入力に対するエンベディングは決定論的です — temperature やランダム性はありません。

ベストプラクティス

  • 速度・品質・コストのトレードオフに応じてモデルを選びましょう — 小型モデル(例:qwen/qwen3-embedding-4b)は安価で高速、大型モデル(例:openai/text-embedding-3-large)は一般的により高精度にエンベディングします。
  • テキストごとに呼び出すのではなく、複数のテキストを1回のリクエストにまとめましょう — ラウンドトリップが減り、オーバーヘッドも下がります。
  • 結果をキャッシュしましょう — 同じ入力のエンベディングは変化しないため、再生成せず保存しておくべきです。
  • 比較にはユークリッド距離ではなくコサイン類似度を使いましょう — スケール不変で高次元ベクトルに向いています。
  • 各モデルのコンテキスト長に注意しましょう — 長い文書はエンベディング前にチャンク分割が必要な場合があります。

パラメータ

サンプリングパラメータはトークン生成プロセスを制御します。BazaarLinkはサポートされているパラメータをアップストリームプロバイダーに渡し、サポートされていないパラメータは黙って無視されます。

サンプリングパラメータ

純粋なパススルー — ローカルデフォルトなし
サンプリング値は範囲検証なしで転送されます。モデルが対応範囲外の値を制限または無視する場合があります。
temperature
number
サンプリング値は範囲検証なしで転送されます。モデルが対応範囲外の値を制限または無視する場合があります。
top_p
number
Nucleusサンプリングの確率質量。デフォルト:1
top_k
integer
サンプリング値は範囲検証なしで転送されます。モデルが対応範囲外の値を制限または無視する場合があります。
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
最高確率トークンに基づく動的top-P。範囲:[0, 1]。デフォルト:0
seed
integer
決定論的サンプリング用の整数シード。すべてのモデルで保証されるわけではない
max_tokens
integer
生成する最大トークン数
n
integer
生成するコンプリーション数。デフォルト:1
logit_bias
object
サンプリング前に追加されるトークンIDからバイアス値[-100, 100]へのマップ。OpenAI系モデルのみ対応 — 下記の注記を参照。
logprobs
boolean
各出力トークンのログ確率を返す。OpenAI系モデルのみ対応 — 下記の注記を参照。
top_logprobs
integer
位置ごとに返す最も可能性の高いトークン数(logprobs: trueが必要)。範囲:0〜20。OpenAI系モデルのみ対応 — 下記の注記を参照。
response_format
object
構造化JSON出力を強制。構造化出力セクションを参照
structured_outputs
boolean
対応プロバイダーで厳密なJSONスキーマ準拠の出力をリクエスト。そのまま転送
reasoning
object
プロバイダー固有のreasoning/thinking設定。そのまま転送
reasoning_effort
string
OpenAI oシリーズ形式のreasoning強度:"low"、"medium"、または"high"。そのまま転送
include_reasoning
boolean
true にすると message.reasoning(ストリーミングでは delta.reasoning)に思考内容を返し、false にすると、デフォルトで思考するモデルの思考をオフにします(推論のセクション参照)。そのため思考は課金されません。reasoning_effort、reasoning、thinking のいずれも送らない場合、デフォルトで思考して返すのはそれらのモデルだけで、ほかのモデルは求めたときだけ返します
stop
string | string[]
停止シーケンス — 検出時に生成が停止
tools
Tool[]
モデルが呼び出せるツール(関数)のリスト
tool_choice
string | object
ツール使用の制御:"auto"、"none"、または特定のツール
parallel_tool_calls
boolean
ツール提供時の並列ファンクションコールを有効化。デフォルト:true。OpenAI系モデルのみ対応 — 下記の注記を参照。

クレジット

現在のクレジット残高と累計 API 使用量を照会。

GET/v1/credits
Auth
Bearer token(標準 API キー sk-bl-...)が必要です。

リクエスト例

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

レスポンス

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

エラー:401(キー無効/欠落)、403(停止中のユーザー)。

生成詳細

レスポンスのidまたはx-request-idヘッダーの不透明なBazaarLinkリクエストIDでGET /v1/generationを呼び出します。非ストリーミングではx-generation-idにも同じIDが返ります。統計は完了後数秒かかる場合があり、404は短時間再試行してください。

GET/v1/generation?id=<generation-id>
Auth
Bearer token(標準 API キー)が必要です。必須 query パラメータ:id。

リクエスト例

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

レスポンス

{
  "data": {
    "id": "85e6f35c71a31f19-SJC",
    "model": "openai/gpt-4o",
    "provider": "bazaarlink",
    "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(id 欠落)、401(auth)、404(generation が見つかりません)。

API キー情報

現在の API キーの rate limit 階層と集計使用量カウンタを照会(レスポンス形式は業界標準のキー情報 API に準拠)。

GET/v1/key
Auth
Bearer token(標準 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
クレジット残高が $10 未満の場合、is_free_tier は true。ウィンドウは UTC:daily = 当日、weekly = 月曜〜日曜、monthly = 1 日〜月末。個別の利用上限が設定されている場合(キー作成・更新時の limit パラメータ)、limit / limit_remaining / limit_reset はその上限と該当期間の使用量を反映します。未設定の場合 limit は null、limit_remaining はアカウントのクレジット残高にフォールバックします。expires_at はキーの有効期限(未設定なら null)。is_management_key と is_provisioning_key は同じ概念の別名で、管理キーの場合どちらも true になります。
BYOK
BazaarLink は BYOK(自前キー持ち込み)プログラムを提供していないため、このエンドポイントは byok_usage 関連フィールドを返しません。

エラー:401(auth)、404(ユーザーなし — まれ)。

エラーコード

Error response format

エラー形式はエンドポイントによって異なります。HTTPステータスと、存在する場合はerror.typeを使用してください。error.codeは文字列または数値で、省略されることもあります。error.messageは表示用です。

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

HTTP status and error.code

エラー形式はエンドポイントによって異なります。HTTPステータスと、存在する場合はerror.typeを使用してください。error.codeは文字列または数値で、省略されることもあります。error.messageは表示用です。

コード
名前
説明
424依存関係の失敗ご自身で設定した BYOK キーがアップストリームプロバイダーに拒否されました。BYOK 設定で確認またはローテーションしてください。strict モードでのみ発生します
400Bad Request不正なリクエスト、空のmessages配列、または必須フィールドの欠落
401UnauthorizedAPIキーが欠落、無効、または無効化されている
402Payment Requiredアカウントクレジット不足、キーごとの支出制限到達、または月次/週次予算上限超過
403Forbiddenアカウントが停止されているか、権限がない
404Not FoundRequested model, generation, key, or other resource does not exist
409ConflictResource is not in the required state, such as an incomplete video job
410GoneRequested model has been retired and must be replaced
413Payload Too Largeリクエストボディが10MBを超えています。コンテンツサイズを縮小するかリクエストを分割してください
416Range Not SatisfiableRequested byte range is invalid for generated video content
429Too Many Requestsレート制限超過。リトライ前にRetry-Afterヘッダーを確認してください
432無料枠の上限Tavily 互換エンドポイント(/v1/search、/v1/extract、/v1/crawl、/v1/map):無料の検索枠を使い切ったか、残高が 0 以下です。クレジットを追加してください。レスポンス本文は Tavily 形式です:{"detail":{"error":"..."}}
500Server ErrorBazaarLink内部エラー
502Bad Gatewayすべての上流接続先で処理できませんでした。リクエストにはエラーが返されます。
503Service Unavailableこのモデルにアップストリームプロバイダーが設定されていません。管理者に連絡してください
504Gateway TimeoutUpstream connection or stream stalled and timed out

Machine-readable billing codes

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

コード
説明
byok_key_invalidご自身で設定した BYOK キーがアップストリームプロバイダーに拒否されました。BYOK 設定で確認またはローテーションしてください。strict モードでのみ発生します。
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.
capacity_unavailableこのモデルは一時的に容量が不足しています。しばらくしてから再試行してください。待機秒数は Retry-After ヘッダーに入ります。

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.

Model and endpoint
Model lookup, lifecycle, pricing, modality, and endpoint compatibility errors.
コード
HTTP status
unknown_model400
invalid_model_id400
model_not_found404
model_retired410
model_endpoint_mismatch400
embedding_on_chat_endpoint400
model_not_priced400
invalid_modality_for_model400
Request and safety
Invalid parameters, context, tools, schemas, and content-safety refusals.
コード
HTTP status
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 generation and editing
Image input, multipart editing, output, and image-pipeline errors.
コード
HTTP status
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
Upstream routing
Sanitized provider connectivity, authentication, throttling, and availability errors.
コード
HTTP status
upstream_unreachable502
upstream_auth_failed502
upstream_rate_limited429
capacity_unavailable429
upstream_unavailable502/503
byok_key_invalid424

コンテンツモデレーション

すべてのリクエストは、モデルに送信される前に自動コンテンツモデレーションを受けます。利用規約に違反するリクエストはモデルに送られる前に拒否され、403エラーが返されます。

ブロックされるコンテンツのカテゴリ

モデレーションは利用規約(Acceptable Use Policy)に基づいており、主に以下のカテゴリのコンテンツをブロックします:

  • 性的搾取コンテンツ
  • 暴力的な脅迫
  • 違法行為の実行指示
  • 生物学的危害に関するコンテンツ

403レスポンスの形式

モデレーションによってブロックされたリクエストは、次の形式のエラーを返します:

{
  "error": {
    "message": "Your prompt was blocked by content moderation.",
    "type": "invalid_request_error",
    "code": "content_filter"
  }
}

ブロックされたリクエストには課金されません——拒否されたリクエストの料金は発生しません。

誤検知の異議申し立て

リクエストが誤ってブロックされたと思われる場合は、リクエスト時刻と(可能であれば)request idを添えてサポートまでご連絡ください。確認いたします。

プライバシーについて

すべてのリクエストは自動的にコンテンツモデレーションの審査を受けます。

違反と判定されたリクエストは、コンプライアンス上の証拠としてその内容を保持します。

それ以外のリクエストは、完全なプロンプト内容を保持しません。

Rate limits, budgets, and emergency brakes

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

Control
HTTP status
How to identify it
リクエストレート制限429文字列コードまたは数値コード429。Retry-AfterとX-RateLimit-*ヘッダーを使用してください。
Rate-limit penalty block429Numeric code 429 and a temporary restriction message; use Retry-After.
Global spend emergency brake503Numeric code 503, global spend-limit message, and Retry-After of 30 or 300 seconds.
Scoped spend brake429Numeric code 429 and a spend circuit-breaker message naming the scope.
Billing and budget controls402Use the stable billing string codes listed above.

エラー形式はエンドポイントによって異なります。HTTPステータスと、存在する場合はerror.typeを使用してください。error.codeは文字列または数値で、省略されることもあります。error.messageは表示用です。

Video and media resource state

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 policy

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.

Retry with backoff
429, 502, 503, and 504. Check the original generation job before creating another after an ambiguous network failure.
Fix before retrying
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://api.bazaarlink.ai/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-4o",
            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エラーレスポンスを返します。

ストリームが開始されると、HTTPレスポンスはすでに200です。各SSEデータフレームを解析し、トップレベルのerror、またはchoices[0].finish_reason === "error" が現れた場合は、失敗した不完全なレスポンスとして扱ってください。

ストリームの開始後に失敗した場合、BazaarLinkはトップレベルのerrorオブジェクトを含む最後のSSEイベントを送信し、その後にdata: [DONE]を送ることがあります。レスポンスは不完全として扱い、部分的な出力を完了した結果として使用しないでください。

data: {"error":{"message":"The request could not be completed.","type":"upstream_error","code":502}}

data: [DONE]

// Branch on error.code; error.type can vary by failure path.

バージョニング

BazaarLink は単一の安定した API パス /v1 を公開しています — 日付固定のバージョンやバージョンヘッダーを管理する必要はありません。API は番号付きリリースではなく、継続的に進化します。

非破壊的変更

以下は事前通知なしにリリースされます:

  • 新しいエンドポイント
  • カタログへの新しいモデルの追加
  • 新しい任意のリクエストパラメータ
  • 新しいレスポンスフィールド
  • 任意プロパティを持つ新しいスキーマ
  • 追加のレスポンスステータス/エラーコード
クライアントは防御的に実装してください
認識できないレスポンスフィールドは無視し、enum 的なフィールドの未知の値でも失敗しないようにしてください — カタログや機能の拡大に伴い新しい値が追加されます。

破壊的変更

これらは稀で、以下を含みます:

  • エンドポイント/パラメータ/レスポンスフィールドの削除や名称変更
  • フィールドの型変更
  • 任意パラメータの必須化

発生した場合も、破壊的変更は /v1 全体ではなく特定のエンドポイントに限定されます — すべての連携を一度に壊すような単一のバージョン切り替えはありません。Breaking タグ付きの正式な changelog はまだ公開していません(下記「最新情報の入手」参照)— 連携にとって重要な部分については、ドキュメント化されていない挙動に依存する前に Support までご連絡ください。

廃止ポリシー

想定しておくべき唯一の定常的な「破壊的」イベントは、アップストリームプロバイダーが廃止した個々のモデルが引退することです。モデルの現在のステータスは GET /v1/models で確認できます。

GET https://api.bazaarlink.ai/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 changelog や RSS フィードはまだ公開していません。現時点では、このページを直接ご確認いただくか、GET /v1/models でモデルのステータスを確認するか、重要な連携で事前通知が必要な場合は Support までご連絡ください。

サポート
サポート
こんにちは。どのようなご用件でしょうか?
メッセージをお送りください。担当者より返信します。