GirtAI
API documentation
← All guides

Use the DeepSeek API with Python and GirtAI

A server-side Python example with environment-based authentication and a bounded response.

Before you start

Create a verified GirtAI account and an API key in the console. A DeepSeek-issued key cannot authenticate to GirtAI. Check the model list in the console and ensure your account has usable credit.

Install and configure

Install Python 3.9 or newer and run: python -m pip install openai. Set GIRTAI_API_KEY in your server environment or secret manager. Do not commit its value. Save the example as example.py and run python example.py.

Read the result

The example requests at most 128 output tokens and prints the first response message. This is a paid API request, not a local simulation. Inspect response.usage for actual usage; a timeout is not evidence that no tokens were generated.

Production handling

The example disables automatic retries so one application action does not silently create repeated requests. Add bounded backoff only for transient failures, and give users a way to cancel long-running requests.

Example — run on your server

import os
from openai import OpenAI

client = OpenAI(api_key=os.environ["GIRTAI_API_KEY"],
                base_url="https://girtai.com/v1", timeout=60, max_retries=0)
response = client.chat.completions.create(
    model="deepseek-flash",
    messages=[{"role": "user", "content": "Hello!"}],
    max_tokens=128,
    stream=False,
)
print(response.choices[0].message.content)
View prices & local peak hours