News
FreeBSD 15, Fresh OS Options on VMware, and New 1-Click Apps Are Now Available in the Control Panel!
DF
June 1 2026
Updated June 1 2026

How to Use the Serverspace GPT API in a Python Application

Control panel FAQ

Modern language models make it possible to add text generation capabilities, intelligent assistants, automated data processing, user support, and content analysis to applications. Thanks to the compatibility of the Serverspace GPT API with the OpenAI format, integration into a Python application takes only a few minutes and requires minimal code.

In this guide, we will look at connecting the Serverspace GPT API to a Python project, sending the first request, and receiving a response from the model.

What You Need Before Getting Started

Before connecting, make sure you have:

  • a Serverspace account in the control panel;
  • a created API key;
  • Python 3.9 or newer installed;
  • the OpenAI library for Python.

Serverspace uses an OpenAI-compatible request format and a standard endpoint for working with chat models.

Obtaining an API Key

To work with the GPT API, you need to create or copy an existing API key.

Open the GPT section in the Serverspace control panel.
Go to the API Keys tab.
Copy the generated access key.

By default, one API key is already created when using the GPT service for the first time.

gpt2 screen3 eng

Installing Required Libraries

Install the official OpenAI SDK:

pip install openai

Thanks to full compatibility with OpenAI, you can use the standard library without any additional modifications.

Creating Your First Request

Create a file main.py and add the following code:

from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://gpt.serverspace.io/v1"
)

response = client.chat.completions.create(
model="gpt-5.4-mini",
messages=[
{
"role": "user",
"content": "Hello! Briefly tell me about the Serverspace platform."
}
],
temperature=0.6,
max_tokens=300
)

print(response.choices[0].message.content)

Where:

  • api_key — your API key from the control panel;
  • base_url — Serverspace GPT API address;
  • model — the selected AI model;
  • messages — chat history;
  • temperature — response variability level;
  • max_tokens — maximum response length.

The endpoint used for requests:

https://gpt.serverspace.io/v1/chat/completions

Running the Application

Run the script using the command:

python main.py

After executing the request, the model will return a response in the console:

Serverspace is a cloud platform for deploying virtual infrastructure and using modern AI models via API.

Working with System Instructions

System messages can be used to control the model’s behavior.

Example:

from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://gpt.serverspace.io/v1"
)

response = client.chat.completions.create(
model="gpt-5.4-mini",
messages=[
{
"role": "system",
"content": "You are a technical consultant for Linux."
},
{
"role": "user",
"content": "How do I check RAM usage in Ubuntu?"
}
]
)

print(response.choices[0].message.content)

A system message helps define the response style, constraints, and role of the model within the application.

Processing JSON Responses

The API response contains additional metadata.

Example of retrieving the full response:

from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://gpt.serverspace.io/v1"
)

response = client.chat.completions.create(
model="gpt-5.4-mini",
messages=[
{
"role": "user",
"content": "What is Docker?"
}
]
)

print(response.model_dump())

As a result, you will receive an object containing information about the model, token usage, and the generated message.

Practical Use Cases

Serverspace GPT API can be used for a wide range of tasks:

  • building chatbots and virtual assistants;
  • automating customer support;
  • text content generation;
  • processing user requests;
  • data analysis and classification;
  • text translation;
  • building internal AI tools for business.

Thanks to OpenAI compatibility, existing projects can be adapted to the Serverspace GPT API with minimal code changes.

FAQ

  • Can I use the official OpenAI SDK with Serverspace GPT API?
    Yes. The Serverspace GPT API is fully compatible with the OpenAI API, so integration only requires installing the `openai` library, setting your API key, and changing the `base_url` to the Serverspace endpoint.
  • Which models are available via the GPT API?
    Several models from different providers are available in the Serverspace control panel. The current list of models can be viewed in the GPT section before sending a request.
  • Can I use the GPT API in an existing Python project?
    Yes. If your project already works with the OpenAI API, you usually only need to replace the API key and Serverspace endpoint. The core application logic remains unchanged.
  • How can I secure the API key in a Python application?
    It is not recommended to store the key directly in the source code. Instead, use environment variables or secret management systems to prevent accidental exposure.
  • Are there any request limits?
    The number of available requests depends on your current balance and token usage. Costs are calculated based on the number of input and output tokens.
  • What tasks is the Serverspace GPT API suitable for?
    The API can be used for building chatbots, AI assistants, content generation, customer support automation, text translation, data analysis, and other natural language processing tasks.

Conclusion

The Serverspace GPT API allows you to quickly add artificial intelligence capabilities to Python applications. To get started, you only need to create an API key, install the OpenAI library, and set the Serverspace endpoint. Thanks to the compatible request format, integration takes just a few minutes and is suitable for both small scripts and full-scale commercial services.

Vote:
5 out of 5
Аverage rating : 5
Rated by: 1
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
ITGLOBAL.COM NL
700 300
We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.