> ## Documentation Index
> Fetch the complete documentation index at: https://help.emergent.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI (ChatGPT) Integration

> Add AI chat and text generation to your app with ChatGPT

## What is OpenAI?

OpenAI is the company behind ChatGPT. You can add the same AI technology to your own app - for chatbots, content writing, answering questions, and more.

**Perfect for:**

* AI chatbots and assistants
* Generating content (blog posts, emails, etc.)
* Answering customer questions
* Helping users with tasks
* Creative writing tools

## The Easy Way: Emergent Universal Key

<Note>
  **Good news!** You don't need to create an OpenAI account. Emergent provides a Universal Key that works with OpenAI, Claude, and Google AI - all in one!\
  \
  **TLDR**: View our article on the [Universal Key](/features/universal-key) to get started.
</Note>

### How to Get It

<Steps>
  <Step title="Click Your Profile">
    In Emergent, click your profile picture (top right)
  </Step>

  <Step title="Go to Universal Key">
    Select **Universal Key** from the menu
  </Step>

  <Step title="View Your Key">
    Your key is displayed there
  </Step>

  <Step title="Add Credits">
    Click **Add Balance** to add credits (starts at \$10)
  </Step>

  <Step title="Done!">
    You're ready to use AI!
  </Step>
</Steps>

**Pricing:** Pay only for what you use (about \$0.01 per 750 words)

## Tell the Agent What You Want

Just describe what you're building! Here are examples:

### Example 1: Customer Support Chatbot

```
I want to add an AI chatbot to help customers.

The chatbot should:
- Answer questions about my product
- Be friendly and helpful
- Remember the conversation
- Show typing indicator while thinking

Use Emergent Universal Key for OpenAI.
Use GPT-4 (the smart one).

Please set this up for me.
```

### Example 2: Content Writer

```
I need a tool that writes blog posts.

Users should be able to:
- Enter a topic
- Choose blog length (short, medium, long)
- Click "Generate" and get a complete blog post
- Copy the result

Use Emergent Universal Key for OpenAI.
Use GPT-4.

Please set this up for me.
```

### Example 3: Q\&A Assistant

```
I want users to ask questions and get AI answers.

Features:
- Simple question box
- AI provides detailed answer
- Show sources if possible
- Keep history of past questions

Use Emergent Universal Key for OpenAI.

Please set this up for me.
```

<Tip>
  **That's it!** Just tell the agent what you want in plain English. No technical knowledge needed.
</Tip>

***

## Choose Your AI Model

Think of models like different versions of AI - some are smarter but cost more:

<CardGroup cols={2}>
  <Card title="GPT-4 Turbo" icon="bolt" color="#10b981">
    **Best for:** Most things

    **Speed:** Fast

    **Cost:** Medium

    **Recommended!**
  </Card>

  <Card title="GPT-4" icon="brain" color="#3b82f6">
    **Best for:** Complex tasks

    **Speed:** Slower

    **Cost:** Higher

    Great for difficult questions
  </Card>

  <Card title="GPT-3.5" icon="gauge-high" color="#f59e0b">
    **Best for:** Simple tasks

    **Speed:** Very fast

    **Cost:** Cheapest

    Good for basic chatbots
  </Card>

  <Card title="GPT-4o" icon="star" color="#8b5cf6">
    **Best for:** Latest features

    **Speed:** Fast

    **Cost:** Medium

    Newest model
  </Card>
</CardGroup>

**Not sure which to choose?** Start with **GPT-4 Turbo** - it's the best balance.

## Test Your AI

After the agent sets it up:

<Steps>
  <Step title="Click Preview">
    In Emergent, click the **Preview** button
  </Step>

  <Step title="Try It Out">
    If it's a chat: Send a message

    If it's a generator: Enter some text and click generate
  </Step>

  <Step title="Wait for AI">
    The AI will think for a few seconds, then respond
  </Step>

  <Step title="Test Different Things">
    Try asking different questions

    Test if the conversation memory works
  </Step>

  <Step title="Check It Makes Sense">
    Make sure the AI responses are helpful and accurate
  </Step>
</Steps>

**Tip:** If the AI isn't responding the way you want, tell the agent:

```
The AI responses are [too long/too short/not helpful enough].
Can you adjust it to be more [specific/concise/friendly]?
```

## Managing Your Credits

### Check Your Balance

1. Profile → Universal Key
2. See remaining credits
3. View usage history

### Add More Credits

1. Click **Add Balance**
2. Choose amount (10, 25, 50, or custom)
3. Complete payment
4. Credits added instantly!

### Set Up Auto-Recharge (Optional)

1. Profile → Universal Key
2. Enable **Auto-recharge**
3. Choose amount and trigger point
4. Never run out of credits!

**Example:** Auto-add 5 credits when running out of balance.

## How Much Does It Cost?

Very affordable! Here's what you get:

**GPT-4 Turbo** (recommended):

* About **\$0.01 per 750 words**
* A full conversation (10 messages): \~\$0.05
* 1,000 customer questions: \~\$10

**GPT-3.5** (cheaper option):

* About **\$0.002 per 750 words**
* A full conversation: \~\$0.01
* 1,000 customer questions: \~\$2

<Note>
  With the Emergent Universal Key, you only pay for what you use. No monthly fees!
</Note>

## Common Questions

<AccordionGroup>
  <Accordion title="Do I need my own OpenAI account?">
    **No!** Just use the Emergent Universal Key. It's simpler and you can use it for multiple AI providers.
  </Accordion>

  <Accordion title="Can the AI learn about my business?">
    Yes! Tell the agent:

    ```
    I want the AI to know about my business:
    - We sell [products/services]
    - Our pricing is [details]
    - Common customer questions are [list]

    Please train it on this information.
    ```
  </Accordion>

  <Accordion title="What if AI gives wrong answers?">
    AI isn't perfect. Tell the agent:

    ```
    The AI is giving incorrect information about [topic].
    It should say [correct information] instead.
    Can you fix this?
    ```
  </Accordion>

  <Accordion title="Can I make the AI responses shorter/longer?">
    Yes! Tell the agent:

    ```
    The AI responses are too long. 
    Can you make them more concise (2-3 sentences max)?
    ```
  </Accordion>

  <Accordion title="Is my data private?">
    Yes. Conversations are private and not used to train OpenAI's models (when using their API).
  </Accordion>
</AccordionGroup>

## Something Not Working?

### AI Not Responding

**Tell the agent:**

```
The AI isn't responding when I send a message.
Can you check the OpenAI integration?
```

### "Out of Credits" Error

**Solution:**

1. Go to Profile → Universal Key
2. Add more credits
3. Try again

### Responses Are Too Slow

**Tell the agent:**

```
The AI is taking too long to respond.
Can you make it faster or show a better loading indicator?
```

### AI Personality Isn't Right

**Tell the agent:**

```
I want the AI to be more [professional/friendly/casual/technical].
Can you adjust its personality?
```

## Real Examples

### Example 1: Recipe Generator

```
Build a recipe generator where users:
1. Enter ingredients they have
2. Click "Generate Recipe"
3. Get a complete recipe with instructions

Use Emergent Universal Key with GPT-4.
Make the recipes creative and easy to follow.

Please build this for me.
```

### Example 2: Email Writer

```
I need a tool that writes professional emails.

Users enter:
- What the email is about
- Tone (formal, casual, friendly)
- Key points to include

The AI generates a complete email they can copy.

Use Emergent Universal Key with GPT-4.

Please build this.
```

### Example 3: Study Buddy

```
Create a study assistant where students can:
- Ask questions about any topic
- Get explained answers
- Request practice questions
- Get homework help

Make it encouraging and patient.
Remember the conversation topic.

Use Emergent Universal Key with GPT-4.

Please build this.
```

## Making Your AI Better

### Give It Personality

```
Make the AI chatbot sound like:
- A friendly expert
- Professional but warm
- Enthusiastic and encouraging

Add these traits to my AI.
```

### Add Knowledge

```
Teach the AI about:
- My product features
- Common customer issues  
- Company policies
- FAQ answers

Here's the information: [paste details]
```

### Set Boundaries

```
The AI should NOT:
- Make promises about pricing
- Give medical/legal advice
- Share personal information
- Discuss competitors

Please add these restrictions.
```

## Tips for Best Results

<CardGroup cols={2}>
  <Card title="Start Simple" icon="seedling">
    Begin with basic features

    Add complexity later
  </Card>

  <Card title="Test Thoroughly" icon="vial">
    Try many different questions

    Find edge cases
  </Card>

  <Card title="Monitor Usage" icon="chart-line">
    Check credit usage regularly

    Optimize if needed
  </Card>

  <Card title="Get Feedback" icon="comments">
    Ask users what they think

    Improve based on feedback
  </Card>
</CardGroup>

## Alternative: Use Your Own OpenAI Key

If you prefer to use your own OpenAI account:

<Steps>
  <Step title="Create OpenAI Account">
    Go to [platform.openai.com](https://platform.openai.com)
  </Step>

  <Step title="Add Payment Method">
    OpenAI requires a credit card on file
  </Step>

  <Step title="Create API Key">
    Go to API Keys → Create new key
  </Step>

  <Step title="Copy Key">
    Starts with `sk-proj-`
  </Step>

  <Step title="Tell Agent">
    ```
    Use my OpenAI API key instead of Emergent Universal Key:
    sk-proj-xxxxxxxxxxxxx
    ```
  </Step>
</Steps>

## Quick Checklist

Before going live:

* Tested AI with many different questions
* AI responses are helpful and accurate
* Added enough credits to Universal Key
* Set up auto-recharge (optional)
* Tested on different devices
* AI has the right personality/tone
* Taught AI about your business (if needed)

## Get Help

<CardGroup cols={2}>
  <Card title="Universal Key" icon="star">
    Profile → Universal Key

    Manage credits and usage
  </Card>

  <Card title="Ask the Agent" icon="message">
    Describe what's not working

    Agent will fix it
  </Card>

  <Card title="OpenAI Status" icon="signal" href="https://status.openai.com">
    Check if OpenAI is having issues
  </Card>

  <Card title="Support" icon="life-ring">
    [support@emergent.sh](mailto:support@emergent.sh)

    We're here to help
  </Card>

  ## Remember
</CardGroup>

**Use Emergent Universal Key** - It's the easiest way

**Start with GPT-4 Turbo** - Best balance of cost and quality

**Test everything** before launching to users

**Monitor your credits** - Set up auto-recharge if needed

**Keep improving** - Tell the agent what to adjust based on user feedback

<Info>
  Stuck? Just tell the agent: "I need help with my AI chatbot" and explain what you want to change or fix.
</Info>
