The TIR SDK calls a fixed list of eight models for you and fills in the request body, so you pass only the model name and your data. The examples call Whisper Large V3, one of the eight, and you can use any of them that is available in the GenAI API list. See Is a model on GenAI API guaranteed to stay available?.
Before you begin
Section titled “Before you begin”You need:
- A Personal Access Token. See Get started with TIR GenAI API.
- Your project ID.
The eight models the TIR SDK knows are llama-2-13b-chat, stable-diffusion-2-1,
mixtral-8x7b-instruct, codellama-13b-instruct, whisper-large-v3, e5-mistral-7b-instruct,
llama-3-8b-instruct, and parakeet-ctc-asr. Any other model name raises “model not present”.
Call that model with the OpenAI SDK or
REST instead.
Install the TIR SDK
Section titled “Install the TIR SDK”pip install e2enetworksInitialize the client
Section titled “Initialize the client”from e2enetworks.cloud import tir
tir.init(api_key="<your-api-key>", access_token="<your-auth-token>")tir_client = tir.ModelAPIClient(project="<your-project-id>")<your-auth-token> is the Auth Token from your Personal Access Token. Copy it from the Create
Token dialog or, later, from the Personal Access Tokens list. <your-api-key> is that same
token’s API Key. To get it, use the Download Config File action next to the token in the list;
the file holds both values. <your-project-id> is the project the token belongs to.
You can also set these as environment variables and initialize the client with no arguments; the SDK then reads them from the environment:
export E2E_TIR_API_KEY=<your-api-key>export E2E_TIR_ACCESS_TOKEN=<your-auth-token>Call the model
Section titled “Call the model”Whisper Large V3 takes the path to a local audio file of up to 50 MB. The SDK uploads the file for you before it calls the model:
response = tir_client.infer( model_name="whisper-large-v3", data={ "input": "<path-to-your-local-audio-file>", "task": "transcribe", "language": "english", # "max_new_tokens": 200, # optional: 1 to 445 # "return_timestamps": "sentence", # optional: none, sentence, or word },)print(response.outputs[0].data)Replace <path-to-your-local-audio-file> with the path to the audio file on your machine. task
and language are required; set language to the language spoken in the audio. The two commented
lines are optional: one caps the length of the transcript, and the other adds timestamps to it.
Read the transcription
Section titled “Read the transcription”response.outputs[0].data holds the transcription.
To call any other model in the catalog, see Call the API with REST or, for a text or embedding model, Call the API with the OpenAI SDK. If the call fails, see Troubleshooting TIR GenAI API.