forked from xai-org/xai-sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtokenizer.py
More file actions
19 lines (13 loc) · 444 Bytes
/
tokenizer.py
File metadata and controls
19 lines (13 loc) · 444 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from xai_sdk import Client
def tokenize_text(client: Client):
prompt = input("Enter a prompt: ")
tokens = client.tokenize.tokenize_text(prompt, model="grok-3")
for token in tokens:
print(f"Token ID: {token.token_id}")
print(f"Token Text: {token.string_token}")
print(f"Token Bytes: {token.token_bytes}")
def main():
client = Client()
tokenize_text(client)
if __name__ == "__main__":
main()