πŸ—¨οΈAlpha Chat API

Integrate Alpha Chat in your product.

The API endpoint for Alpha Chat is compatible with OpenAI's Chat Completion API and can be used as a drop-in replacement by changing three lines of code:

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_TOKEN_HERE",  # Replace OpenAI's token with AlphaKEK's
    base_url="https://api.alphakek.ai/v1"  # Switch to Alpha API server
)

response = client.chat.completions.create(
  model="nexus",  # Switch to Nexus model with crypto knowledge
  messages=[
    {"role": "user", "content": "What to expect from Ethereum ETFs?"}
  ]
)

Available models: versa, nexus, eclipse. Refer to AI Models for the detailed comparison of each model. The pricing information is available at #api-costs.

Chat Completions

POST/v1/chat/completions
Authorization
Header parameters
Body
model*ModelName
versanexuseclipse
messages*Messages
streamStream
personaPersona
json_schemaJson Schema
temperatureTemperature
top_pTop P
frequency_penaltyFrequency Penalty
top_kTop K
Other propertiesany
Response

Successful Response

Body
Completion response, when stream=False
Request
const response = await fetch('/v1/chat/completions', {
    method: 'POST',
    headers: {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "model": "versa",
      "messages": [
        {
          "role": "system",
          "content": "text"
        }
      ]
    }),
});
const data = await response.json();
Response
{
  "id": "text",
  "choices": [
    {
      "finish_reason": "stop",
      "logprobs": {
        "content": [
          {
            "token": "text",
            "bytes": [],
            "logprob": 0,
            "top_logprobs": [
              {
                "token": "text",
                "bytes": [],
                "logprob": 0
              }
            ]
          }
        ]
      },
      "message": {
        "content": "text",
        "role": "assistant",
        "function_call": {
          "arguments": "text",
          "name": "text"
        },
        "tool_calls": [
          {
            "id": "text",
            "function": {
              "arguments": "text",
              "name": "text"
            },
            "type": "function"
          }
        ]
      }
    }
  ],
  "model": "text",
  "object": "chat.completion",
  "service_tier": "scale",
  "system_fingerprint": "text",
  "usage": {}
}

JSON Schema

To enable JSON-constrained generation, pass json_schema argument to the extra_body field:

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.alphakek.ai/v1"
)
messages = [
    {
        "role": "user",
        "content": "Write 5 tweets about crypto ETF news in a JSON format."
    },
]

response = client.chat.completions.create(
    model='nexus',
    messages=messages,
    extra_body={
        'json_schema': {
            "$schema": "http://json-schema.org/draft-07/schema#",
            "type": "object",
            "properties": {
                "tweet1": {
                    "type": "string"
                },
                "tweet2": {
                    "type": "string"
                },
                "tweet3": {
                    "type": "string"
                },
                "tweet4": {
                    "type": "string"
                },
                "tweet5": {
                    "type": "string"
                }
            },
            "required": [
                "tweet1",
                "tweet2",
                "tweet3",
                "tweet4",
                "tweet5"
            ]
        }
    }
)

response_text = response.choices[0].message.content
print(response_text)

Sample output:

```json
[
    {
        "text": "πŸš€ #Ethereum #ETFs expected to attract $15B in investments within 18 months of launch. First ETFs predicted to drop this summer. Time to load up the bags! #Crypto #ETH"
    },
    {
        "text": "#VanEck files for a spot #Solana ETF, sending $SOL surging over 6%. Will this be the next big thing after their successful $BTC and $ETH ETFs? Place your bets! πŸ€‘ #Crypto"
    },
    {
        "text": "The battle of the #SmartContract platforms: While $SOL surges on ETF news, analysts predict slower but steadier growth for $AVAX. Which horse are you backing? #CryptoBets"
    },
    {
        "text": "#Ethereum #ETF launch might be postponed until after July 4th due to paperwork issues. Don't worry, it's still coming! Time to stack more $ETH while it's still cheap! πŸ’° #BuyTheDip"
    },
    {
        "text": "#21Shares joins the race to launch a #Solana ETF. Will this be the first spot $SOL ETF? Let's goooooo! πŸš€ #CryptoNews"
    }
]
```

Limitations

  • Function calling is not supported (except for the functions of Alpha Alerts API that are being called automatically by nexus and eclipse models.

This list of limitations is subject to change.


Chat API Costs

The pricing for Chat API is per request and depends on the model used. Learn more about API Credits at API Credits.

ModelAPI Credits per request

Versa

1

Nexus

2

Eclipse

3

πŸ“–API Usage Examples

Last updated