OpenAI Compatible
Use the official OpenAI SDK. Just change the base URL and API key — your existing code works instantly.
Secure by Default
All requests are encrypted via HTTPS. API keys are scoped and can be revoked at any time.
Global CDN
Low-latency access from anywhere. Our infrastructure is distributed across multiple regions.
Quick Start
Install the SDK
Use the official OpenAI SDK for your language, or make direct HTTP requests.
# No installation needed for cURLMake your first API call
Generate an image with a single API call. Replace YOUR_API_KEY with your actual key.
curl -X POST https://api.hiapi.ai/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "Nano-Banana-Pro", "stream": false, "messages": [{"role": "user", "content": "Draw a cute cat"}]}'Authentication
All API requests require an API key passed in the Authorization header as a Bearer token.
Authorization: Bearer YOUR_API_KEYNever expose your API key in client-side code or public repositories. Use environment variables to store your key securely.
Base URL
All API endpoints are relative to this base URL. If you're using the OpenAI SDK, set this as the base_url parameter.
https://api.hiapi.ai/v1API Endpoints
Chat Completions (Image Generation)
/v1/chat/completionsGenerate high-quality images via chat-style API. Use Nano-Banana-Pro for best quality with configurable aspect ratio and resolution, or Nano-Banana for fast generation.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| model | string | Required | Nano-Banana-Pro (high quality) or Nano-Banana (fast) |
| messages | array | Required | Array of message objects with role and content |
| stream | boolean | Optional | Enable streaming responses (default: false) |
| extra_body.google.image_config.aspect_ratio | string | Optional | Image aspect ratio: 1:1, 16:9, 9:16, 4:3, 3:4 (default: 1:1) |
| extra_body.google.image_config.image_size | string | Optional | Image resolution: 1K (1024px) or 2K (2048px, Pro only) |
Code Example
curl -X POST https://api.hiapi.ai/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "Nano-Banana-Pro",
"stream": false,
"messages": [
{
"role": "user",
"content": "Draw a cute cat sitting on a windowsill"
}
],
"extra_body": {
"google": {
"image_config": {
"aspect_ratio": "1:1",
"image_size": "1K"
}
}
}
}'Error Handling
The API uses standard HTTP status codes. Errors return a JSON object with details.
| Status Code | Description |
|---|---|
| 400 | Bad Request — Invalid parameters or missing required fields |
| 401 | Unauthorized — Invalid or missing API key |
| 403 | Forbidden — Insufficient permissions or account suspended |
| 429 | Too Many Requests — Rate limit exceeded. Please slow down. |
| 500 | Internal Server Error — Something went wrong on our end. Try again later. |
Error Response Format
{
"error": {
"message": "Invalid token",
"type": "new_api_error",
"code": ""
}
}