Code Examples
Get started quickly with example code showing how to use your purchased API key
JavaScript
Python
PHP
cURL
// Using your purchased API key from ai.mottatracking.com
const API_KEY = 'nyata_your_api_key_here'; // From your dashboard
const API_URL = 'https://ai.mottatracking.com/chat_api.php';
async function chatWithAI(message) {
try {
const response = await fetch(API_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': API_KEY // Your purchased API key
},
body: JSON.stringify({
model: 'gpt-4-turbo',
messages: [
{ role: 'user', content: message }
],
max_tokens: 150,
temperature: 0.7
})
});
const data = await response.json();
// Check API usage from response
if (data.api_usage) {
console.log('Requests remaining:', data.api_usage.requests_remaining);
}
return data.choices[0].message.content;
} catch (error) {
console.error('Error:', error);
}
}
// Example usage
chatWithAI('Hello, can you help me find food in Bristol?')
.then(reply => console.log('AI Reply:', reply));
# Using your purchased API key from ai.mottatracking.com
import requests
API_KEY = 'nyata_your_api_key_here' # From your dashboard
API_URL = 'https://ai.mottatracking.com/chat_api.php'
def chat_with_ai(message):
headers = {
'Content-Type': 'application/json',
'X-API-Key': API_KEY # Your purchased API key
}
payload = {
'model': 'gpt-4-turbo',
'messages': [
{'role': 'user', 'content': message}
],
'max_tokens': 150,
'temperature': 0.7
}
try:
response = requests.post(API_URL, headers=headers, json=payload)
data = response.json()
# Check API usage
if 'api_usage' in data:
print(f"Requests remaining: {data['api_usage']['requests_remaining']}")
return data['choices'][0]['message']['content']
except Exception as e:
print(f"Error: {e}")
return None
# Example usage
reply = chat_with_ai('Hello, can you help me find food in Bristol?')
print(f"AI Reply: {reply}")
// Using your purchased API key from ai.mottatracking.com
AI Reply: Sure! Bristol has a vibrant food scene with a wide variety of options. Whether you're looking for fine dining, street food, or cozy cafes, there's something for everyone. Here are some popular choices across different types:
1. **Casamia** - This is a high-end restaurant that offers a tasting menu tailored to the season. It’s perfect for special occasions.
2. **St Nicholas Market** - Located in the heart of the city, this market offers a range of street food from local vendors. You can find everything from gourmet burgers to vegetarian delights.
3. **The Ox** - A great choice if you’re in the mood for steak or British cuisine served in an intimate basement setting.
4. **Thali Cafe**
# Using your purchased API key from ai.mottatracking.com
curl -X POST "https://ai.mottatracking.com/chat_api.php" \
-H "Content-Type: application/json" \
-H "X-API-Key: nyata_your_api_key_here" \
-d '{
"model": "gpt-4-turbo",
"messages": [
{
"role": "user",
"content": "Hello, can you help me find food in Bristol?"
}
],
"max_tokens": 150,
"temperature": 0.7
}'