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

エラーコード

エラーコード

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を添えてサポートまでご連絡ください。確認いたします。

プライバシーについて

リクエストは自動的にコンテンツ安全の審査を受け、最新の入力のテキストと画像が第三者のコンテンツ安全スコアリングサービスに送信されることがあります。

違反、違反の疑い、しきい値付近、またはランダム抽出と判断されたリクエストは、コンプライアンス上の証拠、紛争対応および監査のため、全文または冒頭部分を保存することがあり、固定の削除期間は約束しません。

それ以外の通常の成功リクエストでは、プロンプトや応答の内容を保持しません。ZDRキーのリクエストには最初の2点は適用されません。

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