Curl Example for Chat Streaming

curl -X POST "https://apitheaimartaimodels2-g3c9rzqu.b4a.run/chatcompletions" \
-H "Content-Type: application/json" \
-H "X-API-Key: your_api_key_here" \
-d '{
    "model": "meta-llama/Llama-3-8b-chat-hf",
    "messages": [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello, how are you?"}
    ],
    "max_tokens": 50,
    "temperature": 0.7,
    "top_p": 0.9
}'

Python Example for Chat Streaming

import requests

# API endpoint
url = "https://apitheaimartaimodels2-g3c9rzqu.b4a.run/chatcompletions"

# Set headers with the correct API key header
headers = {
    "Content-Type": "application/json",
    "X-API-Key": "your_api_key_here"  # Ensure this matches your server's expected key
}

# Payload for the POST request
data = {
    "model": "meta-llama/Llama-3-8b-chat-hf",
    "messages": [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello, how are you?"}
    ],
    "stream": True,  
    "max_tokens": 50,
    "temperature": 0.7,
    "top_p": 0.9
}

# Send POST request to the server
response = requests.post(url, headers=headers, json=data)

# Check if the request was successful
if response.status_code == 200:
    print(response.json())  # Print the JSON response
else:
    print(f"Request failed: {response.status_code} - {response.text}")