Learn how to integrate Pham 89 AI into your applications
The Pham 89 AI API allows you to access 100+ AI models through a simple REST API. To get started, you'll need your API secret key which you can find in your dashboard.
All API requests require authentication using your secret key in the request headers:
Authorization: Bearer YOUR_SECRET_KEY
Content-Type: application/json
Send a prompt to any of our 100+ AI models and receive a completion response.
POST https://api.pham89ai.com/v1/completions
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | The AI model to use (e.g., "llama3.1", "deepseek-v3", "qwen3") |
| prompt | string | Yes | The prompt text to send to the model |
| max_tokens | integer | No | Maximum number of tokens to generate (default: 1000) |
| temperature | float | No | Controls randomness (0.0 to 2.0, default: 0.7) |
| stream | boolean | No | Enable streaming responses (default: false) |
{
"id": "cmpl-7x8y9z",
"model": "llama3.1",
"created": 1702847123,
"choices": [
{
"text": "The generated response text...",
"index": 0,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 50,
"total_tokens": 60
}
}
Below are examples in various programming languages showing how to make API requests.
curl -X POST https://api.pham89ai.com/v1/completions \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "llama3.1",
"prompt": "Explain quantum computing in simple terms",
"max_tokens": 500,
"temperature": 0.7
}'
import requests
import json
url = "https://api.pham89ai.com/v1/completions"
headers = {
"Authorization": "Bearer YOUR_SECRET_KEY",
"Content-Type": "application/json"
}
payload = {
"model": "llama3.1",
"prompt": "Explain quantum computing in simple terms",
"max_tokens": 500,
"temperature": 0.7
}
response = requests.post(url, headers=headers, json=payload)
result = response.json()
print(result["choices"][0]["text"])
const axios = require('axios');
const url = 'https://api.pham89ai.com/v1/completions';
const headers = {
'Authorization': 'Bearer YOUR_SECRET_KEY',
'Content-Type': 'application/json'
};
const payload = {
model: 'llama3.1',
prompt: 'Explain quantum computing in simple terms',
max_tokens: 500,
temperature: 0.7
};
axios.post(url, payload, { headers })
.then(response => {
console.log(response.data.choices[0].text);
})
.catch(error => {
console.error('Error:', error.response.data);
});
const url = 'https://api.pham89ai.com/v1/completions';
fetch(url, {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_SECRET_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'llama3.1',
prompt: 'Explain quantum computing in simple terms',
max_tokens: 500,
temperature: 0.7
})
})
.then(response => response.json())
.then(data => {
console.log(data.choices[0].text);
})
.catch(error => {
console.error('Error:', error);
});
<?php
$url = 'https://api.pham89ai.com/v1/completions';
$headers = [
'Authorization: Bearer YOUR_SECRET_KEY',
'Content-Type: application/json'
];
$payload = json_encode([
'model' => 'llama3.1',
'prompt' => 'Explain quantum computing in simple terms',
'max_tokens' => 500,
'temperature' => 0.7
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
echo $result['choices'][0]['text'];
?>
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
type CompletionRequest struct {
Model string `json:"model"`
Prompt string `json:"prompt"`
MaxTokens int `json:"max_tokens"`
Temperature float64 `json:"temperature"`
}
func main() {
url := "https://api.pham89ai.com/v1/completions"
payload := CompletionRequest{
Model: "llama3.1",
Prompt: "Explain quantum computing in simple terms",
MaxTokens: 500,
Temperature: 0.7,
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer YOUR_SECRET_KEY")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
choices := result["choices"].([]interface{})
choice := choices[0].(map[string]interface{})
fmt.Println(choice["text"])
}
require 'net/http'
require 'json'
url = URI('https://api.pham89ai.com/v1/completions')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request['Authorization'] = 'Bearer YOUR_SECRET_KEY'
request['Content-Type'] = 'application/json'
request.body = {
model: 'llama3.1',
prompt: 'Explain quantum computing in simple terms',
max_tokens: 500,
temperature: 0.7
}.to_json
response = http.request(request)
result = JSON.parse(response.body)
puts result['choices'][0]['text']
Pham 89 AI supports 100+ AI models. Here are some popular options:
For a complete list of available models, visit the All Models page.
The API uses standard HTTP response codes to indicate success or failure:
| Status Code | Description |
|---|---|
| 200 | Success - Request completed successfully |
| 401 | Unauthorized - Invalid or missing API key |
| 400 | Bad Request - Invalid request parameters |
| 429 | Rate Limit - Too many requests |
| 500 | Server Error - Something went wrong on our end |
{
"error": {
"message": "Invalid API key provided",
"type": "authentication_error",
"code": "invalid_api_key"
}
}
If you have questions or need assistance with the API, our support team is here to help: