OpenAI は、API の再利用可能なプロンプトオブジェクトを廃止する予定です。
2026 年 6 月 3 日からプロンプト作成の推奨が控えられ、v1/prompts は
2026 年 11 月 30 日に提供を終了する予定です。最新のスケジュールは、
廃止予定
ページをご覧ください。
OpenAI API プラットフォームの プロンプト から移行するには、管理対象の prompt オブジェクトにあるプロンプトの内容をアプリケーションコードに移します。これにより、レビュー、テスト、デプロイ、バージョン管理をより柔軟に制御できます。
移行前:プロンプトオブジェクトの使用
import OpenAI from "openai";
const client = new OpenAI();
const response = await client.responses.create({
prompt: {
id: "pmpt_123",
version: "1",
variables: {
customer_name: "Acme",
issue: "billing question",
},
},
});移行後:コードへのプロンプトの直接記述
import OpenAI from "openai";
const client = new OpenAI();
const response = await client.responses.create({
model: "gpt-6-astra",
input: [
{
role: "system",
content:
"You are a helpful support assistant. Be concise, accurate, and friendly.",
},
{
role: "user",
content:
"Customer name: Acme. Issue: billing question. Write a response to the customer.",
},
],
});
console.log(response.output_text);Codex を使った移行
OpenAI Developers プラグインと OpenAI Docs スキルを使うと、移行を自動化し、OpenAI API を使った開発を加速できます。
$openai-docs update this project to store prompts in code instead of using a prompts object
変更点
API リクエストで保存済みのプロンプトオブジェクトを参照する代わりに、プロンプトのテキストをコードベースに保存し、生成したメッセージを Responses API 呼び出しの input に直接渡します。
- プロンプトの内容をソースコードに移します 。これにより、プロンプトの変更にもプロダクトのロジックと同じレビューとリリースのプロセスを適用できます。
- プロンプトの変数を関数の引数に置き換えます 。これにより、アプリケーション内の動的な値を明示し、型を定義できます。
- Responses API の呼び出しでは、
promptオブジェクトを使う代わりに、inputを通じてメッセージを渡します 。 - git コミット、PR レビュー、テストや評価を使い、バージョン管理をリポジトリに移します 。
- プロンプトキャッシュの利点を維持するために、静的なコンテンツを先に、動的なコンテンツを後に配置します 。キャッシュがヒットするには、プレフィックスが完全に一致する必要があるためです。
例
import OpenAI from "openai";
const client = new OpenAI();
function buildSupportPrompt({ customerName, issue }) {
return [
{
role: "system",
content:
"You are a helpful support assistant. Be concise, accurate, and friendly. Do not invent policy details.",
},
{
role: "user",
content: `Customer name: ${customerName}. Issue: ${issue}. Write a response to the customer.`,
},
];
}
const response = await client.responses.create({
model: "gpt-6-astra",
input: buildSupportPrompt({
customerName: "Acme",
issue: "billing question",
}),
});移行のメリット
開発上の管理をより徹底できます。プロンプトをプロダクトのコードと一緒に管理し、変更は PR を通じて行い、テストや評価を CI で実行できます。また、ロールアウトや実験を独自の設定や機能フラグで管理できます。
プロンプトをコードベースのあちこちに直接書き込まないでください。小さな prompts/ モジュールを作成し、各プロンプトを名前付きのビルダー関数として管理します。さらに、軽量な評価用フィクスチャを追加し、プロンプトの変更をプロダクトのロジックと同様にレビューできるようにします。