🪙Tokenizer Completions

Ever wanted to see how many tokens something is depending on the model? Here you go.


Models can be found here.


import requests

# Define the URL for the Shard AI API endpoint.
api_url = "https://api.shard-ai.xyz/v1/tokenizer/completions"

# Define the data to be sent in the request.
request_data = {
    "model": "gpt-3.5-turbo",  # Specify the model to be used.
    "input": 'hey how are you?'  # Provide the input text.
}

# Provide the authorization token for accessing the API.
authorization_token = "Bearer shard-xxx"

# Prepare the request headers.
headers = {
    "Authorization": authorization_token
}

# Send the HTTP POST request to the API endpoint.
response = requests.post(api_url, headers=headers, json=request_data)

# Print the response received from the API.
print(response.text)

Responses


{
    "total_tokens": 5,
    "input": "hey how are you?",
    "model": "gpt-3.5-turbo",
    "created": 1714017655
}

Last updated