Skip to content

Hackathon Access Guide

Screenshot

Introduction

This guide is designed to facilitate your participation by providing instructions on how to obtain and use necessary resources. You'll learn how to request API access to Azure language models and the MAVI project on Jira (jira.telekom.de). Additionally, we've included practical examples for API usage via command line and Python.

Accessing Azure Language Models

Verifying Network Connection

Before proceeding, ensure your network connection to the Azure model API endpoint is active. You can check this using the curl -v telnet:// command:

curl -v telnet://api.ril.one:443
*   Trying 52.59.101.133:443...
* Connected to api.ril.one (52.59.101.133) port 443 (#0)

A successful connection will be indicated by the above output.

Note for Windows NucleOS Users

If you are using a Windows laptop with NucleOS and are unable to access https://api.ril.one or other internet addresses from the command line, you may need to configure a proxy manually. Here's how to set up the proxy for different tools:

For curl requests, add the --proxy flag like this:

curl --proxy http://sia-lb.telekom.de:8080 ...

For Python and pip, set an environment variable like this:

SET HTTPS_PROXY=http://sia-lb.telekom.de:8080

Setting Up Your API Key

You must set your API key in your environment. Replace the demonstration key below with your actual API key:

export AZURE_API_KEY=<put here key>

Testing the API

Using the Curl Command Line

Execute the following command in your terminal to test the API:

curl --request POST \
  --url 'https://api.ril.one/openai/deployments/gpt-4o-mini/chat/completions?api-version=2023-12-01-preview' \
  --header 'Content-Type: application/json' \
  --header "api-key: ${AZURE_API_KEY}" \
  --data '{
   "messages":[
      {
         "role":"user",
         "content":"Translate this sentence from English to German. I love magenta color."
      }
   ]
}
'

A correct setup will yield a response like the following:

{
  "id": "chatcmpl-8V07vpY0VQvOWSrZCZmOiWIjH7W5u",
  "object": "chat.completion",
  "created": 1702399347,
  "model": "gpt-4o-mini",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Ich liebe die Farbe Magenta"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 22,
    "completion_tokens": 13,
    "total_tokens": 35
  },
  "system_fingerprint": null
}

Using Python

For Python access, it is recommended to use specific libraries, but for simplicity, this demonstration uses the requests package. Ensure you have requests installed and your AZURE_API_KEY set in your environment.

import requests
import os

# Define the API URL
url = 'https://api.ril.one/openai/deployments/gpt-4o-mini/chat/completions?api-version=2023-12-01-preview'

# Define the headers
headers = {
    'Content-Type': 'application/json',
    'api-key': os.environ.get('AZURE_API_KEY')  # Using an environment variable for the API key
}

# Define the data payload
data = {
    "messages": [
        {
            "role": "user",
            "content": "Translate this sentence from English to German. I love magenta color."
        }
    ]
}

# Make the POST request
response = requests.post(url, json=data, headers=headers)

# Handle the response (optional)
if response.status_code == 200:
    print(response.json())
else:
    print("Error:", response.status_code, response.text)

In the additional materials section, you will find a repository link to the langchain library for more advanced usage.

Supported Azure Models

Below is a list of available models with corresponding deployment names. Refer to this table to select the appropriate deployment name for your requests:

Deployment name Model name Model version Kind
gpt-4o-mini gpt-4o-mini 0301 Chat completion
hackathon-embedding text-embedding-ada-002 2 Embedding

For more details on each model, visit the Azure website here.

API specifics for chat completions and embeddings can be found here.