Cookieを使用しています. Cookieとブラウザストレージは、ログイン状態の維持と設定の保存に使われます。許可いただいた場合は、サイトの利用状況も計測します。はいつでも変更できます。詳しくはCookieポリシーをご覧ください。

Completions

エンドポイント

Completions

レガシーの POST /completions で、生の prompt 文字列からテキストを生成する方法です。チャットテンプレートが適用されないため、ベースモデルや fill-in-the-middle に向き、レスポンスとエラーも載せています。

プレイグラウンドで試す

レガシーの Completions エンドポイントは、生の prompt 文字列を受け取って生成テキストを返します。チャットテンプレートは適用されません。ベースモデル、fill-in-the-middle、古い連携に便利です。新しいコードでは Chat Completions を使ってください。

POST https://api14.com/api/v1/completions
Authorization: Bearer sk-api14-...
Content-Type: application/json

リクエスト

パラメーター型説明
modelstring, 必須モデル ID。例: meta-llama/llama-3.1-8b-instruct。
promptstring, 必須続きを生成する元のテキスト。
max_tokensinteger生成するトークン数の上限。
temperature, top_p, top_knumberサンプリング制御。
stopstring | string[]停止シーケンス。
seedintegerベストエフォートの決定的サンプリング。
logprobsintegerモデルが対応している場合に、上位トークンの対数確率を返します。
streambooleanテキストのチャンクを SSE でストリーミングします。
provider, models, transformsChat Completions と同じゲートウェイ拡張。
curl https://api14.com/api/v1/completions \
  -H "Authorization: Bearer $API14_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-3.5-turbo-instruct",
    "prompt": "The three primary colors are",
    "max_tokens": 20
  }'
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api14.com/api/v1",
  apiKey: process.env.API14_API_KEY,
});

const result = await client.chat.completions.create({
  "model": "openai/gpt-5-mini",
  "messages": [
    {
      "role": "user",
      "content": "Explain vector databases in two sentences."
    }
  ]
});
console.log(result.choices[0].message.content);

レスポンス

{
  "id": "gen-1760000000-xyz789",
  "object": "text_completion",
  "created": 1760000000,
  "model": "openai/gpt-3.5-turbo-instruct",
  "choices": [
    { "index": 0, "text": " red, yellow and blue.", "finish_reason": "stop" }
  ],
  "usage": {
    "prompt_tokens": 6,
    "completion_tokens": 7,
    "total_tokens": 13,
    "cost": 0.0000195
  }
}

エラー

400 model_required、400 invalid_json、401 invalid_api_key、402 insufficient_balance、403 model_not_allowed / plan_required、404 model_not_found、413 payload_too_large、429 rate_limited、502 upstream_unavailable。プロバイダーからのエラーは元のステータスのまま返されます。エラーを参照してください。