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

# Authentication

> How to authenticate requests to the Apollo AI API

The Apollo AI API uses API keys to authenticate requests. You can view and manage your API keys in the [Apollo AI Dashboard](http://localhost:5173/admin/settings).

### Authentication Header

All API requests must include your API key in the `x-api-key` header.

```bash theme={null}
x-api-key: your_api_key_here
```

### Example Request

<RequestExample>
  ```bash Curl theme={null}
  curl -X POST "https://apolloai.lol/v1/generation/prompt" \
    -H "x-api-key: your_api_key_here" \
    -H "Content-Type: application/json" \
    -d '{
      "prompt": "Hello world"
    }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://apolloai.lol/v1/generation/prompt"
  headers = {
      "x-api-key": "your_api_key_here",
      "Content-Type": "application/json"
  }
  data = {
      "prompt": "Hello world"
  }

  response = requests.post(url, headers=headers, json=data)
  print(response.text)
  ```

  ```javascript JavaScript theme={null}
  const url = "https://apolloai.lol/v1/generation/prompt";
  const headers = {
    "x-api-key": "your_api_key_here",
    "Content-Type": "application/json"
  };
  const body = JSON.stringify({
    prompt: "Hello world"
  });

  fetch(url, { method: "POST", headers, body })
    .then(response => response.text())
    .then(console.log);
  ```

  ```go Go theme={null}
  package main

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

  func main() {
  	url := "https://apolloai.lol/v1/generation/prompt"
  	var jsonStr = []byte(`{"prompt":"Hello world"}`)
  	req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
  	req.Header.Set("x-api-key", "your_api_key_here")
  	req.Header.Set("Content-Type", "application/json")

  	client := &http.Client{}
  	resp, _ := client.Do(req)
      defer resp.Body.Close()
      
      body, _ := ioutil.ReadAll(resp.Body)
  	fmt.Println(string(body))
  }
  ```

  ```java Java theme={null}
  import java.net.URI;
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;
  import java.net.http.HttpResponse.BodyHandlers;

  public class Main {
      public static void main(String[] args) throws Exception {
          String url = "https://apolloai.lol/v1/generation/prompt";
          String json = "{\"prompt\":\"Hello world\"}";

          HttpClient client = HttpClient.newHttpClient();
          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create(url))
              .header("x-api-key", "your_api_key_here")
              .header("Content-Type", "application/json")
              .POST(HttpRequest.BodyPublishers.ofString(json))
              .build();

          client.sendAsync(request, BodyHandlers.ofString())
              .thenApply(HttpResponse::body)
              .thenAccept(System.out::println)
              .join();
      }
  }
  ```

  ```ruby Ruby theme={null}
  require 'uri'
  require 'net/http'
  require 'json'

  url = URI("https://apolloai.lol/v1/generation/prompt")

  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(url)
  request["x-api-key"] = "your_api_key_here"
  request["Content-Type"] = "application/json"
  request.body = JSON.dump({
    "prompt": "Hello world"
  })

  response = http.request(request)
  puts response.read_body
  ```

  ```c C theme={null}
  #include <stdio.h>
  #include <curl/curl.h>

  int main(void) {
    CURL *curl;
    CURLcode res;

    curl = curl_easy_init();
    if(curl) {
      curl_easy_setopt(curl, CURLOPT_URL, "https://apolloai.lol/v1/generation/prompt");
      
      struct curl_slist *headers = NULL;
      headers = curl_slist_append(headers, "x-api-key: your_api_key_here");
      headers = curl_slist_append(headers, "Content-Type: application/json");
      curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

      const char *data = "{\"prompt\":\"Hello world\"}";
      curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);

      res = curl_easy_perform(curl);
      
      curl_slist_free_all(headers);
      curl_easy_cleanup(curl);
    }
    return 0;
  }
  ```

  ```rust Rust theme={null}
  use reqwest::Client;
  use serde_json::json;

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn std::error::Error>> {
      let client = Client::new();
      let res = client.post("https://apolloai.lol/v1/generation/prompt")
          .header("x-api-key", "your_api_key_here")
          .header("Content-Type", "application/json")
          .json(&json!({
              "prompt": "Hello world"
          }))
          .send()
          .await?;

      let body = res.text().await?;
      println!("{}", body);
      Ok(())
  }
  ```
</RequestExample>

### Response Codes

| Status Code | Description                                                                                                       |
| :---------- | :---------------------------------------------------------------------------------------------------------------- |
| 401         | **Unauthorized**: API key is missing or invalid.                                                                  |
| 403         | **Forbidden**: API key is valid but does not have permission for the requested resource (e.g. tier restrictions). |
