API Reference
Complete reference documentation for the AI Platform REST API. Build powerful AI applications with our simple, intuitive endpoints.
Authentication
The AI Platform API uses API keys for authentication. Include your API key in the Authorization header of all requests.
curl https://api.aiplatform.com/v2/completions \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json"
Keep your API key secure
Never expose your API key in client-side code. Use environment variables and server-side calls.
Rate Limits
Rate limits vary by plan tier. Limits are applied per API key and reset every minute.
| Plan | Requests/min | Tokens/min |
|---|---|---|
| Free | 20 | 40,000 |
| Pro | 100 | 200,000 |
| Enterprise | Unlimited | Custom |
Create Completion
POST
/v2/completions
Creates a completion for the provided prompt and parameters. Returns generated text based on your input.
Request Body
model
required
ID of the model to use (e.g., "aip-4-turbo")
prompt
required
The prompt(s) to generate completions for
max_tokens
Maximum tokens to generate. Defaults to 1024.
temperature
Sampling temperature (0-2). Higher = more random. Defaults to 1.
Example Request
import aiplatform client = aiplatform.Client(api_key="YOUR_API_KEY") response = client.completions.create( model="aip-4-turbo", prompt="Explain quantum computing in simple terms:", max_tokens=500, temperature=0.7 ) print(response.text)
Example Response
{
"id": "cmpl-abc123",
"object": "text_completion",
"created": 1704067200,
"model": "aip-4-turbo",
"choices": [{
"text": "Quantum computing uses quantum mechanics...",
"index": 0,
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 8,
"completion_tokens": 156,
"total_tokens": 164
}
}
Create Embeddings
POST
/v2/embeddings
Creates an embedding vector representing the input text. Use for semantic search, clustering, and recommendations.
response = client.embeddings.create( model="aip-embed-v2", input="The quick brown fox jumps over the lazy dog" ) embedding = response.data[0].embedding # Returns 1536-dimensional vector
List Models
GET
/v2/models
Lists all available models and their capabilities.
curl https://api.aiplatform.com/v2/models \ -H "Authorization: Bearer YOUR_API_KEY"
Error Handling
The API uses standard HTTP response codes to indicate success or failure.
200
Success - Request completed successfully
400
Bad Request - Invalid parameters
401
Unauthorized - Invalid API key
429
Rate Limited - Too many requests
500
Server Error - Something went wrong on our end