> ## Documentation Index
> Fetch the complete documentation index at: https://docs.atlaso.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Your first call

> A two-minute walkthrough once your keys are ready.

## Set up once

On the **Provider keys** page, save an enabled OpenAI key.
On the **API keys** page, create a key, give it a name, choose a project (or
**No project**), and select **Use only**. Under **Memory for**, choose
**Each user of my app**. Copy the Atlaso key when it appears;
it is shown only once.

Export it in the terminal where you run the example. A file containing these
variables is not loaded automatically. Keep the Atlaso key on your server.

```bash theme={null}
export ATLASO_KEY='sk-at-...'
export ATLASO_BASE_URL='https://api.atlaso.ai/v1'
```

The SDK reads only `ATLASO_KEY`; its address is built in. `ATLASO_BASE_URL` is
for curl and the pages that call the HTTP API directly.

Use a test user ID from your own app, such as `demo-user-42`. In your app, pass
the signed-in user's ID after your own sign-in check.

## Save a fact, then ask about it

Each tab saves the same made-up fact, then asks a new chat a question that only
the fact answers. The answer cannot come from chat history. Run one tab, not
all three, to avoid saving the fact more than once.

> [tab] Python
>
> ```bash theme={null}
> pip install atlaso openai
> ```
>
> Save this as `quickstart.py` and run `python quickstart.py`:
>
> ```python theme={null}
> from atlaso import Atlaso
>
> atlaso = Atlaso()                      # reads ATLASO_KEY
> user = atlaso.for_user("demo-user-42")
> user.memory.add("My demo project is named Lantern and its launch day is Tuesday.")
> reply = user.openai().chat.completions.create(
>     model="openai/gpt-6.1-terra",
>     messages=[{"role": "user", "content": "What is my demo project called, and what day does it launch?"}],
> )
> print(reply.choices[0].message.content)
> ```

> [tab] TypeScript
>
> ```bash theme={null}
> npm install atlaso openai
> ```
>
> Save this as `quickstart.mjs` and run `node quickstart.mjs` (Node 18 or newer;
> the same code is valid TypeScript):
>
> ```javascript theme={null}
> import OpenAI from "openai";
> import { Atlaso } from "atlaso";
>
> const atlaso = new Atlaso({ OpenAI });         // reads ATLASO_KEY
> const user = atlaso.forUser("demo-user-42");
> await user.memory.add("My demo project is named Lantern and its launch day is Tuesday.");
> const reply = await user.openai().chat.completions.create({
>   model: "openai/gpt-6.1-terra",
>   messages: [{ role: "user", content: "What is my demo project called, and what day does it launch?" }],
> });
> console.log(reply.choices[0].message.content);
> ```

> [tab] curl
>
> The chat request runs only after the fact saves successfully; if saving fails,
> fix that error before testing recall. A
> [memory\_unavailable](https://docs.atlaso.ai/gateway/errors.md#memory_unavailable) save may still have
> finished, so check that entry before you send it again.
>
> ```bash theme={null}
> curl --fail-with-body "$ATLASO_BASE_URL/memory/facts" \
>   -H "Authorization: Bearer $ATLASO_KEY" \
>   -H 'Content-Type: application/json' \
>   -H 'x-atlaso-user: demo-user-42' \
>   -d '{"text":"My demo project is named Lantern and its launch day is Tuesday."}' &&
> curl --fail-with-body -i "$ATLASO_BASE_URL/chat/completions" \
>   -H "Authorization: Bearer $ATLASO_KEY" \
>   -H 'Content-Type: application/json' \
>   -H 'x-atlaso-user: demo-user-42' \
>   -d '{
>     "model": "openai/gpt-6.1-terra",
>     "messages": [{"role":"user","content":"What is my demo project called, and what day does it launch?"}]
>   }'
> ```
>
> The save returns a `memory.fact` object with an `id`. In the chat response,
> look for `status=used` in the `x-atlaso-memory` header and that fact's ID in
> `ids`. The answer text is at `choices[0].message.content`.

The assistant should mention **Lantern** and **Tuesday**, though its wording
varies. The SDK retries an uncertain save by itself; if a save still fails, fix
that error before testing recall (see [Errors](https://docs.atlaso.ai/gateway/errors.md)).

## See which memories it used

Add these lines to the end of the same file. They ask again, and print the IDs
of the facts Atlaso put into the prompt (the saved fact's ID) and the cost.

> [tab] Python
>
> ```python theme={null}
> raw = user.openai().chat.completions.with_raw_response.create(
>     model="openai/gpt-6.1-terra",
>     messages=[{"role": "user", "content": "What day does my demo project launch?"}],
> )
> call = atlaso.read_receipt(raw)
> print(call.receipt.memory.memory_ids if call.receipt.memory else [])   # IDs of the facts put into the prompt
> print(call.receipt.cost)
> ```

> [tab] TypeScript
>
> ```javascript theme={null}
> const call = atlaso.readReceipt(await user.openai().chat.completions.create({
>   model: "openai/gpt-6.1-terra",
>   messages: [{ role: "user", content: "What day does my demo project launch?" }],
> }).withResponse());
> console.log(call.receipt.memory?.memoryIds);   // IDs of the facts put into the prompt
> console.log(call.receipt.cost);
> ```

`user.memory.list()` shows the saved fact with the same ID. The
[Atlaso SDK](https://docs.atlaso.ai/gateway/sdk.md) page covers the receipt, saves, deletes and agent tools.

## Just for you

For a script of your own, create the key with **Memory for** set to **Me**
instead. Calls without a user then use your own memory, the same facts your
Atlaso tools save:

> [tab] Python
>
> ```python theme={null}
> from atlaso import Atlaso
>
> reply = Atlaso().openai().chat.completions.create(
>     model="openai/gpt-6.1-terra",
>     messages=[{"role": "user", "content": "Which units do I prefer?"}],
> )
> print(reply.choices[0].message.content)
> ```

> [tab] TypeScript
>
> ```javascript theme={null}
> import OpenAI from "openai";
> import { Atlaso } from "atlaso";
>
> const reply = await new Atlaso({ OpenAI }).openai().chat.completions.create({
>   model: "openai/gpt-6.1-terra",
>   messages: [{ role: "user", content: "Which units do I prefer?" }],
> });
> console.log(reply.choices[0].message.content);
> ```

Save, list and delete your own facts with `atlaso.memory`, using the same **Me**
key (its memory must not be **Off**):

> [tab] Python
>
> ```python theme={null}
> from atlaso import Atlaso
>
> atlaso = Atlaso()
> atlaso.memory.add("I prefer metric units.")
> fact = atlaso.memory.list().page().data[0]
> atlaso.memory.delete(fact.id)
> ```

> [tab] TypeScript
>
> ```javascript theme={null}
> import { Atlaso } from "atlaso";
>
> const atlaso = new Atlaso();
> await atlaso.memory.add("I prefer metric units.");
> const fact = (await atlaso.memory.list().page()).data[0];
> await atlaso.memory.delete(fact.id);
> ```

See [Use it for yourself](https://docs.atlaso.ai/gateway/sdk.md#use-it-for-yourself).

## Check that memory worked

`status=none` in the receipt (or the `x-atlaso-memory` header) means recall found
no facts; check the user ID, key scope and project. `status=off` means memory is
off. `status=skipped` includes a `reason` explaining why recall was skipped. See
[Memory](https://docs.atlaso.ai/gateway/memory.md) and [Errors](https://docs.atlaso.ai/gateway/errors.md).

For an isolation check, ask the same question as `demo-user-43`, a fresh test
user. It must not receive the saved fact.

When you are done, delete `demo-user-42`'s memory with `user.memory.erase()`, or
with [the Memory API](https://docs.atlaso.ai/gateway/memory-api.md#delete-user-memory):

```bash theme={null}
curl --fail-with-body -X DELETE "$ATLASO_BASE_URL/memory/user" \
  -H "Authorization: Bearer $ATLASO_KEY" \
  -H 'x-atlaso-user: demo-user-42'
```

## Other languages

Go, Java and C# call the gateway over HTTP with the OpenAI library, using the
two variables from [Set up once](#set-up-once). Send the user in the
`x-atlaso-user` header on each request from your server.

> [tab] Go
>
> ```bash theme={null}
> go mod init quickstart
> go get github.com/openai/openai-go/v3
> ```
>
> Save this as `main.go` and run `go run .`:
>
> ```go theme={null}
> package main
>
> import (
> 	"bytes"
> 	"context"
> 	"encoding/json"
> 	"fmt"
> 	"log"
> 	"net/http"
> 	"os"
>
> 	"github.com/openai/openai-go/v3"
> 	"github.com/openai/openai-go/v3/option"
> )
>
> func main() {
> 	base := os.Getenv("ATLASO_BASE_URL")
> 	key := os.Getenv("ATLASO_KEY")
>
> 	body := []byte(`{"text": "My demo project is named Lantern and its launch day is Tuesday."}`)
> 	req, _ := http.NewRequest("POST", base+"/memory/facts", bytes.NewReader(body))
> 	req.Header.Set("Authorization", "Bearer "+key)
> 	req.Header.Set("Content-Type", "application/json")
> 	req.Header.Set("x-atlaso-user", "demo-user-42")
> 	res, err := http.DefaultClient.Do(req)
> 	if err != nil {
> 		log.Fatal(err)
> 	}
> 	defer res.Body.Close()
> 	if res.StatusCode/100 != 2 {
> 		log.Fatalf("saving the fact failed: %s", res.Status)
> 	}
> 	var fact struct{ ID string }
> 	if err := json.NewDecoder(res.Body).Decode(&fact); err != nil {
> 		log.Fatal(err)
> 	}
> 	fmt.Println(fact.ID)
>
> 	client := openai.NewClient(option.WithBaseURL(base), option.WithAPIKey(key), option.WithMaxRetries(0))
> 	var raw *http.Response
> 	chat, err := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{
> 		Model: "openai/gpt-6.1-terra",
> 		Messages: []openai.ChatCompletionMessageParamUnion{
> 			openai.UserMessage("What is my demo project called, and what day does it launch?"),
> 		},
> 	}, option.WithHeader("x-atlaso-user", "demo-user-42"), option.WithResponseInto(&raw))
> 	if err != nil {
> 		log.Fatal(err)
> 	}
> 	fmt.Println(raw.Header.Get("x-atlaso-memory"))
> 	fmt.Println(chat.Choices[0].Message.Content)
> }
> ```

> [tab] Java
>
> Add the OpenAI library to your `pom.xml` (with Gradle:
> `implementation("com.openai:openai-java:4.106.0")`):
>
> ```xml theme={null}
> <dependency>
>   <groupId>com.openai</groupId>
>   <artifactId>openai-java</artifactId>
>   <version>4.106.0</version>
> </dependency>
> ```
>
> Save this as `src/main/java/Main.java` (Java 11 or newer) and run
> `mvn -q compile exec:java -Dexec.mainClass=Main`:
>
> ```java theme={null}
> import com.fasterxml.jackson.databind.ObjectMapper;
> import com.openai.client.okhttp.OpenAIOkHttpClient;
> import com.openai.models.chat.completions.ChatCompletionCreateParams;
> import java.net.URI;
> import java.net.http.HttpClient;
> import java.net.http.HttpRequest;
> import java.net.http.HttpResponse;
>
> public class Main {
>     public static void main(String[] args) throws Exception {
>         String base = System.getenv("ATLASO_BASE_URL");
>         String key = System.getenv("ATLASO_KEY");
>
>         HttpRequest save = HttpRequest.newBuilder(URI.create(base + "/memory/facts"))
>                 .header("Authorization", "Bearer " + key)
>                 .header("Content-Type", "application/json")
>                 .header("x-atlaso-user", "demo-user-42")
>                 .POST(HttpRequest.BodyPublishers.ofString(
>                         "{\"text\": \"My demo project is named Lantern and its launch day is Tuesday.\"}"))
>                 .build();
>         HttpResponse<String> saved = HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1).build()
>                 .send(save, HttpResponse.BodyHandlers.ofString());
>         if (saved.statusCode() / 100 != 2) {
>             throw new RuntimeException("Saving the fact failed: " + saved.statusCode() + " " + saved.body());
>         }
>         System.out.println(new ObjectMapper().readTree(saved.body()).get("id").asText());
>
>         var client = OpenAIOkHttpClient.builder().baseUrl(base).apiKey(key).maxRetries(0).build();
>         var params = ChatCompletionCreateParams.builder()
>                 .model("openai/gpt-6.1-terra")
>                 .addUserMessage("What is my demo project called, and what day does it launch?")
>                 .putAdditionalHeader("x-atlaso-user", "demo-user-42")
>                 .build();
>         try (var response = client.chat().completions().withRawResponse().create(params)) {
>             System.out.println(response.headers().values("x-atlaso-memory").get(0));
>             System.out.println(response.parse().choices().get(0).message().content().orElse(""));
>         }
>         client.close();
>     }
> }
> ```

> [tab] C#
>
> ```bash theme={null}
> dotnet new console -n quickstart
> cd quickstart
> dotnet add package OpenAI
> ```
>
> Replace `Program.cs` with this and run `dotnet run`. The OpenAI library adds a
> header to one call only through its lower-level method, so this example reads
> the reply from its JSON:
>
> ```csharp theme={null}
> using System.ClientModel;
> using System.ClientModel.Primitives;
> using System.Net.Http.Json;
> using System.Text.Json;
> using OpenAI;
> using OpenAI.Chat;
>
> var baseUrl = Environment.GetEnvironmentVariable("ATLASO_BASE_URL")!;
> var key = Environment.GetEnvironmentVariable("ATLASO_KEY")!;
>
> using var http = new HttpClient();
> var save = new HttpRequestMessage(HttpMethod.Post, baseUrl + "/memory/facts")
> {
>     Content = JsonContent.Create(new { text = "My demo project is named Lantern and its launch day is Tuesday." }),
> };
> save.Headers.Add("Authorization", "Bearer " + key);
> save.Headers.Add("x-atlaso-user", "demo-user-42");
> var saved = await http.SendAsync(save);
> saved.EnsureSuccessStatusCode();
> var fact = await saved.Content.ReadFromJsonAsync<JsonElement>();
> Console.WriteLine(fact.GetProperty("id").GetString());
>
> var client = new ChatClient("openai/gpt-6.1-terra", new ApiKeyCredential(key), new OpenAIClientOptions
> {
>     Endpoint = new Uri(baseUrl),
>     RetryPolicy = new ClientRetryPolicy(maxRetries: 0),
> });
> var options = new RequestOptions();
> options.AddHeader("x-atlaso-user", "demo-user-42");
> var body = BinaryContent.Create(BinaryData.FromObjectAsJson(new
> {
>     model = "openai/gpt-6.1-terra",
>     messages = new[] { new { role = "user", content = "What is my demo project called, and what day does it launch?" } },
> }));
> var response = (await client.CompleteChatAsync(body, options)).GetRawResponse();
> response.Headers.TryGetValue("x-atlaso-memory", out var memory);
> Console.WriteLine(memory);
> var reply = JsonDocument.Parse(response.Content).RootElement;
> Console.WriteLine(reply.GetProperty("choices")[0].GetProperty("message").GetProperty("content").GetString());
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.