Skip to main content
OpenAI provides access to powerful language models like GPT-4 and GPT-3.5 through their API. These models offer state-of-the-art performance for a wide range of tasks.

Overview

Prerequisites

1

Create an OpenAI account

Sign up at platform.openai.com if you don’t have an account yet.
2

Add billing information

Go to Billing settings and add a payment method. You’ll need to add credits to use the API.
3

Generate an API key

Navigate to API keys page and click Create new secret key. Copy the key immediately - you won’t be able to see it again!
Never share your API key or commit it to version control. Store it securely in Obsidian’s AI Providers settings.

Setup in AI Providers

1

Select OpenAI provider

In the AI Providers settings, click Create AI provider and select OpenAI as the provider type.
2

Configure provider URL

Set the Provider URL to:
https://api.openai.com/v1
3

Enter API key

Paste your API key from the API keys page into the API key field.
4

Select model

Click the refresh button to fetch available models, then select the model that suits your needs (e.g., gpt-4o).
5

Test the provider

Click Test to verify your configuration is working correctly.
ModelDescriptionBest For
gpt-4oLatest GPT-4 Omni model, multimodalComplex tasks, vision, best quality
gpt-4o-miniSmaller, faster GPT-4 variantFast responses, cost-effective
gpt-4-turboHigh intelligence, lower cost than GPT-4Complex reasoning tasks
gpt-3.5-turboFast and affordableSimple tasks, high volume
o1-previewAdvanced reasoning modelComplex problem solving
o1-miniFaster reasoning modelCoding, math, science
GPT-4 models support vision capabilities, allowing you to include images in your prompts.

Embedding Models

For embedding generation (used in RAG and semantic search), OpenAI provides:
  • text-embedding-3-large - Highest quality embeddings
  • text-embedding-3-small - Fast and cost-effective
  • text-embedding-ada-002 - Legacy model (still supported)

Troubleshooting

Rate Limit Errors

If you encounter rate limit errors:
  1. Check your usage limits
  2. Upgrade your account tier by adding more credits
  3. Implement request throttling in plugins that use AI Providers

Invalid API Key

If you see “Invalid API key” errors:
  1. Verify you copied the entire API key correctly
  2. Check that the key hasn’t been revoked in your API keys page
  3. Ensure you’re using an API key (starts with sk-) not an organization ID

Model Not Available

Some models (like GPT-4) require specific access tiers. Check your account limits to see which models you can use.

Insufficient Credits

If requests fail with billing errors:
  1. Check your billing overview
  2. Add more credits to your account
  3. Verify your payment method is valid

Pricing Considerations

OpenAI charges based on tokens processed:
  • Input tokens (what you send)
  • Output tokens (what the model generates)
Cost-saving tips:
  • Use gpt-4o-mini for simpler tasks instead of gpt-4o
  • Use gpt-3.5-turbo for high-volume, straightforward tasks
  • Keep prompts concise
  • Monitor your usage in the usage dashboard

Advanced Features

Reasoning Models (o1 series)

The o1 models use extended thinking time before responding. They’re designed for complex reasoning but:
  • Cost more per token
  • Have slower response times
  • Don’t support streaming
  • Don’t support system prompts in the traditional way

Vision Capabilities

GPT-4o and GPT-4 Turbo support image inputs. You can include images in your prompts by passing them as base64-encoded data URLs.

Custom Options

You can pass additional parameters to the OpenAI API:
  • temperature - Controls randomness (0.0 to 2.0)
  • max_tokens - Maximum response length
  • top_p - Nucleus sampling parameter
  • stop - Stop sequences

Build docs developers (and LLMs) love