openai-responses
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. 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. 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
What this skill does
# OpenAI Responses API **Status**: Production Ready **Last Updated**: 2025-10-25 **API Launch**: March 2025 **Dependencies**: [email protected]+ (Node.js) or fetch API (Cloudflare Workers) --- ## What Is the Responses API? The Responses API (`/v1/responses`) 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**. ### Key Innovation: Preserved Reasoning State Unlike 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. ### Why Use Responses Over Chat Completions? | Feature | Chat Completions | Responses API | Benefit | |---------|-----------------|---------------|---------| | **State Management** | Manual (you track history) | Automatic (conversation IDs) | Simpler code, less error-prone | | **Reasoning** | Dropped between turns | Preserved across turns | Better multi-turn performance | | **Tools** | Client-side round trips | Server-side hosted | Lower latency, simpler code | | **Output Format** | Single message | Polymorphic (messages, reasoning, tool calls) | Richer debugging, better UX | | **Cache Utilization** | Baseline | 40-80% better | Lower costs, faster responses | | **MCP Support** | Manual integration | Built-in | Easy external tool connections | --- ## Quick Start (5 Minutes) ### 1. Get API Key ```bash # Sign up at https://platform.openai.com/ # Navigate to API Keys section # Create new key and save securely export OPENAI_API_KEY="sk-proj-..." ``` **Why this matters:** - API key required for all requests - Keep secure (never commit to git) - Use environment variables ### 2. Install SDK (Node.js) ```bash npm install openai ``` ```typescript import OpenAI from 'openai'; const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY, }); const response = await openai.responses.create({ model: 'gpt-5', input: 'What are the 5 Ds of dodgeball?', }); console.log(response.output_text); ``` **CRITICAL:** - Always use server-side (never expose API key in client code) - Model defaults to `gpt-5` (can use `gpt-5-mini`, `gpt-4o`, etc.) - `input` can be string or array of messages ### 3. Or Use Direct API (Cloudflare Workers) ```typescript // No SDK needed - use fetch() const response = await fetch('https://api.openai.com/v1/responses', { method: 'POST', headers: { 'Authorization': `Bearer ${env.OPENAI_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ model: 'gpt-5', input: 'Hello, world!', }), }); const data = await response.json(); console.log(data.output_text); ``` **Why fetch?** - No dependencies in edge environments - Full control over request/response - Works in Cloudflare Workers, Deno, Bun --- ## Responses vs Chat Completions: Complete Comparison ### When to Use Each **Use Responses API when:** - ✅ Building agentic applications (reasoning + actions) - ✅ Need preserved reasoning state across turns - ✅ Want built-in tools (Code Interpreter, File Search, Web Search) - ✅ Using MCP servers for external integrations - ✅ Implementing conversational AI with automatic state management - ✅ Background processing for long-running tasks - ✅ Need polymorphic outputs (messages, reasoning, tool calls) **Use Chat Completions when:** - ✅ Simple one-off text generation - ✅ Fully stateless interactions (no conversation continuity needed) - ✅ Legacy integrations (existing Chat Completions code) - ✅ Very simple use cases without tools ### Architecture Differences **Chat Completions Flow:** ``` User Input → Model → Single Message → Done (Reasoning discarded, state lost) ``` **Responses API Flow:** ``` User Input → Model (preserved reasoning) → Polymorphic Outputs ↓ (server-side tools) Tool Call → Tool Result → Model → Final Response (Reasoning preserved, state maintained) ``` ### Performance Benefits **Cache Utilization:** - Chat Completions: Baseline performance - Responses API: **40-80% better cache utilization** - Result: Lower latency + reduced costs **Reasoning Performance:** - Chat Completions: Reasoning dropped between turns - Responses API: Reasoning preserved across turns - Result: **5% better on TAUBench** (GPT-5 with Responses vs Chat Completions) --- ## Stateful Conversations ### Automatic State Management The Responses API can automatically manage conversation state using **conversation IDs**. #### Creating a Conversation ```typescript // Create conversation with initial message const conversation = await openai.conversations.create({ metadata: { user_id: 'user_123' }, items: [ { type: 'message', role: 'user', content: 'Hello!', }, ], }); console.log(conversation.id); // "conv_abc123..." ``` #### Using Conversation ID ```typescript // First turn const response1 = await openai.responses.create({ model: 'gpt-5', conversation: 'conv_abc123', input: 'What are the 5 Ds of dodgeball?', }); console.log(response1.output_text); // Second turn - model remembers previous context const response2 = await openai.responses.create({ model: 'gpt-5', conversation: 'conv_abc123', input: 'Tell me more about the first one', }); console.log(response2.output_text); // Model automatically knows "first one" refers to first D from previous turn ``` **Why this matters:** - No manual history tracking required - Reasoning state preserved between turns - Automatic context management - Lower risk of context errors ### Manual State Management (Alternative) If you need full control, you can manually manage history: ```typescript let history = [ { role: 'user', content: 'Tell me a joke' }, ]; const response = await openai.responses.create({ model: 'gpt-5', input: history, store: true, // Optional: store for retrieval later }); // Add response to history history = [ ...history, ...response.output.map(el => ({ role: el.role, content: el.content, })), ]; // Next turn history.push({ role: 'user', content: 'Tell me another' }); const secondResponse = await openai.responses.create({ model: 'gpt-5', input: history, }); ``` **When to use manual management:** - Need custom history pruning logic - Want to modify conversation history programmatically - Implementing custom caching strategies --- ## Built-in Tools (Server-Side) The Responses API includes **server-side hosted tools** that eliminate costly backend round trips. ### Available Tools | Tool | Purpose | Use Case | |------|---------|----------| | **Code Interpreter** | Execute Python code | Data analysis, calculations, charts | | **File Search** | RAG without vector stores | Search uploaded files for answers | | **Web Search** | Real-time web information | Current events, fact-checking | | **Image Generation** | DALL-E integration | Create images from descriptions | | **MCP** | Connect external tools | Stripe, databases, custom APIs | ### Code Interpreter Execute Python code server-side for data analysis, calculations, and visualizations. ```typescript const response = await openai.responses.create({ model: 'gpt-5', input: 'Calculate the mean, median, and mode of: 10, 20, 30, 40, 50', tools: [{ type: 'code_interpreter' }], }); console.log(response.output_text); // Model writes and executes Python code, returns results ``` **Advanced Example: Data Analysis** ```typescript const response = await openai.responses.create({ model: 'gpt-5', input: 'Analyze this sales data and create a bar chart showing monthly revenue: [data here]', tools: [{ type: 'code_interpreter' }], }); // Check output for code execution results response.output.forEach(item => { if (item.type === 'code_interpreter_call') { console.log('Code executed:', item
Related in Image & Video
watch
IncludedWatch a video (URL or local path). Downloads with yt-dlp, extracts auto-scaled frames with ffmpeg, pulls the transcript from captions (or Whisper API fallback), and hands the result to Claude so it can answer questions about what's in the video.
physical-ai-defect-image-generation
IncludedUse when the user wants to orchestrate defect image generation, run associated setup, or handle outputs on OSMO. The Day 0 path handles cold-start with USD-to-ROI, image-edit augmentation, and AnomalyGen to create initial PCBA datasets. The Day 1 path performs inference and labeling on real images. This skill helps with first-time asset setup, creation of finetuning checkpoints, and configuring deployment. Trigger keywords: defect image generation, dig workflow, dig pipeline, defect image detection workflow, aoi pipeline, aoi anomalygen, usd2roi anomalygen, day 0 pcba, day 1 pcba, day 1 real-photo alignment, day 1 manual roi, metal surface anomaly, glass defect, anomalygen finetune, setup_pcb, setup_metal, setup_glass, setup_pretrained, dig setup, dig datasets, dig pretrained checkpoint, dig image-edit endpoint.
accelint-react-best-practices
IncludedReact performance optimization and best practices. ALWAYS use this skill when working with any React code - writing components, hooks, JSX; refactoring; optimizing re-renders, memoization, state management; reviewing for performance; fixing hydration mismatches; debugging infinite re-renders, stale closures, input focus loss, animations restarting; preventing remounting; implementing transitions, lazy initialization, effect dependencies. Even simple React tasks benefit from these patterns. Covers React 19+ (useEffectEvent, Activity, ref props). Triggers - useEffect, useState, useMemo, useCallback, memo, inline components, nested components, components inside components, re-render, performance, hydration, SSR, Next.js, useDeferredValue, combined hooks.
elevenlabs-agents
IncludedBuild conversational AI voice agents with ElevenLabs Platform using React, JavaScript, React Native, or Swift SDKs. Configure agents, tools (client/server/MCP), RAG knowledge bases, multi-voice, and Scribe real-time STT. Use when: building voice chat interfaces, implementing AI phone agents with Twilio, configuring agent workflows or tools, adding RAG knowledge bases, testing with CLI "agents as code", or troubleshooting deprecated @11labs packages, Android audio cutoff, CSP violations, dynamic variables, or WebRTC config. Keywords: ElevenLabs Agents, ElevenLabs voice agents, AI voice agents, conversational AI, @elevenlabs/react, @elevenlabs/client, @elevenlabs/react-native, @elevenlabs/elevenlabs-js, @elevenlabs/agents-cli, elevenlabs SDK, voice AI, TTS, text-to-speech, ASR, speech recognition, turn-taking model, WebRTC voice, WebSocket voice, ElevenLabs conversation, agent system prompt, agent tools, agent knowledge base, RAG voice agents, multi-voice agents, pronunciation dictionary, voice speed control, elevenlabs scribe, @11labs deprecated, Android audio cutoff, CSP violation elevenlabs, dynamic variables elevenlabs, case-sensitive tool names, webhook authentication
humanizer
IncludedHumanize AI-generated text by detecting and removing patterns typical of LLM output. Rewrites text to sound natural, specific, and human. Uses 28 pattern detectors, 560+ AI vocabulary terms across 3 tiers, and statistical analysis (burstiness, type-token ratio, readability) for comprehensive detection. Use when asked to humanize text, de-AI writing, make content sound more natural/human, review writing for AI patterns, score text for AI detection, or improve AI-generated drafts. Covers content, language, style, communication, and filler categories.
generating-mermaid-diagrams
IncludedSalesforce architecture diagrams using Mermaid with ASCII fallback. Use this skill when generating text-based diagrams for Salesforce architecture, OAuth flows, ERDs, integration sequences, or Agentforce structure. TRIGGER when: user says "diagram", "visualize", "ERD", or asks for sequence diagrams, flowcharts, class diagrams, or architecture visualizations in Mermaid. DO NOT TRIGGER when: user wants PNG/SVG image output (use generating-visual-diagrams), or asks about non-Salesforce systems.