1

Get Your API Key

Create your free account at playground.electronhub.ai

Generate API Key

Visit the API Keys section to generate your first API key.

Keep your API key secure! Never share it or include it in client-side code.

2

Make Your First Request

import requests

response = requests.post(
    'https://api.electronhub.ai/v1/chat/completions',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
    },
    json={
        'model': 'gpt-3.5-turbo',
        'messages': [
            {'role': 'user', 'content': 'Hello! How are you?'}
        ]
    }
)

print(response.json()['choices'][0]['message']['content'])
3

Explore Different Models

Chat Models

Perfect for conversations and text generation:

  • GPT-4: Most capable, best for complex tasks
  • GPT-3.5-turbo: Fast and cost-effective
  • Claude 3: Great for analysis and reasoning

Example: Using GPT-4

response = requests.post(
    'https://api.electronhub.ai/v1/chat/completions',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
    },
    json={
        'model': 'gpt-4',
        'messages': [
            {'role': 'user', 'content': 'Explain quantum computing in simple terms'}
        ]
    }
)
4

Try Image Generation

Generate images from text descriptions:

response = requests.post(
    'https://api.electronhub.ai/v1/images/generations',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
    },
    json={
        'prompt': 'A futuristic cityscape at sunset',
        'model': 'dall-e-3',
        'size': '1024x1024'
    }
)

image_url = response.json()['data'][0]['url']
print(f"Generated image: {image_url}")
5

Text Embeddings

Convert text to vectors for semantic search:

response = requests.post(
    'https://api.electronhub.ai/v1/embeddings',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
    },
    json={
        'input': 'Your text to embed',
        'model': 'text-embedding-3-small'
    }
)

embedding = response.json()['data'][0]['embedding']

Next Steps

Troubleshooting

Common Issues

401 Unauthorized

  • Check that your API key is correct
  • Ensure you’re using the Bearer prefix
  • Verify your key hasn’t expired

429 Rate Limited

  • Slow down your request rate
  • Check your usage limits in the dashboard
  • Consider upgrading your plan

400 Bad Request

  • Verify all required parameters are included
  • Check parameter types and formats
  • Review the API reference for correct syntax

Need more help? Join our Discord community or check the troubleshooting guide.