Skip to main content

OpenAI

OpenAI integration allows your product to connect with OpenAI's API platform to use advanced language models (e.g., GPT-4, GPT-4 Turbo, GPT-3.5, DALL·E, Whisper, and Embeddings). This integration enables your product to provide AI-driven features such as text generation, summarization, code assistance, image generation, and natural language processing.

Credentials Needed

To integrate with the OpenAI API, you need an OpenAI API Key associated with your account or organization.

Required credentials:

  • OpenAI API Key (sk-xxxxxx...)
  • (Optional) Organization ID (for multi-org setups)

Each API key is tied to your OpenAI account and billing plan — ensure keys are not shared publicly.

Permissions Needed / API Scopes

OpenAI uses API keys instead of scoped OAuth tokens. API keys grant full access to the capabilities enabled for your account or organization.

FunctionalityEndpointDescription
Text and chat models/v1/chat/completionsGenerate text, code, or conversation responses
Embeddings/v1/embeddingsGenerate vector embeddings for semantic search or clustering
Images (DALL·E)/v1/imagesGenerate or edit images
Audio/v1/audioTranscribe or translate audio files
Fine-tuning/v1/fine_tuningCreate or manage fine-tuned models
Models/v1/modelsList available models and their capabilities

OpenAI API keys grant full access — there are no partial scopes or restricted permissions. For multi-user or SaaS integrations, use a backend proxy or OAuth app (available for enterprise plans).

Creating Users / Access Tokens

Step 1: Create an API Key

  1. Log in to your OpenAI account: https://platform.openai.com/
  2. Go to Dashboard → API Keys or directly visit: https://platform.openai.com/account/api-keys
  3. Click + Create new secret key.
  4. Enter a name (e.g., OpenAIIntegrationKey).
  5. Copy and securely store the API key (sk-xxxxx) — it will only be displayed once.

Step 2 (Optional): Retrieve Organization ID

  1. Go to https://platform.openai.com/account/org-settings.
  2. Copy the Organization ID (e.g., org-abc123xyz).
  3. Include this ID in API requests if your account belongs to multiple organizations.

Test Connectivity

You can test the API connection using curl or a REST client:

# Test with Chat Completion API
curl https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <OPENAI_API_KEY>" \
-d '{
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "Hello from my integration!"}]
}'

# Example response includes model output and usage metadata

If you receive a valid JSON response with a message, your credentials are working correctly.

Save the Results in the Platform and Create Connection

  1. In your product's integration setup, securely store:
    • OPENAI_API_KEY
    • (Optional) OPENAI_ORG_ID
  2. Create a new connector labeled OpenAI Integration.
  3. Test the connection by making a sample API call (e.g., text generation).
  4. Validate that requests and responses are successfully exchanged.

Best Practices

  • Never expose API keys in frontend or client-side code — always call OpenAI APIs from a secure backend.
  • Store your keys in an encrypted secret manager or environment variables.
  • Rotate keys regularly (every 90 days) and revoke unused keys immediately.
  • Apply usage limits and rate control to prevent unexpected billing.
  • Use streaming responses for chat APIs to improve user experience.
  • For enterprise or team setups, manage API keys via Organization Controls in the OpenAI dashboard.
  • Monitor usage and costs under https://platform.openai.com/usage.
  • If building SaaS integrations, implement request logging and error handling for stability.