Docs/API Setup

API Setup

ModelHub uses OpenAI's API to power all AI interactions. This guide explains how to configure your API key and understand the connection.

Getting an OpenAI API Key

1

Visit platform.openai.com and sign in or create an account.

2

Navigate to API Keys in the left sidebar.

3

Click Create new secret key and give it a name like "ModelHub".

4

Copy the key immediately — you won't be able to see it again.

Configuration

The API key should be stored server-side for security. In a self-hosted setup, add it to your environment variables:

# .env.local
OPENAI_API_KEY=sk-proj-your-api-key-here

Security Note: Never expose your API key in client-side code or commit it to version control. The key should only be accessed on the server.

How It Works

ModelHub routes all AI requests through OpenAI's API. When you select different "personalities" (Claude, GPT, Grok, etc.), the system applies custom system prompts to create distinct interaction styles, but all requests go through OpenAI models.

Personality Mapping

Each personality has a unique system prompt that shapes response style, tone, and approach.

Variant Mapping

Variants map to different OpenAI models (e.g., GPT-4o, GPT-4o-mini) based on their speed/quality tiers.

Server-Side Processing

All API calls are made from the server, keeping your API key secure and enabling streaming responses.

Checking API Status

ModelHub includes API health monitoring. You can check the connection status in:

  • The Live Status Strip on the homepage
  • The Workspace Header showing connection state
  • API endpoint: /api/health/openai

Troubleshooting

"API not connected"

  • • Verify your API key is correctly set in environment variables
  • • Check that the key hasn't been revoked on OpenAI's dashboard
  • • Ensure your OpenAI account has available credits

"Rate limit exceeded"

  • • Wait a few minutes and try again
  • • Consider upgrading your OpenAI plan for higher limits
  • • Use faster/cheaper model variants for development

"Invalid API key"

  • • Double-check the key for typos
  • • Ensure there are no extra spaces or line breaks
  • • Try generating a new key

Related