[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ANVDAP73DXMM8B42R1MEDY":3,"skill-same:01M7ANVDAP73DXMM8B42R1MEDY":59},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":24,"commitSha":25,"skillDirectory":5,"forksCount":13,"repositoryHtmlUrl":26,"repositoryHomepageUrl":6,"ownerHtmlUrl":27,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":28,"install":29,"resources":42},"01M7ANVDAP73DXMM8B42R1MEDY","openai-responses",null,"This skill provides comprehensive knowledge for working with OpenAI's Responses API, the unified stateful API for building agentic applications. It should be used when building AI agents that preserve reasoning across turns, integrating MCP servers for external tools, using built-in tools (Code Interpreter, File Search, Web Search, Image Generation), managing stateful conversations, implementing background processing, or migrating from Chat Completions API.\n\nUse when building agentic workflows, conversational AI with memory, tools-based applications, RAG systems, data analysis agents, or any application requiring OpenAI's reasoning models with persistent state. Covers both Node.js SDK and Cloudflare Workers implementations.\n\nKeywords: responses api, openai responses, stateful openai, openai mcp, code interpreter openai, file search openai, web search openai, image generation openai, reasoning preservation, agentic workflows, conversation state, background mode, chat completions migration, gpt-5, polymorphic outputs","davidanthonyn\u002Fclaude-skills","davidanthonyn","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F55152980?v=4","01M7AJ4MY8S5C2RJCGX6626J0G","01M7AJ7JE1K98GRPH9Z57Z0R0W",0,"MIT","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fopenai-responses\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: openai-responses\ndescription: |\n  This skill provides comprehensive knowledge for working with OpenAI's Responses API, the unified stateful API for building agentic applications. It should be used when building AI agents that preserve reasoning across turns, integrating MCP servers for external tools, using built-in tools (Code Interpreter, File Search, Web Search, Image Generation), managing stateful conversations, implementing background processing, or migrating from Chat Completions API.\n\n  Use when building agentic workflows, conversational AI with memory, tools-based applications, RAG systems, data analysis agents, or any application requiring OpenAI's reasoning models with persistent state. Covers both Node.js SDK and Cloudflare Workers implementations.\n\n  Keywords: responses api, openai responses, stateful openai, openai mcp, code interpreter openai, file search openai, web search openai, image generation openai, reasoning preservation, agentic workflows, conversation state, background mode, chat completions migration, gpt-5, polymorphic outputs\nlicense: MIT\n---\n\n# OpenAI Responses API\n\n**Status**: Production Ready\n**Last Updated**: 2025-10-25\n**API Launch**: March 2025\n**Dependencies**: openai@5.19.1+ (Node.js) or fetch API (Cloudflare Workers)\n\n---\n\n## What Is the Responses API?\n\nThe Responses API (`\u002Fv1\u002Fresponses`) is OpenAI's unified interface for building agentic applications, launched in March 2025. It fundamentally changes how you interact with OpenAI models by providing **stateful conversations** and a **structured loop for reasoning and acting**.\n\n### Key Innovation: Preserved Reasoning State\n\nUnlike Chat Completions where reasoning is discarded between turns, Responses **keeps the notebook open**. The model's step-by-step thought processes survive into the next turn, improving performance by approximately **5% on TAUBench** and enabling better multi-turn interactions.\n\n### Why Use Responses Over Chat Completions?\n\n| Feature | Chat Completions | Responses API | Benefit |\n|---------|-----------------|---------------|---------|\n| **State Management** | Manual (you track history) | Automatic (conversation IDs) | Simpler code, less error-prone |\n| **Reasoning** | Dropped between turns | Preserved across turns | Better multi-turn performance |\n| **Tools** | Client-side round trips | Server-side hosted | Lower latency, simpler code |\n| **Output Format** | Single message | Polymorphic (messages, reasoning, tool calls) | Richer debugging, better UX |\n| **Cache Utilization** | Baseline | 40-80% better | Lower costs, faster responses |\n| **MCP Support** | Manual integration | Built-in | Easy external tool connections |\n\n---\n\n## Quick Start (5 Minutes)\n\n### 1. Get API Key\n\n```bash\n# Sign up at https:\u002F\u002Fplatform.openai.com\u002F\n# Navigate to API Keys section\n# Create new key and save securely\nexport OPENAI_API_KEY=\"sk-proj-...\"\n```\n\n**Why this matters:**\n- API key required for all requests\n- Keep secure (never commit to git)\n- Use environment variables\n\n### 2. Install SDK (Node.js)\n\n```bash\nnpm install openai\n```\n\n```typescript\nimport OpenAI from 'openai';\n\nconst openai = new OpenAI({\n  apiKey: process.env.OPENAI_API_KEY,\n});\n\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'What are the 5 Ds of dodgeball?',\n});\n\nconsole.log(response.output_text);\n```\n\n**CRITICAL:**\n- Always use server-side (never expose API key in client code)\n- Model defaults to `gpt-5` (can use `gpt-5-mini`, `gpt-4o`, etc.)\n- `input` can be string or array of messages\n\n### 3. Or Use Direct API (Cloudflare Workers)\n\n```typescript\n\u002F\u002F No SDK needed - use fetch()\nconst response = await fetch('https:\u002F\u002Fapi.openai.com\u002Fv1\u002Fresponses', {\n  method: 'POST',\n  headers: {\n    'Authorization': `Bearer ${env.OPENAI_API_KEY}`,\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\n    model: 'gpt-5',\n    input: 'Hello, world!',\n  }),\n});\n\nconst data = await response.json();\nconsole.log(data.output_text);\n```\n\n**Why fetch?**\n- No dependencies in edge environments\n- Full control over request\u002Fresponse\n- Works in Cloudflare Workers, Deno, Bun\n\n---\n\n## Responses vs Chat Completions: Complete Comparison\n\n### When to Use Each\n\n**Use Responses API when:**\n- ✅ Building agentic applications (reasoning + actions)\n- ✅ Need preserved reasoning state across turns\n- ✅ Want built-in tools (Code Interpreter, File Search, Web Search)\n- ✅ Using MCP servers for external integrations\n- ✅ Implementing conversational AI with automatic state management\n- ✅ Background processing for long-running tasks\n- ✅ Need polymorphic outputs (messages, reasoning, tool calls)\n\n**Use Chat Completions when:**\n- ✅ Simple one-off text generation\n- ✅ Fully stateless interactions (no conversation continuity needed)\n- ✅ Legacy integrations (existing Chat Completions code)\n- ✅ Very simple use cases without tools\n\n### Architecture Differences\n\n**Chat Completions Flow:**\n```\nUser Input → Model → Single Message → Done\n(Reasoning discarded, state lost)\n```\n\n**Responses API Flow:**\n```\nUser Input → Model (preserved reasoning) → Polymorphic Outputs\n            ↓ (server-side tools)\n    Tool Call → Tool Result → Model → Final Response\n(Reasoning preserved, state maintained)\n```\n\n### Performance Benefits\n\n**Cache Utilization:**\n- Chat Completions: Baseline performance\n- Responses API: **40-80% better cache utilization**\n- Result: Lower latency + reduced costs\n\n**Reasoning Performance:**\n- Chat Completions: Reasoning dropped between turns\n- Responses API: Reasoning preserved across turns\n- Result: **5% better on TAUBench** (GPT-5 with Responses vs Chat Completions)\n\n---\n\n## Stateful Conversations\n\n### Automatic State Management\n\nThe Responses API can automatically manage conversation state using **conversation IDs**.\n\n#### Creating a Conversation\n\n```typescript\n\u002F\u002F Create conversation with initial message\nconst conversation = await openai.conversations.create({\n  metadata: { user_id: 'user_123' },\n  items: [\n    {\n      type: 'message',\n      role: 'user',\n      content: 'Hello!',\n    },\n  ],\n});\n\nconsole.log(conversation.id); \u002F\u002F \"conv_abc123...\"\n```\n\n#### Using Conversation ID\n\n```typescript\n\u002F\u002F First turn\nconst response1 = await openai.responses.create({\n  model: 'gpt-5',\n  conversation: 'conv_abc123',\n  input: 'What are the 5 Ds of dodgeball?',\n});\n\nconsole.log(response1.output_text);\n\n\u002F\u002F Second turn - model remembers previous context\nconst response2 = await openai.responses.create({\n  model: 'gpt-5',\n  conversation: 'conv_abc123',\n  input: 'Tell me more about the first one',\n});\n\nconsole.log(response2.output_text);\n\u002F\u002F Model automatically knows \"first one\" refers to first D from previous turn\n```\n\n**Why this matters:**\n- No manual history tracking required\n- Reasoning state preserved between turns\n- Automatic context management\n- Lower risk of context errors\n\n### Manual State Management (Alternative)\n\nIf you need full control, you can manually manage history:\n\n```typescript\nlet history = [\n  { role: 'user', content: 'Tell me a joke' },\n];\n\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: history,\n  store: true, \u002F\u002F Optional: store for retrieval later\n});\n\n\u002F\u002F Add response to history\nhistory = [\n  ...history,\n  ...response.output.map(el => ({\n    role: el.role,\n    content: el.content,\n  })),\n];\n\n\u002F\u002F Next turn\nhistory.push({ role: 'user', content: 'Tell me another' });\n\nconst secondResponse = await openai.responses.create({\n  model: 'gpt-5',\n  input: history,\n});\n```\n\n**When to use manual management:**\n- Need custom history pruning logic\n- Want to modify conversation history programmatically\n- Implementing custom caching strategies\n\n---\n\n## Built-in Tools (Server-Side)\n\nThe Responses API includes **server-side hosted tools** that eliminate costly backend round trips.\n\n### Available Tools\n\n| Tool | Purpose | Use Case |\n|------|---------|----------|\n| **Code Interpreter** | Execute Python code | Data analysis, calculations, charts |\n| **File Search** | RAG without vector stores | Search uploaded files for answers |\n| **Web Search** | Real-time web information | Current events, fact-checking |\n| **Image Generation** | DALL-E integration | Create images from descriptions |\n| **MCP** | Connect external tools | Stripe, databases, custom APIs |\n\n### Code Interpreter\n\nExecute Python code server-side for data analysis, calculations, and visualizations.\n\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Calculate the mean, median, and mode of: 10, 20, 30, 40, 50',\n  tools: [{ type: 'code_interpreter' }],\n});\n\nconsole.log(response.output_text);\n\u002F\u002F Model writes and executes Python code, returns results\n```\n\n**Advanced Example: Data Analysis**\n\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Analyze this sales data and create a bar chart showing monthly revenue: [data here]',\n  tools: [{ type: 'code_interpreter' }],\n});\n\n\u002F\u002F Check output for code execution results\nresponse.output.forEach(item => {\n  if (item.type === 'code_interpreter_call') {\n    console.log('Code executed:', item.input);\n    console.log('Result:', item.output);\n  }\n});\n```\n\n**Why this matters:**\n- No need to run Python locally\n- Sandboxed execution environment\n- Automatic chart generation\n- Can process uploaded files\n\n### File Search (RAG Without Vector Stores)\n\nSearch through uploaded files without building your own RAG pipeline.\n\n```typescript\n\u002F\u002F 1. Upload files first (one-time setup)\nconst file = await openai.files.create({\n  file: fs.createReadStream('knowledge-base.pdf'),\n  purpose: 'assistants',\n});\n\n\u002F\u002F 2. Use file search\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'What does the document say about pricing?',\n  tools: [\n    {\n      type: 'file_search',\n      file_ids: [file.id],\n    },\n  ],\n});\n\nconsole.log(response.output_text);\n\u002F\u002F Model searches file and provides answer with citations\n```\n\n**Supported File Types:**\n- PDFs, Word docs, text files\n- Markdown, HTML\n- Code files (Python, JavaScript, etc.)\n- Max: 512MB per file\n\n### Web Search\n\nGet real-time information from the web.\n\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'What are the latest updates on GPT-5?',\n  tools: [{ type: 'web_search' }],\n});\n\nconsole.log(response.output_text);\n\u002F\u002F Model searches web and provides current information with sources\n```\n\n**Why this matters:**\n- No cutoff date limitations\n- Automatic source citations\n- Real-time data access\n- No need for external search APIs\n\n### Image Generation (DALL-E)\n\nGenerate images directly in the Responses API.\n\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Create an image of a futuristic cityscape at sunset',\n  tools: [{ type: 'image_generation' }],\n});\n\n\u002F\u002F Find image in output\nresponse.output.forEach(item => {\n  if (item.type === 'image_generation_call') {\n    console.log('Image URL:', item.output.url);\n  }\n});\n```\n\n**Models Available:**\n- DALL-E 3 (default)\n- Various sizes and quality options\n\n---\n\n## MCP Server Integration\n\nThe Responses API has built-in support for **Model Context Protocol (MCP)** servers, allowing you to connect external tools.\n\n### What Is MCP?\n\nMCP is an open protocol that standardizes how applications provide context to LLMs. It allows you to:\n- Connect to external APIs (Stripe, databases, CRMs)\n- Use hosted MCP servers\n- Build custom tool integrations\n\n### Basic MCP Integration\n\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Roll 2d6 dice',\n  tools: [\n    {\n      type: 'mcp',\n      server_label: 'dice',\n      server_url: 'https:\u002F\u002Fexample.com\u002Fmcp',\n    },\n  ],\n});\n\n\u002F\u002F Model discovers available tools on MCP server and uses them\nconsole.log(response.output_text);\n```\n\n### MCP with Authentication (OAuth)\n\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Create a $20 payment link',\n  tools: [\n    {\n      type: 'mcp',\n      server_label: 'stripe',\n      server_url: 'https:\u002F\u002Fmcp.stripe.com',\n      authorization: process.env.STRIPE_OAUTH_TOKEN,\n    },\n  ],\n});\n\nconsole.log(response.output_text);\n\u002F\u002F Model uses Stripe MCP server to create payment link\n```\n\n**CRITICAL:**\n- API does NOT store authorization tokens\n- Must provide token with each request\n- Use environment variables for security\n\n### Polymorphic Output: MCP Tool Calls\n\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Roll 2d4+1',\n  tools: [\n    {\n      type: 'mcp',\n      server_label: 'dice',\n      server_url: 'https:\u002F\u002Fdmcp.example.com',\n    },\n  ],\n});\n\n\u002F\u002F Inspect tool calls\nresponse.output.forEach(item => {\n  if (item.type === 'mcp_call') {\n    console.log('Tool:', item.name);\n    console.log('Arguments:', item.arguments);\n    console.log('Output:', item.output);\n  }\n  if (item.type === 'mcp_list_tools') {\n    console.log('Available tools:', item.tools);\n  }\n});\n```\n\n**Output Types:**\n- `mcp_list_tools` - Tools discovered on server\n- `mcp_call` - Tool invocation and result\n- `message` - Final response to user\n\n---\n\n## Reasoning Preservation\n\n### How It Works\n\nThe Responses API preserves the model's **internal reasoning state** across turns, unlike Chat Completions which discards it.\n\n**Visual Analogy:**\n- **Chat Completions**: Model has a scratchpad, writes reasoning, then **tears out the page** before responding\n- **Responses API**: Model keeps the scratchpad open, **previous reasoning visible** for next turn\n\n### Performance Impact\n\n**TAUBench Results (GPT-5):**\n- Chat Completions: Baseline score\n- Responses API: **+5% better** (purely from preserved reasoning)\n\n**Why This Matters:**\n- Better multi-turn problem solving\n- More coherent long conversations\n- Improved step-by-step reasoning\n- Fewer context errors\n\n### Reasoning Summaries (Free!)\n\nThe Responses API provides **reasoning summaries** at no additional cost.\n\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Solve this complex math problem: [problem]',\n});\n\n\u002F\u002F Inspect reasoning\nresponse.output.forEach(item => {\n  if (item.type === 'reasoning') {\n    console.log('Model reasoning:', item.summary[0].text);\n  }\n  if (item.type === 'message') {\n    console.log('Final answer:', item.content[0].text);\n  }\n});\n```\n\n**Use Cases:**\n- Debugging model decisions\n- Audit trails for compliance\n- Understanding model thought process\n- Building transparent AI systems\n\n---\n\n## Background Mode (Long-Running Tasks)\n\nFor tasks that take longer than standard timeout limits, use **background mode**.\n\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Analyze this 500-page document and summarize key findings',\n  background: true,\n  tools: [{ type: 'file_search', file_ids: [fileId] }],\n});\n\n\u002F\u002F Returns immediately with status\nconsole.log(response.status); \u002F\u002F \"in_progress\"\nconsole.log(response.id); \u002F\u002F Use to check status later\n\n\u002F\u002F Poll for completion\nconst checkStatus = async (responseId) => {\n  const result = await openai.responses.retrieve(responseId);\n  if (result.status === 'completed') {\n    console.log(result.output_text);\n  } else if (result.status === 'failed') {\n    console.error('Task failed:', result.error);\n  } else {\n    \u002F\u002F Still running, check again later\n    setTimeout(() => checkStatus(responseId), 5000);\n  }\n};\n\ncheckStatus(response.id);\n```\n\n**When to Use:**\n- Large file processing\n- Complex calculations\n- Multi-step research tasks\n- Data analysis on large datasets\n\n**Timeout Limits:**\n- Standard mode: 60 seconds\n- Background mode: Up to 10 minutes\n\n---\n\n## Polymorphic Outputs\n\nThe Responses API returns **multiple output types** instead of a single message.\n\n### Output Types\n\n| Type | Description | Example |\n|------|-------------|---------|\n| `message` | Text response to user | Final answer, explanation |\n| `reasoning` | Model's internal thought process | Step-by-step reasoning summary |\n| `code_interpreter_call` | Code execution | Python code + results |\n| `mcp_call` | Tool invocation | Tool name, args, output |\n| `mcp_list_tools` | Available tools | Tool definitions from MCP server |\n| `file_search_call` | File search results | Matched chunks, citations |\n| `web_search_call` | Web search results | URLs, snippets |\n| `image_generation_call` | Image generation | Image URL |\n\n### Processing Polymorphic Outputs\n\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Search the web for the latest AI news and summarize',\n  tools: [{ type: 'web_search' }],\n});\n\n\u002F\u002F Process different output types\nresponse.output.forEach(item => {\n  switch (item.type) {\n    case 'reasoning':\n      console.log('Reasoning:', item.summary[0].text);\n      break;\n    case 'web_search_call':\n      console.log('Searched:', item.query);\n      console.log('Sources:', item.results);\n      break;\n    case 'message':\n      console.log('Response:', item.content[0].text);\n      break;\n  }\n});\n\n\u002F\u002F Or use helper for text-only\nconsole.log(response.output_text);\n```\n\n**Why This Matters:**\n- Better debugging (see all steps)\n- Audit trails (track all tool calls)\n- Richer UX (show progress to users)\n- Compliance (log all actions)\n\n---\n\n## Migration from Chat Completions\n\n### Breaking Changes\n\n| Feature | Chat Completions | Responses API | Migration |\n|---------|-----------------|---------------|-----------|\n| **Endpoint** | `\u002Fv1\u002Fchat\u002Fcompletions` | `\u002Fv1\u002Fresponses` | Update URL |\n| **Parameter** | `messages` | `input` | Rename parameter |\n| **State** | Manual (`messages` array) | Automatic (`conversation` ID) | Use conversation IDs |\n| **Tools** | `tools` array with functions | Built-in types + MCP | Update tool definitions |\n| **Output** | `choices[0].message.content` | `output_text` or `output` array | Update response parsing |\n| **Streaming** | `data: {\"choices\":[...]}` | SSE with multiple item types | Update stream parser |\n\n### Migration Example\n\n**Before (Chat Completions):**\n```typescript\nconst response = await openai.chat.completions.create({\n  model: 'gpt-5',\n  messages: [\n    { role: 'system', content: 'You are a helpful assistant.' },\n    { role: 'user', content: 'Hello!' },\n  ],\n});\n\nconsole.log(response.choices[0].message.content);\n```\n\n**After (Responses):**\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: [\n    { role: 'developer', content: 'You are a helpful assistant.' },\n    { role: 'user', content: 'Hello!' },\n  ],\n});\n\nconsole.log(response.output_text);\n```\n\n**Key Differences:**\n1. `chat.completions.create` → `responses.create`\n2. `messages` → `input`\n3. `system` role → `developer` role\n4. `choices[0].message.content` → `output_text`\n\n### When to Migrate\n\n**Migrate now if:**\n- ✅ Building new applications\n- ✅ Need stateful conversations\n- ✅ Using agentic patterns (reasoning + tools)\n- ✅ Want better performance (preserved reasoning)\n\n**Stay on Chat Completions if:**\n- ✅ Simple one-off generations\n- ✅ Legacy integrations\n- ✅ No need for state management\n\n---\n\n## Error Handling\n\n### Common Errors and Solutions\n\n#### 1. Session State Not Persisting\n\n**Error:**\n```\nConversation state not maintained between turns\n```\n\n**Cause:**\n- Not using conversation IDs\n- Using different conversation IDs per turn\n\n**Solution:**\n```typescript\n\u002F\u002F Create conversation once\nconst conv = await openai.conversations.create();\n\n\u002F\u002F Reuse conversation ID for all turns\nconst response1 = await openai.responses.create({\n  model: 'gpt-5',\n  conversation: conv.id, \u002F\u002F ✅ Same ID\n  input: 'First message',\n});\n\nconst response2 = await openai.responses.create({\n  model: 'gpt-5',\n  conversation: conv.id, \u002F\u002F ✅ Same ID\n  input: 'Follow-up message',\n});\n```\n\n#### 2. MCP Server Connection Failed\n\n**Error:**\n```json\n{\n  \"error\": {\n    \"type\": \"mcp_connection_error\",\n    \"message\": \"Failed to connect to MCP server\"\n  }\n}\n```\n\n**Causes:**\n- Invalid server URL\n- Missing or expired authorization token\n- Server not responding\n\n**Solutions:**\n```typescript\n\u002F\u002F 1. Verify URL is correct\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Test MCP',\n  tools: [\n    {\n      type: 'mcp',\n      server_label: 'test',\n      server_url: 'https:\u002F\u002Fapi.example.com\u002Fmcp', \u002F\u002F ✅ Full URL\n      authorization: process.env.AUTH_TOKEN, \u002F\u002F ✅ Valid token\n    },\n  ],\n});\n\n\u002F\u002F 2. Test server URL manually\nconst testResponse = await fetch('https:\u002F\u002Fapi.example.com\u002Fmcp');\nconsole.log(testResponse.status); \u002F\u002F Should be 200\n\n\u002F\u002F 3. Check token expiration\nconsole.log('Token expires:', parseJWT(token).exp);\n```\n\n#### 3. Code Interpreter Timeout\n\n**Error:**\n```json\n{\n  \"error\": {\n    \"type\": \"code_interpreter_timeout\",\n    \"message\": \"Code execution exceeded time limit\"\n  }\n}\n```\n\n**Cause:**\n- Code runs longer than 30 seconds\n\n**Solution:**\n```typescript\n\u002F\u002F Use background mode for long-running code\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Process this large dataset',\n  background: true, \u002F\u002F ✅ Extended timeout\n  tools: [{ type: 'code_interpreter' }],\n});\n\n\u002F\u002F Poll for results\nconst result = await openai.responses.retrieve(response.id);\n```\n\n#### 4. Image Generation Rate Limit\n\n**Error:**\n```json\n{\n  \"error\": {\n    \"type\": \"rate_limit_error\",\n    \"message\": \"DALL-E rate limit exceeded\"\n  }\n}\n```\n\n**Cause:**\n- Too many image generation requests\n\n**Solution:**\n```typescript\n\u002F\u002F Implement retry with exponential backoff\nconst generateImage = async (prompt, retries = 3) => {\n  try {\n    return await openai.responses.create({\n      model: 'gpt-5',\n      input: prompt,\n      tools: [{ type: 'image_generation' }],\n    });\n  } catch (error) {\n    if (error.type === 'rate_limit_error' && retries > 0) {\n      const delay = (4 - retries) * 1000; \u002F\u002F 1s, 2s, 3s\n      await new Promise(resolve => setTimeout(resolve, delay));\n      return generateImage(prompt, retries - 1);\n    }\n    throw error;\n  }\n};\n```\n\n#### 5. File Search Relevance Issues\n\n**Problem:**\n- File search returns irrelevant results\n\n**Solution:**\n```typescript\n\u002F\u002F Use more specific queries\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Find sections about pricing in Q4 2024 specifically', \u002F\u002F ✅ Specific\n  \u002F\u002F NOT: 'Find pricing' (too vague)\n  tools: [{ type: 'file_search', file_ids: [fileId] }],\n});\n\n\u002F\u002F Or filter results manually\nresponse.output.forEach(item => {\n  if (item.type === 'file_search_call') {\n    const relevantChunks = item.results.filter(\n      chunk => chunk.score > 0.7 \u002F\u002F ✅ Only high-confidence matches\n    );\n  }\n});\n```\n\n#### 6. Cost Tracking Confusion\n\n**Problem:**\n- Billing different than expected\n\n**Explanation:**\n- Responses API bills for: input tokens + output tokens + tool usage + stored conversations\n- Chat Completions bills only: input tokens + output tokens\n\n**Solution:**\n```typescript\n\u002F\u002F Monitor usage\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Hello',\n  store: false, \u002F\u002F ✅ Don't store if not needed\n});\n\nconsole.log('Usage:', response.usage);\n\u002F\u002F {\n\u002F\u002F   prompt_tokens: 10,\n\u002F\u002F   completion_tokens: 20,\n\u002F\u002F   tool_tokens: 5,\n\u002F\u002F   total_tokens: 35\n\u002F\u002F }\n```\n\n#### 7. Conversation Not Found\n\n**Error:**\n```json\n{\n  \"error\": {\n    \"type\": \"invalid_request_error\",\n    \"message\": \"Conversation conv_xyz not found\"\n  }\n}\n```\n\n**Causes:**\n- Conversation ID typo\n- Conversation deleted\n- Conversation expired (90 days)\n\n**Solution:**\n```typescript\n\u002F\u002F Verify conversation exists before using\nconst conversations = await openai.conversations.list();\nconst exists = conversations.data.some(c => c.id === 'conv_xyz');\n\nif (!exists) {\n  \u002F\u002F Create new conversation\n  const newConv = await openai.conversations.create();\n  \u002F\u002F Use newConv.id\n}\n```\n\n#### 8. Tool Output Parsing Failed\n\n**Problem:**\n- Can't access tool outputs correctly\n\n**Solution:**\n```typescript\n\u002F\u002F Use helper methods\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Search for AI news',\n  tools: [{ type: 'web_search' }],\n});\n\n\u002F\u002F Helper: Get text-only output\nconsole.log(response.output_text);\n\n\u002F\u002F Manual: Inspect all outputs\nresponse.output.forEach(item => {\n  console.log('Type:', item.type);\n  console.log('Content:', item);\n});\n```\n\n---\n\n## Production Patterns\n\n### Cost Optimization\n\n**1. Use Conversation IDs (Cache Benefits)**\n```typescript\n\u002F\u002F ✅ GOOD: Reuse conversation ID\nconst conv = await openai.conversations.create();\nconst response1 = await openai.responses.create({\n  model: 'gpt-5',\n  conversation: conv.id,\n  input: 'Question 1',\n});\n\u002F\u002F 40-80% better cache utilization\n\n\u002F\u002F ❌ BAD: New manual history each time\nconst response2 = await openai.responses.create({\n  model: 'gpt-5',\n  input: [...previousHistory, newMessage],\n});\n\u002F\u002F No cache benefits\n```\n\n**2. Disable Storage When Not Needed**\n```typescript\n\u002F\u002F For one-off requests\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Quick question',\n  store: false, \u002F\u002F ✅ Don't store conversation\n});\n```\n\n**3. Use Smaller Models When Possible**\n```typescript\n\u002F\u002F For simple tasks\nconst response = await openai.responses.create({\n  model: 'gpt-5-mini', \u002F\u002F ✅ 50% cheaper\n  input: 'Summarize this paragraph',\n});\n```\n\n### Rate Limit Handling\n\n```typescript\nconst createResponseWithRetry = async (params, maxRetries = 3) => {\n  for (let i = 0; i \u003C maxRetries; i++) {\n    try {\n      return await openai.responses.create(params);\n    } catch (error) {\n      if (error.type === 'rate_limit_error' && i \u003C maxRetries - 1) {\n        const delay = Math.pow(2, i) * 1000; \u002F\u002F Exponential backoff\n        console.log(`Rate limited, retrying in ${delay}ms`);\n        await new Promise(resolve => setTimeout(resolve, delay));\n      } else {\n        throw error;\n      }\n    }\n  }\n};\n```\n\n### Monitoring and Logging\n\n```typescript\nconst monitoredResponse = async (input) => {\n  const startTime = Date.now();\n\n  try {\n    const response = await openai.responses.create({\n      model: 'gpt-5',\n      input,\n    });\n\n    \u002F\u002F Log success metrics\n    console.log({\n      status: 'success',\n      latency: Date.now() - startTime,\n      tokens: response.usage.total_tokens,\n      model: response.model,\n      conversation: response.conversation_id,\n    });\n\n    return response;\n  } catch (error) {\n    \u002F\u002F Log error metrics\n    console.error({\n      status: 'error',\n      latency: Date.now() - startTime,\n      error: error.message,\n      type: error.type,\n    });\n    throw error;\n  }\n};\n```\n\n---\n\n## Node.js vs Cloudflare Workers\n\n### Node.js Implementation\n\n```typescript\nimport OpenAI from 'openai';\n\nconst openai = new OpenAI({\n  apiKey: process.env.OPENAI_API_KEY,\n});\n\nexport async function handleRequest(input: string) {\n  const response = await openai.responses.create({\n    model: 'gpt-5',\n    input,\n    tools: [{ type: 'web_search' }],\n  });\n\n  return response.output_text;\n}\n```\n\n**Pros:**\n- Full SDK support\n- Type safety\n- Streaming helpers\n\n**Cons:**\n- Requires Node.js runtime\n- Larger bundle size\n\n### Cloudflare Workers Implementation\n\n```typescript\nexport default {\n  async fetch(request: Request, env: Env): Promise\u003CResponse> {\n    const { input } = await request.json();\n\n    const response = await fetch('https:\u002F\u002Fapi.openai.com\u002Fv1\u002Fresponses', {\n      method: 'POST',\n      headers: {\n        'Authorization': `Bearer ${env.OPENAI_API_KEY}`,\n        'Content-Type': 'application\u002Fjson',\n      },\n      body: JSON.stringify({\n        model: 'gpt-5',\n        input,\n        tools: [{ type: 'web_search' }],\n      }),\n    });\n\n    const data = await response.json();\n\n    return new Response(data.output_text, {\n      headers: { 'Content-Type': 'text\u002Fplain' },\n    });\n  },\n};\n```\n\n**Pros:**\n- No dependencies\n- Edge deployment\n- Faster cold starts\n\n**Cons:**\n- Manual request building\n- No type safety without custom types\n\n---\n\n## Always Do \u002F Never Do\n\n### ✅ Always Do\n\n1. **Use conversation IDs for multi-turn interactions**\n   ```typescript\n   const conv = await openai.conversations.create();\n   \u002F\u002F Reuse conv.id for all related turns\n   ```\n\n2. **Handle all output types in polymorphic responses**\n   ```typescript\n   response.output.forEach(item => {\n     if (item.type === 'reasoning') { \u002F* log *\u002F }\n     if (item.type === 'message') { \u002F* display *\u002F }\n   });\n   ```\n\n3. **Use background mode for long-running tasks**\n   ```typescript\n   const response = await openai.responses.create({\n     background: true, \u002F\u002F ✅ For tasks >30s\n     ...\n   });\n   ```\n\n4. **Provide authorization tokens for MCP servers**\n   ```typescript\n   tools: [{\n     type: 'mcp',\n     authorization: process.env.TOKEN, \u002F\u002F ✅ Required\n   }]\n   ```\n\n5. **Monitor token usage for cost control**\n   ```typescript\n   console.log(response.usage.total_tokens);\n   ```\n\n### ❌ Never Do\n\n1. **Never expose API keys in client-side code**\n   ```typescript\n   \u002F\u002F ❌ DANGER: API key in browser\n   const response = await fetch('https:\u002F\u002Fapi.openai.com\u002Fv1\u002Fresponses', {\n     headers: { 'Authorization': 'Bearer sk-proj-...' }\n   });\n   ```\n\n2. **Never assume single message output**\n   ```typescript\n   \u002F\u002F ❌ BAD: Ignores reasoning, tool calls\n   console.log(response.output[0].content);\n\n   \u002F\u002F ✅ GOOD: Use helper or check all types\n   console.log(response.output_text);\n   ```\n\n3. **Never reuse conversation IDs across users**\n   ```typescript\n   \u002F\u002F ❌ DANGER: User A sees User B's conversation\n   const sharedConv = 'conv_123';\n   ```\n\n4. **Never ignore error types**\n   ```typescript\n   \u002F\u002F ❌ BAD: Generic error handling\n   try { ... } catch (e) { console.log('error'); }\n\n   \u002F\u002F ✅ GOOD: Type-specific handling\n   catch (e) {\n     if (e.type === 'rate_limit_error') { \u002F* retry *\u002F }\n     if (e.type === 'mcp_connection_error') { \u002F* alert *\u002F }\n   }\n   ```\n\n5. **Never poll faster than 1 second for background tasks**\n   ```typescript\n   \u002F\u002F ❌ BAD: Too frequent\n   setInterval(() => checkStatus(), 100);\n\n   \u002F\u002F ✅ GOOD: Reasonable interval\n   setInterval(() => checkStatus(), 5000);\n   ```\n\n---\n\n## References\n\n### Official Documentation\n- **Responses API Guide**: https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Fguides\u002Fresponses\n- **API Reference**: https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Fapi-reference\u002Fresponses\n- **MCP Integration**: https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Fguides\u002Ftools-connectors-mcp\n- **Blog Post (Why Responses API)**: https:\u002F\u002Fdevelopers.openai.com\u002Fblog\u002Fresponses-api\u002F\n- **Starter App**: https:\u002F\u002Fgithub.com\u002Fopenai\u002Fopenai-responses-starter-app\n\n### Skill Resources\n- `templates\u002F` - Working code examples\n- `references\u002Fresponses-vs-chat-completions.md` - Feature comparison\n- `references\u002Fmcp-integration-guide.md` - MCP server setup\n- `references\u002Fbuilt-in-tools-guide.md` - Tool usage patterns\n- `references\u002Fstateful-conversations.md` - Conversation management\n- `references\u002Fmigration-guide.md` - Chat Completions → Responses\n- `references\u002Ftop-errors.md` - Common errors and solutions\n\n---\n\n## Next Steps\n\n1. ✅ Read `templates\u002Fbasic-response.ts` - Simple example\n2. ✅ Try `templates\u002Fstateful-conversation.ts` - Multi-turn chat\n3. ✅ Explore `templates\u002Fmcp-integration.ts` - External tools\n4. ✅ Review `references\u002Ftop-errors.md` - Avoid common pitfalls\n5. ✅ Check `references\u002Fmigration-guide.md` - If migrating from Chat Completions\n\n**Happy building with the Responses API!** 🚀\n","# OpenAI Responses API\n\n**Status**: Production Ready\n**Last Updated**: 2025-10-25\n**API Launch**: March 2025\n**Dependencies**: openai@5.19.1+ (Node.js) or fetch API (Cloudflare Workers)\n\n---\n\n## What Is the Responses API?\n\nThe Responses API (`\u002Fv1\u002Fresponses`) is OpenAI's unified interface for building agentic applications, launched in March 2025. It fundamentally changes how you interact with OpenAI models by providing **stateful conversations** and a **structured loop for reasoning and acting**.\n\n### Key Innovation: Preserved Reasoning State\n\nUnlike Chat Completions where reasoning is discarded between turns, Responses **keeps the notebook open**. The model's step-by-step thought processes survive into the next turn, improving performance by approximately **5% on TAUBench** and enabling better multi-turn interactions.\n\n### Why Use Responses Over Chat Completions?\n\n| Feature | Chat Completions | Responses API | Benefit |\n|---------|-----------------|---------------|---------|\n| **State Management** | Manual (you track history) | Automatic (conversation IDs) | Simpler code, less error-prone |\n| **Reasoning** | Dropped between turns | Preserved across turns | Better multi-turn performance |\n| **Tools** | Client-side round trips | Server-side hosted | Lower latency, simpler code |\n| **Output Format** | Single message | Polymorphic (messages, reasoning, tool calls) | Richer debugging, better UX |\n| **Cache Utilization** | Baseline | 40-80% better | Lower costs, faster responses |\n| **MCP Support** | Manual integration | Built-in | Easy external tool connections |\n\n---\n\n## Quick Start (5 Minutes)\n\n### 1. Get API Key\n\n```bash\n# Sign up at https:\u002F\u002Fplatform.openai.com\u002F\n# Navigate to API Keys section\n# Create new key and save securely\nexport OPENAI_API_KEY=\"sk-proj-...\"\n```\n\n**Why this matters:**\n- API key required for all requests\n- Keep secure (never commit to git)\n- Use environment variables\n\n### 2. Install SDK (Node.js)\n\n```bash\nnpm install openai\n```\n\n```typescript\nimport OpenAI from 'openai';\n\nconst openai = new OpenAI({\n  apiKey: process.env.OPENAI_API_KEY,\n});\n\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'What are the 5 Ds of dodgeball?',\n});\n\nconsole.log(response.output_text);\n```\n\n**CRITICAL:**\n- Always use server-side (never expose API key in client code)\n- Model defaults to `gpt-5` (can use `gpt-5-mini`, `gpt-4o`, etc.)\n- `input` can be string or array of messages\n\n### 3. Or Use Direct API (Cloudflare Workers)\n\n```typescript\n\u002F\u002F No SDK needed - use fetch()\nconst response = await fetch('https:\u002F\u002Fapi.openai.com\u002Fv1\u002Fresponses', {\n  method: 'POST',\n  headers: {\n    'Authorization': `Bearer ${env.OPENAI_API_KEY}`,\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\n    model: 'gpt-5',\n    input: 'Hello, world!',\n  }),\n});\n\nconst data = await response.json();\nconsole.log(data.output_text);\n```\n\n**Why fetch?**\n- No dependencies in edge environments\n- Full control over request\u002Fresponse\n- Works in Cloudflare Workers, Deno, Bun\n\n---\n\n## Responses vs Chat Completions: Complete Comparison\n\n### When to Use Each\n\n**Use Responses API when:**\n- ✅ Building agentic applications (reasoning + actions)\n- ✅ Need preserved reasoning state across turns\n- ✅ Want built-in tools (Code Interpreter, File Search, Web Search)\n- ✅ Using MCP servers for external integrations\n- ✅ Implementing conversational AI with automatic state management\n- ✅ Background processing for long-running tasks\n- ✅ Need polymorphic outputs (messages, reasoning, tool calls)\n\n**Use Chat Completions when:**\n- ✅ Simple one-off text generation\n- ✅ Fully stateless interactions (no conversation continuity needed)\n- ✅ Legacy integrations (existing Chat Completions code)\n- ✅ Very simple use cases without tools\n\n### Architecture Differences\n\n**Chat Completions Flow:**\n```\nUser Input → Model → Single Message → Done\n(Reasoning discarded, state lost)\n```\n\n**Responses API Flow:**\n```\nUser Input → Model (preserved reasoning) → Polymorphic Outputs\n            ↓ (server-side tools)\n    Tool Call → Tool Result → Model → Final Response\n(Reasoning preserved, state maintained)\n```\n\n### Performance Benefits\n\n**Cache Utilization:**\n- Chat Completions: Baseline performance\n- Responses API: **40-80% better cache utilization**\n- Result: Lower latency + reduced costs\n\n**Reasoning Performance:**\n- Chat Completions: Reasoning dropped between turns\n- Responses API: Reasoning preserved across turns\n- Result: **5% better on TAUBench** (GPT-5 with Responses vs Chat Completions)\n\n---\n\n## Stateful Conversations\n\n### Automatic State Management\n\nThe Responses API can automatically manage conversation state using **conversation IDs**.\n\n#### Creating a Conversation\n\n```typescript\n\u002F\u002F Create conversation with initial message\nconst conversation = await openai.conversations.create({\n  metadata: { user_id: 'user_123' },\n  items: [\n    {\n      type: 'message',\n      role: 'user',\n      content: 'Hello!',\n    },\n  ],\n});\n\nconsole.log(conversation.id); \u002F\u002F \"conv_abc123...\"\n```\n\n#### Using Conversation ID\n\n```typescript\n\u002F\u002F First turn\nconst response1 = await openai.responses.create({\n  model: 'gpt-5',\n  conversation: 'conv_abc123',\n  input: 'What are the 5 Ds of dodgeball?',\n});\n\nconsole.log(response1.output_text);\n\n\u002F\u002F Second turn - model remembers previous context\nconst response2 = await openai.responses.create({\n  model: 'gpt-5',\n  conversation: 'conv_abc123',\n  input: 'Tell me more about the first one',\n});\n\nconsole.log(response2.output_text);\n\u002F\u002F Model automatically knows \"first one\" refers to first D from previous turn\n```\n\n**Why this matters:**\n- No manual history tracking required\n- Reasoning state preserved between turns\n- Automatic context management\n- Lower risk of context errors\n\n### Manual State Management (Alternative)\n\nIf you need full control, you can manually manage history:\n\n```typescript\nlet history = [\n  { role: 'user', content: 'Tell me a joke' },\n];\n\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: history,\n  store: true, \u002F\u002F Optional: store for retrieval later\n});\n\n\u002F\u002F Add response to history\nhistory = [\n  ...history,\n  ...response.output.map(el => ({\n    role: el.role,\n    content: el.content,\n  })),\n];\n\n\u002F\u002F Next turn\nhistory.push({ role: 'user', content: 'Tell me another' });\n\nconst secondResponse = await openai.responses.create({\n  model: 'gpt-5',\n  input: history,\n});\n```\n\n**When to use manual management:**\n- Need custom history pruning logic\n- Want to modify conversation history programmatically\n- Implementing custom caching strategies\n\n---\n\n## Built-in Tools (Server-Side)\n\nThe Responses API includes **server-side hosted tools** that eliminate costly backend round trips.\n\n### Available Tools\n\n| Tool | Purpose | Use Case |\n|------|---------|----------|\n| **Code Interpreter** | Execute Python code | Data analysis, calculations, charts |\n| **File Search** | RAG without vector stores | Search uploaded files for answers |\n| **Web Search** | Real-time web information | Current events, fact-checking |\n| **Image Generation** | DALL-E integration | Create images from descriptions |\n| **MCP** | Connect external tools | Stripe, databases, custom APIs |\n\n### Code Interpreter\n\nExecute Python code server-side for data analysis, calculations, and visualizations.\n\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Calculate the mean, median, and mode of: 10, 20, 30, 40, 50',\n  tools: [{ type: 'code_interpreter' }],\n});\n\nconsole.log(response.output_text);\n\u002F\u002F Model writes and executes Python code, returns results\n```\n\n**Advanced Example: Data Analysis**\n\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Analyze this sales data and create a bar chart showing monthly revenue: [data here]',\n  tools: [{ type: 'code_interpreter' }],\n});\n\n\u002F\u002F Check output for code execution results\nresponse.output.forEach(item => {\n  if (item.type === 'code_interpreter_call') {\n    console.log('Code executed:', item.input);\n    console.log('Result:', item.output);\n  }\n});\n```\n\n**Why this matters:**\n- No need to run Python locally\n- Sandboxed execution environment\n- Automatic chart generation\n- Can process uploaded files\n\n### File Search (RAG Without Vector Stores)\n\nSearch through uploaded files without building your own RAG pipeline.\n\n```typescript\n\u002F\u002F 1. Upload files first (one-time setup)\nconst file = await openai.files.create({\n  file: fs.createReadStream('knowledge-base.pdf'),\n  purpose: 'assistants',\n});\n\n\u002F\u002F 2. Use file search\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'What does the document say about pricing?',\n  tools: [\n    {\n      type: 'file_search',\n      file_ids: [file.id],\n    },\n  ],\n});\n\nconsole.log(response.output_text);\n\u002F\u002F Model searches file and provides answer with citations\n```\n\n**Supported File Types:**\n- PDFs, Word docs, text files\n- Markdown, HTML\n- Code files (Python, JavaScript, etc.)\n- Max: 512MB per file\n\n### Web Search\n\nGet real-time information from the web.\n\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'What are the latest updates on GPT-5?',\n  tools: [{ type: 'web_search' }],\n});\n\nconsole.log(response.output_text);\n\u002F\u002F Model searches web and provides current information with sources\n```\n\n**Why this matters:**\n- No cutoff date limitations\n- Automatic source citations\n- Real-time data access\n- No need for external search APIs\n\n### Image Generation (DALL-E)\n\nGenerate images directly in the Responses API.\n\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Create an image of a futuristic cityscape at sunset',\n  tools: [{ type: 'image_generation' }],\n});\n\n\u002F\u002F Find image in output\nresponse.output.forEach(item => {\n  if (item.type === 'image_generation_call') {\n    console.log('Image URL:', item.output.url);\n  }\n});\n```\n\n**Models Available:**\n- DALL-E 3 (default)\n- Various sizes and quality options\n\n---\n\n## MCP Server Integration\n\nThe Responses API has built-in support for **Model Context Protocol (MCP)** servers, allowing you to connect external tools.\n\n### What Is MCP?\n\nMCP is an open protocol that standardizes how applications provide context to LLMs. It allows you to:\n- Connect to external APIs (Stripe, databases, CRMs)\n- Use hosted MCP servers\n- Build custom tool integrations\n\n### Basic MCP Integration\n\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Roll 2d6 dice',\n  tools: [\n    {\n      type: 'mcp',\n      server_label: 'dice',\n      server_url: 'https:\u002F\u002Fexample.com\u002Fmcp',\n    },\n  ],\n});\n\n\u002F\u002F Model discovers available tools on MCP server and uses them\nconsole.log(response.output_text);\n```\n\n### MCP with Authentication (OAuth)\n\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Create a $20 payment link',\n  tools: [\n    {\n      type: 'mcp',\n      server_label: 'stripe',\n      server_url: 'https:\u002F\u002Fmcp.stripe.com',\n      authorization: process.env.STRIPE_OAUTH_TOKEN,\n    },\n  ],\n});\n\nconsole.log(response.output_text);\n\u002F\u002F Model uses Stripe MCP server to create payment link\n```\n\n**CRITICAL:**\n- API does NOT store authorization tokens\n- Must provide token with each request\n- Use environment variables for security\n\n### Polymorphic Output: MCP Tool Calls\n\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Roll 2d4+1',\n  tools: [\n    {\n      type: 'mcp',\n      server_label: 'dice',\n      server_url: 'https:\u002F\u002Fdmcp.example.com',\n    },\n  ],\n});\n\n\u002F\u002F Inspect tool calls\nresponse.output.forEach(item => {\n  if (item.type === 'mcp_call') {\n    console.log('Tool:', item.name);\n    console.log('Arguments:', item.arguments);\n    console.log('Output:', item.output);\n  }\n  if (item.type === 'mcp_list_tools') {\n    console.log('Available tools:', item.tools);\n  }\n});\n```\n\n**Output Types:**\n- `mcp_list_tools` - Tools discovered on server\n- `mcp_call` - Tool invocation and result\n- `message` - Final response to user\n\n---\n\n## Reasoning Preservation\n\n### How It Works\n\nThe Responses API preserves the model's **internal reasoning state** across turns, unlike Chat Completions which discards it.\n\n**Visual Analogy:**\n- **Chat Completions**: Model has a scratchpad, writes reasoning, then **tears out the page** before responding\n- **Responses API**: Model keeps the scratchpad open, **previous reasoning visible** for next turn\n\n### Performance Impact\n\n**TAUBench Results (GPT-5):**\n- Chat Completions: Baseline score\n- Responses API: **+5% better** (purely from preserved reasoning)\n\n**Why This Matters:**\n- Better multi-turn problem solving\n- More coherent long conversations\n- Improved step-by-step reasoning\n- Fewer context errors\n\n### Reasoning Summaries (Free!)\n\nThe Responses API provides **reasoning summaries** at no additional cost.\n\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Solve this complex math problem: [problem]',\n});\n\n\u002F\u002F Inspect reasoning\nresponse.output.forEach(item => {\n  if (item.type === 'reasoning') {\n    console.log('Model reasoning:', item.summary[0].text);\n  }\n  if (item.type === 'message') {\n    console.log('Final answer:', item.content[0].text);\n  }\n});\n```\n\n**Use Cases:**\n- Debugging model decisions\n- Audit trails for compliance\n- Understanding model thought process\n- Building transparent AI systems\n\n---\n\n## Background Mode (Long-Running Tasks)\n\nFor tasks that take longer than standard timeout limits, use **background mode**.\n\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Analyze this 500-page document and summarize key findings',\n  background: true,\n  tools: [{ type: 'file_search', file_ids: [fileId] }],\n});\n\n\u002F\u002F Returns immediately with status\nconsole.log(response.status); \u002F\u002F \"in_progress\"\nconsole.log(response.id); \u002F\u002F Use to check status later\n\n\u002F\u002F Poll for completion\nconst checkStatus = async (responseId) => {\n  const result = await openai.responses.retrieve(responseId);\n  if (result.status === 'completed') {\n    console.log(result.output_text);\n  } else if (result.status === 'failed') {\n    console.error('Task failed:', result.error);\n  } else {\n    \u002F\u002F Still running, check again later\n    setTimeout(() => checkStatus(responseId), 5000);\n  }\n};\n\ncheckStatus(response.id);\n```\n\n**When to Use:**\n- Large file processing\n- Complex calculations\n- Multi-step research tasks\n- Data analysis on large datasets\n\n**Timeout Limits:**\n- Standard mode: 60 seconds\n- Background mode: Up to 10 minutes\n\n---\n\n## Polymorphic Outputs\n\nThe Responses API returns **multiple output types** instead of a single message.\n\n### Output Types\n\n| Type | Description | Example |\n|------|-------------|---------|\n| `message` | Text response to user | Final answer, explanation |\n| `reasoning` | Model's internal thought process | Step-by-step reasoning summary |\n| `code_interpreter_call` | Code execution | Python code + results |\n| `mcp_call` | Tool invocation | Tool name, args, output |\n| `mcp_list_tools` | Available tools | Tool definitions from MCP server |\n| `file_search_call` | File search results | Matched chunks, citations |\n| `web_search_call` | Web search results | URLs, snippets |\n| `image_generation_call` | Image generation | Image URL |\n\n### Processing Polymorphic Outputs\n\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Search the web for the latest AI news and summarize',\n  tools: [{ type: 'web_search' }],\n});\n\n\u002F\u002F Process different output types\nresponse.output.forEach(item => {\n  switch (item.type) {\n    case 'reasoning':\n      console.log('Reasoning:', item.summary[0].text);\n      break;\n    case 'web_search_call':\n      console.log('Searched:', item.query);\n      console.log('Sources:', item.results);\n      break;\n    case 'message':\n      console.log('Response:', item.content[0].text);\n      break;\n  }\n});\n\n\u002F\u002F Or use helper for text-only\nconsole.log(response.output_text);\n```\n\n**Why This Matters:**\n- Better debugging (see all steps)\n- Audit trails (track all tool calls)\n- Richer UX (show progress to users)\n- Compliance (log all actions)\n\n---\n\n## Migration from Chat Completions\n\n### Breaking Changes\n\n| Feature | Chat Completions | Responses API | Migration |\n|---------|-----------------|---------------|-----------|\n| **Endpoint** | `\u002Fv1\u002Fchat\u002Fcompletions` | `\u002Fv1\u002Fresponses` | Update URL |\n| **Parameter** | `messages` | `input` | Rename parameter |\n| **State** | Manual (`messages` array) | Automatic (`conversation` ID) | Use conversation IDs |\n| **Tools** | `tools` array with functions | Built-in types + MCP | Update tool definitions |\n| **Output** | `choices[0].message.content` | `output_text` or `output` array | Update response parsing |\n| **Streaming** | `data: {\"choices\":[...]}` | SSE with multiple item types | Update stream parser |\n\n### Migration Example\n\n**Before (Chat Completions):**\n```typescript\nconst response = await openai.chat.completions.create({\n  model: 'gpt-5',\n  messages: [\n    { role: 'system', content: 'You are a helpful assistant.' },\n    { role: 'user', content: 'Hello!' },\n  ],\n});\n\nconsole.log(response.choices[0].message.content);\n```\n\n**After (Responses):**\n```typescript\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: [\n    { role: 'developer', content: 'You are a helpful assistant.' },\n    { role: 'user', content: 'Hello!' },\n  ],\n});\n\nconsole.log(response.output_text);\n```\n\n**Key Differences:**\n1. `chat.completions.create` → `responses.create`\n2. `messages` → `input`\n3. `system` role → `developer` role\n4. `choices[0].message.content` → `output_text`\n\n### When to Migrate\n\n**Migrate now if:**\n- ✅ Building new applications\n- ✅ Need stateful conversations\n- ✅ Using agentic patterns (reasoning + tools)\n- ✅ Want better performance (preserved reasoning)\n\n**Stay on Chat Completions if:**\n- ✅ Simple one-off generations\n- ✅ Legacy integrations\n- ✅ No need for state management\n\n---\n\n## Error Handling\n\n### Common Errors and Solutions\n\n#### 1. Session State Not Persisting\n\n**Error:**\n```\nConversation state not maintained between turns\n```\n\n**Cause:**\n- Not using conversation IDs\n- Using different conversation IDs per turn\n\n**Solution:**\n```typescript\n\u002F\u002F Create conversation once\nconst conv = await openai.conversations.create();\n\n\u002F\u002F Reuse conversation ID for all turns\nconst response1 = await openai.responses.create({\n  model: 'gpt-5',\n  conversation: conv.id, \u002F\u002F ✅ Same ID\n  input: 'First message',\n});\n\nconst response2 = await openai.responses.create({\n  model: 'gpt-5',\n  conversation: conv.id, \u002F\u002F ✅ Same ID\n  input: 'Follow-up message',\n});\n```\n\n#### 2. MCP Server Connection Failed\n\n**Error:**\n```json\n{\n  \"error\": {\n    \"type\": \"mcp_connection_error\",\n    \"message\": \"Failed to connect to MCP server\"\n  }\n}\n```\n\n**Causes:**\n- Invalid server URL\n- Missing or expired authorization token\n- Server not responding\n\n**Solutions:**\n```typescript\n\u002F\u002F 1. Verify URL is correct\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Test MCP',\n  tools: [\n    {\n      type: 'mcp',\n      server_label: 'test',\n      server_url: 'https:\u002F\u002Fapi.example.com\u002Fmcp', \u002F\u002F ✅ Full URL\n      authorization: process.env.AUTH_TOKEN, \u002F\u002F ✅ Valid token\n    },\n  ],\n});\n\n\u002F\u002F 2. Test server URL manually\nconst testResponse = await fetch('https:\u002F\u002Fapi.example.com\u002Fmcp');\nconsole.log(testResponse.status); \u002F\u002F Should be 200\n\n\u002F\u002F 3. Check token expiration\nconsole.log('Token expires:', parseJWT(token).exp);\n```\n\n#### 3. Code Interpreter Timeout\n\n**Error:**\n```json\n{\n  \"error\": {\n    \"type\": \"code_interpreter_timeout\",\n    \"message\": \"Code execution exceeded time limit\"\n  }\n}\n```\n\n**Cause:**\n- Code runs longer than 30 seconds\n\n**Solution:**\n```typescript\n\u002F\u002F Use background mode for long-running code\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Process this large dataset',\n  background: true, \u002F\u002F ✅ Extended timeout\n  tools: [{ type: 'code_interpreter' }],\n});\n\n\u002F\u002F Poll for results\nconst result = await openai.responses.retrieve(response.id);\n```\n\n#### 4. Image Generation Rate Limit\n\n**Error:**\n```json\n{\n  \"error\": {\n    \"type\": \"rate_limit_error\",\n    \"message\": \"DALL-E rate limit exceeded\"\n  }\n}\n```\n\n**Cause:**\n- Too many image generation requests\n\n**Solution:**\n```typescript\n\u002F\u002F Implement retry with exponential backoff\nconst generateImage = async (prompt, retries = 3) => {\n  try {\n    return await openai.responses.create({\n      model: 'gpt-5',\n      input: prompt,\n      tools: [{ type: 'image_generation' }],\n    });\n  } catch (error) {\n    if (error.type === 'rate_limit_error' && retries > 0) {\n      const delay = (4 - retries) * 1000; \u002F\u002F 1s, 2s, 3s\n      await new Promise(resolve => setTimeout(resolve, delay));\n      return generateImage(prompt, retries - 1);\n    }\n    throw error;\n  }\n};\n```\n\n#### 5. File Search Relevance Issues\n\n**Problem:**\n- File search returns irrelevant results\n\n**Solution:**\n```typescript\n\u002F\u002F Use more specific queries\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Find sections about pricing in Q4 2024 specifically', \u002F\u002F ✅ Specific\n  \u002F\u002F NOT: 'Find pricing' (too vague)\n  tools: [{ type: 'file_search', file_ids: [fileId] }],\n});\n\n\u002F\u002F Or filter results manually\nresponse.output.forEach(item => {\n  if (item.type === 'file_search_call') {\n    const relevantChunks = item.results.filter(\n      chunk => chunk.score > 0.7 \u002F\u002F ✅ Only high-confidence matches\n    );\n  }\n});\n```\n\n#### 6. Cost Tracking Confusion\n\n**Problem:**\n- Billing different than expected\n\n**Explanation:**\n- Responses API bills for: input tokens + output tokens + tool usage + stored conversations\n- Chat Completions bills only: input tokens + output tokens\n\n**Solution:**\n```typescript\n\u002F\u002F Monitor usage\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Hello',\n  store: false, \u002F\u002F ✅ Don't store if not needed\n});\n\nconsole.log('Usage:', response.usage);\n\u002F\u002F {\n\u002F\u002F   prompt_tokens: 10,\n\u002F\u002F   completion_tokens: 20,\n\u002F\u002F   tool_tokens: 5,\n\u002F\u002F   total_tokens: 35\n\u002F\u002F }\n```\n\n#### 7. Conversation Not Found\n\n**Error:**\n```json\n{\n  \"error\": {\n    \"type\": \"invalid_request_error\",\n    \"message\": \"Conversation conv_xyz not found\"\n  }\n}\n```\n\n**Causes:**\n- Conversation ID typo\n- Conversation deleted\n- Conversation expired (90 days)\n\n**Solution:**\n```typescript\n\u002F\u002F Verify conversation exists before using\nconst conversations = await openai.conversations.list();\nconst exists = conversations.data.some(c => c.id === 'conv_xyz');\n\nif (!exists) {\n  \u002F\u002F Create new conversation\n  const newConv = await openai.conversations.create();\n  \u002F\u002F Use newConv.id\n}\n```\n\n#### 8. Tool Output Parsing Failed\n\n**Problem:**\n- Can't access tool outputs correctly\n\n**Solution:**\n```typescript\n\u002F\u002F Use helper methods\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Search for AI news',\n  tools: [{ type: 'web_search' }],\n});\n\n\u002F\u002F Helper: Get text-only output\nconsole.log(response.output_text);\n\n\u002F\u002F Manual: Inspect all outputs\nresponse.output.forEach(item => {\n  console.log('Type:', item.type);\n  console.log('Content:', item);\n});\n```\n\n---\n\n## Production Patterns\n\n### Cost Optimization\n\n**1. Use Conversation IDs (Cache Benefits)**\n```typescript\n\u002F\u002F ✅ GOOD: Reuse conversation ID\nconst conv = await openai.conversations.create();\nconst response1 = await openai.responses.create({\n  model: 'gpt-5',\n  conversation: conv.id,\n  input: 'Question 1',\n});\n\u002F\u002F 40-80% better cache utilization\n\n\u002F\u002F ❌ BAD: New manual history each time\nconst response2 = await openai.responses.create({\n  model: 'gpt-5',\n  input: [...previousHistory, newMessage],\n});\n\u002F\u002F No cache benefits\n```\n\n**2. Disable Storage When Not Needed**\n```typescript\n\u002F\u002F For one-off requests\nconst response = await openai.responses.create({\n  model: 'gpt-5',\n  input: 'Quick question',\n  store: false, \u002F\u002F ✅ Don't store conversation\n});\n```\n\n**3. Use Smaller Models When Possible**\n```typescript\n\u002F\u002F For simple tasks\nconst response = await openai.responses.create({\n  model: 'gpt-5-mini', \u002F\u002F ✅ 50% cheaper\n  input: 'Summarize this paragraph',\n});\n```\n\n### Rate Limit Handling\n\n```typescript\nconst createResponseWithRetry = async (params, maxRetries = 3) => {\n  for (let i = 0; i \u003C maxRetries; i++) {\n    try {\n      return await openai.responses.create(params);\n    } catch (error) {\n      if (error.type === 'rate_limit_error' && i \u003C maxRetries - 1) {\n        const delay = Math.pow(2, i) * 1000; \u002F\u002F Exponential backoff\n        console.log(`Rate limited, retrying in ${delay}ms`);\n        await new Promise(resolve => setTimeout(resolve, delay));\n      } else {\n        throw error;\n      }\n    }\n  }\n};\n```\n\n### Monitoring and Logging\n\n```typescript\nconst monitoredResponse = async (input) => {\n  const startTime = Date.now();\n\n  try {\n    const response = await openai.responses.create({\n      model: 'gpt-5',\n      input,\n    });\n\n    \u002F\u002F Log success metrics\n    console.log({\n      status: 'success',\n      latency: Date.now() - startTime,\n      tokens: response.usage.total_tokens,\n      model: response.model,\n      conversation: response.conversation_id,\n    });\n\n    return response;\n  } catch (error) {\n    \u002F\u002F Log error metrics\n    console.error({\n      status: 'error',\n      latency: Date.now() - startTime,\n      error: error.message,\n      type: error.type,\n    });\n    throw error;\n  }\n};\n```\n\n---\n\n## Node.js vs Cloudflare Workers\n\n### Node.js Implementation\n\n```typescript\nimport OpenAI from 'openai';\n\nconst openai = new OpenAI({\n  apiKey: process.env.OPENAI_API_KEY,\n});\n\nexport async function handleRequest(input: string) {\n  const response = await openai.responses.create({\n    model: 'gpt-5',\n    input,\n    tools: [{ type: 'web_search' }],\n  });\n\n  return response.output_text;\n}\n```\n\n**Pros:**\n- Full SDK support\n- Type safety\n- Streaming helpers\n\n**Cons:**\n- Requires Node.js runtime\n- Larger bundle size\n\n### Cloudflare Workers Implementation\n\n```typescript\nexport default {\n  async fetch(request: Request, env: Env): Promise\u003CResponse> {\n    const { input } = await request.json();\n\n    const response = await fetch('https:\u002F\u002Fapi.openai.com\u002Fv1\u002Fresponses', {\n      method: 'POST',\n      headers: {\n        'Authorization': `Bearer ${env.OPENAI_API_KEY}`,\n        'Content-Type': 'application\u002Fjson',\n      },\n      body: JSON.stringify({\n        model: 'gpt-5',\n        input,\n        tools: [{ type: 'web_search' }],\n      }),\n    });\n\n    const data = await response.json();\n\n    return new Response(data.output_text, {\n      headers: { 'Content-Type': 'text\u002Fplain' },\n    });\n  },\n};\n```\n\n**Pros:**\n- No dependencies\n- Edge deployment\n- Faster cold starts\n\n**Cons:**\n- Manual request building\n- No type safety without custom types\n\n---\n\n## Always Do \u002F Never Do\n\n### ✅ Always Do\n\n1. **Use conversation IDs for multi-turn interactions**\n   ```typescript\n   const conv = await openai.conversations.create();\n   \u002F\u002F Reuse conv.id for all related turns\n   ```\n\n2. **Handle all output types in polymorphic responses**\n   ```typescript\n   response.output.forEach(item => {\n     if (item.type === 'reasoning') { \u002F* log *\u002F }\n     if (item.type === 'message') { \u002F* display *\u002F }\n   });\n   ```\n\n3. **Use background mode for long-running tasks**\n   ```typescript\n   const response = await openai.responses.create({\n     background: true, \u002F\u002F ✅ For tasks >30s\n     ...\n   });\n   ```\n\n4. **Provide authorization tokens for MCP servers**\n   ```typescript\n   tools: [{\n     type: 'mcp',\n     authorization: process.env.TOKEN, \u002F\u002F ✅ Required\n   }]\n   ```\n\n5. **Monitor token usage for cost control**\n   ```typescript\n   console.log(response.usage.total_tokens);\n   ```\n\n### ❌ Never Do\n\n1. **Never expose API keys in client-side code**\n   ```typescript\n   \u002F\u002F ❌ DANGER: API key in browser\n   const response = await fetch('https:\u002F\u002Fapi.openai.com\u002Fv1\u002Fresponses', {\n     headers: { 'Authorization': 'Bearer sk-proj-...' }\n   });\n   ```\n\n2. **Never assume single message output**\n   ```typescript\n   \u002F\u002F ❌ BAD: Ignores reasoning, tool calls\n   console.log(response.output[0].content);\n\n   \u002F\u002F ✅ GOOD: Use helper or check all types\n   console.log(response.output_text);\n   ```\n\n3. **Never reuse conversation IDs across users**\n   ```typescript\n   \u002F\u002F ❌ DANGER: User A sees User B's conversation\n   const sharedConv = 'conv_123';\n   ```\n\n4. **Never ignore error types**\n   ```typescript\n   \u002F\u002F ❌ BAD: Generic error handling\n   try { ... } catch (e) { console.log('error'); }\n\n   \u002F\u002F ✅ GOOD: Type-specific handling\n   catch (e) {\n     if (e.type === 'rate_limit_error') { \u002F* retry *\u002F }\n     if (e.type === 'mcp_connection_error') { \u002F* alert *\u002F }\n   }\n   ```\n\n5. **Never poll faster than 1 second for background tasks**\n   ```typescript\n   \u002F\u002F ❌ BAD: Too frequent\n   setInterval(() => checkStatus(), 100);\n\n   \u002F\u002F ✅ GOOD: Reasonable interval\n   setInterval(() => checkStatus(), 5000);\n   ```\n\n---\n\n## References\n\n### Official Documentation\n- **Responses API Guide**: https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Fguides\u002Fresponses\n- **API Reference**: https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Fapi-reference\u002Fresponses\n- **MCP Integration**: https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Fguides\u002Ftools-connectors-mcp\n- **Blog Post (Why Responses API)**: https:\u002F\u002Fdevelopers.openai.com\u002Fblog\u002Fresponses-api\u002F\n- **Starter App**: https:\u002F\u002Fgithub.com\u002Fopenai\u002Fopenai-responses-starter-app\n\n### Skill Resources\n- `templates\u002F` - Working code examples\n- `references\u002Fresponses-vs-chat-completions.md` - Feature comparison\n- `references\u002Fmcp-integration-guide.md` - MCP server setup\n- `references\u002Fbuilt-in-tools-guide.md` - Tool usage patterns\n- `references\u002Fstateful-conversations.md` - Conversation management\n- `references\u002Fmigration-guide.md` - Chat Completions → Responses\n- `references\u002Ftop-errors.md` - Common errors and solutions\n\n---\n\n## Next Steps\n\n1. ✅ Read `templates\u002Fbasic-response.ts` - Simple example\n2. ✅ Try `templates\u002Fstateful-conversation.ts` - Multi-turn chat\n3. ✅ Explore `templates\u002Fmcp-integration.ts` - External tools\n4. ✅ Review `references\u002Ftop-errors.md` - Avoid common pitfalls\n5. ✅ Check `references\u002Fmigration-guide.md` - If migrating from Chat Completions\n\n**Happy building with the Responses API!** 🚀\n",{"name":5,"license":14,"description":23},"This skill provides comprehensive knowledge for working with OpenAI's Responses API, the unified stateful API for building agentic applications. It should be used when building AI agents that preserve reasoning across turns, integrating MCP servers for external tools, using built-in tools (Code Interpreter, File Search, Web Search, Image Generation), managing stateful conversations, implementing background processing, or migrating from Chat Completions API.\n\nUse when building agentic workflows, conversational AI with memory, tools-based applications, RAG systems, data analysis agents, or any application requiring OpenAI's reasoning models with persistent state. Covers both Node.js SDK and Cloudflare Workers implementations.\n\nKeywords: responses api, openai responses, stateful openai, openai mcp, code interpreter openai, file search openai, web search openai, image generation openai, reasoning preservation, agentic workflows, conversation state, background mode, chat completions migration, gpt-5, polymorphic outputs\n","main","45d5ac830c3e238eeba6d0b4e6fd7cf6b56bf380","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn","2026-09-09 16:05:56",{"source":8,"skillName":5,"commands":30,"prompt":40,"zipAvailable":41},[31,34,37],{"tool":32,"command":33},"npx","npx skills add davidanthonyn\u002Fclaude-skills --skill openai-responses",{"tool":35,"command":36},"bunx","bunx skills add davidanthonyn\u002Fclaude-skills --skill openai-responses",{"tool":38,"command":39},"pnpm","pnpm dlx skills add davidanthonyn\u002Fclaude-skills --skill openai-responses","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fopenai-responses\u002FSKILL.md",true,[43,49,53],{"path":44,"resourceType":45,"resourceTypeDesc":46,"sizeBytes":47,"sourceHtmlUrl":48},"README.md","REFERENCE","参考文档",12006,"https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fopenai-responses\u002FREADME.md",{"path":50,"resourceType":45,"resourceTypeDesc":46,"sizeBytes":51,"sourceHtmlUrl":52},"SKILL.json",34122,"https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fopenai-responses\u002FSKILL.json",{"path":54,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":57,"sourceHtmlUrl":58},"SKILL.md.backup","OTHER","其他",31289,"https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fopenai-responses\u002FSKILL.md.backup",[60,67,75,82,89,98],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":18},"01M7AQPHJF528A4MD52YZEZV3R","zustand-state-management","Production-tested setup for Zustand state management in React applications with TypeScript.\nThis skill provides comprehensive patterns for building scalable, type-safe global state.\n\nUse when: setting up global state in React, migrating from Redux or Context API, implementing\nstate persistence with localStorage, configuring TypeScript with Zustand, using slices pattern\nfor modular stores, adding devtools middleware for debugging, handling Next.js SSR hydration,\nor encountering hydration errors, TypeScript inference issues, or persist middleware problems.\n\nPrevents 5 documented issues: Next.js hydration mismatches, TypeScript double parentheses\nsyntax errors, persist middleware export errors, infinite render loops, and slices pattern\ntype inference failures.\n\nKeywords: zustand, state management, React state, TypeScript state, persist middleware,\ndevtools, slices pattern, global state, React hooks, create store, useBoundStore,\nStateCreator, hydration error, text content mismatch, infinite render, localStorage,\nsessionStorage, immer middleware, shallow equality, selector pattern, zustand v5","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fzustand-state-management\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":71,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":18},"01M7AQP2XJRPNYEH323GJ81NN5","zetic-mlange","Help users integrate the ZETIC Melange (MLange) on-device AI SDK into Android (Kotlin\u002FJava) and iOS (Swift) mobile apps. Use this skill whenever the user mentions Zetic, MLange, Melange, ZeticMLangeModel, ZeticMLangeLLMModel, ZeticMLangeHFModel, on-device NPU inference for mobile, or deploying ML models to Android\u002FiOS with NPU acceleration. Also trigger when users ask about running LLMs on-device with GGUF quantization, mobile NPU model deployment, or converting PyTorch\u002FONNX models for mobile inference. Covers general model inference, LLM inference (streaming token generation), and HuggingFace model loading.","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fzetic-mlange\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fzetic-mlange\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":18},"01M7AQNEJHD27NNF5PYQDSW8B9","youtube-downloader","Download videos, audio, playlists, and channels from YouTube and 1000+ websites using yt-dlp. Supports quality selection, format conversion, subtitle download, playlist filtering, metadata extraction, thumbnail download, and batch operations. Use when downloading YouTube videos in any quality (4K, 8K, HDR), extracting audio as MP3\u002FM4A\u002FFLAC, downloading entire playlists\u002Fchannels, getting subtitles in multiple languages, converting to specific formats, downloading live streams, archiving content, or batch processing multiple URLs. Optimized for reliability with automatic retries, rate limiting, and error handling.","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fyoutube-downloader\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":18},"01M7AQJQSD2H04EE2EPNAQ8A3M","wordpress-plugin-core","This skill provides comprehensive knowledge for WordPress plugin development, covering core patterns, security best practices, database interactions, hooks\u002Ffilters, Settings API, custom post types, REST API, and AJAX. This skill should be used when creating WordPress plugins, troubleshooting security issues, implementing custom post types\u002Ftaxonomies, building admin interfaces, or working with the WordPress database.\n\nUse when: Creating new WordPress plugins, implementing nonces\u002Fsanitization\u002Fescaping, working with $wpdb and prepared statements, building Settings API pages, registering custom post types or taxonomies, implementing REST API endpoints, handling AJAX requests, debugging plugin activation\u002Fdeactivation issues, preventing SQL injection\u002FXSS\u002FCSRF vulnerabilities.\n\nKeywords: wordpress plugin development, wordpress security, wordpress hooks, wordpress filters, wordpress database, wpdb prepare, sanitize_text_field, esc_html, wp_nonce, custom post type, register_post_type, settings api, rest api, admin-ajax, wordpress sql injection, wordpress xss, wordpress csrf, plugin header, activation hook, deactivation hook, wordpress coding standards, wordpress plugin architecture","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fwordpress-plugin-core\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":93,"licenseFileUrl":94,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":18},"01M7AQJ91T970QCFMN9R1EHZXV","webapp-testing","Test local web applications with Playwright. Use when asked to verify frontend functionality, debug UI behavior, capture browser screenshots, or inspect browser logs.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":18},"01M7AQJ5E89MS8C5K3GZTY4B48","web-performance-audit","Audit web performance using Chrome DevTools MCP. Use when asked to audit, profile, debug, or optimize page load performance, Lighthouse scores, or site speed.","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fweb-performance-audit\u002FSKILL.md",[],[]]