A

API Key Management

Generate and manage secure API keys for your applications. Track usage and maintain control over your API access.

Your API Keys

Manage access to the Theaimart API

How to Use Your API Keys

Include your API key in the headers of your requests to authenticate with our services.

import requests

url = "https://api.theaimart.com/chatcompletions"
headers = {
    "Content-Type": "application/json",
    "X-API-Key": "Your_api_key" 
}
data = {
    "model": "microsoft/phi-4",
    "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
}
try:
    response = requests.post(url, headers=headers, json=data, stream=True)
    if response.status_code == 200:
        for chunk in response.iter_lines(decode_unicode=True):
            if chunk:  
                try:
                    chunk_data = eval(chunk)  
                    for item in chunk_data:
                        if "content" in item:
                            print(item["content"], end="")
                except Exception as e:
                    print(f"Error parsing chunk: {e}")
    else:
        print(f"Request failed: {response.status_code} - {response.text}")
except requests.exceptions.RequestException as e:
    print(f"An error occurred: {e}")

Keep your API keys secure and never share them publicly. You can regenerate keys anytime if they are compromised.