AI Playground Quickstart
Sign up for a Telnyx mission control portal account
If you haven't already, head to telnyx.com/sign-up to sign up for your free Telnyx account. It’ll give you access to our Mission Control Portal where you can chat with language models running on Telnyx in the AI Playground.
You can use the system prompt to give context and instructions before asking a question to a model. For example, users can specify a role, how to personalize the response, or what tone to use.
You can also choose from a variety of open-source models or pass us your OpenAI API key to use their models. For the open source models:
- If you are optimizing for price, try
meta-llama/Meta-Llama-3.1-8B-Instruct
- For quality, try
meta-llama/Meta-Llama-3.1-70B-Instruct
Using the API
You can also use our OpenAI-compatible chat completions API to interact programmatically with a language model.
Getting a v2 API Key
You can create a v2 API Key using these instructions.
Python Example
Here is some simple Python to stream a chat response using Telnyx.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.getenv("TELNYX_API_KEY"),
base_url="https://api.telnyx.com/v2/ai",
)
chat_completion = client.chat.completions.create(
messages=[{
"role": "user",
"content": "Can you explain 10DLC to me?"
}],
model="meta-llama/Meta-Llama-3.1-8B-Instruct",
stream=True
)
for chunk in chat_completion:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)