← Back to dashboard

OpenAI Integration Guide

What is the OpenAI API?

The real model

GPT-6 on Responses: strict schemas, Decisions, webhooks, agents.

Use `responses.parse` + `zodTextFormat` for typed output (`gpt-6-luna`, $0.10/$0.50 per 1M tokens). GPT-6 rejects `temperature`/`top_p` when reasoning is on, and Astra and 6.1 Sol reject effort `none`. The Decisions API (beta, Luna only) returns probabilities, choices, or scores for fast routing. Webhooks follow Standard Webhooks: verify the raw body with `client.webhooks.unwrap`. Voice uses Realtime (`gpt-realtime-2.1`) or GPT-Live. Agents run on the Agents SDK (your loop) or the hosted Agents API (managed Codex harness). GPT-4o shuts down on 2027-01-14, and its replacement is `gpt-6-luna`. In openai v7, `{ body }` as create()'s second argument replaces the whole request.

Five OpenAI primitives

One Responses API across GPT-6 models. Pick the tier, then the output mode.

Text
 ██████╗ ██████╗ ███████╗███╗   ██╗ █████╗ ██╗
██╔═══██╗██╔══██╗██╔════╝████╗  ██║██╔══██╗██║
██║   ██║██████╔╝█████╗  ██╔██╗ ██║███████║██║
██║   ██║██╔═══╝ ██╔══╝  ██║╚██╗██║██╔══██║██║
╚██████╔╝██║     ███████╗██║ ╚████║██║  ██║██║
 ╚═════╝ ╚═╝     ╚══════╝╚═╝  ╚═══╝╚═╝  ╚═╝╚═╝

OpenAI Integration Guide

Focus: Using OpenAI as codeAmani's secondary AI provider — GPT-6 models on the Responses API, Structured Outputs, the Decisions API for routing, built-in tools and remote MCP, webhooks, and the Agents SDK — alongside Claude in Claude Code workflows.

Overview

Claude Code and OpenAI are complementary. OpenAI's current models — the GPT-6 family (gpt-6-astra, gpt-6.1-sol, gpt-6-sol, gpt-6-luna), with GPT-5.6 (gpt-5.6-sol / -terra / -luna) still fully supported — are called through the openai SDK or the Vercel AI SDK. New work targets the Responses API (client.responses). OpenAI's wording: "While Chat Completions remains supported, Responses is recommended for all new projects." For GPT-6 it is more than a recommendation: tool calling with reasoning only works on Responses.

Here is where OpenAI sits as the secondary provider: reach for it when structured output, fast classification, or function calling matters, while Claude stays primary for reasoning.

Official Documentation

Docs domain note: platform.openai.com/docs/* links still resolve, but the canonical docs live on developers.openai.com. Every docs page has a Markdown version: append .md to its URL. Codex docs under developers.openai.com/codex/* now redirect to learn.chatgpt.com/docs/*.


Models at a glance (verified 2026-10-20)

Standard pricing per 1M tokens, short context (≤272K input tokens). Long-context requests cost more; Batch and Flex halve the rates; Fast mode doubles them. Full table: reference/pricing-snapshot.md.

TierModel idInput / cached / outputUse it for
Flagshipgpt-6-astra$10.00 / $1.00 / $50.00Hardest end-to-end work. Claude is codeAmani's primary here.
Balancedgpt-6.1-sol$2.00 / $0.10 / $10.00Complex extraction and agentic work at lower cost ("near-Astra").
Coding/agenticgpt-6-sol$2.00 / $0.20 / $10.00Superseded for most work by gpt-6.1-sol.
Budgetgpt-6-luna$0.10 / $0.01 / $0.50codeAmani default for structured output, extraction, routing. The only Decisions API model.
Previous familygpt-5.6-sol (alias gpt-5.6), gpt-5.6-terra, gpt-5.6-luna$4/$20, $2/$12, $0.20/$1.20Still supported. Sol's promotional price runs "at least through November 21, 2026".
Embeddingstext-embedding-3-small (1536), text-embedding-3-large (3072)$0.02, $0.13RAG / semantic search. Unchanged.
Imagesgpt-image-2.5-flare, gpt-image-2.5-sunburst, gpt-image-2token-pricedFlare for everyday generation, Sunburst for precise edits.
Voicegpt-realtime-2.1, gpt-realtime-2.1-mini, gpt-live-1see pricingSpeech-to-speech agents; GPT-Live is $0.05/min plus backend usage.
Transcriptiongpt-transcribe, gpt-live-transcribe$0.0045/min, $0.017/minReplace whisper-1 and gpt-4o-*-transcribe (shut down 2027-02-26).

All GPT-6 models have a 1,050,000-token context window and 128,000 max output tokens. They accept text and image input and support Structured Outputs and function calling.

GPT-6 differences that break old code (from the "Using GPT-6" guide):

  • reasoning.effort takes low, medium (default), high, xhigh, or max. gpt-6-astra and gpt-6.1-sol reject none; gpt-6-sol and gpt-6-luna accept it. Replace minimal with low.
  • When effort isn't none, remove temperature, top_p and top_logprobs (and logprobs on Chat Completions).
  • Tool calling needs the Responses API. On Chat Completions, gpt-6-sol and gpt-6-luna call functions only with reasoning_effort: "none".
  • Prompt caching: on GPT-5.6 and later, prompt_cache_options.ttl (only "30m") replaces prompt_cache_retention, and cache writes bill at 1.25× the input rate.
  • GPT-6 models publish no dated snapshot IDs yet (the model pages list only the alias). Pin by evaluating, not by date.

Deprecations you will hit (from the deprecations page)

ShutdownWhatReplacement
Already goneAssistants API (2026-08-26), Sora 2 + Videos API (2026-09-24), Realtime API beta header (2026-05-12), DALL·E 2/3 (2026-05-12)Responses + Conversations; no video replacement; Realtime GA; GPT Image
2026-10-23o4-mini, o3-mini, o1, gpt-4.1-nano, gpt-4-turbo, gpt-3.5-turbo, gpt-4o-2024-05-13, gpt-image-1gpt-5.6-terra / gpt-5.6-sol / gpt-5.6-luna / GPT Image 2.5
2026-11-30Reusable prompts (v1/prompts), Evals platform, Agent BuilderPrompts in your code; Promptfoo; Agents SDK
2026-12-01gpt-image-1-mini, gpt-image-1.5, chatgpt-image-latestgpt-image-2.5-flare / -sunburst
2026-12-11gpt-5-2025-08-07 (+ mini/nano/pro), o3, o3-proGPT-5.6 Sol / Terra / Luna
2027-01-14gpt-4o (2024-08-06, 2024-11-20), gpt-4o-mini, gpt-4.1, gpt-4.1-minigpt-6-luna
2027-01-06New fine-tuning jobs for existing customers (closed to new orgs since 2026-05-07); tts-1, tts-1-hd, gpt-4o-mini-ttsPrompting + Structured Outputs; gpt-realtime-2.1-mini
2027-04-01gpt-5.1, gpt-5.3-codex, gpt-5.4-nanogpt-6-sol / gpt-6-luna

To monitor shutdowns in code, GET /v1/models returns an optional shutdown_date per model.


OpenAI SDK Integration

Here is how a Responses call travels from your app through the SDK to the model and back.

Node.js / TypeScript

Bash
npm install openai   # 7.39.0 verified 2026-10-20 — requires Node >= 22; zod ^3.25 || ^4 for helpers
TypeScript
import OpenAI from "openai";

const client = new OpenAI(); // reads OPENAI_API_KEY; server-side only

const response = await client.responses.create({
  model: "gpt-6-luna",
  reasoning: { effort: "low" },
  instructions: "You are a TypeScript expert.",
  input: "Convert this class to use composition over inheritance.",
});

console.log(response.output_text);

v7 gotcha — the second argument is RequestOptions, not extra params. The SDK builds the request as { body, ...options }, so client.responses.create(params, { body: { foo: 1 } }) sends only { foo: 1 } and drops your model, input and tools. Put extra or undocumented fields in the first argument (with // @ts-expect-error if the types don't know them yet); use the second for headers, timeout, maxRetries, signal, and idempotencyKey.

Chat Completions still works, without tools on GPT-6 reasoning models:

TypeScript
const completion = await client.chat.completions.create({
  model: "gpt-6-luna",
  reasoning_effort: "low",
  messages: [
    { role: "system", content: "You are a TypeScript expert." },
    { role: "user", content: "Convert this class to use composition over inheritance." },
  ],
});
console.log(completion.choices[0]?.message.content);

Python

Bash
pip install openai   # 3.35.1 verified 2026-10-20 — requires Python >= 3.10
Python
import os
from openai import OpenAI

client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])

response = client.responses.create(
    model="gpt-6-luna",
    input="Generate unit tests for this function.",
)
print(response.output_text)

CLI

OpenAI now ships an official CLI (brew install openai/tools/openai) for shell workflows:

Bash
openai responses create --model "gpt-6-luna" --input "Summarise this diff" --raw-output \
  --transform 'output.#(type=="message").content.0.text'

On Windows or in CI, a curl to https://api.openai.com/v1/responses with Authorization: Bearer $OPENAI_API_KEY works anywhere; read .output_text from the JSON.


Structured output & function calling

This is the main reason OpenAI is codeAmani's secondary provider. With a strict JSON schema the model is guaranteed to emit JSON that matches it, and the SDK hands you a typed object. Structured Outputs work on every current model (GPT-4o 2024-08-06 and later, all GPT-5.x and GPT-6).

(a) Structured output — Responses API

TypeScript
import OpenAI from "openai";
import { zodTextFormat } from "openai/helpers/zod";
import { z } from "zod";

const client = new OpenAI();

// Extract order data from a free-text payment SMS (Kenya-targeted projects only;
// US projects get the same pattern for Stripe receipts or invoices).
const OrderExtraction = z.object({
  amount_kes: z.number().int(),       // Daraja amounts are integer KES
  phone: z.string(),                   // normalise to 254XXXXXXXXX downstream
  reference: z.string(),
  confidence: z.enum(["high", "medium", "low"]),
});

const response = await client.responses.parse({
  model: "gpt-6-luna",
  reasoning: { effort: "low" },
  store: false,
  input: [
    { role: "system", content: "Extract the payment fields from the message." },
    { role: "user", content: "Got KES 1500 from 0712345678 ref INV-204" },
  ],
  text: { format: zodTextFormat(OrderExtraction, "order_extraction") },
});

const order = response.output_parsed; // typed, or null on refusal
if (order) console.log(order.amount_kes, order.phone, order.confidence);

(b) Function calling — Responses API

Function tools use the flat shape (type: "function" at the top level, strict: true). Calls come back as function_call items in response.output, with name, call_id, and arguments as a JSON string. Validate the arguments with Zod before you act on them. See examples/structured-output.ts.

GPT-6 adds async tool calling (async: true on a function tool lets the model keep working while your code runs it) and Programmatic Tool Calling (the model writes JavaScript that orchestrates several tool calls). Both are Responses-only.

Strict-schema gotcha: every property must be listed in required. Model an optional field as z.union([T, z.null()]), not .optional(), and keep additionalProperties: false.

(c) Classify or route? Use the Decisions API (beta)

For "which team gets this ticket?" or "is this photo damaged?", the Decisions API (client.decisions.create, POST /v1/decisions) returns typed answers "about 10x faster than the Responses API". It has three question types: predicate (a probability), choice (one of 2–255 values), and score (ordered levels). Only gpt-6-luna is supported, and it needs openai ≥ 7.30.0 (JS) or ≥ 3.26.0 (Python). See examples/decisions-routing.ts. Use Structured Outputs when you need to generate an object.

(d) Vercel AI SDK 7

codeAmani apps usually call models through the AI SDK, so switching providers is a one-line model change. With ai 7.0.146 and @ai-sdk/openai 4.0.98 (verified 2026-10-20):

TypeScript
import { openai } from "@ai-sdk/openai";
import { generateText, Output } from "ai";
import { z } from "zod";

const { output } = await generateText({
  model: openai("gpt-6-luna"),            // Responses API by default; openai.chat(...) for Chat Completions
  output: Output.object({ schema: z.object({ intent: z.enum(["demo", "pricing", "support"]) }) }),
  prompt: "Classify: 'Can I get a quote for 50 seats?'",
  providerOptions: { openai: { reasoningEffort: "low", store: false } },
});

generateObject and streamObject are deprecated (AI SDK 6); use generateText / streamText with output. AI SDK 7 removed experimental_output; read result.output. See examples/ai-sdk-structured.ts.


Conversation state

There are three ways to carry context between turns:

ApproachHowStorage
ManualResend the message array each turnNothing stored by OpenAI if store: false
Chainingprevious_response_id: prev.idResponses are stored 30 days by default (store: true)
Conversations APIconst c = await client.conversations.create({}), then responses.create({ conversation: c.id, ... })Items persist until deleted, with no 30-day TTL. Not ZDR-eligible.

The Assistants API (threads, runs) shut down on 2026-08-26. Migrate threads to the Conversations API using the Assistants migration guide.

For long jobs, set background: true and either poll client.responses.retrieve(id) or subscribe to the response.completed webhook (below).


Built-in tools

Responses API built-in tools (from the tools guide): web search (now with image results), file search, remote MCP servers, skills, shell (hosted container or local), computer use, image generation, tool search, Programmatic Tool Calling, plus Code Interpreter. They bill at the model's token rates plus per-tool fees, e.g. web search at $10 per 1K calls, file search at $2.50 per 1K calls plus $0.10/GB-day storage, and containers from $0.03 per 1 GB per 20-minute session (billed per minute, 5-minute minimum).

Image generation

Use the Image API (client.images.generate({ model: "gpt-image-2.5-flare", prompt }), which returns b64_json) for one-shot images. Use the Responses image_generation tool for multi-turn editing:

TypeScript
const res = await client.responses.create({
  model: "gpt-6-luna",
  input: "A clean product photo of a reusable water bottle on white",
  tools: [{ type: "image_generation", model: "gpt-image-2.5-flare" }],
});
const b64 = res.output.find((o) => o.type === "image_generation_call")?.result;

GPT Image models may require API Organization Verification. Transparent backgrounds (background: "transparent" with png/webp) are in preview for gpt-image-2. There is no video API: Sora 2 and the Videos API shut down 2026-09-24.

Voice: Realtime API and GPT-Live

  • Realtime API (GA): speech-to-speech agents over WebRTC (browser) or WebSocket (server). Your server mints an ephemeral key via POST /v1/realtime/client_secrets; the browser connects with RealtimeSession from @openai/agents/realtime, using gpt-realtime-2.1. The beta interface (OpenAI-Beta: realtime=v1) was removed 2026-05-12.
  • GPT-Live (gpt-live-1, GA 2026-09-10): full-duplex voice that delegates work to a backend Responses model or your own agent. It costs $0.05/min, billed per second, plus backend usage.
  • Send a stable OpenAI-Safety-Identifier header for per-end-user enforcement.

MCP integration — the Responses API mcp tool

The OpenAI model acts as an MCP client. You give it a remote MCP server URL and it lists and calls that server's tools itself.

TypeScript
import OpenAI from "openai";

const client = new OpenAI();

const resp = await client.responses.create({
  model: "gpt-6.1-sol",
  tools: [
    {
      type: "mcp",
      server_label: "openai_docs",
      server_description: "Search and read the public OpenAI documentation.",
      server_url: "https://developers.openai.com/mcp",
      allowed_tools: ["search_openai_docs"],
      require_approval: "never", // read-only public server; use "always" for anything that writes
    },
  ],
  input: "Find the Responses API streaming docs and return the links.",
});

console.log(resp.output_text);
  • Approvals: by default the API asks for approval before sending data to an MCP server and emits an mcp_approval_request item. Reply in the next request with an mcp_approval_response item.
  • Connectors: OpenAI-hosted connectors (connector_id: "connector_googledrive", connector_gmail, connector_dropbox, and others, each with an OAuth authorization token) are deprecated for models released after 2026-09-01. For new models, use server_url, or tunnel_id with Secure MCP Tunnel for private or on-prem servers.
  • Data you send to a third-party MCP server falls under their retention policy, not OpenAI's.
  • Never give a third-party MCP server your OPENAI_API_KEY.

The other direction: to give Claude Code or Codex your tools, build a standard MCP server (see the repo's MCP guides). Codex itself is an MCP client: codex mcp add <name> --url https://... or [mcp_servers.<name>] in ~/.codex/config.toml. The old codex mcp-server command has been removed; use the Codex app server.


Webhooks (with signature verification)

OpenAI webhooks follow the Standard Webhooks spec, with webhook-id, webhook-timestamp, and webhook-signature headers. Create an endpoint in the dashboard (Project → Webhooks) to get a signing secret. You can only view it once.

Events include response.completed / .failed / .cancelled / .incomplete, batch.*, fine_tuning.job.*, realtime.call.incoming, Agents API session events, and safety alerts.

TypeScript
// app/api/webhooks/openai/route.ts — full version in examples/webhook-route.ts
import OpenAI from "openai";

const client = new OpenAI({ webhookSecret: process.env.OPENAI_WEBHOOK_SECRET });

export async function POST(req: Request): Promise<Response> {
  const raw = await req.text(); // verify the RAW body, never parsed JSON
  try {
    const event = await client.webhooks.unwrap(raw, req.headers);
    if (event.type === "response.completed") {
      // enqueue work keyed on event.data.id; dedupe on the webhook-id header
    }
    return new Response(null, { status: 200 });
  } catch (err) {
    if (err instanceof OpenAI.InvalidWebhookSignatureError) {
      return new Response("Invalid signature", { status: 400 });
    }
    throw err;
  }
}

Return 2xx within a few seconds. Failed or slow deliveries are retried with exponential backoff for up to 72 hours, 3xx redirects are not followed, and duplicate deliveries can happen, so dedupe on webhook-id. client.webhooks.verifySignature(raw, headers) verifies without parsing.


Agents: Agents SDK, Agents API, Codex

You want toUse
Run the agent loop in your app (tools, handoffs, approvals, your storage)Agents SDK: npm install @openai/agents zod (0.20.0, pre-1.0, pin exactly) / pip install openai-agents (0.24.0)
Let OpenAI run a managed Codex harness plus sandbox, with durable sessionsAgents API (public beta since 2026-09-10): client.beta.agents.sessions.create(...)
Call models directly and build your own loopResponses API
Drive coding tasks from CI or scriptsCodex SDK: npm install @openai/codex-sdk (0.163.0, Node ≥ 18) or the codex CLI
TypeScript
import { Agent, run, tool } from "@openai/agents";
import { z } from "zod";

const orderStatus = tool({
  name: "order_status",
  description: "Look up an order's status by reference.",
  parameters: z.object({ reference: z.string() }),
  async execute({ reference }) { return `Order ${reference}: shipped`; },
});

const agent = new Agent({ name: "Support", instructions: "Answer briefly.", model: "gpt-6-luna", tools: [orderStatus] });
const result = await run(agent, "Where is order INV-9?");
console.log(result.finalOutput);

Agent Builder shuts down 2026-11-30. OpenAI points its users to the Agents SDK. ChatKit remains available.


Data controls (ZDR, retention, residency)

  • Training: API data isn't used for training unless you opt in.
  • Abuse-monitoring logs are kept up to 30 days for most endpoints.
  • Zero Data Retention and Modified Abuse Monitoring need sales approval. Under ZDR, store is always treated as false on /v1/responses and /v1/chat/completions.
  • Not ZDR-eligible (they store state until you delete it): Conversations, /v1/agents, vector stores, files, batches, /v1/audio/voices, ChatKit threads. ZDR-eligible: Responses, Chat Completions, Decisions, embeddings, images, audio, moderations, Realtime, and GPT-Live (with limits).
  • Responses store: the default true keeps responses for at least 30 days. Background mode writes to disk for about 10 minutes.
  • Prompt caching: without ZDR, extended (24h) caching is the default.
  • Data residency: set per project, by sales eligibility. Use regional hosts such as us.api.openai.com / eu.api.openai.com per request (since 2026-08-21) with a Global-geography project key. Regional endpoints carry a 10% uplift for models released on or after 2026-03-05.
  • HIPAA: eligible orgs can accept the BAA in Organization settings (since 2026-10-05).

codeAmani default: send store: false for one-shot extraction, and only use Conversations when you need durable chat history.


Environment Variables

Secrets only — keep these server-side:

Bash
OPENAI_API_KEY=sk-proj-...
OPENAI_WEBHOOK_SECRET=whsec_...

Optional secret, only for scripts that call the Admin API (usage, costs, key management):

Bash
OPENAI_ADMIN_KEY=sk-admin-...

Non-secret settings (the SDK reads them automatically when set):

VariablePurposeDefault
OPENAI_ORG_IDOrganization for billing attributionaccount default
OPENAI_PROJECT_IDProject scopingkey's project
OPENAI_BASE_URLOverride the API host (e.g. a regional host or a gateway)https://api.openai.com/v1

Store secrets in .env.local and the Vercel dashboard (see ENV_MASTER.md). Never ship them to the browser. Project keys can now have expiry dates, and orgs can restrict key creation. Trusted workloads can also use workload identity federation instead of long-lived keys.


Automation Workflows

Dual-provider review hook

Use a Claude Code Stop hook to send a summary to OpenAI for a cross-model review.

.claude/settings.json:

JSON
{
  "hooks": {
    "Stop": [
      { "hooks": [{ "type": "command", "command": "node scripts/openai-second-opinion.mjs" }] }
    ]
  }
}

scripts/openai-second-opinion.mjs:

JavaScript
import OpenAI from "openai";
import { readFileSync } from "node:fs";

const client = new OpenAI();
const sessionLog = readFileSync(".claude/session.log", "utf-8");

const result = await client.responses.create({
  model: "gpt-6.1-sol",
  instructions: "Review this Claude Code session for potential issues.",
  input: sessionLog,
  store: false,
});

console.log("GPT-6.1 Sol review:", result.output_text);

CI: OpenAI code-quality gate

YAML
# .github/workflows/ai-review.yml
name: AI Code Review
on: [pull_request]

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4   # pin to a commit SHA per the SLSA policy
        with: { fetch-depth: 0 }
      - name: Get diff
        run: git diff origin/${{ github.base_ref }}...HEAD > diff.txt
      - name: OpenAI review
        env:
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
        run: |
          pip install "openai==3.35.1"
          python scripts/review.py diff.txt

Common Use Cases

Use caseApproach
Structured extractionresponses.parse + zodTextFormat on gpt-6-luna (step up to gpt-6.1-sol)
Ticket / lead routing, moderation-style yes/noDecisions API on gpt-6-luna
Vision / OCRinput_image parts on any GPT-6 model
Embeddings for searchtext-embedding-3-small → pgvector
Imagesgpt-image-2.5-flare via Image API or the Responses tool
Voice agentRealtime API (gpt-realtime-2.1) or GPT-Live
Transcriptiongpt-transcribe (files) / gpt-live-transcribe (streaming)
Fine-tuningDon't start new work. Fine-tuning is closed to new orgs; use prompting plus Structured Outputs
Cross-model validationClaude drafts, GPT-6.1 Sol validates

Troubleshooting

IssueFix
401 UnauthorizedCheck OPENAI_API_KEY, project permissions, key expiry, and the org's IP allowlist
model_not_found / shut-down modelCheck the deprecations table above; GET /v1/models shows shutdown_date
400 on temperature / top_pGPT-6 with reasoning effort ≠ none rejects them; remove them
400 on reasoning.effort: "none"gpt-6-astra and gpt-6.1-sol don't support none; use low
Tools ignored on Chat CompletionsMove to the Responses API (GPT-6 tool calling requires it)
Request sent with missing fieldsYou passed { body } as the 2nd arg to create(); it replaced the whole body (v7)
output_parsed is nullThe model refused; inspect response.output for a refusal item
Strict-schema errorEvery property in required; nullable unions instead of .optional(); additionalProperties: false
429 slow_down / 503 server_is_overloadedHonour Retry-After, else back off exponentially. A 429 can also mean a hard spend limit was hit
Webhook "Invalid signature"Verify the raw text body (don't let a JSON parser consume it) and check the secret is for the right project
Rate-limit tiersNow three tiers: Build ($5 credit), Launch ($100), Grow ($500). See the rate-limits guide

codeAmani notes

  • Role: OpenAI is the secondary provider (CLAUDE.md AI Routing Policy). Claude handles complex reasoning and code generation; OpenAI handles structured output, function calling, fast classification (Decisions API), embeddings, and image or voice features.
  • Routing-policy drift (for the user to decide): CLAUDE.md names "OpenAI GPT-4o" for structured output. GPT-4o is deprecated: its snapshots shut down 2027-01-14, and OpenAI's named replacement is gpt-6-luna. This guide uses gpt-6-luna as the default and gpt-6.1-sol for harder cases. CLAUDE.md was not edited; see NOTES.md.
  • Secrets are server-side only: OPENAI_API_KEY, OPENAI_WEBHOOK_SECRET, and OPENAI_ADMIN_KEY live in .env.local / Vercel env, never in client bundles. Browser voice clients get short-lived Realtime client secrets minted by your server.
  • Webhooks: verify signatures before processing (repo security rule), dedupe on webhook-id, and keep the route under app/api/webhooks/.
  • Payments: Stripe is the default rail. M-Pesa / Daraja applies only to Kenya-targeted projects. The KES SMS-extraction example above is for those projects; keep amounts as integer KES and phones as 254XXXXXXXXX.
  • Kenya-targeted / low-bandwidth apps: prefer gpt-6-luna or the Decisions API for latency and cost, stream text responses, and keep voice features optional. GPT-Live adds per-minute cost on top of backend usage.
  • Data: default to store: false. Conversations, vector stores, and files persist until deleted and are not ZDR-eligible, so add deletion to your data-retention jobs.