import y from"@contractspec/lib.ui-link";import{ChevronRight as z}from"lucide-react";import{jsx as f,jsxs as q}from"react/jsx-runtime";function E(){return q("div",{className:"space-y-8",children:[q("div",{className:"space-y-4",children:[f("h1",{className:"font-bold text-4xl",children:"OpenAI"}),f("p",{className:"text-muted-foreground",children:"Integrate OpenAI's powerful AI models for chat completion, embeddings, and speech-to-text. Build intelligent features with GPT-4, generate embeddings for semantic search, and transcribe audio with Whisper."})]}),q("div",{className:"space-y-4",children:[f("h2",{className:"font-bold text-2xl",children:"Setup"}),f("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:f("pre",{children:`# .env
OPENAI_API_KEY=sk-...
OPENAI_ORGANIZATION=org-...`})})]}),q("div",{className:"space-y-4",children:[f("h2",{className:"font-bold text-2xl",children:"Chat completions"}),f("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:f("pre",{children:`capabilityId: openai-chat
provider:
  type: openai
  operation: chatCompletion

inputs:
  messages:
    type: array
    items:
      type: object
      properties:
        role: string
        content: string
  model:
    type: string
    default: "gpt-4"
  temperature:
    type: number
    default: 0.7
    optional: true

outputs:
  content:
    type: string
  usage:
    type: object`})})]}),q("div",{className:"space-y-4",children:[f("h2",{className:"font-bold text-2xl",children:"Embeddings"}),f("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:f("pre",{children:`capabilityId: openai-embeddings
provider:
  type: openai
  operation: createEmbedding

inputs:
  text:
    type: string
  model:
    type: string
    default: "text-embedding-3-small"

outputs:
  embedding:
    type: array
    items:
      type: number`})})]}),q("div",{className:"space-y-4",children:[f("h2",{className:"font-bold text-2xl",children:"Whisper (Speech-to-Text)"}),f("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:f("pre",{children:`capabilityId: openai-transcribe
provider:
  type: openai
  operation: transcribe

inputs:
  audioFile:
    type: file
  language:
    type: string
    optional: true

outputs:
  text:
    type: string
  language:
    type: string`})})]}),q("div",{className:"space-y-4",children:[f("h2",{className:"font-bold text-2xl",children:"Best practices"}),q("ul",{className:"list-inside list-disc space-y-2 text-muted-foreground",children:[f("li",{children:"Use streaming for real-time chat responses"}),f("li",{children:"Cache embeddings to reduce API costs"}),f("li",{children:"Implement rate limiting to avoid quota issues"}),f("li",{children:"Store conversation history for context"}),f("li",{children:"Monitor token usage and costs"})]})]}),q("div",{className:"flex items-center gap-4 pt-4",children:[f(y,{href:"/docs/integrations/google-calendar",className:"btn-ghost",children:"Previous: Google Calendar"}),q(y,{href:"/docs/integrations/mistral",className:"btn-primary",children:["Next: Mistral ",f(z,{size:16})]})]})]})}export{E as IntegrationsOpenAIPage};
