📖API Usage Examples

Checking Account Status


The code sample below checks the account status of the API token owner: API Credits balance, User Tier, and $AIKEK balance. This API endpoint is free.

import requests  # pip install requests

api_key = "YOUR_TOKEN_HERE"
url = "https://api.alphakek.ai/user-info"

response = requests.get(url, headers={"Authorization": f'Bearer {api_key}'})

user_data = response.json()

print(f"User credits: {user_data['credits']}")
print(f"User tier: {user_data['tier']}")
print(f"Amount of $AIKEK in USD: {user_data['tokens_usd']}")

Comparing Our AI Models


This code sample calls Alpha API for each of the three available Alpha Chat AI Models, asks them the same question, and returns a streaming response.

Note: The code sample below spends 6 API Credits upon running.

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_TOKEN_HERE",
    base_url="https://api.alphakek.ai/v1"
)
question = "What to expect from Ethereum ETFs?"
print("Question:", question)

models = ["versa", "nexus", "eclipse"]
for model in models:
    response = client.chat.completions.create(
        model=model,
        messages=[
            {
                'role': 'user',
                'content': question
            }
        ],
        stream=True,
    )

    print(f"\n\nResponse from the {model.capitalize()} model:")
    for chunk in response:
        if chunk.choices[0].delta.content is None:
            continue
        print(chunk.choices[0].delta.content, end="")

Last updated