# Getting started

> Make your first request to Serenity Edge, the OpenAI-compatible inference API running on GPUs in Spain.

Source: https://docs.serenityedge.ai/docs/getting-started/

Serenity Edge is an OpenAI-compatible inference API run by Substrate AI on its own GPU infrastructure in Valencia, Spain. Prompts and completions are never written to disk or logs and never used for training; prompt prefixes may be cached in volatile memory for at most 24 hours (see [Data residency](https://docs.serenityedge.ai/docs/data-residency/)). If your code already talks to the OpenAI API, you only need to change the base URL and the API key.

|  |  |
| --- | --- |
| Base URL | `https://api.serenityedge.ai/v1` |
| Authentication | `Authorization: Bearer <key>` |
| Endpoints | `POST /v1/chat/completions`, `POST /v1/responses` ([Responses API](https://docs.serenityedge.ai/docs/responses-api/)), `GET /v1/models` |
| Models | See [Models](https://docs.serenityedge.ai/docs/models/) |

## 1\. Get an API key

There are three ways to use Serenity Edge. Pick the one that fits you and follow its page to get a key.

[Serenity Star account](https://docs.serenityedge.ai/docs/access/serenity-star-account/): Create API keys and buy prepaid credits.

[Routers and marketplaces](https://docs.serenityedge.ai/docs/access/channels/): Choose Serenity Edge as the provider from your cortecs or EUrouter account.

[Enterprise](https://docs.serenityedge.ai/docs/access/enterprise/): A contract with committed capacity and a service level agreement.

The examples below call the API directly at `https://api.serenityedge.ai/v1`, with a key from a Serenity Star account or an enterprise contract. Through a router or marketplace, use the base URL and key that the platform gives you instead, as its documentation explains.

Keep the key secret. Do not embed it in client-side code or commit it to a repository.

## 2\. Make a request

All examples below send the same chat completion. Replace `$SERENITY_EDGE_API_KEY` with your key.

### curl

```bash
curl https://api.serenityedge.ai/v1/chat/completions \
  -H "Authorization: Bearer $SERENITY_EDGE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "orion-pro",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Explain what a token is in one sentence."}
    ]
  }'
```

### Python

Install the official OpenAI library (`pip install openai`) and point it at Serenity Edge:

```python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.serenityedge.ai/v1",
    api_key="YOUR_SERENITY_EDGE_API_KEY",
)

completion = client.chat.completions.create(
    model="orion-pro",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Explain what a token is in one sentence."},
    ],
)

print(completion.choices[0].message.content)
```

### Node.js

Install the official OpenAI library (`npm install openai`):

```javascript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.serenityedge.ai/v1",
  apiKey: process.env.SERENITY_EDGE_API_KEY,
});

const completion = await client.chat.completions.create({
  model: "orion-pro",
  messages: [
    { role: "system", content: "You are a helpful assistant." },
    { role: "user", content: "Explain what a token is in one sentence." },
  ],
});

console.log(completion.choices[0].message.content);
```

### .NET

Install the official `OpenAI` NuGet package (`dotnet add package OpenAI`):

```csharp
using System.ClientModel;
using OpenAI;
using OpenAI.Chat;

var client = new OpenAIClient(
    new ApiKeyCredential(Environment.GetEnvironmentVariable("SERENITY_EDGE_API_KEY")!),
    new OpenAIClientOptions { Endpoint = new Uri("https://api.serenityedge.ai/v1") });

ChatClient chat = client.GetChatClient("orion-pro");

ChatCompletion completion = chat.CompleteChat(
    new SystemChatMessage("You are a helpful assistant."),
    new UserChatMessage("Explain what a token is in one sentence."));

Console.WriteLine(completion.Content[0].Text);
```

## 3\. Read the response

A non-streaming response is a standard chat completion object. The `usage` block is what you are billed on.

```json
{
  "id": "chatcmpl-8f0f1e2a",
  "object": "chat.completion",
  "created": 1758542400,
  "model": "orion-pro",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "A token is a small unit of text, roughly a word or part of a word, that a language model reads and writes."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 27,
    "completion_tokens": 26,
    "total_tokens": 53,
    "prompt_tokens_details": { "cached_tokens": 0 }
  }
}
```

## Next steps

-   [Models](https://docs.serenityedge.ai/docs/models/): the two model families and when to use each.
-   [Pricing and limits](https://docs.serenityedge.ai/docs/pricing-and-limits/): prices per million tokens, context window and rate limits.
-   [Streaming](https://docs.serenityedge.ai/docs/streaming/), [Tool calling](https://docs.serenityedge.ai/docs/tool-calling/) and [Structured outputs](https://docs.serenityedge.ai/docs/structured-outputs/).
-   [Data residency](https://docs.serenityedge.ai/docs/data-residency/): where your data is processed and for how long.
-   [API reference](https://docs.serenityedge.ai/docs/api/edge/serenity-edge-api/): every parameter and response field.
-   [Status page](https://status.serenityedge.ai/): current availability and incident history.
