# 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 the European Union. 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 | The routes below, all in the [API reference](https://docs.serenityedge.ai/docs/api/edge/serenity-edge-api/) |
| Models | See [Models](https://docs.serenityedge.ai/docs/models/) |

The API serves these routes:

-   `POST /v1/chat/completions`: chat completions, on this page and in [Streaming](https://docs.serenityedge.ai/docs/streaming/).
-   `POST /v1/responses`: the [Responses API](https://docs.serenityedge.ai/docs/responses-api/).
-   `POST /v1/embeddings`, `POST /v1/rerank` and `POST /v1/redact`: [Embeddings, rerank and redaction](https://docs.serenityedge.ai/docs/embeddings-rerank-and-redaction/).
-   `POST /v1/audio/transcriptions`: [Speech to text](https://docs.serenityedge.ai/docs/audio-transcriptions/), transcripts of audio files with speakers and timestamps.
-   `POST /v1/decisions` and `POST /v1/systemone`: [Decisions](https://docs.serenityedge.ai/docs/decisions/), in preview.
-   `GET /v1/models`: the catalogue, see [Models](https://docs.serenityedge.ai/docs/models/).
-   `GET /v1/usage`: your key's usage records of [Sandboxes](https://docs.serenityedge.ai/docs/sandboxes/pricing-and-usage/#check-your-usage), in private preview.

## 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.
