To use the NeuralHub API, you need an API key. Generate one from the API Keys page in your dashboard. If you haven't generated one yet, the code examples below will use a placeholder.
Here’s how to call the API using Curl, Python, or JavaScript:
curl -X POST https://neuralhubapi.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "google/gemini-2.0-flash-001",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "What is the answer to life, the universe, and everything?" }
],
"temperature": 0.7,
"max_tokens": 500,
"top_p": 0.9
}'
The API returns an OpenAI-compatible response. Example:
{
"id": "chatcmpl-f9fcd949-1415-4990-bad1-ff64df14e028",
"object": "chat.completion",
"created": 1747800982,
"model": "google/gemini-2.0-flash-001",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The answer to life, the universe, and everything is famously **42**, according to Douglas Adams' *The Hitchhiker’s Guide to the Galaxy*. This humorous response has become iconic, but in the story, the actual question remains unknown, sparking philosophical discussions."
},
"finish_reason": "end_turn"
}
],
"usage": {
"prompt_tokens": 18,
"completion_tokens": 100,
"total_tokens": 118
}
}
Try the API in our Playground, or explore the available Models.