# OpenAI API

## OpenAI API Setup

Connect your OpenAI API key to Cuppa to generate content using GPT models. This is required for all Cuppa users.

***

### Why OpenAI?

OpenAI's GPT models power many of Cuppa's features:

* Article generation (single and bulk)
* Outline creation
* Metadata generation
* Content optimization

Even if you prefer other models (Claude, Grok), OpenAI is required for internal features.

***

### Available Models

| Model           | Best For                | Cost   | Speed   |
| --------------- | ----------------------- | ------ | ------- |
| **GPT-4o-mini** | Bulk generation, drafts | Lowest | Fastest |
| **GPT-4o**      | High-quality articles   | Medium | Fast    |
| **GPT-4.1**     | Premium quality         | Higher | Medium  |
| **o3-mini**     | Reasoning tasks         | Medium | Medium  |
| **GPT-5**       | Latest capabilities     | Higher | Medium  |
| GPT-5.1         | Latest capabilities     | Higher | Medium  |

> **Recommendation**: Start with GPT-4o-mini for testing, GPT-4o for production content.

***

### Step 1: Create an OpenAI API Account

1. Go to [platform.openai.com](https://platform.openai.com)
2. Click **Sign Up** (or **Log In**)
3. Complete account verification

> **Note**: This is different from ChatGPT. You need a separate API account.

***

### Step 2: Add Payment & Credits

OpenAI API requires prepaid credits:

1. Go to **Settings** → **Billing**
2. Click **Add payment method**
3. Add a credit card
4. Click **Add to credit balance**
5. Start with **$10-20** for testing

#### API Tiers

OpenAI has usage tiers that affect rate limits:

| Tier       | Requirement | Rate Limits                    |
| ---------- | ----------- | ------------------------------ |
| **Free**   | New account | Very limited (won't work well) |
| **Tier 1** | $5+ spent   | Good for single generation     |
| **Tier 2** | $50+ spent  | **Recommended for Cuppa**      |
| **Tier 3** | $100+ spent | Best for heavy bulk generation |

For bulk generation (10+ articles), **Tier 2 is recommended**.

***

### Step 3: Generate Your API Key

1. Go to [platform.openai.com/api-keys](https://platform.openai.com/api-keys)
2. Click **Create new secret key**
3. Name it "Cuppa" (optional)
4. Click **Create secret key**
5. **Copy the key immediately** — you won't see it again!

Your key looks like: `sk-proj-xxxxxxxxxxxxxxxxxxxx`

***

### Step 4: Add Key to Cuppa

1. Log in to [app.cuppa.ai](https://app.cuppa.ai)
2. Go to **Team Settings** → **API Keys**
3. Find the **OpenAI** section
4. Paste your API key
5. Click **Save**

Cuppa will validate your key before saving.

***

### Verify It's Working

Test your connection:

1. Go to **Create Content** → **Single Generation**
2. Enter any keyword (e.g., "test article")
3. Select a GPT model
4. Click **Generate**

If it works, you're all set!

***

### Multiple API Keys (Business+)

On Business plans and higher, you can add multiple OpenAI keys for:

* **Faster bulk generation** — parallel API calls
* **Higher rate limits** — spread requests across keys
* **Redundancy** — if one key hits limits, others continue

To add multiple keys:

1. Go to **Team Settings** → **API Keys**
2. Click **Add Another Key**
3. Paste your additional key

***

### Protected Models

Some newer OpenAI models (GPT-5, o3-mini) require organization verification:

1. Go to [platform.openai.com/settings/organization](https://platform.openai.com/settings/organization)
2. Complete **Organization Verification**
3. Wait for approval (usually 1-2 business days)

If a model isn't working, check if it requires verification.

***

### Cost Management

#### Monitoring Usage

Track your API costs:

1. Go to [platform.openai.com/usage](https://platform.openai.com/usage)
2. View daily and monthly spending
3. Set usage limits to prevent surprises

#### Setting Limits

Protect against unexpected costs:

1. Go to **Settings** → **Limits**
2. Set a **Monthly budget** (e.g., $50)
3. Set a **Notification threshold** (e.g., 80%)

***

### Troubleshooting

#### "Invalid API key"

* Check you copied the full key (starts with `sk-`)
* Verify the key hasn't been deleted in OpenAI
* Create a new key if unsure

#### "Insufficient quota" or "Rate limit"

* Add more credits to your OpenAI account
* Upgrade to Tier 2 ($50+ spent)
* Wait a minute and try again
* Use multiple API keys (Business+)

#### "Model not found"

* Some models require organization verification
* Check the model name is correct
* Ensure your account has access to that model

#### "Free credits don't work"

OpenAI's free trial credits don't work with Cuppa. Add a payment method and prepay credits.

#### Generation takes too long

* Check [status.openai.com](https://status.openai.com) for outages
* Try a faster model (GPT-4o-mini)
* Reduce article length/complexity

***

### FAQ

**Is OpenAI API the same as ChatGPT Plus?**

No. ChatGPT Plus ($20/month) is for the chat interface. The API is separate with pay-per-use pricing.

**Why do I need OpenAI even with Claude?**

Cuppa uses OpenAI for certain internal features (outline generation, SEO metadata). Your main article content can use any model.

**How do I check my OpenAI tier?**

Go to [platform.openai.com/settings/organization/limits](https://platform.openai.com/settings/organization/limits) to see your current tier.

**Can I use my employer's OpenAI account?**

Yes, if you have access to create API keys. Just copy the key to Cuppa.

**What if I run out of credits mid-generation?**

The generation will fail. Top up your credits and retry — partial progress is usually saved.

**Are my API keys secure?**

Yes. Keys are encrypted at rest and never shared. You can revoke a key anytime from OpenAI.

***

### Related Docs

* Anthropic API Setup — Add Claude models
* Perplexity API Setup — Enable auto-research
* Team Settings — Manage your API keys


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.cuppa.ai/getting-started/publish-your-docs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
