Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.llmgrid.ai/llms.txt

Use this file to discover all available pages before exploring further.

OpenAI provides official SDKs across multiple languages, and you can always use standard HTTP clients against OpenAI-compatible endpoints. .NET (HttpClient)
using System.Net.Http;
using System.Text;
using System.Text.Json;

var http = new HttpClient();
http.DefaultRequestHeaders.Authorization =
  new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("LLMGRID_API_KEY"));

var payload = new {
  model = "gpt-4.1",
  messages = new[] { new { role = "user", content = "Hello from .NET via LLMGrid" } }
};

var content = new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json");
var resp = await http.PostAsync("https://api.llmgrid.ai/v1/chat/completions", content);
resp.EnsureSuccessStatusCode();

Console.WriteLine(await resp.Content.ReadAsStringAsync());
Java (java.net.http)
import java.net.URI;
import java.net.http.*;
import java.nio.charset.StandardCharsets;

public class Main {
  public static void main(String[] args) throws Exception {
    String apiKey = System.getenv("LLMGRID_API_KEY");

    String json = """
    {
      "model": "gpt-4.1",
      "messages": [{"role": "user", "content": "Hello from Java via LLMGrid"}]
    }
    """;

    HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create("https://api.llmgrid.ai/v1/chat/completions"))
      .header("Authorization", "Bearer " + apiKey)
      .header("Content-Type", "application/json")
      .POST(HttpRequest.BodyPublishers.ofString(json, StandardCharsets.UTF_8))
      .build();

    HttpClient client = HttpClient.newHttpClient();
    HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
    System.out.println(response.body());
  }
}
Go (net/http)
package main

import (
  "bytes"
  "fmt"
  "net/http"
  "os"
)

func main() {
  apiKey := os.Getenv("LLMGRID_API_KEY")

  body := []byte(`{
    "model":"gpt-4.1",
    "messages":[{"role":"user","content":"Hello from Go via LLMGrid"}]
  }`)

  req, _ := http.NewRequest("POST", "https://api.llmgrid.ai/v1/chat/completions", bytes.NewBuffer(body))
  req.Header.Set("Authorization", "Bearer "+apiKey)
  req.Header.Set("Content-Type", "application/json")

  resp, err := http.DefaultClient.Do(req)
  if err != nil { panic(err) }
  defer resp.Body.Close()

  buf := new(bytes.Buffer)
  buf.ReadFrom(resp.Body)
  fmt.Println(buf.String())
}

Base URL rules (important)

When using OpenAI-compatible client libraries, set the base URL to:
https://api.llmgrid.ai/v1
Do not append route paths like /chat/completions to the base URL; the client will append them automatically.u