# Whether this account keeps AI keys (the person turns it on), and the keys. Sealed on the server; only this account’s own sessions get them.

```http
GET /api/ai-keys
```

## Authorization

- **session**: `Authorization: Bearer <token>`. The session token from signing in (or the session cookie in a browser on the same origin).

## Response

**200**: It worked

- **on** `boolean` (required): The person chose to keep keys in the account
- **keys** `array<AiKey>` (required)
  - **name** `string`: At most 64 characters
  - **key** `string`: At most 4000 characters

Other answers:

- **4XX**: Refused, with a message to show the person

## Example request

````tabs
tab: cURL
```bash
curl -X GET 'https://your-hatch-server/api/ai-keys' \
  -H 'Authorization: Bearer <token>'
```

tab: JavaScript
```js
const res = await fetch("https://your-hatch-server/api/ai-keys", {
  method: "GET",
  headers: {
    Authorization: "Bearer <token>",
  },
})
const data = await res.json()
```

tab: Python
```python
import requests

res = requests.request("GET", "https://your-hatch-server/api/ai-keys", headers={"Authorization": "Bearer <token>"})
data = res.json()
```

tab: Go
```go
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, err := http.NewRequest("GET", "https://your-hatch-server/api/ai-keys", nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer <token>")
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	data, _ := io.ReadAll(res.Body)
	fmt.Println(string(data))
}
```

tab: Ruby
```ruby
require "net/http"

uri = URI('https://your-hatch-server/api/ai-keys')
req = Net::HTTP::Get.new(uri)
req['Authorization'] = 'Bearer <token>'

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
  http.request(req)
end
puts res.body
```

tab: PHP
```php
<?php

$ch = curl_init('https://your-hatch-server/api/ai-keys');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer <token>',
    ],
]);

$response = curl_exec($ch);
echo $response;
```

tab: Java
```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://your-hatch-server/api/ai-keys"))
    .header("Authorization", "Bearer <token>")
    .method("GET", HttpRequest.BodyPublishers.noBody())
    .build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```
````

## Example response

````tabs
tab: 200
```json
{
  "on": true,
  "keys": [
    {
      "name": "string",
      "key": "string"
    }
  ]
}
```

tab: 4XX
```json
{
  "message": "string",
  "code": "string",
  "retryable": true,
  "requestId": "string"
}
```
````
