Pick a model, create an API key, and send the model your first prompt from Python with the OpenAI SDK.
Pick a model
Section titled “Pick a model”- In TIR, open a project. In the side menu, under INFERENCE, select Token Factory. It lists every model you can call, with its context window and its prices per million tokens.
- Select a model to open its page. The examples use Gemma 4 31B, whose model ID is
google/gemma-4-31b-it; any model on the list works the same way.
Create an API key
Section titled “Create an API key”Every request to a Token Factory model needs an API key from your project. On a prepaid account, you need a credit balance above zero to create one.
- On the model’s page, select Create API key.
- In Name, say where you will use the key, for example
getting-started. In Expires, choose Never, or In 30 days for a key you need only for a short time. - Select Create Key.
- In Copy your new API key, copy the key and keep it somewhere safe. TIR shows it only once and does not keep a copy. Tick I have copied the API key., then select Done.
Call the model
Section titled “Call the model”-
Install the OpenAI SDK:
pip install -U openai -
Put the key in an environment variable, so it stays out of your code.
<your-api-key>is the key you copied:export TOKEN_FACTORY_API_KEY="<your-api-key>" -
Save this in a file named hello.py:
import osfrom openai import OpenAIclient = OpenAI(api_key=os.environ["TOKEN_FACTORY_API_KEY"],base_url="https://blaze.e2enetworks.net/v1",)response = client.chat.completions.create(model="google/gemma-4-31b-it",messages=[{"role": "user", "content": "Say hello in one sentence."}],)print(response.choices[0].message.content)Call this model on the model’s page shows the same request in Python, Node, and cURL, with that model’s ID already filled in.
-
Run it from the same terminal:
python hello.py
The model’s reply prints to your console. The request can take up to a minute to appear on the model page’s Metrics, and its tokens are billed to your project.
What to do next
Section titled “What to do next”- Call a model with the OpenAI SDK covers Node and streaming.
- To compare models before you build on one, see Choose a model.
- Tokens and billing explains what a request costs.
For help with an error, see Troubleshooting TIR Token Factory, which lists each message with its fix.
Was this page helpful?