Example usage
curl
The simplest type of API use with language models is via the command "curl". This is the fastest way to check whether your API connection is working.
Using curl assumes that you are comfortable using the terminal. If you are not, some of the other methods described in this document may suit you better.
The most common endpoints are v1/chat/completions and v1/responses. The latter is gradually taking over and is a newer type that better supports agentic use.
chat-completions
Example of what a curl call to chat/completions looks like:
export token=<YOUR-API-KEY>
curl -X POST "https://gpt.uio.no/api/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $token" \
-d '{
"model": "gpt-oss-120b",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hei, dette er en test, svar med ok"
}
]
}'responses
Example of what an API call to the responses endpoint looks like:
export token=<YOUR-API-KEY>
curl "https://gpt.uio.no/api/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $token" \
-d '{
"model": "gpt-oss-120b",
"input": "Write a one-sentence bedtime story about a unicorn."
}'Code agents
Security
Tools such as opencode, codex, claude code and others are AI agents. This means that they can perform actions on your machine, such as creating, deleting or editing files, or carrying out other actions you ask your agent to do.
Since the agents can make changes on your behalf, you must be extra careful with access and security.
Always give the code agent the minimum rights it needs:
- Run the agent (start the tool) in a dedicated project folder, not from your home directory.
- Share only the files and folders the agent actually needs.
- Avoid granting access to folders with restricted or confidential content such as keys, passwords and other secrets (yellow and red data) that are not necessary for the task.
API keys must be treated in the same way as passwords. Do not share agent configuration files or other files containing keys in version control (for example Git) or with others. Follow UiO’s guidelines for information security and the use of AI tools.
Installing agent apps
On a UiO-managed machine you get access to agent software such as VSCode (not strictly an agent app), Codex, Cline, OpenCode and others from
- Company Portal (for Windows)
- Managed Software Center for Mac.
If you do not have a UiO-managed machine, follow the guides linked from the IT services page for software.
How to set up environment variables
In agent apps it is good practice to store API keys in so‑called environment variables rather than in plain text in the apps’ configuration files. Here is a description of how to do this on Mac and Windows.
Mac
On Mac you can add the following two lines to the file `~/.bash_profile`.
export UIO_YELLOW_API_KEY=yellow_API_key_xxxdin-egen-nokkelxxx
export UIO_RED_API_KEY=red_API_key_xxxdin-egen-nokkelxxxTo activate them you must either
- close the terminal and open it again for them to be active
- or run the command `source ~/bash_profile` in the same terminal window.
The environment variables will be available from your terminal as $UIO_YELLOW_API_KEY og $UIO_RED_API_KEY.
Environment variables Windows
To add environment variables in Windows you access the System settings:
- System settings -> “Edit environment variables for your account”
- Add a new variable named UIO_YELLOW_API_KEY or UIO_RED_API_KEY and paste in the API key itself, which you will find in gpt.uio.no
- Close all dialogs by choosing “OK”. Your changes are saved!
After adding the environment variables they will be available as $env:UIO_YELLOW_API_KEY or $env:UIO_RED_API_KEY in Powershell or %UIO_YELLOW_API_KEY% og %UIO_RED_API_KEY% iinCommand Prompt.
Example of using the variables
In the configuration files for Codex and opencode you then use these variables rather than putting the API key in clear text.
MAC
curl "https://gpt.uio.no/api/v1/responses" -H "Content-Type: application/json" -H "Authorization: Bearer $UIO_YELLOW_API_KEY" -d '{"model": "gpt-oss-120b","input": "Write a one-sentence bedtime story about a unicorn."}'Windows Powershell
curl "https://gpt.uio.no/api/v1/responses" -H "Content-Type: application/json" -H "Authorization: Bearer $env:UIO_YELLOW_API_KEY" -d '{"model":"gpt-oss-120b","input":"Write a one-sentence bedtime story about a unicorn"}'Windows Command Prompt
curl "https://gpt.uio.no/api/v1/responses" -H "Content-Type: application/json" -H "Authorization: Bearer %UIO_YELLOW_API_KEY%" -d "{\"model\":\"gpt-oss-120b\",\"input\":\"Write a one-sentence bedtime story about a unicorn\"}"
VSCode and Cline extension
The API setup for gpt.uio.no is of the type OpenAI Compatible. You must choose this type for the API access to work.
Example configuration for agent plugins in VSCode such as RooCode and Cline looks like this:

opencode
OpenCode is an open AI code agent. It is available from the terminal, as a desktop app, and also as an IDE extension (from your code editor).
OpenCode can be configured to use the language models that are available via gpt.uio.no. Then you can use opencode for both yellow and red data depending on which model you choose. Remember that it is the model choice and configuration that determine what is allowed.
Configuration
You can configure opencode so that the setup applies at different levels on your laptop.
- Global setup: Applies regardless of where you use OpenCode.
- Project setup: Applies only in a specific file area (an OpenCode project).
Note that opencode merges configuration files. If you have a global configuration and a project configuration, the active configuration will be the combination of both.
For up‑to‑date and detailed documentation, see opencode’s own documentation.
The configuration file opencode.json
You configure opencode by editing the file `opencode.json`.
- Global configuration: create or edit the file in your home area: `~/.config/opencode/opencode.json`.
- For project‑specific configuration, create a new file `opencode.json` in the project folder you want to work in.
Example configuration file
Below is an example of an opencode.json configuration file that sets up two red models in addition to one yellow model. Always check which models are currently available in gpt.uio.no; they are updated regularly. Only the fields in "models" then need to be updated.
You must also enter your own API key in the "apiKey" field as well as in the "Authorization" field. Use the environment variables you set up as explained in How to set up environment variables.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"gpt-ntnu-llm-red": {
"npm": "@ai-sdk/openai-compatible",
"name": "GPT UIO red",
"options": {
"baseURL": "https://gpt.uio.no/api/v1",
"apiKey": "$UIO_RED_API_KEY",
"headers": {
"Authorization": "Bearer $UIO_RED_API_KEY"
}
},
"models": {
"gpt-oss-120b": {
"name": "GPT OSS"
},
"zai-org/GLM-4.7-FP8": {
"name": "GLM-4.7-FP8"
}
}
},
"gpt-ntnu-llm-yellow": {
"npm": "@ai-sdk/openai-compatible",
"name": "GPT UIO yellow",
"options": {
"baseURL": "https://gpt.uio.no/api/v1",
"apiKey": "$UIO_YELLOW_API_KEY",
"headers": {
"Authorization": "Bearer $UIO_YELLOW_API_KEY"
}
},
"models": {
"moonshotai/Kimi-K2.6": {
"name": "Kimi-K2.6"
}
}
}
}
}
With this configuration you can now open opencode and select UiO models. Here we show how you can select a UiO model after you have set up the configuration file as shown above. You must retrieve your API key from gpt.uio.no as described in Using GPT with API keys.
codex
To configure codex with the models in gpt.uio.no, add the following to your `~/.codex/config.toml` file, which is automatically created when you install codex.
You must also create some environment variables that contain the API key; see How to set up environment variables.
Note: At the moment, no models other than gpt-5.4 work in codex. But the configuration shows how to add a couple of models that run at NTNU.
model_reasoning_effort = "medium"
personality = "pragmatic"
##################
# Default model
##################
model = "gpt-5.4"
model_provider = "UIO-gpt5-4"
##################################
# UIO 5.4 settings - Azure OPENAI
##################################
[model_providers.UIO-gpt5-4]
name = "UIO-GPT5-4"
base_url = "https://gpt.uio.no/api/v1"
env_key = "UIO_YELLOW_API_KEY"
[profiles.uio-gpt5.4]
model_provider = "UIO-gpt5-4"
model = "gpt-5.4"
##########################
# UIO red settings - NTNU
##########################
[model_providers.UIO-red]
name = "UIO-red"
base_url = "https://gpt.uio.no/api/v1"
env_key = "UIO_RED_API_KEY"
[profiles.uio-red]
model_provider = "UIO-red"
model = "zai-org/GLM-4.7-FP8"
############################
# UIO yellow settings - NTNU
############################
[model_providers.UIO-yellow]
name = "UIO-yellow"
base_url = "https://gpt.uio.no/api/v1"
env_key = "UIO_YELLOW_API_KEY"
[profiles.uio-yellow]
model_provider = "UIO-yellow"
model = "gpt-oss-120b"
More information about codex configuration can be found in codex’s own documentation.